tvplanit: Add demo for TVpCalendar.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8451 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-09-05 15:38:18 +00:00
parent 6eda0b879b
commit 0df94bbd24
4 changed files with 700 additions and 0 deletions

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<Title Value="VpCalendarDemo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes>
<Item Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages>
<Item>
<PackageName Value="laz_visualplanit_design"/>
</Item>
<Item>
<PackageName Value="laz_visualplanit"/>
</Item>
<Item>
<PackageName Value="LCL"/>
</Item>
</RequiredPackages>
<Units>
<Unit>
<Filename Value="VpCalendarDemo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="VpCalendarDemo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions>
<Item>
<Name Value="EAbort"/>
</Item>
<Item>
<Name Value="ECodetoolError"/>
</Item>
<Item>
<Name Value="EFOpenError"/>
</Item>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,25 @@
program VpCalendarDemo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, main
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,404 @@
object Form1: TForm1
Left = 327
Height = 607
Top = 130
Width = 565
Caption = 'Form1'
ClientHeight = 607
ClientWidth = 565
OnCreate = FormCreate
object VpCalendar1: TVpCalendar
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Bevel1
Left = 128
Height = 319
Top = 8
Width = 309
DataStore = VpIniDatastore1
ControlLink = VpControlLink1
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 120
BorderSpacing.Right = 120
BorderSpacing.Around = 8
Colors.ActiveDay = clWindow
Colors.ActiveDayBorder = clWindowText
Colors.ActiveDayText = clWindowText
Colors.Background = clDefault
Colors.ColorScheme = cscalCustom
Colors.DayNames = clWindowText
Colors.Days = clWindowText
Colors.InactiveDays = clWindowText
Colors.MonthAndYear = clWindowText
Colors.Weekend = clWindowText
Colors.EventDays = clWindowText
TabOrder = 0
TabStop = True
end
object Panel1: TPanel
AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 250
Top = 349
Width = 548
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Around = 8
BevelOuter = bvNone
ClientHeight = 250
ClientWidth = 548
TabOrder = 1
object cbActiveDayColor: TColorButton
AnchorSideLeft.Control = rgColorScheme
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 409
Height = 25
Top = 0
Width = 139
BorderSpacing.Left = 16
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Active day'
Margin = 4
OnColorChanged = cbActiveDayColorColorChanged
end
object cgOptions: TCheckGroup
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 0
Height = 165
Top = 0
Width = 257
AutoFill = True
Caption = 'Options'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 145
ClientWidth = 253
Columns = 2
Items.Strings = (
'cdoShortNames'
'cdoShowYear'
'cdoShowInactive'
'cdoShowRevert'
'cdoShowToday'
'cdoShowNavBtns'
'cdoHideActive'
'cdoHighlightSat'
'cdoHighlightSun'
)
OnItemClick = cgOptionsItemClick
TabOrder = 0
Data = {
09000000020202020202020202
}
end
object rgColorScheme: TRadioGroup
AnchorSideLeft.Control = cgOptions
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 273
Height = 200
Top = 0
Width = 120
AutoFill = True
BorderSpacing.Left = 16
Caption = 'Color Scheme'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 180
ClientWidth = 116
Items.Strings = (
'cscalCustom'
'cscalClassic'
'cscalWindows'
'cscalGold'
'cscalOcean'
'cscalRose'
)
OnClick = rgColorSchemeClick
TabOrder = 1
end
object cbDayNamesColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbActiveDayTextColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 75
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Day names'
Margin = 4
OnColorChanged = cbDayNamesColorColorChanged
end
object cbDaysColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbDayNamesColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 100
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Days'
Margin = 4
OnColorChanged = cbDaysColorColorChanged
end
object cbInactiveDaysColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbDaysColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 125
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Inactive days'
Margin = 4
OnColorChanged = cbInactiveDaysColorColorChanged
end
object cbMonthAndYearColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbInactiveDaysColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 150
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Month and year'
Margin = 4
OnColorChanged = cbMonthAndYearColorColorChanged
end
object cbWeekendColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbMonthAndYearColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 175
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Weekend'
Margin = 4
OnColorChanged = cbWeekendColorColorChanged
end
object cbEventDaysColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbWeekendColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 200
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Event days'
Margin = 4
OnColorChanged = cbEventDaysColorColorChanged
end
object cbBackgroundColor: TColorButton
AnchorSideLeft.Control = cbActiveDayColor
AnchorSideTop.Control = cbEventDaysColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 225
Width = 139
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Background'
Margin = 4
OnColorChanged = cbBackgroundColorColorChanged
end
object cbBorder: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = cgOptions
AnchorSideTop.Side = asrBottom
Left = 0
Height = 19
Top = 173
Width = 53
BorderSpacing.Top = 8
Caption = 'Border'
OnChange = cbBorderChange
TabOrder = 2
end
object lblDayNameWidth: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = seDayNameWidth
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 204
Width = 90
Caption = 'Date name width'
end
object seDayNameWidth: TSpinEdit
AnchorSideLeft.Control = lblDayNameWidth
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbBorder
AnchorSideTop.Side = asrBottom
Left = 106
Height = 23
Top = 200
Width = 108
Alignment = taRightJustify
BorderSpacing.Left = 16
BorderSpacing.Top = 8
MaxValue = 999
OnChange = seDayNameWidthChange
TabOrder = 3
end
object lblWeekStarts: TLabel
AnchorSideLeft.Control = lblDayNameWidth
AnchorSideTop.Control = cbWeekStarts
AnchorSideTop.Side = asrCenter
Left = 0
Height = 15
Top = 231
Width = 77
Caption = 'Week starts on'
end
object cbWeekStarts: TComboBox
AnchorSideLeft.Control = seDayNameWidth
AnchorSideTop.Control = seDayNameWidth
AnchorSideTop.Side = asrBottom
Left = 106
Height = 23
Top = 227
Width = 106
BorderSpacing.Top = 4
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'dtSunday'
'dtMonday'
'dtTuesday'
'dtWednesday'
'dtThursday'
'dtFriday'
'dtSaturday'
)
OnChange = cbWeekStartsChange
TabOrder = 4
Text = 'dtSunday'
end
object cbActiveDayBorderColor: TColorButton
AnchorSideLeft.Control = rgColorScheme
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbActiveDayColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 25
Width = 139
BorderSpacing.Left = 16
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Active day border'
Margin = 4
OnColorChanged = cbActiveDayBorderColorColorChanged
end
object cbActiveDayTextColor: TColorButton
AnchorSideLeft.Control = rgColorScheme
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbActiveDayBorderColor
AnchorSideTop.Side = asrBottom
Left = 409
Height = 25
Top = 50
Width = 139
BorderSpacing.Left = 16
BorderWidth = 2
ButtonColorAutoSize = False
ButtonColorSize = 16
ButtonColor = clSilver
Caption = 'Active day text'
Margin = 4
OnColorChanged = cbActiveDayTextColorColorChanged
end
end
object Bevel1: TBevel
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Panel1
Left = 8
Height = 6
Top = 335
Width = 549
Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Shape = bsTopLine
end
object VpControlLink1: TVpControlLink
DataStore = VpIniDatastore1
Printer.DayStart = h_08
Printer.DayEnd = h_05
Printer.Granularity = gr30Min
Printer.MarginUnits = imAbsolutePixel
Printer.PrintFormats = <>
Left = 40
Top = 72
end
object VpIniDatastore1: TVpIniDatastore
CategoryColorMap.Category0.Description = 'Category 0'
CategoryColorMap.Category1.Description = 'Category 1'
CategoryColorMap.Category2.Description = 'Category 2'
CategoryColorMap.Category3.Description = 'Category 3'
CategoryColorMap.Category4.Description = 'Category 4'
CategoryColorMap.Category5.Description = 'Category 5'
CategoryColorMap.Category6.Description = 'Category 6'
CategoryColorMap.Category7.Description = 'Category 7'
CategoryColorMap.Category8.Description = 'Category 8'
CategoryColorMap.Category9.Description = 'Category 9'
HiddenCategories.BackgroundColor = clSilver
HiddenCategories.Color = clGray
AutoConnect = True
FileName = 'data.ini'
Left = 40
Top = 176
end
end

