Difference between revisions of "CalLite"

From Lazarus wiki
Jump to navigationJump to search
(→‎Changing colors: Calendar Options)
Line 71: Line 71:
 
* '''coShowWeekend''': Highlights weekend days (see also: <code>Colors.WeekendColor</code>).
 
* '''coShowWeekend''': Highlights weekend days (see also: <code>Colors.WeekendColor</code>).
 
* '''coUseTopRowColors''': Paints background and text of the top navigation row using the colors defined by <code>Colors.TopRowColor</code> and <code>Colors.TopRowTextColor</code>
 
* '''coUseTopRowColors''': Paints background and text of the top navigation row using the colors defined by <code>Colors.TopRowColor</code> and <code>Colors.TopRowTextColor</code>
 +
 +
===Events===
 +
In addition to the standard events TCalendarLite fires the following events. Some events get year, month and day numbers of the currently painted cell as a parameter. A set of state flags indicates whether this day is selected, today or belongs to the previous or next month:
 +
<syntaxhighlight>
 +
type
 +
  TCalCellState = (csSelectedDay, csToday, csOtherMonth);
 +
  TCalCellStates = set of TCalCellState;
 +
</syntaxhighlight>
 +
 +
*'''OnDateChange''': Fires whenever another date is selected in the calendar.
 +
*'''OnDrawCell''': Can be used to override the painting process of a day cell completely or partially. If the boolean parameter <code>AContinueDrawing</code> is set to true the normal painting process continues after leaving the event handler; if it is false then no default painting occurs for this day. The event can be used, for example, to add birthday or holiday icons to the day cells.
 +
*'''OnGetDayText''': Can be used to modify the text display for the specified day. The default is a string showing the day value. Using this event, the names of holidays can be added to calendar, for example.
 +
*'''OnGetHolidays''': Defines which days of current month are holidays. The day number of the holidays are encoded as set bits in a 32-bit integer.
 +
*'''OnHint''': Defines a hint which can be displayed in a popup hint window for each day. Useful, for example, to show the name of holidays if the mouse hovers over a holiday.
 +
*'''OnPrepareCanvas''': Is called immediately before a cell is painted. Can be used to override Brush and Pen properties, for example, in order to draw different backgrounds for appointments and important events.

Revision as of 13:57, 10 November 2016

English (en) suomi (fi) русский (ru)

About

CalLite

TCalendarLite is a light-weight calendar component, a TGraphicControl descendant which consequently is not dependent on any widgetset. It is not a fixed-size component, as are most calendars, but will align and resize as needed. A variety of property gives access to almost every aspect of its appearance.

Authors

Howard Page-Clark, Ariel Rodriguez and Werner Pamler

License

Modified LGPL (with linking exception, like Lazarus LCL)

Download and Installation

Release version

A zip file with the most recent release version can be found at Lazarus CCR at SourceForge. Unzip the file into any folder.

The current release version is 0.2

Development version

Use an svn client to download the current trunk version from svn://svn.code.sf.net/p/lazarus-ccr/svn/components/callite/

Installation

In Lazarus, go to "Package" > "Open Package File .lpk". Navigate to the folder with the callite sources, and select callight_pkg.lkp. Click "Compile", then "Use" > "Install". This will rebuild the IDE (it may take some time). When the process is finished the IDE will restart, and you'll find TCalendarLite in the component palette Misc.

Usage

Simply drop a TCalendarLite component on the form and get a functional month-calendar.

Navigation

  • Click on any date
  • Use the arrow keys on the keyboard
  • Click on the arrow keys above the calendar; the single arrow advances by one month, the double arrow advances by one year
  • Click on the month name to open a popdown menu with month names, or click on the year number to open a popdown menu with the last and next ten years.

Changing colors

