CalLite: Add colors to demo2. Fix positioning issue for bold TodayRow.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5320 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-11-06 17:28:04 +00:00
parent 0dd55ed594
commit 4ac2ecd5ec
3 changed files with 364 additions and 57 deletions

View File

@@ -1,29 +1,29 @@
object Form1: TForm1 object Form1: TForm1
Left = 536 Left = 687
Height = 845 Height = 845
Top = 72 Top = 88
Width = 648 Width = 753
Caption = 'Examples of the TCalendaLite component' Caption = 'Examples of the TCalendaLite component'
ClientHeight = 845 ClientHeight = 845
ClientWidth = 648 ClientWidth = 753
Color = clWindow Color = clWindow
Font.CharSet = ANSI_CHARSET Font.CharSet = ANSI_CHARSET
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '1.7' LCLVersion = '1.7'
object PSettings: TPanel object PSettings: TPanel
Left = 0 Left = 0
Height = 376 Height = 408
Top = 0 Top = 0
Width = 648 Width = 753
Align = alTop Align = alTop
ClientHeight = 376 ClientHeight = 408
ClientWidth = 648 ClientWidth = 753
TabOrder = 0 TabOrder = 0
object cgOptions: TCheckGroup object cgOptions: TCheckGroup
Left = 24 Left = 24
Height = 296 Height = 352
Top = 40 Top = 40
Width = 185 Width = 160
AutoFill = True AutoFill = True
Caption = 'Set calendar Options' Caption = 'Set calendar Options'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
@@ -34,8 +34,8 @@ object Form1: TForm1
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 276 ClientHeight = 332
ClientWidth = 181 ClientWidth = 156
Items.Strings = ( Items.Strings = (
'coBoldDayNames' 'coBoldDayNames'
'coBoldHolidays' 'coBoldHolidays'
@@ -58,9 +58,9 @@ object Form1: TForm1
} }
end end
object cbUseHolidays: TCheckBox object cbUseHolidays: TCheckBox
Left = 239 Left = 560
Height = 19 Height = 19
Top = 40 Top = 48
Width = 169 Width = 169
Caption = 'Ignore OnGetHolidays event' Caption = 'Ignore OnGetHolidays event'
OnChange = cbUseHolidaysChange OnChange = cbUseHolidaysChange
@@ -78,17 +78,17 @@ object Form1: TForm1
ParentFont = False ParentFont = False
end end
object LWidth: TLabel object LWidth: TLabel
Left = 239 Left = 560
Height = 15 Height = 15
Top = 81 Top = 89
Width = 32 Width = 32
Caption = 'Width' Caption = 'Width'
ParentColor = False ParentColor = False
end end
object seWidth: TSpinEdit object seWidth: TSpinEdit
Left = 296 Left = 617
Height = 23 Height = 23
Top = 79 Top = 87
Width = 66 Width = 66
MaxValue = 430 MaxValue = 430
MinValue = 120 MinValue = 120
@@ -97,9 +97,9 @@ object Form1: TForm1
Value = 300 Value = 300
end end
object seHeight: TSpinEdit object seHeight: TSpinEdit
Left = 296 Left = 617
Height = 23 Height = 23
Top = 112 Top = 120
Width = 66 Width = 66
MaxValue = 250 MaxValue = 250
MinValue = 120 MinValue = 120
@@ -108,18 +108,18 @@ object Form1: TForm1
Value = 200 Value = 200
end end
object lHeight: TLabel object lHeight: TLabel
Left = 239 Left = 560
Height = 15 Height = 15
Top = 112 Top = 120
Width = 36 Width = 36
Caption = 'Height' Caption = 'Height'
ParentColor = False ParentColor = False
end end
object rgLanguage: TRadioGroup object rgLanguage: TRadioGroup
Left = 239 Left = 200
Height = 160 Height = 144
Top = 176 Top = 248
Width = 180 Width = 160
AutoFill = True AutoFill = True
Caption = 'Language to use' Caption = 'Language to use'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
@@ -130,8 +130,8 @@ object Form1: TForm1
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 140 ClientHeight = 124
ClientWidth = 176 ClientWidth = 156
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'English (default)' 'English (default)'
@@ -144,10 +144,10 @@ object Form1: TForm1
TabOrder = 4 TabOrder = 4
end end
object rgStartingDOW: TRadioGroup object rgStartingDOW: TRadioGroup
Left = 440 Left = 200
Height = 192 Height = 192
Top = 40 Top = 40
Width = 176 Width = 160
AutoFill = True AutoFill = True
Caption = 'Starting day of the week' Caption = 'Starting day of the week'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
@@ -159,7 +159,7 @@ object Form1: TForm1
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 172 ClientHeight = 172
ClientWidth = 172 ClientWidth = 156
Items.Strings = ( Items.Strings = (
'Sunday' 'Sunday'
'Monday' 'Monday'
@@ -172,26 +172,262 @@ object Form1: TForm1
OnClick = rgStartingDOWClick OnClick = rgStartingDOWClick
TabOrder = 5 TabOrder = 5
end end
end object GroupBox1: TGroupBox
object CalendarLite1: TCalendarLite Left = 376
Left = 132 Height = 352
Height = 160 Top = 40
Top = 489 Width = 160
Width = 210 Caption = 'Colors'
Constraints.MinHeight = 120 ClientHeight = 332
Constraints.MinWidth = 120 ClientWidth = 156
ParentColor = False TabOrder = 6
TabOrder = 1 object CbArrowBorder: TColorButton
Date = 42678 Left = 16
DisplayTexts = '"Today is",dd/mm/yyyy,"Holidays during","There are no holidays set for"' Height = 25
WeekendDays = [dowSunday, dowSaturday] Top = 8
end Width = 26
object Label1: TLabel BorderWidth = 2
Left = 76 ButtonColorSize = 16
Height = 15 ButtonColor = clBlack
Top = 425 Flat = True
Width = 34 OnColorChanged = ColorButtonChanged
Caption = 'Label1' end
ParentColor = False object CbArrow: TColorButton
Left = 16
Height = 25
Top = 32
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label2: TLabel
Left = 49
Height = 15
Top = 13
Width = 67
Caption = 'ArrowBorder'
ParentColor = False
end
object Label3: TLabel
Left = 49
Height = 15
Top = 37
Width = 32
Caption = 'Arrow'
ParentColor = False
end
object CbBackground: TColorButton
Left = 16
Height = 25
Top = 56
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object CbBorder: TColorButton
Left = 16
Height = 25
Top = 80
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label4: TLabel
Left = 49
Height = 15
Top = 61
Width = 64
Caption = 'Background'
ParentColor = False
end
object Label5: TLabel
Left = 49
Height = 15
Top = 85
Width = 35
Caption = 'Border'
ParentColor = False
end
object CbDayLine: TColorButton
Left = 16
Height = 25
Top = 104
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object CbHolidays: TColorButton
Left = 16
Height = 25
Top = 128
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label6: TLabel
Left = 49
Height = 15
Top = 109
Width = 42
Caption = 'Day line'
ParentColor = False
end
object Label7: TLabel
Left = 49
Height = 15
Top = 133
Width = 46
Caption = 'Holidays'
ParentColor = False
end
object CbPastMonth: TColorButton
Left = 16
Height = 25
Top = 152
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object CbSelectedDate: TColorButton
Left = 16
Height = 25
Top = 176
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label8: TLabel
Left = 49
Height = 15
Top = 157
Width = 88
Caption = 'Past/next month'
ParentColor = False
end
object Label9: TLabel
Left = 49
Height = 15
Top = 181
Width = 70
Caption = 'Selected date'
ParentColor = False
end
object CbText: TColorButton
Left = 16
Height = 25
Top = 200
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object CbTodayFrame: TColorButton
Left = 16
Height = 25
Top = 224
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label10: TLabel
Left = 49
Height = 15
Top = 205
Width = 21
Caption = 'Text'
ParentColor = False
end
object Label11: TLabel
Left = 49
Height = 15
Top = 229
Width = 66
Caption = 'Today frame'
ParentColor = False
end
object CbTopRow: TColorButton
Left = 16
Height = 25
Top = 248
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object CbTopRowText: TColorButton
Left = 16
Height = 25
Top = 272
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label12: TLabel
Left = 49
Height = 15
Top = 253
Width = 43
Caption = 'Top row'
ParentColor = False
end
object Label13: TLabel
Left = 49
Height = 15
Top = 277
Width = 65
Caption = 'Top row text'
ParentColor = False
end
object CbWeekend: TColorButton
Left = 16
Height = 25
Top = 296
Width = 26
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
Flat = True
OnColorChanged = ColorButtonChanged
end
object Label14: TLabel
Left = 49
Height = 15
Top = 301
Width = 49
Caption = 'Weekend'
ParentColor = False
end
end
end end
end end

View File

@@ -5,17 +5,43 @@ unit uMainTestCalLite;
interface interface
uses uses
Classes, SysUtils, Forms, Graphics, ExtCtrls, StdCtrls, Spin, CalendarLite; Classes, SysUtils, Forms, Graphics, ExtCtrls, StdCtrls, Spin, Dialogs,
CalendarLite;
type type
{ TForm1 } { TForm1 }
TForm1 = class(TForm) TForm1 = class(TForm)
CalendarLite1: TCalendarLite;
cbUseHolidays: TCheckBox; cbUseHolidays: TCheckBox;
cgOptions: TCheckGroup; cgOptions: TCheckGroup;
Label1: TLabel; CbArrowBorder: TColorButton;
CbTodayFrame: TColorButton;
CbTopRow: TColorButton;
CbTopRowText: TColorButton;
CbWeekend: TColorButton;
CbArrow: TColorButton;
CbBackground: TColorButton;
CbBorder: TColorButton;
CbDayLine: TColorButton;
CbHolidays: TColorButton;
CbPastMonth: TColorButton;
CbSelectedDate: TColorButton;
CbText: TColorButton;
GroupBox1: TGroupBox;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
LTitle: TLabel; LTitle: TLabel;
LWidth: TLabel; LWidth: TLabel;
lHeight: TLabel; lHeight: TLabel;
@@ -24,6 +50,7 @@ type
rgStartingDOW: TRadioGroup; rgStartingDOW: TRadioGroup;
seWidth: TSpinEdit; seWidth: TSpinEdit;
seHeight: TSpinEdit; seHeight: TSpinEdit;
procedure ColorButtonChanged(Sender: TObject);
procedure cbUseHolidaysChange(Sender: TObject); procedure cbUseHolidaysChange(Sender: TObject);
procedure cgOptionsItemClick(Sender: TObject; Index: integer); procedure cgOptionsItemClick(Sender: TObject; Index: integer);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
@@ -47,8 +74,6 @@ implementation
{$R *.lfm} {$R *.lfm}
uses
Dialogs;
function Easter(year:integer) : TDateTime; // wp function Easter(year:integer) : TDateTime; // wp
var var
@@ -114,6 +139,20 @@ begin
copyCal.StartingDayOfWeek:= dowSaturday; copyCal.StartingDayOfWeek:= dowSaturday;
copyCal.OnGetHolidays := @GetHolidays; copyCal.OnGetHolidays := @GetHolidays;
copyCal.Options := copyCal.Options + [coShowBorder,coUseTopRowColors,coDayLine]; copyCal.Options := copyCal.Options + [coShowBorder,coUseTopRowColors,coDayLine];
CbArrowBorder.ButtonColor := demoCal.Colors.ArrowBorderColor;
CbArrow.ButtonColor := demoCal.Colors.ArrowColor;
CbBackground.ButtonColor := demoCal.Colors.BackgroundColor;
CbBorder.ButtonColor := demoCal.Colors.BorderColor;
CbDayLine.ButtonColor := demoCal.Colors.DayLineColor;
CbHolidays.Buttoncolor := demoCal.colors.HolidayColor;
CbPastMonth.ButtonColor := demoCal.Colors.PastMonthColor;
CbSelectedDate.ButtonColor := demoCal.Colors.SelectedDateColor;
CbText.ButtonColor := demoCal.Colors.TextColor;
CbTodayFrame.ButtonColor := demoCal.Colors.TodayFrameColor;
CbTopRow.ButtonColor := demoCal.Colors.TopRowColor;
CbTopRowText.ButtonColor := democal.Colors.TopRowTextColor;
CbWeekend.ButtonColor := demoCal.Colors.WeekendColor;
end; end;
procedure TForm1.rgLanguageClick(Sender: TObject); procedure TForm1.rgLanguageClick(Sender: TObject);
@@ -142,6 +181,31 @@ begin
demoCal.Width := seWidth.Value; demoCal.Width := seWidth.Value;
end; end;
procedure TForm1.ColorButtonChanged(Sender: TObject);
var
calendar: TCalendarLite;
col: TColor;
begin
calendar := demoCal;
col := (Sender as TColorButton).ButtonColor;
case (Sender as TColorButton).Name of
'CbArrowBorder': calendar.Colors.ArrowBorderColor := col;
'CbArror': calendar.Colors.ArrowColor := col;
'CbBackground': calendar.Colors.BackgroundColor := col;
'CbBorder': calendar.Colors.BorderColor := col;
'CbDayLine': calendar.Colors.DayLineColor := col;
'CbHolidays': calendar.Colors.HolidayColor := col;
'CbPastMonth': calendar.Colors.PastMonthColor := col;
'CbSelectedDate': calendar.Colors.SelectedDateColor := col;
'CbText': calendar.Colors.TextColor := col;
'CbTodayFrame': calendar.Colors.TodayFrameColor := col;
'CbTopRow': calendar.Colors.TopRowColor := col;
'CbTopRowText': calendar.Colors.TopRowTextColor := col;
'CbWeekend': calendar.Colors.WeekendColor := col;
end;
calendar.Invalidate;
end;
procedure TForm1.cbUseHolidaysChange(Sender: TObject); procedure TForm1.cbUseHolidaysChange(Sender: TObject);
begin begin
FNoHolidays := not FNoHolidays; FNoHolidays := not FNoHolidays;

View File

@@ -100,6 +100,9 @@ type
TGetHolidaysEvent = procedure (Sender: TObject; AMonth, AYear: Integer; TGetHolidaysEvent = procedure (Sender: TObject; AMonth, AYear: Integer;
var Holidays: THolidays) of object; var Holidays: THolidays) of object;
TFormatEvent = procedure (Sender: TObject; ADate: TDate;
AFont: TFont; ABkColor: TColor) of object;
TCalOption = (coBoldDayNames, coBoldHolidays, coBoldToday, coBoldTopRow, TCalOption = (coBoldDayNames, coBoldHolidays, coBoldToday, coBoldTopRow,
coBoldWeekend, coDayLine, coShowBorder, coShowHolidays, coBoldWeekend, coDayLine, coShowBorder, coShowHolidays,
coShowTodayFrame, coShowTodayName, coShowTodayRow, coShowTodayFrame, coShowTodayName, coShowTodayRow,
@@ -612,6 +615,10 @@ begin
if (FCanvas.Font.Color <> FOwner.Colors.TextColor) then if (FCanvas.Font.Color <> FOwner.Colors.TextColor) then
FCanvas.Font.Color:= FOwner.Colors.TextColor; FCanvas.Font.Color:= FOwner.Colors.TextColor;
if coBoldToday in FOwner.Options then
FCanvas.Font.Style := [fsBold] else
FCanvas.Font.Style := [];
s:= FOwner.GetDisplayText(dtToday); s:= FOwner.GetDisplayText(dtToday);
if (coShowTodayName in FOwner.Options) then if (coShowTodayName in FOwner.Options) then
s := Format('%s %s',[s, FOwner.GetDayName(TDayOfWeek(DayOfWeek(Date())))]); s := Format('%s %s',[s, FOwner.GetDayName(TDayOfWeek(DayOfWeek(Date())))]);