Defines a base class which provides a wrapper for the calendar control displayed in TDateTimePicker and descendent classes.

By default, TDateTimePicker uses the LCL TCalendar control to represent its drop-down calendar. But you can use some other calendar control instead. In order to use another calendar control, you should "wrap" that control with a CalendarControlWrapper.

For use in TDateTimePicker, the calendar control must at least provide a way to determine whether the coordinates are on a date. When the control is clicked, we must decide if the date has just been chosen and respond by closing the drop-down form and setting the date from the calendar to the DateTimePicker control. For example, in the LCL TCalendar will respond when the calendar is clicked on a date, but not when the user clicks in the title area changing month or year. Then we let the user keep browsing the calendar.

When creating a new wrapper, there are four abstract methods which need to be overridden.

calcontrolwrapper.pas is part of DateTimeCtrls package for Lazarus.

Author:

Zoran Vučenović
Зоран Вученовић

LICENSE

Modified LGPL -- see the file COPYING.modifiedLGPL.

NO WARRANTY

There is no warranty whatsoever.

Original documentation is located on the Lazarus Wiki at:

DateTimeCtrls Package

Specifies an abstract class used as wrapper for the calendar control used in TDateTimePicker.

By default, TDateTimePicker uses the LCL TCalendar control to represent its drop-down calendar. But you can use some other calendar control instead. In order to use another calendar control, you should "wrap" that control with a CalendarControlWrapper.

For use in TDateTimePicker, the calendar control must at least provide a way to determine whether the coordinates are on a date. When the control is clicked, we must decide if the date has just been chosen and respond by closing the drop-down form and setting the date from the calendar to the DateTimePicker control. For example, in the LCL TCalendar will respond when the calendar is clicked on a date, but not when the user clicks in the title area changing month or year. Then we let the user keep browsing the calendar.

When creating a new wrapper, there are four abstract methods which need to be overridden: GetCalendarControlClass, GetDate, SetDate, and AreCoordinatesOnDate.

See TLCLCalendarWrapper in lazcalwrapper.pas for the default implementation used in the LCL.

TLCLCalendarWrapper
Gets the class reference used to create new instances of the calendar control.

Should be overridden to return the class type needed for the calendar control in an implementation

Returns TControlClass in TCalendarControlWrapper.
Abstract virtual method used to set the date for the calendar control.

Should be overridden to set the date in the calendar control.

TDate value stored in the date for the calendar control.
Abstract virtual method used to get the date for the calendar control.

Should be overridden to get the date from the calendar control.

TDate value read from the date in the calendar control.
Indicates if the specified coordinates on a date in the calendar control.

AreCoordinatesOnDate is an abstract virtual Boolean function which indicates if the coordinates (X, Y) are on a date in the calendar control. TDateTimePicker calls this function when the calendar is clicked, to determine whether the drop-down calendar should return the selected date - or not.

The calendar control must at least provide a way to determine whether the coordinates are on a date value when the control is clicked. When a date is chosen, the drop-down form is closed and the date is returned to the TDateTimePicker control. The method must differentiate between coordinates for a date value and those for other user interface elements on the dialog, like: the title area, buttons which change the current month or year, and unused spaces on the calendar control.

For example, the LCL TCalendar control responds when the calendar is clicked on a date, but not when the user clicks in title area changing months or years. In that situation, the user can continue to use the calendar to navigate between months and years.

Returns True if the specified coordinates are on a date in the day grid for the calendar control. False indicates a date value was not selected.
Horizontal coordinate examined for a date value.
Vertical coordinate examined for a date value.
Indicates if the month view is active on the calendar control.

InMonthView is a virtual Boolean function used to indicates if the month view is active on the calendar control. InMonthView can be overridden in descendent classes which use a calendar control that can display view(s) other than a grid with day values, like the TCalendar control on the Windows widgetset.

Used in TDateTimePicker when the drop-down dialog for the control is closed.

False if the calendar control is displaying a view other than the month view. True if the calendar control does not support any other view.
Gets the TControl instance with the calendar control for the wrapper.

GetCalendarControl is a TControl function used to get the calendar control for the wrapper. It returns the class instance, created in the constructor, by instantiating the class type returned from the GetCalendarControlClass method.

Gets the calendar control in the class instance.
Constructor for the class instance.

Create is the constructor for the class instance. It creates and stores a new instance of the class type returned by the GetCalendarControlClass method. Use GetCalendarControl to access the calendar control instance.

Destructor for the class instance.

Frees the calendar control allocated in the constructor, and calls the inherited method to free the class instance.

Base class type used to create mew instances of a calendar control wrapper.