Recent

Author Topic: Small questions of a "visitor"  (Read 27133 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Small questions of a "visitor"
« Reply #30 on: July 26, 2012, 11:05:47 am »
My point is that you have brought up the tcalendar problem in the forum, which is good. You gotd comments, and you tried solving your issues. Also good.

You're still not satisfied with how tcalendar works and tell us on the forum. My polite suggestion to you was to do that on the bugtracker in an issue.
This way, it can get the attention of the developers and can get fixed.

I'm ignoring the rest of your post. It's a bit too aggressive and it's trying to put intentions in my posts that aren't there. Furthermore, I just don't understand the language of the parts about updating.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

gjpneac

  • New Member
  • *
  • Posts: 16
Re: Small questions of a "visitor"
« Reply #31 on: July 26, 2012, 11:11:48 am »
OK BigChimp,

I remove the part which you consider aggressive. You became aware of the problem. The aggression seems to me mutual by the attitude (self-satisfied almost sectarian) of some "Hero menbers". Lazarus is a very ambitious, but unstable and very badly documented project. Please take this into account.

Regards.
« Last Edit: July 26, 2012, 11:26:38 am by gjpneac »

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Small questions of a "visitor"
« Reply #32 on: July 26, 2012, 11:35:38 am »
Quote
You're still not satisfied with how tcalendar works and tell us on the forum

@Bigchimp,  I think the problem here is that the problems with TCalendar, Lazarus developers can't really fix, as there OS Widgets that at this level of detail we have very little control off.

Making a custom Calendar is certainly not a bad idea, as you can extend way beyond what the OS will allow.  And of course the Calendar is then instantly cross-platform, without the glitches.

Rather than creating a custom component, Lazarus like Delphi supports Frame's, so that also an option.

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Small questions of a "visitor"
« Reply #33 on: July 26, 2012, 02:46:23 pm »
I've knocked up a quick Calendar control that uses Frames.

There is plenty that can be done to improve, but I've kept it very simple so that you can modify to your needs.  One advantage already to the Windows Calendar is as you can see it's scalable.  And hopefully consistent between OS's.

There is a Demo that also shows how you can link multiple Date Controls together.

I've only tested in Windows, but should work Linux/MacOS.

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Small questions of a "visitor"
« Reply #34 on: July 26, 2012, 05:28:05 pm »
I only took a quick look at the code so far and have not tried it yet.  I see that you took a different approach to positioning the Labels than I did.  I used ChildSizing.  I don't know if it was by design or just luck, but ChildSizing is BiDi aware :)  So when I set BiDiMode:= beRightToLeft, I 'magically' get a RightToLeft Calendar :)  It also handles resizing for me.

As I said, I only took a quick look so I don't know if your Calendar is BiDi aware.  I will look closer when I have the chance.  I do understand that you were addressing a specific question and not reinventing TCalendar so BiDiMode probably wasn't one of your concerns.

I'm always impressed when I see good clean code like yours.  Maybe someday I will be able to do that too.  My code always look I wrote it with a crayon :(
Lazarus Trunk / fpc 2.6.2 / Win32

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Small questions of a "visitor"
« Reply #35 on: July 26, 2012, 06:21:01 pm »
Quote
have not tried it yet.

You should be able to just open project and run,.  There's no components or anything to install.  One of the nice things of using a TFrame.

Quote
I don't know if your Calendar is BiDi aware

No it's not, but I'll do a quick mod to make it.

Never really noticed child sizing, my code just manually sets the control positions.  Sound a good idea though, have to have a closer look.  The only thing I can't see is Font autosizing, so I assume you still do that in code?

Ok, I've attached a modified version for RightToLeft, hopefully it's correct.  I'm not sure if I've done everything required or not.

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Small questions of a "visitor"
« Reply #36 on: July 26, 2012, 07:19:59 pm »
Ha!  I haven't used Frames for a while so it slipped my mind.  But if I remember correctly, Frames are BiDi aware as well.  I just downloaded your file and will take a look as soon as I get back from an appointment.
Lazarus Trunk / fpc 2.6.2 / Win32

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Small questions of a "visitor"
« Reply #37 on: July 26, 2012, 08:03:17 pm »
Quote
You're still not satisfied with how tcalendar works and tell us on the forum

@Bigchimp,  I think the problem here is that the problems with TCalendar, Lazarus developers can't really fix, as there OS Widgets that at this level of detail we have very little control off.

Making a custom Calendar is certainly not a bad idea, as you can extend way beyond what the OS will allow.  And of course the Calendar is then instantly cross-platform, without the glitches.

Rather than creating a custom component, Lazarus like Delphi supports Frame's, so that also an option.
@Kpjcomp: thanks! If the problems with the existing TCalendar are big enough so that it just won't work well on some widgetset, I think it would make sense to rewrite it as you indicate...
Either that or pass them upstream to the widgetset devs... and hope things get fixed quickly enough.

Regards,
BigChimp
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Small questions of a "visitor"
« Reply #38 on: July 26, 2012, 10:07:05 pm »
@BigChimp, like many things in Lazarus, and almost all development environments, when BiDiMode enters the picture, they just don't work or work poorly.  As you can see from KpjComp's Calendar, when 'Right To Left' is checked,  the Calendar mirrors the days so that they read from RightToLeft.  This is as it should be.  TCalendar does not do this.  It is LeftToRight ONLY.

@KpjComp, Man that is NICE!  There a couple of problems for RTL but I think they are minor, and maybe I just didn't find the code that makes the settings. 
1. Hebrew weeks start with Sunday so a setting for this would be nice.
2. When the days are mirrored, then Arrows for PrevMonth and NextMont should also be mirrored.  That is, the functionality should be reversed, not the actual Arrows.
3. Of course the Month and Day names would need to reflect the Language :)  I've tried the 'Translate' routines from time to time, but for my needs, it's just more trouble than it's worth.  I still think 'property Lang' needs to be added to any control that is Language Sensitive.
4. And most importantly, I'm not asking you to fix any of this :)  With you code I'm sure I can figure out how to make it work for my needs.  I always learn something new when I read your code.  Really elegant.
« Last Edit: July 27, 2012, 12:01:41 am by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Small questions of a "visitor"
« Reply #39 on: July 27, 2012, 12:35:47 am »
@KpjComp,  I' too lazy for scaling the TLabel.Font.Size.  I just used constraints on the Form Size. :)
Lazarus Trunk / fpc 2.6.2 / Win32

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Small questions of a "visitor"
« Reply #40 on: July 27, 2012, 02:13:35 am »
@Avishai:  I'll have a look at those modifications, I did wonder about the arrows but wasn't sure.  The language part I might need help with, I hard coded the Mo,Tu,We for quickness, I could have used Formatdatetime really and just trimmed the first 2 chars, but I've no idea how that would work for other languages.  Would that work for Hebrew?