The property Colors of the calendar collects all settings affecting the colors used for the various items:

  • ArrowBorderColor: the color of the border of the arrows above the calendar (default: clSilver)
  • ArrowColor: the fill color of the arrows above the calendar (default: clSilver)
  • BackgroundColor: the background color of the entire calendar (default: clWhite)
  • BorderColor: the color of an optional border around the calenard (default: clSilver). Add coShowBorder to the calendar's Options to display the border.
  • DayLineColor: the color of an optional separating line between the top navigation pane and the calendar's day area (default: clSilver). Add coDayLine to the calendar's Options to display the line.
  • HolidayColor: the text color used to display holidays (default: clRed). Add an event handler to OnGetHolidays to define which days are holidays.
  • PastMonthColor: the text color used to display the days of the previous or next month (default: clSilver).
  • SelectedDateColor: fill color of the currently selected day (default: clMoneyGreen)
  • TextColor: text color used for paint the regular calendar days (default: clBlack)
  • TodayFrameColor: color used to draw a rectangular line around the "today" cell (default: clLime)
  • TopRowColor: background color used for the top navigation line (default: clHighlight)
  • TopRowTextColor: text color used in the top navigation line (default: clHighlightText)
  • WeekendColor: text color used for painting weekend days (default: clRed)

Using the calendar's Options

The display of the calendar can be modified by changing the calendar's Options, an enumeration of flags:

type
  TCalOption = (coBoldDayNames, coBoldHolidays, coBoldToday, coBoldTopRow,
                coBoldWeekend, coDayLine, coShowBorder, coShowHolidays,
                coShowTodayFrame, coShowTodayName, coShowTodayRow,
                coShowWeekend, coUseTopRowColors);
  • coBoldDayNames: Draws the line with the day names using bold characters
  • coBoldHolidays: Draws the day number of holidays using bold characters. Holidays are normally off, but you an add an event handler to OnGetHolidays in order to define holidays.
  • coBoldToday: Draws today's cell using bold characters
  • coBoldTopRow: Draws the month name and year number in the top row using bold characters
  • coBoldWeekend: Draws the cells of weekend days using bold characters
  • coDayLine: Adds a separating line between the top navigation line and the calendar's day area.
  • coShowBorder: Paints a thin border rectangle around the calendar
  • coShowHolidays: Activate highlighting holidays. Note that there must be also an event handler for OnGetHolidays which defines the holidays.
  • coShowTodayFrame: Draws a rectangle around the "today" cell.
  • coShowTodayName: Adds the day name to the line displaying today's date (see also: coShowTodayRow)
  • coShowTodayRow: Shows a line at the bottom of the calendar to display today's date (see also: coShowTodayName).
  • coShowWeekend: Highlights weekend days (see also: Colors.WeekendColor).
  • coUseTopRowColors: Paints background and text of the top navigation row using the colors defined by Colors.TopRowColor and Colors.TopRowTextColor

Events

In addition to the standard events TCalendarLite fires the following events. Some events get year, month and day numbers of the currently painted cell as a parameter. A set of state flags indicates whether this day is selected, today or belongs to the previous or next month:

type
  TCalCellState = (csSelectedDay, csToday, csOtherMonth);
  TCalCellStates = set of TCalCellState;
  • OnDateChange: Fires whenever another date is selected in the calendar.
  • OnDrawCell: Can be used to override the painting process of a day cell completely or partially. If the boolean parameter AContinueDrawing is set to true the normal painting process continues after leaving the event handler; if it is false then no default painting occurs for this day. The event can be used, for example, to add birthday or holiday icons to the day cells.
  • OnGetDayText: Can be used to modify the text display for the specified day. The default is a string showing the day value. Using this event, the names of holidays can be added to calendar, for example.
  • OnGetHolidays: Defines which days of current month are holidays. The day number of the holidays are encoded as set bits in a 32-bit integer.
  • OnHint: Defines a hint which can be displayed in a popup hint window for each day. Useful, for example, to show the name of holidays if the mouse hovers over a holiday.
  • OnPrepareCanvas: Is called immediately before a cell is painted. Can be used to override Brush and Pen properties, for example, in order to draw different backgrounds for appointments and important events.