From 219cf32bb715b2467c1a28721dde78354c92a666 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 29 Dec 2018 15:32:45 +0000 Subject: [PATCH] CalLite: Add demo for multi-selection of dates git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6777 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/callite/demo3/main.lpi | 82 +++++++++++++++++++++ components/callite/demo3/main.lpr | 22 ++++++ components/callite/demo3/selectiondemo.lfm | 83 ++++++++++++++++++++++ components/callite/demo3/selectiondemo.pas | 60 ++++++++++++++++ components/callite/source/calendarlite.pas | 2 +- 5 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 components/callite/demo3/main.lpi create mode 100644 components/callite/demo3/main.lpr create mode 100644 components/callite/demo3/selectiondemo.lfm create mode 100644 components/callite/demo3/selectiondemo.pas diff --git a/components/callite/demo3/main.lpi b/components/callite/demo3/main.lpi new file mode 100644 index 000000000..6296f6889 --- /dev/null +++ b/components/callite/demo3/main.lpi @@ -0,0 +1,82 @@ + + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="callight_pkg"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="main.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="selectiondemo.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="SelectionDemo"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="main"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/callite/demo3/main.lpr b/components/callite/demo3/main.lpr new file mode 100644 index 000000000..a20a6abb9 --- /dev/null +++ b/components/callite/demo3/main.lpr @@ -0,0 +1,22 @@ +program main; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, SelectionDemo + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/components/callite/demo3/selectiondemo.lfm b/components/callite/demo3/selectiondemo.lfm new file mode 100644 index 000000000..af324c980 --- /dev/null +++ b/components/callite/demo3/selectiondemo.lfm @@ -0,0 +1,83 @@ +object Form1: TForm1 + Left = 282 + Height = 248 + Top = 133 + Width = 398 + Caption = 'Date selection demo' + ClientHeight = 248 + ClientWidth = 398 + LCLVersion = '2.1.0.0' + object ListBox1: TListBox + Left = 287 + Height = 240 + Top = 4 + Width = 107 + Align = alRight + BorderSpacing.Around = 4 + ItemHeight = 0 + TabOrder = 0 + end + object Panel1: TPanel + Left = 0 + Height = 248 + Top = 0 + Width = 278 + Align = alClient + BevelOuter = bvNone + ClientHeight = 248 + ClientWidth = 278 + TabOrder = 1 + object CalendarLite1: TCalendarLite + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = Panel1 + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = CbMultiselect + Left = 4 + Height = 217 + Top = 4 + Width = 274 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 4 + BorderSpacing.Top = 4 + BorderSpacing.Bottom = 4 + Constraints.MinHeight = 120 + Constraints.MinWidth = 120 + ParentColor = False + TabOrder = 0 + TabStop = True + Colors.TodayFrameColor = clGray + Date = 43463 + DisplayTexts = '"Today is %s","mmm dd"", ""yyyy","Holidays in %d","There are no holidays set for %d","dddd"", "" mmm dd"", ""yyyy","mmmm yyyy"' + MultiSelect = True + Options = [coBoldHolidays, coBoldTopRow, coDayLine, coShowBorder, coShowHolidays, coShowTodayFrame, coShowTodayName, coShowTodayRow, coShowWeekend] + WeekendDays = [dowSunday, dowSaturday] + OnDateChange = CalendarLite1DateChange + end + object CbMultiselect: TCheckBox + AnchorSideLeft.Control = Panel1 + AnchorSideBottom.Control = Panel1 + AnchorSideBottom.Side = asrBottom + Left = 4 + Height = 19 + Top = 225 + Width = 100 + Anchors = [akLeft, akBottom] + BorderSpacing.Left = 4 + BorderSpacing.Bottom = 4 + Caption = 'Multi-selection' + Checked = True + OnChange = CbMultiselectChange + State = cbChecked + TabOrder = 1 + end + end + object Splitter1: TSplitter + Left = 278 + Height = 248 + Top = 0 + Width = 5 + Align = alRight + ResizeAnchor = akRight + end +end diff --git a/components/callite/demo3/selectiondemo.pas b/components/callite/demo3/selectiondemo.pas new file mode 100644 index 000000000..785a55cfc --- /dev/null +++ b/components/callite/demo3/selectiondemo.pas @@ -0,0 +1,60 @@ +unit SelectionDemo; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, + CalendarLite; + +type + + { TForm1 } + + TForm1 = class(TForm) + CalendarLite1: TCalendarLite; + CbMultiselect: TCheckBox; + ListBox1: TListBox; + Panel1: TPanel; + Splitter1: TSplitter; + procedure CalendarLite1DateChange(Sender: TObject); + procedure CbMultiselectChange(Sender: TObject); + private + + public + + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.CalendarLite1DateChange(Sender: TObject); +var + d: TDate; + selDates: TCalDateArray; +begin + Listbox1.Items.BeginUpdate; + try + Listbox1.Items.Clear; + selDates := CalendarLite1.SelectedDates; + for d in selDates do + Listbox1.Items.Add(DateToStr(d)); + finally + Listbox1.Items.EndUpdate; + end; +end; + +procedure TForm1.CbMultiselectChange(Sender: TObject); +begin + CalendarLite1.MultiSelect := cbMultiSelect.Checked; +end; + +end. + diff --git a/components/callite/source/calendarlite.pas b/components/callite/source/calendarlite.pas index ff0937561..49d317231 100644 --- a/components/callite/source/calendarlite.pas +++ b/components/callite/source/calendarlite.pas @@ -371,7 +371,7 @@ uses resourcestring rsCalTodayIs = 'Today is %s'; rsCalTodayFormat = 'mmm dd, yyyy'; - rsCalTodayFormatLong = 'dddd mmm dd, yyyy'; + rsCalTodayFormatLong = 'dddd, mmm dd, yyyy'; rsCalCaptionFormat = 'mmmm yyyy'; rsCalHolidaysIn = 'Holidays in %d'; rsCalNoHolidaysIn = 'There are no holidays set for %d';