Quote
I'm not asking you to fix any of this

No problem, I did write this as a getting started for @gjpneac.  But if others are finding it useful too, I have no problems adding extra features.

There are lots of ways I could enhance too.
1. Custom colours.
2. 12 of them linked together to create a Yearly calendar.
3. Multi-Select (range).

Quote
I always learn something new when I read your code.

That is great!!  :), I code the way it makes sense to me.  I'm glad that others can follow & learn from it too.


Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: Small questions of a "visitor"
« Reply #41 on: July 27, 2012, 07:09:05 am »
This is a code snippet from my Calendar program and like you I hard coded.

const
  EngMonths: Array[1..12] of String = ('January','February','March','April',
     'May','June','July','August','September','October','November','December');
  HebMonths: Array[1..12] of String = ('ינואר','פברואר','מרץ','אפריל','מאי',
     'יוני','יולי','אוגוסט','ספטמבר','אוקטובר','נובמבר','דצמבר');

  EngDayNames: Array[1..7] of String = ('Su','Mo','Tu','We','Th','Fr','Sa');
  HebDayNames: Array[1..7] of String = ('א','ב','ג','ד','ה','ו','ש');

But this only solves for 2 languages so...
A word of caution: Trying to edit RTL text in Lazarus code editor is nearly impossible.

I will have to take a look at Formatdatetime.

Edit: FormatDateTime does not seem to work out too well.  It seems to depend on Locale and if your Locale Language is Hebrew, the numbers are OK but text is just '????'.  Anyway, I usually log in to my English account, but need a Hebrew Calendar, so being Locale dependent doesn't always work.
« Last Edit: July 27, 2012, 02:01:01 pm by Avishai »
Lazarus Trunk / fpc 2.6.2 / Win32

KpjComp

  • Hero Member
  • *****
  • Posts: 680
Re: Small questions of a "visitor"
« Reply #42 on: July 27, 2012, 04:32:51 pm »
Hi Avishai,

I've moved the Calendar stuff to a new thread, to save this thread getting too long.

http://www.lazarus.freepascal.org/index.php/topic,17672.0.html

 

TinyPortal © 2005-2018