View File

@ -0,0 +1,185 @@
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Spin,
VpBaseDS, VpMisc, VpIniDs, VpContactGrid, VpCalendar;
type
{ TForm1 }
TForm1 = class(TForm)
Bevel1: TBevel;
cbActiveDayBorderColor: TColorButton;
cbActiveDayTextColor: TColorButton;
cbDayNamesColor: TColorButton;
cbDaysColor: TColorButton;
cbBackgroundColor: TColorButton;
cbInactiveDaysColor: TColorButton;
cbMonthAndYearColor: TColorButton;
cbWeekendColor: TColorButton;
cbEventDaysColor: TColorButton;
cbBorder: TCheckBox;
cbActiveDayColor: TColorButton;
cgOptions: TCheckGroup;
cbWeekStarts: TComboBox;
lblWeekStarts: TLabel;
lblDayNameWidth: TLabel;
Panel1: TPanel;
rgColorScheme: TRadioGroup;
seDayNameWidth: TSpinEdit;
VpCalendar1: TVpCalendar;
VpControlLink1: TVpControlLink;
VpIniDatastore1: TVpIniDatastore;
procedure cbActiveDayBorderColorColorChanged(Sender: TObject);
procedure cbActiveDayTextColorColorChanged(Sender: TObject);
procedure cbBackgroundColorColorChanged(Sender: TObject);
procedure cbDayNamesColorColorChanged(Sender: TObject);
procedure cbDaysColorColorChanged(Sender: TObject);
procedure cbInactiveDaysColorColorChanged(Sender: TObject);
procedure cbMonthAndYearColorColorChanged(Sender: TObject);
procedure cbEventDaysColorColorChanged(Sender: TObject);
procedure cbWeekendColorColorChanged(Sender: TObject);
procedure cbWeekStartsChange(Sender: TObject);
procedure cgOptionsItemClick(Sender: TObject; Index: integer);
procedure cbBorderChange(Sender: TObject);
procedure cbActiveDayColorColorChanged(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure rgColorSchemeClick(Sender: TObject);
procedure seDayNameWidthChange(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
uses
VpBase;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
option: TVpCalDisplayOption;
begin
if VpIniDatastore1.Resources.Count > 0 then
VpIniDatastore1.Resource := VpIniDatastore1.Resources.Items[0];
for option in TVpCalDisplayOption do
cgOptions.Checked[ord(option)] := option in VpCalendar1.Options;
rgColorScheme.ItemIndex := ord(VpCalendar1.Colors.ColorScheme);
seDayNameWidth.Value := VpCalendar1.DayNameWidth;
cbWeekStarts.ItemIndex := ord(VpCalendar1.WeekStarts);
end;
procedure TForm1.rgColorSchemeClick(Sender: TObject);
begin
VpCalendar1.Colors.ColorScheme := TVpCalColorScheme(rgColorScheme.ItemIndex);
cbActiveDayColor.ButtonColor := VpCalendar1.Colors.ActiveDay;
cbActiveDayBorderColor.ButtonColor := VpCalendar1.Colors.ActiveDayBorder;
cbActiveDayTextColor.ButtonColor := VpCalendar1.Colors.ActiveDayText;
cbDayNamesColor.ButtonColor := VpCalendar1.Colors.DayNames;
cbDaysColor.ButtonColor := VpCalendar1.Colors.Days;
cbInactiveDaysColor.ButtonColor := VpCalendar1.Colors.InactiveDays;
cbMonthAndYearColor.ButtonColor := VpCalendar1.Colors.MonthAndYear;
cbEventDaysColor.ButtonColor := VpCalendar1.Colors.EventDays;
cbWeekendColor.ButtonColor := VpCalendar1.Colors.Weekend;
cbBackgroundColor.ButtonColor := VpCalendar1.Colors.Background;
end;
procedure TForm1.seDayNameWidthChange(Sender: TObject);
begin
VpCalendar1.DayNameWidth := seDayNameWidth.Value;
end;
procedure TForm1.cbBorderChange(Sender: TObject);
begin
if cbBorder.Checked then
VpCalendar1.BorderStyle := bsSingle
else
VpCalendar1.BorderStyle := bsNone;
end;
procedure TForm1.cgOptionsItemClick(Sender: TObject; Index: integer);
var
options: TVpCalDisplayOptions;
i: Integer;
begin
options := [];
for i := 0 to cgOptions.Items.Count-1 do
if cgOptions.Checked[i] then
Include(options, TVpCalDisplayOption(i));
VpCalendar1.Options := options;
end;
procedure TForm1.cbActiveDayColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.ActiveDay := cbActiveDayColor.ButtonColor;
end;
procedure TForm1.cbDayNamesColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.DayNames := cbDayNamesColor.ButtonColor;
end;
procedure TForm1.cbBackgroundColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.Background := cbBackgroundColor.ButtonColor;
end;
procedure TForm1.cbActiveDayBorderColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.ActiveDayBorder := cbActiveDayBorderColor.ButtonColor;
end;
procedure TForm1.cbActiveDayTextColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.ActiveDayText := cbActiveDayTextColor.ButtonColor;
end;
procedure TForm1.cbInactiveDaysColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.InactiveDays := cbInactiveDaysColor.ButtonColor;
end;
procedure TForm1.cbMonthAndYearColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.MonthAndYear := cbMonthAndYearColor.ButtonColor;
end;
procedure TForm1.cbEventDaysColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.EventDays := cbEventDaysColor.ButtonColor;
end;
procedure TForm1.cbDaysColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.Days := cbDaysColor.ButtonColor;
end;
procedure TForm1.cbWeekendColorColorChanged(Sender: TObject);
begin
VpCalendar1.Colors.Weekend := cbWeekendColor.ButtonColor;
end;
procedure TForm1.cbWeekStartsChange(Sender: TObject);
begin
VpCalendar1.WeekStarts := TVpDayType(cbWeekStarts.ItemIndex);
end;
end.