Custom date display in TCalendar lazarus / 31-LCL ---------------------------------------------------------------------- JD · 2012-08-28 16:54 Hi there everyone, I have an old project that uses a TCalendar to keep track of events. I want to update it so that if an event occurred on a particular date, the date appears different (bold, italic, underline, different colour etc) from the others. In my head, I think I'll need to play with Canvas, Rect etc but I don't know where to start from because I haven't done work with graphics in a long time. Using the RxCalendarGrid in place of the TCalendar is another option for me but my problem is still remains. Any suggestions will be welcome. ---------------------------------------------------------------------- Avishai · 2012-08-28 17:00 For which OS?  From what I hear, TCalendar is very different from one OS to the next.  I did what you are talking about long ago in Delphi 6.  TCalendar had the properties to highlight Dates, but I don't know if Lazarus is the same.  I doubt it.  A lot has changed since Delphi 6. ---------------------------------------------------------------------- JD · 2012-08-28 17:03 Quote from: Avishai on August 28, 2012, 07:00:39 pmFor which OS?  From what I hear, TCalendar is very different from one OS to the next.  I did what you are talking about long ago in Delphi 6.  TCalendar had the properties to highlight Dates, but I don't know if Lazarus is the same.  I doubt it.  A lot has changed since Delphi 6. Win32. I'm not really stuck on TCalendar. I think all the calendars use similar methods to display dates so what works for one might work for another with minimal modifications. I selected TCalendar because it is the most common in use. It's part of an old project that needs a little facelift!  Users always ask for more, alas! ---------------------------------------------------------------------- Phil · 2012-08-28 17:04 Quote from: Avishai on August 28, 2012, 07:00:39 pmFor which OS?  From what I hear, TCalendar is very different from one OS to the next.  I did what you are talking about long ago in Delphi 6.  TCalendar had the properties to highlight Dates, but I don't know if Lazarus is the same.  I doubt it.  A lot has changed since Delphi 6. In TOvcCalendar, I see the OnGetHighlight and OnDrawDate events that should allow you to highlight specific dates in the calendar. Thanks. -Phil ---------------------------------------------------------------------- JD · 2012-08-28 17:05 Quote from: Phil on August 28, 2012, 07:04:10 pmQuote from: Avishai on August 28, 2012, 07:00:39 pmFor which OS?  From what I hear, TCalendar is very different from one OS to the next.  I did what you are talking about long ago in Delphi 6.  TCalendar had the properties to highlight Dates, but I don't know if Lazarus is the same.  I doubt it.  A lot has changed since Delphi 6. In TOvcCalendar, I see the OnGetHighlight and OnDrawDate events that should allow you to highlight specific dates in the calendar. Thanks. -Phil It has problems with accented text. Works OK in Delphi 2010 but garbles accented characters in Delphi 2006 and Lazarus 1.1/FPC 2.6.1. ---------------------------------------------------------------------- Phil · 2012-08-28 17:07 Quote from: JD on August 28, 2012, 07:05:53 pmIt has problems with accented text. Works OK in Delphi 2010 but garbles accented characters in Delphi 2006 and Lazarus 1.1/FPC 2.6.1. Not sure what you're referring to. Are you talking about TOvcCalendar? Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-28 17:09 I just checked my very old Delphi 6 code and TCalendar had a property BoldDays that allow highlighting dates.  I don't see that in Lazarus TCalendar.  I think you would have to do a lot of work with TCalendar and I doubt it would be worth it. ---------------------------------------------------------------------- JD · 2012-08-28 17:14 Quote from: Phil on August 28, 2012, 07:07:24 pmQuote from: JD on August 28, 2012, 07:05:53 pmIt has problems with accented text. Works OK in Delphi 2010 but garbles accented characters in Delphi 2006 and Lazarus 1.1/FPC 2.6.1. Not sure what you're referring to. Are you talking about TOvcCalendar? Thanks. -Phil Oh yes. The Orpheus calendar. I can show you screenshots if you want. ---------------------------------------------------------------------- Phil · 2012-08-28 17:16 Quote from: JD on August 28, 2012, 07:14:52 pmQuote from: Phil on August 28, 2012, 07:07:24 pmQuote from: JD on August 28, 2012, 07:05:53 pmIt has problems with accented text. Works OK in Delphi 2010 but garbles accented characters in Delphi 2006 and Lazarus 1.1/FPC 2.6.1. Not sure what you're referring to. Are you talking about TOvcCalendar? Thanks. -Phil Oh yes. The Orpheus calendar. I can show you screenshots if you want. Please do - for Lazarus version. Thanks. -Phil ---------------------------------------------------------------------- JD · 2012-08-28 17:23 Quote from: Phil on August 28, 2012, 07:16:07 pmQuote from: JD on August 28, 2012, 07:14:52 pmQuote from: Phil on August 28, 2012, 07:07:24 pmQuote from: JD on August 28, 2012, 07:05:53 pmIt has problems with accented text. Works OK in Delphi 2010 but garbles accented characters in Delphi 2006 and Lazarus 1.1/FPC 2.6.1. Not sure what you're referring to. Are you talking about TOvcCalendar? Thanks. -Phil Oh yes. The Orpheus calendar. I can show you screenshots if you want. Please do - for Lazarus version. Thanks. -Phil Your wish is my command.....  This is in French. ---------------------------------------------------------------------- Phil · 2012-08-28 17:48 Quote from: JD on August 28, 2012, 07:23:58 pmYour wish is my command.....  This is in French. LCL interface functions like DrawText (used in ovccal.pas) always expect strings to be in UTF8 on most widgetsets. It appears as though FPC LongMonthNames, etc. are returning non-UTF8 strings - hence the resulting display. Should be easy to fix if you want to try. Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-28 17:51 This may be what you are looking for Code: [Select]function GetLongMonthNames(I: Integer): String; begin   Result:= SysToUTF8(LongMonthNames[I]); end; function GetShortMonthNames(I: Integer): String; begin   Result:= SysToUTF8(ShortMonthNames[I]); end; I have heard that FPC is in the process of fixing it but haven't relieced it yet. ---------------------------------------------------------------------- Phil · 2012-08-28 18:57 Quote from: Avishai on August 28, 2012, 07:51:41 pmI have heard that FPC is in the process of fixing it but haven't relieced it yet. I'm not familiar with SysToUtf8 - that doesn't appear to be in 2.6.0. AnsiToUtf8 would probably work. Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-28 19:14 It's in "..\lazarus\components\lazutils\fileutil.pas" at Line#201.  I tried AnsiToUtf8 and had problems.  I don't remember what the problems were, I just remember getting frustrated ---------------------------------------------------------------------- Phil · 2012-08-28 19:41 Quote from: Avishai on August 28, 2012, 09:14:52 pmIt's in "..\lazarus\components\lazutils\fileutil.pas" at Line#201.  I tried AnsiToUtf8 and had problems.  I don't remember what the problems were, I just remember getting frustrated The only thing SysToUtf8 does on Windows is check to see if your system codepage is 65001 (UTF8) - if it is, the function doesn't need to convert to UTF8; if it isn't, the function calls AnsiToUtf8. Do a WriteLn((GetACP); on Windows to see what your system CP is. Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-28 19:49 Ah yes, that's what the problem was. My CodePage changes depending on whether I am logged in to my English account or my Hebrew account.  I live a duel personality life. ---------------------------------------------------------------------- Knipfty · 2012-08-28 19:57 QuoteI live a duel personality life. Do you often argue with yourself and lose? ---------------------------------------------------------------------- Avishai · 2012-08-28 19:59 No, I don't.  Yes you do.  No, I don't!  Yes you do. ---------------------------------------------------------------------- Phil · 2012-08-29 01:18 Quote from: JD on August 28, 2012, 07:14:52 pmOh yes. The Orpheus calendar. I can show you screenshots if you want. It should be fixed now - try it and report back. Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-29 08:19 @Phil.  I have a couple of questions about Orpheus.  Please don't spend much time on this.  If you already know, that's fine.  If not, I will try to find out when I have some time. 1. Do you know if it supports RightToLeft? 2. Will it compile on Win7-64? ---------------------------------------------------------------------- Phil · 2012-08-29 14:51 Quote from: Avishai on August 29, 2012, 10:19:02 am@Phil.  I have a couple of questions about Orpheus.  Please don't spend much time on this.  If you already know, that's fine.  If not, I will try to find out when I have some time. 1. Do you know if it supports RightToLeft? 2. Will it compile on Win7-64? 1. Which components are you interested int? 2. Try it and report back. As I indicated before, I'm limited to 32-bit with Lazarus on Mac because of its dependence on the Carbon framework. Thanks. -Phil ---------------------------------------------------------------------- Avishai · 2012-08-29 15:38 Oh yes.  I forgot I had asked about it before.  Sorry. It doesn't look like it will compile for Win64, but I haven't spent much time with it.  Maybe I can look at it later when I have some time. ---------------------------------------------------------------------- JD · 2012-08-29 15:50 Quote from: Phil on August 29, 2012, 03:18:36 amQuote from: JD on August 28, 2012, 07:14:52 pmOh yes. The Orpheus calendar. I can show you screenshots if you want. It should be fixed now - try it and report back. Thanks. -Phil Did you update the SVN version? If so what is the link to the updated sources. ---------------------------------------------------------------------- Avishai · 2012-08-29 15:57 Yes, from SVN https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus- ccr/components/orpheus ---------------------------------------------------------------------- JD · 2012-08-29 21:53 It seems to handle accented characters properly now. Thanks Phil. I'll see if it will serves my need for custom display dates.