Recent

Author Topic: CalLite and read only  (Read 604 times)

kkuba

  • New Member
  • *
  • Posts: 34
CalLite and read only
« on: August 09, 2022, 12:25:36 am »
Needs a component that would visually show staff absences. CalLite is almost perfect for this, but I have a problem. How to make it read only for a user? The point is that during the preview, the user should not change the selections in the calendar added via AddSelectedDate. The user should be able to change months but not the marked dates. I missed something or it is not implemented unfortunately?
BTW: The AddSelectedRange (b, e: TDate) procedure is missing here. I have to add it in the application code, which is not difficult, but somehow not pretty. I'm afraid to mention that the selections could have a different color: for example, such a procedure AddSelectedRange (b, e: TDate; color: TColor). But it's probably a pretty big rework, I guess the component isn't ready for that.
I hope that although read only can be implemented in CalLite  :'(

dje

  • Full Member
  • ***
  • Posts: 111
Re: CalLite and read only
« Reply #1 on: August 09, 2022, 08:14:26 am »
I checked out TCalendarLite, and you are right. There is no easy way to implement (or hack) what you want.

One idea is to disable the control and hide the top/bottom rows using:
Code: Pascal  [Select][+][-]
  1.   CalendarLite1.Enabled := False;
  2.   CalendarLite1.Options := CalendarLite1.Options - [coShowTopRow, coShowTodayRow];

You would then need to implement your own month change buttons (by setting date using functions from DateUtils), which clears the selected dates, so, they would need to be re-added each time you set "date". I'd say you are using TCalendarLite for a little more than it was designed todo, but, yes its possible.

One alternate is to use TVpMonthView from Turbopower Visual PlanIt, which might be overkill.
https://wiki.freepascal.org/Turbopower_Visual_PlanIt

My feeling ATM is, you might be better off coding your own TDrawGrid calendar (or a grid of custom controls). Often its easier to get what you want that way. Calendars arn't hard to render.

« Last Edit: August 09, 2022, 08:17:52 am by derek.john.evans »

kkuba

  • New Member
  • *
  • Posts: 34
Re: CalLite and read only
« Reply #2 on: August 09, 2022, 09:13:38 am »
I am asking because I would rather not use TVPlainIt for such a trivial matter. It is like shooting a mosquito from a cannon. Secondly, TVPlainIt has a different license, which is a problem in some cases. Unfortunately, it looks like the first time hurts me because there is no equivalent in Lazarus TMonthCalendar. CalLite fills this gap a bit, but not quite as you can see.
BTW TMonthCalendar has property Enabled, which controls whether the control responds to mouse, keyboard, and timer events
« Last Edit: August 09, 2022, 09:37:00 am by kkuba »

dje

  • Full Member
  • ***
  • Posts: 111
Re: CalLite and read only
« Reply #3 on: August 09, 2022, 09:42:00 am »
I am asking because I would rather not use TVPlainIt for such a trivial matter. It is like shooting a mosquito from a cannon. Secondly, TVPlainIt has a different license, which is a problem in some cases. Unfortunately, it looks like the first time hurts me because there is no equivalent in Lazarus TMonthCalendar. CalLite fills this gap a bit, but not quite as you can see.
BTW TMonthCalendar has property Enabled, which controls whether the control responds to mouse, keyboard, and timer events

Yep, I get it. Its one of those things. A more generic calendar component is obviously needed. One which doesn't bind you to a larger, complex code base. Notify events for each date, and a read only option.

TCalendarGrid or TDateGrid? Sounds like a project  :)
« Last Edit: August 09, 2022, 09:43:55 am by derek.john.evans »

Zoran

  • Hero Member
  • *****
  • Posts: 1746
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: CalLite and read only
« Reply #4 on: August 09, 2022, 11:31:14 am »
What about this -- instead of selection, use CalLite's support of showng "holidays" -- in CalLite you might do the following:
- set the SelectedDateColor and BackgroundColor properties to same value, so the selection will not be visible
- activate option coShowHolidays, and use OnShowHolidays event to determine which days you want to be the "holidays". Instead of using selection of dates, you can use some array to hold the days you currently want to be displayed as "holidays".
- to mark the days you want you can take a look at the Flag days in Finland example (see the link below) or simply use the HolidayColor property.

Play with this, you might be able to get just what you need with CalLite.

https://wiki.freepascal.org/CalLite:_Usage
https://wiki.freepascal.org/CalLite:_Flag_days_in_Finland

wp

  • Hero Member
  • *****
  • Posts: 10063
Re: CalLite and read only
« Reply #5 on: August 09, 2022, 07:47:49 pm »
An alternative to CalLite is the JvYearGrid of JVCL. It is pretty much self-contained, and I extracted a stand-alone version for the attached project (i.e. no need to install anything - just add the JvYearGrid files to the project and create the grid at runtime). I spent some time today to provide a ReadOnly property and to improve the usability of the calendar event editor.

kkuba

  • New Member
  • *
  • Posts: 34
Re: CalLite and read only
« Reply #6 on: August 09, 2022, 09:49:07 pm »
I will look at this component JVCL, but I think that probably some of the developers really should take a look at TCalendar. It started to move very far away from Delphi TMonthCalendar.
I also have a minor request by the way. There is a slight translation error in the code. It should be:
PolishDays = 'nie,pon,wto,śro,czw,pią,sob';

 

TinyPortal © 2005-2018