New components TDateTimePicker and TDBDateTimePicker. Copied and modified from ZV-components from Zoran Vučenović.

git-svn-id: trunk@43857 -
This commit is contained in:
juha 2014-01-31 11:03:03 +00:00
parent 27cf7ad57d
commit 425985c464
13 changed files with 5468 additions and 0 deletions

12
.gitattributes vendored
View File

@ -1039,6 +1039,18 @@ components/datadict/reglazdatadict.res -text
components/datadict/testdatadict.lpi svneol=native#text/plain
components/datadict/testdatadict.lpr svneol=native#text/plain
components/datadict/tfpcodegenerator.xpm svneol=native#text/plain
components/datetimectrls/ChangeLog.txt svneol=native#text/plain
components/datetimectrls/calcontrolwrapper.pas svneol=native#text/pascal
components/datetimectrls/datetimecontrolsreg.pas svneol=native#text/pascal
components/datetimectrls/datetimectrls.lpk svneol=native#text/plain
components/datetimectrls/datetimectrls.lrs svneol=native#text/pascal
components/datetimectrls/datetimectrls.pas svneol=native#text/pascal
components/datetimectrls/datetimepicker.pas svneol=native#text/pascal
components/datetimectrls/datetimepickerpropedit.pas svneol=native#text/pascal
components/datetimectrls/dbdatetimepicker.pas svneol=native#text/pascal
components/datetimectrls/lclcalwrapper.pas svneol=native#text/pascal
components/datetimectrls/manual.htm svneol=native#text/plain
components/datetimectrls/readme.txt svneol=native#text/plain
components/dbexport/README.txt svneol=native#text/plain
components/dbexport/dbexportimg.res -text
components/dbexport/dbexportimg.txt svneol=native#text/plain

View File

@ -0,0 +1,68 @@
===================================================
Version 1.0 -- 27. Feb. 2010.
Initial release
===================================================
Version 1.1 -- 18. April 2010.
The Data aware control's (DBZVDateTimePicker's) interacting with DataSource is slightly improved.
There are also several fixes, these are some of them. The first three fixes apply to DBZVDateTimePicker control only, the fourth, fifth and sixth apply to both controls.
1. In runtime changing date/time in DBZVDateTimePicker was possible when not connected to database.
When not connected to specific DB field, or when the Database connection is not active, now the control can only have NULL value, which is appropriate behaviour for a DB control.
2. The Time property was accidentaly published in DBZVDateTimePicker. Time property, as well as Date, cannot be used directly in DBZVDateTimePicker, it is tied to underlying DB field.
The Time property is removed from published section of TDBZVDateTimePicker.
3. The DBZVDateTimePicker's properties MaxDate and MinDate were displayed as real numbers in Object inspector.
They are now displayed as dates.
4. The Hint property didn't work -- the hint didn't appear.
Now the Hint is shown when mouse pointer is over the control, of course only if ShowHint is set to True.
5. When calendar button is shown and AutoSize is False and the width is less than Text's width + SpeedButton's width, then the button gets hidden behind the text.
Now, the button is shown in front of the text, which is more appropriate behaviour.
6. When UpDown is shown and AutoSize is False, if Heigth is set to more than it would be if AutoSized, then, setting AutoSize to True would not trigger shirnking the control's Height as it should.
Fixed, now it does.
===================================================
Version 1.2 -- 12. May 2010.
Because of changes in LCL, some changes in code were needed, so that controls can compile with new Lazarus from svn trunk (since revision 25204).
===================================================
Version 1.3 -- 1. April 2011.
The changes of LCL, made after separating the 0.9.30 branch from the trunk, caused the crash of the control in new Lazarus 0.9.31 from trunk (see: http://wiki.freepascal.org/Lazarus_0.99.0_release_notes#Changes_affecting_compatibility), internal using of constructor TForm.Create had to be replaced by TForm.CreateNew (it was used twice -- for the drop-down form which carries the calendar and for design-time component editor form).
There are also internal changes which improved autosizing of the control.
The code is much simplified and the control is lighter now (there used to be an auxiliary control which is removed now and its code is simplified and unified in the main control).
===================================================
Version 1.4 -- 5. September 2012.
These are main changes:
The ZVDateTimeControls package is now in subversion control.
Added an event to interact with CheckBox -- OnCheckBoxChange (by Daniel S. Almeida).
OnChange event was triggered whenever date/time values change. Now it reacts only on changes made by user interaction, not when the changes are made programatically. The new behaviour is compatible with OnChange event of VCL's TDateTimePicker.
In Linux, locale-dependent properties were not initialized to correct defaults. Fixed now.
In Qt ws, the client rect of the control was not calculated correctly. Fixed now.
Plus many internal changes...

View File

@ -0,0 +1,103 @@
{
CalControlWrapper
- - - - - - - - - - - - - - - - -
Author: Zoran Vučenović
Зоран Вученовић
This unit is part of DateTimeCtrls package for Lazarus.
By default, TDateTimePicker uses LCL's TCalendar to represent the
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.
To be used by DateTimePicker, the calendar control must at least provide
a way to determine whether the coordinates are on the date (when this control
gets clicked, we must decide if the date has just been chosen - then we should
respond by closing the drop-down form and setting the date from calendar to
DateTimePicker - for example in LCL's TCalendar we will respond when the
calendar is clicked on date, but not when the user clicks in title area changing
months or years, then we let the user keep browsing the calendar).
When creating new wrapper, there are four abstract methods which need to be
overriden. Please see the coments in code below.
-----------------------------------------------------------
LICENCE
- - - -
Modified LGPL -- see the file COPYING.modifiedLGPL.
-----------------------------------------------------------
NO WARRANTY
- - - - - -
There is no warranty whatsoever.
-----------------------------------------------------------
BEST REGARDS TO LAZARUS COMMUNITY!
- - - - - - - - - - - - - - - - - -
I do hope the DateTimeCtrls package will be useful.
}
unit calcontrolwrapper;
{$mode objfpc}{$H+}
interface
uses
Controls;
type
{ TCalendarControlWrapper }
TCalendarControlWrapper = class
private
FCalendarControl: TControl;
public
{ There are four methods that derived classes should override: }
{ Should be overriden to just return the class of the calendar control. }
class function GetCalendarControlClass: TControlClass; virtual abstract;
{ Should be overriden to set the date in the calendar control. }
procedure SetDate(Date: TDate); virtual abstract;
{ Should be overriden to get the date from the calendar control. }
function GetDate: TDate; virtual abstract;
{ This function should return True if coordinates (X, Y) are on the date in
the calendar control (DateTimePicker calls this function when the calendar
is clicked, to determine whether the drop-down calendar should return the
date or not). }
function AreCoordinatesOnDate(X, Y: Integer): Boolean; virtual abstract;
function GetCalendarControl: TControl;
constructor Create; virtual;
destructor Destroy; override;
end;
TCalendarControlWrapperClass = class of TCalendarControlWrapper;
implementation
{ TCalendarControlWrapper }
function TCalendarControlWrapper.GetCalendarControl: TControl;
begin
Result := FCalendarControl;
end;
constructor TCalendarControlWrapper.Create;
begin
FCalendarControl := GetCalendarControlClass.Create(nil);
end;
destructor TCalendarControlWrapper.Destroy;
begin
FCalendarControl.Free;
inherited Destroy;
end;
end.

View File

@ -0,0 +1,46 @@
{
DateTimeControlsReg
- - - - - - - - - - - - - - - - - -
Author: Zoran Vučenović, January and February 2010
Зоран Вученовић, јануар и фебруар 2010.
This unit is part of DateTimeCtrls package for Lazarus.
-----------------------------------------------------------
LICENCE
- - - -
Modified LGPL -- see the file COPYING.modifiedLGPL.
-----------------------------------------------------------
NO WARRANTY
- - - - - -
There is no warranty whatsoever.
-----------------------------------------------------------
BEST REGARDS TO LAZARUS COMMUNITY!
- - - - - - - - - - - - - - - - - -
I do hope the DateTimeCtrls package will be useful.
}
unit DateTimeControlsReg;
{$mode objfpc}{$H+}
interface
procedure Register;
implementation
uses
Classes, DateTimePicker, DBDateTimePicker, LResources;
procedure Register;
begin
RegisterComponents('Common Controls', [TDateTimePicker, TDBDateTimePicker]);
end;
initialization
{$i datetimectrls.lrs}
end.

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="DateTimeCtrls"/>
<AddToProjectUsesSection Value="True"/>
<Author Value="Zoran Vučenović"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="2"/>
</Optimizations>
</CodeGeneration>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Description Value="TDateTimePicker - the cross-platform control behaving much like VCL's TDateTimePicker. TDBDateTimePicker - the data-aware version of TDateTimePicker"/>
<License Value="Modified LGPL"/>
<Version Major="1" Minor="4" Release="1"/>
<Files Count="7">
<Item1>
<Filename Value="datetimepicker.pas"/>
<UnitName Value="DateTimePicker"/>
</Item1>
<Item2>
<Filename Value="dbdatetimepicker.pas"/>
<UnitName Value="DBDateTimePicker"/>
</Item2>
<Item3>
<Filename Value="datetimepickerpropedit.pas"/>
<UnitName Value="DateTimePickerPropEdit"/>
</Item3>
<Item4>
<Filename Value="datetimecontrolsreg.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="DateTimeControlsReg"/>
</Item4>
<Item5>
<Filename Value="datetimectrls.lrs"/>
<Type Value="LRS"/>
</Item5>
<Item6>
<Filename Value="calcontrolwrapper.pas"/>
<UnitName Value="calcontrolwrapper"/>
</Item6>
<Item7>
<Filename Value="lclcalwrapper.pas"/>
<UnitName Value="lclcalwrapper"/>
</Item7>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="IDEIntf"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,33 @@
LazarusResources.Add('TDateTimePicker','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#7'tIME'#7#218#3#23#8'$'#25'n'#143#152#193#0#0#0#23'tEXtSoftware'#0'GLDP'
+'NG ver 3.4q'#133#164#225#0#0#0#8'tpNGGLD3'#0#0#0#0'J'#128')'#31#0#0#0#4'gAM'
+'A'#0#0#177#143#11#252'a'#5#0#0#0#206'IDATx'#156#221#148'1'#14#2'!'#16'E9'
+#150'g"'#246#155'P'#209#210'Zx'#6'.`'#236#12#198#214#27'Xli'#165'{'#132#209
+#193#176'!d 0B'#161#147#188#252'd'#19#230#207#31#194#10#241#23'5M;'#232#9'i'
+#176','#143'f'#210's'#238'|)'#27'h'#173'AJY'#165#177#129#16#218#19#12'P'#179
+#9#156's`'#173#173#210'pN)'#5#198#152':'#131#214#21'a'#179#152#172'A'#12'NTC'
+#238#146'I'#131'y'#190#193'f{bA%!'#13#184#144'SS'#6#251#195#157#165'M'#6'%'
+#222#29'V'#226#239#221#18'`'#227#143#194#200#4#224#25#146#160#219#29#228'v'
+#157'r'#188'>='#205#9'r'#187'N'#21#155'3'#19#0#185#235'tr'#150'A'#205#196'A'
+#155#31#218#208#151#252'-E'#3#172#244'g'#197#161'h'#240#179#245#2'2'#16#136
+#27#211'e'#18'f'#0#0#0#0'IEND'#174'B`'#130
]);
LazarusResources.Add('TDBDateTimePicker','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0
+#0#0#7'tIME'#7#218#3#23#8'1'#25'Y:~'#213#0#0#0#23'tEXtSoftware'#0'GLDPNG ver'
+' 3.4q'#133#164#225#0#0#0#8'tpNGGLD3'#0#0#0#0'J'#128')'#31#0#0#0#4'gAMA'#0#0
+#177#143#11#252'a'#5#0#0#1'(IDATx'#156'c`'#160'''X~'#232#217#127#167#178'#X1'
+'H'#142'*'#6'_~'#248#249'?'#8#128#232#189#23#223#128#13#158#184#233'>e'#22
+#129'4'#22#204#190#6'6'#8'd('#186#225#213#139'o'#130#229'S&_'#2'[B'#178#5'0'
+#141'0'#23'b3'#28'&'#15'RK'#150#5' '#131#144#131#2#29'#'#251#130'd'#11'\+'
+#142#194'-'#0#185#30'['#28' '#251#132','#31#128','#1'i'#134'YP^>'#137'"L0'
+#136'@'#138#136#5' '#181#207#159'?'#134'c'#16#127#253#134#237#8'K'#176#5#17
+#204#2'CCc'#188#24#217#2'{{;'#236#22#224#10'"'#170#249#0'W'#16#193'pee'#227
+#255#170#170'*'#156#184#162#162#3'#'#14#136#10#162#251#247'o'#255#159#182#245
+'9Q4'#204'P'#24'F'#137'dPR'#196#22'D '#205#196'b'#12'Wc'#3#200'e'#18'!'#31#0
+'M'#2'ct'#31#16#157'7'#8#249#0#217#2#162'}'#128'n'#1'9q@'#150#15#208']Kv'#28
+#224#242#1#204#2#154#249#0#31#222'~'#230#29#24'S='#14'@'#134'"'#211'dY@*&'
+#201#2#16'x'#255#254'-'#195#186'u'#219#255#195'0rN'#197#133'I'#178#128#26#0#0
+#242#176#9'l'#161#206':'#16#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit DateTimeCtrls;
interface
uses
DateTimePicker, DBDateTimePicker, DateTimePickerPropEdit,
DateTimeControlsReg, calcontrolwrapper, lclcalwrapper, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('DateTimeControlsReg', @DateTimeControlsReg.Register);
end;
initialization
RegisterPackage('DateTimeCtrls', @Register);
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,513 @@
{
DateTimePickerPropEdit
- - - - - - - - - - - - - - - - -
Author: Zoran Vučenović, January and February 2010
Зоран Вученовић, јануар и фебруар 2010.
This unit is part of DateTimeCtrls package for Lazarus. It contains
component and property editors for TDateTimePicker control.
-----------------------------------------------------------
LICENCE
- - - -
Modified LGPL -- see the file COPYING.modifiedLGPL.
-----------------------------------------------------------
NO WARRANTY
- - - - - -
There is no warranty whatsoever.
-----------------------------------------------------------
BEST REGARDS TO LAZARUS COMMUNITY!
- - - - - - - - - - - - - - - - - -
I do hope the DateTimeCtrls package will be useful.
}
unit DateTimePickerPropEdit;
{$mode objfpc}{$H+}
interface
// Nothing needs to be in interface section!
implementation
uses
Classes, SysUtils, Forms, Controls, ButtonPanel, DateTimePicker,
DBDateTimePicker, StdCtrls, Math, Menus, ComponentEditors, PropEdits;
type
{ TFormDateTimePickerEditor }
TFormDateTimePickerEditor = class(TForm)
private
CallerDateTimePicker: TDateTimePicker;
Prop: String;
Modified: Boolean;
ButtonPanel: TButtonPanel;
DateTimePickerMin: TDateTimePicker;
DateTimePicker1: TDateTimePicker;
DateTimePickerMax: TDateTimePicker;
Label1: TLabel;
LabelMin: TLabel;
LabelMax: TLabel;
LabelNull: TLabel;
procedure DateTimePickerMaxExit(Sender: TObject);
procedure DateTimePickerMinExit(Sender: TObject);
procedure DateTimePickersChange(Sender: TObject);
procedure DateTimePicker1Enter(Sender: TObject);
procedure DateTimePicker1Exit(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Initialize(const Caller: TDateTimePicker;
const PropertyName, PropertyType: String);
procedure UpdateMinMaxBounds;
public
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
destructor Destroy; override;
end;
{ TDateTimePickerComponentEditor }
TDateTimePickerComponentEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
{ TDateTimePickerDateTimePropEditor }
TDateTimePickerDateTimePropEditor = class(TDateTimePropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
function AllEqual: Boolean; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure Edit; override;
end;
{ TSimpleDatePropEditor }
TSimpleDatePropEditor = class(TDatePropertyEditor)
public
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
procedure RegPropEdits;
begin
RegisterPropertyEditor(TypeInfo(TTime), TDateTimePicker, 'Time', TDateTimePickerDateTimePropEditor);
RegisterPropertyEditor(TypeInfo(TDate), TDateTimePicker, 'Date', TDateTimePickerDateTimePropEditor);
RegisterPropertyEditor(TypeInfo(TDate), TDateTimePicker, 'MaxDate', TDateTimePickerDateTimePropEditor);
RegisterPropertyEditor(TypeInfo(TDate), TDateTimePicker, 'MinDate', TDateTimePickerDateTimePropEditor);
RegisterPropertyEditor(TypeInfo(TDate), TDBDateTimePicker, 'MaxDate', TSimpleDatePropEditor);
RegisterPropertyEditor(TypeInfo(TDate), TDBDateTimePicker, 'MinDate', TSimpleDatePropEditor);
end;
{ TDateTimePickerComponentEditor }
procedure TDateTimePickerComponentEditor.ExecuteVerb(Index: Integer);
var
F: TFormDateTimePickerEditor;
DTPicker: TDateTimePicker;
begin
if Index = 0 then begin
if GetComponent is TDateTimePicker then begin
F := TFormDateTimePickerEditor.CreateNew(nil, 0);
try
DTPicker := TDateTimePicker(GetComponent);
if DTPicker.Kind = dtkTime then
F.Initialize(DTPicker, '', 'TTime')
else
F.Initialize(DTPicker, '', '');
if F.ShowModal = mrOK then begin
if F.Modified then begin
DTPicker.MinDate := TheSmallestDate;
DTPicker.MaxDate := F.DateTimePickerMax.DateTime;
DTPicker.MinDate := F.DateTimePickerMin.DateTime;
DTPicker.DateTime := F.DateTimePicker1.DateTime;
Modified;
GlobalDesignHook.RefreshPropertyValues;
end;
end;
finally
F.Free;
end;
end else
raise Exception.Create('Unknown DateTimePicker object to edit.');
end;
end;
function TDateTimePickerComponentEditor.GetVerb(Index: Integer): string;
begin
if Index = 0 then
Result := '&Date/Time Editor...';
end;
function TDateTimePickerComponentEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
{ TFormDateTimePickerEditor }
procedure TFormDateTimePickerEditor.DateTimePickerMaxExit(Sender: TObject);
begin
if DateTimePickerMin.Date > DateTimePickerMax.Date then
DateTimePickerMin.Date := DateTimePickerMax.Date;
UpdateMinMaxBounds;
end;
procedure TFormDateTimePickerEditor.DateTimePickerMinExit(Sender: TObject);
begin
if DateTimePickerMax.Date < DateTimePickerMin.Date then
DateTimePickerMax.Date := DateTimePickerMin.Date;
UpdateMinMaxBounds;
end;
procedure TFormDateTimePickerEditor.DateTimePickersChange(Sender: TObject);
begin
Modified := True;
end;
procedure TFormDateTimePickerEditor.DateTimePicker1Enter(Sender: TObject);
begin
if DateTimePicker1.NullInputAllowed then
LabelNull.Show;
end;
procedure TFormDateTimePickerEditor.DateTimePicker1Exit(Sender: TObject);
begin
LabelNull.Hide;
end;
procedure TFormDateTimePickerEditor.FormActivate(Sender: TObject);
var
B: Boolean;
begin
OnActivate := nil;
B := False;
if Prop = 'MAXDATE' then DateTimePickerMax.SetFocus
else if Prop = 'MINDATE' then DateTimePickerMin.SetFocus
else begin
DateTimePicker1.SetFocus;
B := DateTimePicker1.NullInputAllowed;
end;
LabelNull.Visible := B;
LabelNull.BringToFront;
end;
procedure TFormDateTimePickerEditor.Initialize(const Caller: TDateTimePicker;
const PropertyName, PropertyType: String);
var
I: Integer;
DTP: array[1..3] of TDateTimePicker;
L, T, W, H: Integer;
R: TRect;
M: TMonitor;
AnchKindTrailing, AnchKindLeading: TAnchorKind;
begin
if Assigned(Caller) then begin
CallerDateTimePicker := Caller;
Prop := UpperCase(PropertyName);
BiDiMode := CallerDateTimePicker.BiDiMode;
Modified := False;
DateTimePicker1.Kind := dtkDateTime;
if UpperCase(PropertyType) = 'TTIME' then
DateTimePicker1.SelectTime
else
DateTimePicker1.SelectDate;
Label1.Caption := 'Date / Time:';
LabelMax.Caption := 'MaxDate:';
LabelMin.Caption := 'MinDate:';
LabelNull.Caption := '(Press N to set to NULL)';
DateTimePickerMin.DateTime := CallerDateTimePicker.MinDate;
DateTimePickerMax.DateTime := CallerDateTimePicker.MaxDate;
DateTimePicker1.MinDate := CallerDateTimePicker.MinDate;
DateTimePicker1.MaxDate := CallerDateTimePicker.MaxDate;
DateTimePicker1.DateTime := CallerDateTimePicker.DateTime;
DTP[1] := DateTimePickerMin;
DTP[2] := DateTimePickerMax;
DTP[3] := DateTimePicker1;
for I := 1 to 3 do begin
DTP[I].NullInputAllowed := I = 3;
DTP[I].CenturyFrom := CallerDateTimePicker.CenturyFrom;
DTP[I].DateDisplayOrder := CallerDateTimePicker.DateDisplayOrder;
DTP[I].LeadingZeros := CallerDateTimePicker.LeadingZeros;
DTP[I].DateSeparator := CallerDateTimePicker.DateSeparator;
DTP[I].TrailingSeparator := CallerDateTimePicker.TrailingSeparator;
DTP[I].AutoAdvance := CallerDateTimePicker.AutoAdvance;
DTP[I].CalendarWrapperClass := CallerDateTimePicker.CalendarWrapperClass;
end;
DateTimePicker1.TextForNullDate := CallerDateTimePicker.TextForNullDate;
DateTimePicker1.TimeSeparator := CallerDateTimePicker.TimeSeparator;
DateTimePicker1.TimeDisplay := tdHMSMs;
DateTimePicker1.TimeFormat := CallerDateTimePicker.TimeFormat;
if IsRightToLeft then begin
AnchKindLeading := akRight;
AnchKindTrailing := akLeft;
end else begin
AnchKindLeading := akLeft;
AnchKindTrailing := akRight;
end;
DateTimePickerMax.AnchorParallel(akTop, 20, Self);
DateTimePickerMax.AnchorParallel(AnchKindTrailing, 20, Self);
LabelMax.AnchorVerticalCenterTo(DateTimePickerMax);
LabelMax.AnchorToNeighbour(AnchKindTrailing, 2, DateTimePickerMax);
DateTimePickerMin.AnchorParallel(akTop, 20, Self);
DateTimePickerMin.AnchorToNeighbour(AnchKindTrailing, 20, LabelMax);
LabelMin.AnchorToNeighbour(AnchKindTrailing, 2, DateTimePickerMin);
LabelMin.AnchorVerticalCenterTo(DateTimePickerMin);
DateTimePicker1.AnchorParallel(AnchKindLeading, 0, DateTimePickerMin);
DateTimePicker1.AnchorToNeighbour(akTop, 20, DateTimePickerMin);
Label1.AnchorToNeighbour(AnchKindTrailing, 2, DateTimePicker1);
Label1.AnchorVerticalCenterTo(DateTimePicker1);
LabelNull.AnchorToNeighbour(akTop, 2, DateTimePicker1);
LabelNull.AnchorHorizontalCenterTo(DateTimePicker1);
ButtonPanel.Spacing := 10;
ButtonPanel.BorderSpacing.Around := 10;
W := Max(Label1.Width, LabelMin.Width);
W := DateTimePickerMax.Width + DateTimePickerMin.Width
+ LabelMax.Width + W + 80;
H := 2 * DateTimePickerMax.Height + LabelNull.Height + ButtonPanel.Height + 58;
M := Screen.MonitorFromWindow(CallerDateTimePicker.Handle);
R := M.WorkareaRect;
// But if WorkareaRect doesn't work (not implemented for all widgetsets),
// then take BoundsRect:
if (R.Right <= R.Left) or (R.Bottom <= R.Top) then
R := M.BoundsRect;
L := (R.Left + R.Right - W) div 2;
T := (R.Top + R.Bottom - H) div 2;
if L < R.Left then L := R.Left;
if T < R.Top then T := R.Top;
SetBounds(L, T, W, H);
end;
end;
procedure TFormDateTimePickerEditor.UpdateMinMaxBounds;
begin
DateTimePicker1.MinDate := TheSmallestDate;
DateTimePicker1.MaxDate := DateTimePickerMax.Date;
DateTimePicker1.MinDate := DateTimePickerMin.Date;
end;
constructor TFormDateTimePickerEditor.CreateNew(AOwner: TComponent;
Num: Integer);
var
I: Integer;
begin
inherited CreateNew(AOwner, Num);
Hide;
if Font.Size > 10 then
Font.Size := 10;
SetBounds(-8000, -8000, 4, 5);
BorderStyle := bsDialog;
BorderIcons := [biSystemMenu];
Caption := 'DateTimePicker Editor';
DateTimePickerMax := TDateTimePicker.Create(Self);
DateTimePickerMin := TDateTimePicker.Create(Self);
DateTimePicker1 := TDateTimePicker.Create(Self);
Label1 := TLabel.Create(Self);
LabelMin := TLabel.Create(Self);
LabelMax := TLabel.Create(Self);
LabelNull := TLabel.Create(Self);
ButtonPanel := TButtonPanel.Create(Self);
ButtonPanel.ShowButtons := [pbOK, pbCancel];
ButtonPanel.OKButton.GlyphShowMode := gsmAlways;
ButtonPanel.CancelButton.GlyphShowMode := gsmAlways;
ButtonPanel.ShowBevel := False;
DateTimePickerMax.Parent := Self;
DateTimePickerMin.Parent := Self;
DateTimePicker1.Parent := Self;
Label1.Parent := Self;
LabelMin.Parent := Self;
LabelMax.Parent := Self;
LabelNull.Parent := Self;
ButtonPanel.Parent := Self;
ButtonPanel.TabOrder := 0;
DateTimePickerMin.TabOrder := 1;
DateTimePickerMax.TabOrder := 2;
DateTimePicker1.TabOrder := 3;
for I := 0 to ControlCount - 1 do begin
Controls[I].Anchors := [];
Controls[I].AutoSize := True;
end;
DateTimePickerMax.OnExit := @DateTimePickerMaxExit;
DateTimePickerMin.OnExit := @DateTimePickerMinExit;
DateTimePicker1.OnExit := @DateTimePicker1Exit;
DateTimePicker1.OnEnter := @DateTimePicker1Enter;
DateTimePickerMin.OnChange := @DateTimePickersChange;
DateTimePickerMax.OnChange := @DateTimePickersChange;
DateTimePicker1.OnChange := @DateTimePickersChange;
OnActivate := @FormActivate;
end;
destructor TFormDateTimePickerEditor.Destroy;
begin
OnActivate := nil;
OnShow := nil;
DateTimePicker1.OnChange := nil;
DateTimePickerMax.OnChange := nil;
DateTimePickerMin.OnChange := nil;
DateTimePicker1.OnEnter := nil;
DateTimePicker1.OnExit := nil;
DateTimePickerMin.OnExit := nil;
DateTimePickerMax.OnExit := nil;
ButtonPanel.Free;
LabelNull.Free;
LabelMax.Free;
LabelMin.Free;
Label1.Free;
DateTimePicker1.Free;
DateTimePickerMin.Free;
DateTimePickerMax.Free;
inherited Destroy;
end;
{ TDateTimePickerDateTimePropEditor }
function TDateTimePickerDateTimePropEditor.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog];
end;
function TDateTimePickerDateTimePropEditor.AllEqual: Boolean;
var
DT: TDateTime;
N: Integer;
begin
Result := True;
N := PropCount;
if N > 1 then begin
DT := TDateTime(GetFloatValue);
repeat
Dec(N);
Result := EqualDateTime(DT, TDateTime(GetFloatValueAt(N)));
until not(Result and (N > 1));
end;
end;
function TDateTimePickerDateTimePropEditor.GetValue: string;
var
DT: TDateTime;
S: String;
begin
DT := TDateTime(GetFloatValue);
if IsNullDate(DT) then
Result := 'NULL'
else begin
S := UpperCase(GetPropType^.Name);
if S = 'TDATE' then
Result := DateToStr(DT)
else if S = 'TTIME' then
Result := TimeToStr(DT)
else
Result := DateTimeToStr(DT);
end;
end;
procedure TDateTimePickerDateTimePropEditor.SetValue(const Value: string);
var
S: String;
begin
S := Trim(Value);
if (S > '') and (UpCase(S[1]) <> 'N') then begin
S := UpperCase(GetPropType^.Name);
if S = 'TDATE' then
SetFloatValue(StrToDate(Value))
else if S = 'TTIME' then
SetFloatValue(StrToTime(Value))
else
inherited SetValue(Value);
end else
SetFloatValue(NullDate);
end;
procedure TDateTimePickerDateTimePropEditor.Edit;
var
F: TFormDateTimePickerEditor;
I: Integer;
DT: TDateTimePicker;
begin
for I := 0 to PropCount - 1 do
if not (GetComponent(I) is TDateTimePicker) then
Exit;
F := TFormDateTimePickerEditor.CreateNew(nil, 0);
try
F.Initialize(TDateTimePicker(GetComponent(0)), GetName, GetPropType^.Name);
if F.ShowModal = mrOK then begin
if F.Modified then begin
for I := 0 to PropCount - 1 do begin
DT := TDateTimePicker(GetComponent(I));
DT.MinDate := TheSmallestDate;
DT.MaxDate := F.DateTimePickerMax.Date;
DT.MinDate := F.DateTimePickerMin.Date;
DT.DateTime := F.DateTimePicker1.DateTime;
end;
Modified;
GlobalDesignHook.RefreshPropertyValues;
end;
end;
finally
F.Free;
end;
end;
{ TSimpleDatePropEditor }
function TSimpleDatePropEditor.GetValue: string;
begin
Result := DateToStr(GetFloatValue);
end;
procedure TSimpleDatePropEditor.SetValue(const Value: string);
var
S: String;
begin
S := Trim(Value);
if (S > '') and (UpCase(S[1]) <> 'N') then
inherited SetValue(S);
end;
initialization
RegPropEdits;
RegisterComponentEditor(TDateTimePicker, TDateTimePickerComponentEditor);
end.

View File

@ -0,0 +1,289 @@
{
TDBDateTimePicker control for Lazarus
- - - - - - - - - - - - - - - - - - - -
Author: Zoran Vučenović, January and February 2010
Зоран Вученовић, јануар и фебруар 2010.
This unit is part of DateTimeCtrls package for Lazarus.
TDBDateTimePicker is data-aware version of TDateTimePicker control.
-----------------------------------------------------------
LICENCE
- - - -
Modified LGPL -- see the file COPYING.modifiedLGPL.
-----------------------------------------------------------
NO WARRANTY
- - - - - -
There is no warranty whatsoever.
-----------------------------------------------------------
BEST REGARDS TO LAZARUS COMMUNITY!
- - - - - - - - - - - - - - - - - -
I do hope this control will be useful.
}
unit DBDateTimePicker;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, DateTimePicker, db, DBCtrls;
type
{ TDBDateTimePicker }
TDBDateTimePicker = class(TCustomDateTimePicker)
private
{ Private declarations }
FDataLink: TFieldDataLink;
FReadOnly: Boolean;
FDataChangeCount: Integer;
FChangingCount: Integer;
function GetDataField: string;
function GetDataSource: TDataSource;
procedure SetDataField(const AValue: string);
procedure SetDataSource(const AValue: TDataSource);
procedure DataChange(Sender: TObject);
procedure SetReadOnly(const AValue: Boolean);
procedure UpdateData(Sender: TObject);
procedure ActiveChange(Sender: TObject);
function GetField: TField;
procedure CheckField;
protected
{ Protected declarations }
procedure Change; override;
procedure ConfirmChanges; override;
procedure UndoChanges; override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Field: TField read GetField;
property CalendarWrapperClass;
published
{ Published declarations }
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property ReadOnly: Boolean read FReadOnly write SetReadOnly;
property ArrowShape;
property ShowCheckBox;
property Checked;
property CenturyFrom;
property DateDisplayOrder;
property MaxDate;
property MinDate;
property AutoSize;
property Font;
property ParentFont;
property TabOrder;
property TabStop;
property BorderStyle;
property BorderSpacing;
property Enabled;
property Color;
property ParentColor;
property DateSeparator;
property TrailingSeparator;
property TextForNullDate;
property LeadingZeros;
property ShowHint;
property ParentShowHint;
property Align;
property Anchors;
property Constraints;
property Cursor;
property PopupMenu;
property Visible;
property NullInputAllowed;
property Kind;
property TimeSeparator;
property TimeFormat;
property TimeDisplay;
{ property Time; This property should NOT be published here, it was
accidentally added in first release. }
property DateMode;
property UseDefaultSeparators;
property Cascade;
property AutoButtonSize;
property AutoAdvance;
property HideDateTimeParts;
property BiDiMode;
property ParentBiDiMode;
property MonthNames;
property ShowMonthNames;
//events:
property OnChange;
property OnCheckBoxChange;
property OnDropDown;
property OnCloseUp;
property OnChangeBounds;
property OnClick;
property OnContextPopup;
property OnDblClick;
property OnEditingDone;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseEnter;
property OnMouseMove;
property OnMouseUp;
property OnMouseLeave;
property OnResize;
property OnUTF8KeyPress;
end;
implementation
{ TDBDateTimePicker }
function TDBDateTimePicker.GetDataField: string;
begin
Result := FDataLink.FieldName;
end;
function TDBDateTimePicker.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource;
end;
procedure TDBDateTimePicker.SetDataField(const AValue: string);
begin
FDataLink.FieldName := AValue;
CheckField;
end;
procedure TDBDateTimePicker.SetDataSource(const AValue: TDataSource);
begin
ChangeDataSource(Self, FDataLink, AValue);
CheckField;
end;
procedure TDBDateTimePicker.DataChange(Sender: TObject);
begin
if (FChangingCount = 0) then begin
Inc(FDataChangeCount);
try
if Assigned(FDataLink.Field) and not FDataLink.Field.IsNull then begin
// Using the SetTheDateJumpMinMax procedure, instead of property
SetDateTimeJumpMinMax(FDataLink.Field.AsDateTime); // assignment allows
// this control to display dates from database whose value falls
// outside of MinDate and MaxDate interval.
// Note that user still cannot enter such values in the control.
end else
DateTime := NullDate;
finally
Dec(FDataChangeCount);
end;
end;
end;
procedure TDBDateTimePicker.SetReadOnly(const AValue: Boolean);
begin
if FReadOnly <> AValue then begin
FReadOnly := AValue;
CheckField;
end;
end;
procedure TDBDateTimePicker.UpdateData(Sender: TObject);
begin
if Assigned(FDataLink.Field) then begin
if DateIsNull then
FDataLink.Field.AsVariant := Null
else
FDataLink.Field.AsDateTime := DateTime;
end;
end;
procedure TDBDateTimePicker.ActiveChange(Sender: TObject);
begin
CheckField;
end;
function TDBDateTimePicker.GetField: TField;
begin
Result := FDataLink.Field;
end;
procedure TDBDateTimePicker.CheckField;
begin
if (FDataLink.Active) and Assigned(FDataLink.Field) then
inherited ReadOnly := FReadOnly or (not FDataLink.CanModify)
else begin
inherited ReadOnly := True;
DateTime := NullDate;
end;
end;
procedure TDBDateTimePicker.Change;
begin
if (FDataChangeCount <= 0) and Assigned(FDataLink) then begin
Inc(FChangingCount);
try
if FDataLink.Edit then begin
FDataLink.Modified;
inherited Change; // calls OnChange event handler
end else
FDataLink.Reset; // reverts user changes
finally
Dec(FChangingCount);
end;
end;
end;
procedure TDBDateTimePicker.ConfirmChanges;
begin
inherited ConfirmChanges;
if Assigned(FDataLink) then
try
FDataLink.UpdateRecord;
except
SetFocus;
raise;
end;
end;
procedure TDBDateTimePicker.UndoChanges;
begin
FDataLink.Reset;
inherited UndoChanges;
end;
constructor TDBDateTimePicker.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FDataChangeCount := 0;
FChangingCount := 0;
FDataLink := TFieldDataLink.Create;
FDataLink.Control := Self;
DateTime := NullDate;
FDataLink.OnActiveChange := @ActiveChange;
FDataLink.OnDataChange := @DataChange;
FDataLink.OnUpdateData := @UpdateData;
CheckField;
end;
destructor TDBDateTimePicker.Destroy;
begin
FDataLink.OnUpdateData := nil;
FDataLink.OnDataChange := nil;
FDataLink.OnActiveChange := nil;
FreeAndNil(FDataLink);
inherited Destroy;
end;
end.

View File

@ -0,0 +1,74 @@
{
LCLCalWrapper
- - - - - - - - - - - - - - - - -
Author: Zoran Vučenović
Зоран Вученовић
This unit is part of DateTimeCtrls package for Lazarus.
TLCLCalendarWrapper is the default implementation of TCalendarControlWrapper
abstract class, used by DateTimePicker. Wraps LCL's TCalendar.
-----------------------------------------------------------
LICENCE
- - - -
Modified LGPL -- see the file COPYING.modifiedLGPL.
-----------------------------------------------------------
NO WARRANTY
- - - - - -
There is no warranty whatsoever.
-----------------------------------------------------------
BEST REGARDS TO LAZARUS COMMUNITY!
- - - - - - - - - - - - - - - - - -
I do hope the DateTimeCtrls package will be useful.
}
unit lclcalwrapper;
{$mode objfpc}{$H+}
interface
uses
Classes, Controls, Calendar, CalControlWrapper;
type
{ TLCLCalendarWrapper }
TLCLCalendarWrapper = class(TCalendarControlWrapper)
public
class function GetCalendarControlClass: TControlClass; override;
procedure SetDate(Date: TDate); override;
function GetDate: TDate; override;
function AreCoordinatesOnDate(X, Y: Integer): Boolean; override;
end;
implementation
{ TLCLCalendarWrapper }
class function TLCLCalendarWrapper.GetCalendarControlClass: TControlClass;
begin
Result := TCalendar;
end;
procedure TLCLCalendarWrapper.SetDate(Date: TDate);
begin
TCalendar(GetCalendarControl).DateTime := Date;
end;
function TLCLCalendarWrapper.GetDate: TDate;
begin
Result := TCalendar(GetCalendarControl).DateTime;
end;
function TLCLCalendarWrapper.AreCoordinatesOnDate(X, Y: Integer): Boolean;
begin
Result :=
TCalendar(GetCalendarControl).HitTest(Point(X, Y)) in [cpDate, cpNoWhere];
end;
end.

View File

@ -0,0 +1,503 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="LibreOffice 4.0.2.2 (Linux)">
<META NAME="AUTHOR" CONTENT="Zoran Vučenović">
<META NAME="CREATED" CONTENT="20100120;12052000">
<META NAME="CHANGEDBY" CONTENT="Zoran ">
<META NAME="CHANGED" CONTENT="20131012;20570900">
<STYLE TYPE="text/css">
<!--
@page { margin: 2.01cm }
P { margin-bottom: 0.2cm }
H4.cjk { font-family: "WenQuanYi Micro Hei" }
H4.ctl { font-family: "Mangal" }
A.cjk:link { so-language: zxx }
A.ctl:link { so-language: zxx }
-->
</STYLE>
</HEAD>
<BODY LANG="en-GB" DIR="LTR">
<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><FONT SIZE=4 STYLE="font-size: 16pt"><B>DateTimeControls
Package for Lazarus</B></FONT></FONT></P>
<P ALIGN=CENTER STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P ALIGN=CENTER STYLE="margin-bottom: 0cm"><A CLASS="western" HREF="http://wiki.lazarus.freepascal.org/ZVDateTimeControls_Package"><FONT FACE="Arial, sans-serif"><FONT SIZE=3><SPAN LANG="en-GB"><SPAN STYLE="font-weight: normal">http://wiki.lazarus.freepascal.org/ZVDateTimeControls_Package</SPAN></SPAN></FONT></FONT></A></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm"><BR>
</P>
<P ALIGN=CENTER STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm; font-weight: normal"><FONT FACE="Arial, sans-serif"><FONT SIZE=4>The
DateTimeControls package contains two controls:</FONT></FONT></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-left: 2.01cm; margin-bottom: 0cm"><IMG SRC="pictures/TDateTimePicker.png" NAME="grafika2" ALIGN=BOTTOM WIDTH=24 HEIGHT=24 BORDER=0><A CLASS="western" HREF="#TDateTimePicker">
</A><A CLASS="western" HREF="#TDateTimePicker"><FONT FACE="Arial, sans-serif"><FONT SIZE=3><SPAN LANG="en-GB"><SPAN STYLE="font-weight: normal">TDateTimePicker</SPAN></SPAN></FONT></FONT></A></P>
<P ALIGN=LEFT STYLE="margin-left: 2.01cm; margin-bottom: 0cm"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-left: 2.01cm; margin-bottom: 0cm"><IMG SRC="pictures/TDBDateTimePicker.png" NAME="grafika5" ALIGN=BOTTOM WIDTH=24 HEIGHT=24 BORDER=0><A CLASS="western" HREF="#TDBDateTimePicker">
</A><A CLASS="western" HREF="#TDBDateTimePicker"><FONT FACE="Arial, sans-serif"><FONT SIZE=3><SPAN LANG="en-GB"><SPAN STYLE="font-weight: normal">TDBDateTimePicker</SPAN></SPAN></FONT></FONT></A></P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>Author</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><A CLASS="western" HREF="http://wiki.lazarus.freepascal.org/User:Zoran"><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB"><SPAN STYLE="font-weight: normal">Zoran
Vučenović</SPAN></SPAN></FONT></A></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>License</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Modified LGPL, same as Lazarus
component library.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P ALIGN=LEFT STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>Introduction</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Delphi's
VCL has <A CLASS="western" HREF="http://docwiki.embarcadero.com/VCL/en/ComCtrls.TDateTimePicker">a
control named TDateTimePicker</A>, which I find very useful for
editing dates. LCL, however, does not have this control. Instead, for
editing dates <A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/lcl/editbtn/tdateedit.html">LCL
has a control named TDateEdit</A>, but I prefer the VCL's
TDateTimePicker.</SPAN></FONT></P>
<P ALIGN=LEFT STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">Therefore,
I tried to create a cross-platform Lazarus control which would
resemble VCL's TDateTimePicker as much as possible.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">The
TDateTimePicker control does not use <A CLASS="western" HREF="http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.aspx">native
Win control</A>. It descends from LCL's TCustomControl to be
cross-platform. It has been tested on Windows with win32/64 and qt
widgetsets, as well as on Linux with qt and gtk2 widgetsets.</SPAN></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">Note
that the TDateTimePicker control does not descend from TEdit, so it
does not have unnecessary caret. The VCL's control doesn't have caret
either.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>Installation</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">To
install the package in Lazarus IDE follow these steps:</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<OL>
<OL>
<LI><P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">Open
the package in Package Editor (in Lazarus' main menu click <I>Package</I>,
then <I>Open package file...</I> locate the file
<I>datetimectrls.lpk</I> and click <I>Open</I>).</FONT></P>
<LI><P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">Compile
the package (click <I>Compile</I> in Package Editor's tool bar).</FONT></P>
<LI><P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif">Install
the package in the IDE (click <I>Install</I> you will be asked
if you want to rebuild Lazarus, click <I>Yes</I>. Wait until
Lazarus rebuilds and restarts itself. The new tab “<I>Date and
Time Ctrls”</I> appears on the component palette with
TDateTimePicker and TDBDateTimePicker controls.</FONT></P>
</OL>
</OL>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>Change
Log</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">For more details about changes, see
ChangeLog.txt</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Version 1.0 27. February 2010.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Version 1.1 17. April 2010.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Version 1.2 12. May 2010.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Version 1.3 1. April 2011.</FONT></P>
<P STYLE="margin-left: 1.47cm; margin-bottom: 0cm; font-weight: normal">
<FONT FACE="Arial, sans-serif">Version 1.4 4. September 2012.</FONT></P>
<P STYLE="margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-bottom: 0cm"><A NAME="TDateTimePicker"></A><FONT FACE="Arial, sans-serif"><B>TDateTimePicker
<IMG SRC="pictures/TDateTimePicker.png" NAME="grafika9" ALIGN=MIDDLE WIDTH=24 HEIGHT=24 BORDER=0></B></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Properties:</B></FONT></P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">I'll explain some properties of
TDateTimePicker control: </FONT>
</P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>DateTime: TDateTime (public)</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">The DateTime value
displayed on the control. This property is not published in object
inspector, but its value is actually the same as Date and Time
properties composed in one value. This property is provided to allow
setting or reading of both date and time value at once in program
code. In design time, Date and Time can be set in object inspector.
<A CLASS="western" HREF="#DateTimePicker Editor">There is also
component editor</A> which provides easy way of setting this property
in design time.</SPAN></FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Date: TDate</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The date displayed on the control
which the user can edit.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Time: TTime</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The time displayed on the control
which the user can edit.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>MinDate: TDate</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The minimal date user can enter.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>MaxDate: TDate</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The maximal date user can enter.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm"><A NAME="NullInputAllowed"></A>
<FONT FACE="Arial, sans-serif"><B>NullInputAllowed: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When True, the user can set the date
to NullDate constant by pressing N key.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>CenturyFrom: Word</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When user enters the year in two-digit
format, then the CenturyFrom property is used to determine which
century the year belongs to. The default is 1941, which means that
when two digit years is entered, it falls in interval 1941 2040.
Note that MinDate and MaxDate properties can also have influence on
the decision for example, if the CenturyFrom is set to 1941 and
MaxDate to 31. 12. 2010, if user enters year 23, it will be set to
1923, because it cant be 2033, due to MaxDate limit.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm"><A NAME="Kind"></A>
<FONT FACE="Arial, sans-serif"><B>Kind: TDateTimeKind</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace"><B>type</B> TDateTimeKind =
(dtkDate, dtkTime, dtkDateTime);</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The control displays only date, only
time or both.</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<IMG SRC="pictures/DateControls03.PNG" NAME="grafika4" ALIGN=BOTTOM WIDTH=332 HEIGHT=40 BORDER=0></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>DateMode: TDTDateMode</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace"><B>type</B> TDTDateMode =
(dmComboBox, dmUpDown, dmNone);</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">When DateMode is
set to dmComboBox, there is a button on the right side of the
control. When user clicks the button, <A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/lcl/calendar/tcalendar.html">the
calendar control</A> is shown, allowing the user to pick the date.
When set to dmUpDown, then UpDown buttons are shown.</SPAN></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">In my opinion the UpDown buttons
aren't really useful in this control, they are provided for
compatibility with Delphi's TDateTimePicker. Up and down keys can
always serve for same purpose, so can mouse wheel.</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">In the next picture the first
control's DateMode is set to dmComboBox and the second control's to
dmUpDown.</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<IMG SRC="pictures/DateControls01.PNG" NAME="grafika1" ALIGN=BOTTOM WIDTH=151 HEIGHT=72 BORDER=0></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">If DateMode is dmComboBox, when the
user clicks on the button a calendar drops down, allowing the user to
pick a date.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Note:</B> if Kind property is set
to dtkTime, the calendar control is pointless. Therefore, if DateMode
is dmComboBox, the UpDown is shown instead.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>ShowCheckBox: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When set, there is a check box on the
left side of the control. When unchecked, the display appears grayed
and user interaction with the date or time is not possible. (The
control is still enabled, though, only in sense that the check box
remains enabled).</FONT></P>
<P STYLE="margin-left: 2.01cm"><IMG SRC="pictures/DateControls02.PNG" NAME="grafika3" ALIGN=BOTTOM WIDTH=116 HEIGHT=35 BORDER=0></P>
<P><BR><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Checked: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">If ShowCheckBox is set to True, this
property determines whether the check box is checked or not. If
ShowCheckBox is False, this property has no purpose and is
automatically set to True.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>DateDisplayOrder: TDateDisplayOrder</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace"><B>type</B> TDateDisplayOrder =
(ddoDMY, ddoMDY, ddoYMD, ddoTryDefault);</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Defines the order
for displaying day, month and year part of the date. When
ddoTryDefault is set, then the controls tries to determine the order
from <A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/shortdateformat.html">ShortDateFormat
global variable</A>.</SPAN></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">This is similar to
<A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/lcl/editbtn/tdateedit.dateorder.html">DateEdit's
DateOrder</A> property.</SPAN></FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>DateSeparator: String</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">Defines the string used to separate
date, month and year date parts. Setting this property automatically
sets the UseDefaultSeparators property to False. To ensure that date
and time separators are set to user's system defaults, set
UseDefaultSeparators property to True.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>TimeSeparator: String</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">Defines the string used to separate
hour, minute, second and millisecond time parts. Setting this
property automatically sets the UseDefaultSeparators property to
False. To ensure that date and time separators are set to user's
system defaults, set UseDefaultSeparators property to True.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>UseDefaultSeparators: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">When this property
is set to True, then the DateSeparator and TimeSeparator properties
will be set to <A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/dateseparator.html">DateSeparator</A>
and <A CLASS="western" HREF="http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/timeseparator.html">TimeSeparator</A>
global variables, which are set to user system defaults when
application initializes.</SPAN></FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>TrailingSeparator: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When set to True, then the
DateSeparator is shown once more, after the last date part. This
property exists because in some languages the correct date format is
<B>31. 1. 2010.</B> including the last point, after the year.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>LeadingZeros: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">Determines whether the date and time
parts are displayed with or without leading zeros (this actually
affects day, month and hour parts of date and time display).</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm"><A NAME="TimeDisplay"></A>
<FONT FACE="Arial, sans-serif"><B>TimeDisplay: TTimeDisplay</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace"><B>type</B></FONT>
<FONT FACE="Courier New, monospace">TTimeDisplay = (tdHM, tdHMS,
tdHMSMs);</FONT></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">If Kind is dtkTime or dtkDateTime,
then TimeDisplay value of tdHM means that only hours and minutes are
displayed, tdHMS adds displaying of seconds and value of tdHMSMs
means that milliseconds are displayed too.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>TimeFormat: TTimeFormat</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace"><B>type</B> TTimeFormat = (tf12,
tf24);</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">The value of tf12 sets the display of
time to 12 hours format, with AM/PM string and tf24 sets to 24 hours
format.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm"><A NAME="TextForNullDate"></A>
<FONT FACE="Arial, sans-serif"><B>TextForNullDate: String</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Text which appears
when the null date is set and control does not have focus. When
control is focused, the text changes to defined format, but
displaying zeros for date, and nines for time (for example
&quot;00/00/0000 99:99:99&quot;), which is appropriate to user input.
User can set the date to NullDate by pressing N key, provided
<A CLASS="western" HREF="#NullInputAllowed">NullInputAllowed</A>
property is True.</SPAN></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When TextForNullDate is set to empty
string, zeros/nines format is displayed even when control does not
have focus. If you want empty display, this can be achieved by
setting TextForNullDate to one or more space characters.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>AutoAdvance: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When true, then when user is entering
valid text, the selection automatically advances to next part of
date/time. The default is False because of compatibility with
previous version, but switching on this option makes user interaction
easier, this is a useful option and I recommend setting this property
to true.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Cascade: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When true, then when user is
increasing or decreasing one date/time part (using up-down keys or
mouse wheel), it can increase or decrease by one another date/time
part. For example, when date is 31.08.2013. and user increases the
day, the day becomes 1 and month increases by one and becomes 9, so
the date becomes 01.09.2013. If Cascade were set to False, the month
would not change and the date would become 01.08.2013.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>AutoButtonSize: Boolean</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">When true, the width of the arrow
button (or up-down control, if it is shown instead) is automatically
adjusted proportionally to the height.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>HideDateTimeParts: TDateTimeParts</B></FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace"><B>type</B></FONT></P>
<P STYLE="margin-left: 2.49cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace">TDateTimePart = (dtpDay,
dtpMonth, dtpYear, dtpHour, dtpMinute, dtpSecond, dtpMiliSec,
dtpAMPM);</FONT></P>
<P STYLE="margin-left: 2.49cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Courier New, monospace">TDateTimeParts = set of
dtpDay..dtpMiliSec;</FONT></P>
<P STYLE="margin-left: 2.01cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Wit</SPAN></FONT><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB"><SPAN STYLE="font-weight: normal">h
HideDateTimeParts prope</SPAN></SPAN></FONT><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">rty,
you can chose which date/time parts will not be shown. Most of the
time you do not need to use this property and you can get the format
you want by using other properties (see <A CLASS="western" HREF="#Kind">Kind</A>,
<A CLASS="western" HREF="#TimeDisplay">TimeDisplay</A>). However, if
you need more control (for example, you might want to let user edit
only days, months and hours), you can additionally hide any date/time
parts with this control. Keep in mind that, with this property, you
cannot show any date/time part which is hidden by another property
(for example, if TimeDisplay is tdHM, the second part is not shown,
regardless of this property).</SPAN></FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><A NAME="TDBDateTimePicker"></A>
<FONT FACE="Arial, sans-serif"><B>TDBDateTimePicker
<IMG SRC="pictures/TDBDateTimePicker.png" NAME="grafika6" ALIGN=MIDDLE WIDTH=24 HEIGHT=24 BORDER=0></B></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">TDBDateTimePicker is a data-aware
version of TDateTimePicker, with nice way of handling null database
values.</FONT></P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><BR>
</P>
<H4 CLASS="western" STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0.2cm">
<FONT FACE="Arial, sans-serif"><B>Displaying null values </B></FONT>
</H4>
<DL>
<DL>
<DD STYLE="margin-bottom: 0.51cm"><FONT FACE="Arial, sans-serif">When
the underlying DB field has null value, then:</FONT></DD></DL>
</DL>
<UL>
<UL>
<LI><DD STYLE="margin-bottom: 0.51cm">
<FONT FACE="Arial, sans-serif">When the control gets focus, the
text changes to defined format, but displaying zeros for date parts
and nines for time parts (for example &quot;00/00/0000 99:99:99&quot;),
which is appropriate to user input.</FONT></DD><LI><DD STYLE="margin-bottom: 0.51cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">When the control
is not focused, then it displays the text defined in
<A CLASS="western" HREF="#TextForNullDate">TextForNullDate</A>
property. The default is &quot;NULL&quot;.</SPAN></FONT></DD></UL>
</UL>
<H4 CLASS="western" STYLE="margin-left: 1.47cm; margin-top: 0.18cm; margin-bottom: 0.2cm">
<FONT FACE="Arial, sans-serif">Setting the field value to null </FONT>
</H4>
<DL>
<DL>
<DD STYLE="margin-bottom: 0.51cm"><FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">If
<A CLASS="western" HREF="#NullInputAllowed">NullInputAllowed</A>
property is True, the user can set the date and time to null, by
pressing N key. </SPAN></FONT>
</DD></DL>
</DL>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm">
<A NAME="DateTimePicker Editor"></A><FONT FACE="Arial, sans-serif"><B>DateTimePicker
Editor</B></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<IMG SRC="pictures/DateTimePickerEditor.PNG" NAME="grafika8" ALIGN=BOTTOM WIDTH=404 HEIGHT=188 BORDER=0></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif">DateTimePicker Editor is a dialog
which provides easy way to set Date, Time, MinDate and MaxDate
properties in design time. It is invoked when DateTimePicker
control is double-clicked in form designer. It is also shown when the
ellipsis (…) button, shown in Date, Time, MinDate and MaxDate
properties in Object inspector, gets clicked.</FONT></P>
<P STYLE="margin-bottom: 0.51cm"><BR><BR>
</P>
<P STYLE="margin-top: 0.18cm; margin-bottom: 0cm"><FONT FACE="Arial, sans-serif"><B>Tips</B></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><B>Q:</B> When the date/time value is
null, how to display zeros/nines in user format, no matter whether
the control is focused or not?</FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB"><B>A:</B></SPAN></FONT>
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Set <A CLASS="western" HREF="#TextForNullDate">TextForNullDate</A>
property to empty string. If TextForNullDate is set to empty string,
then zeros/nines are displayed, same as when the control has focus.</SPAN></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<BR>
</P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB"><B>Q:</B></SPAN></FONT>
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">When the date/time
value is null, If empty string in <A CLASS="western" HREF="#TextForNullDate">TextForNullDate</A>
property actually sets the display to zeros/nines format, how to set
the control to display nothing?</SPAN></FONT></P>
<P STYLE="margin-left: 0.84cm; margin-top: 0.18cm; margin-bottom: 0cm">
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB"><B>A:</B></SPAN></FONT>
<FONT FACE="Arial, sans-serif"><SPAN LANG="en-GB">Set <A CLASS="western" HREF="#TextForNullDate">TextForNullDate</A>
property to one space character, you will get the empty display.</SPAN></FONT></P>
</BODY>
</HTML>

View File

@ -0,0 +1,14 @@
DateTimeControls Package for Lazarus
--------------------------------------
http://wiki.lazarus.freepascal.org/DateTimeControls_Package
About:
The package contains two controls — TDateTimePicker and TDBDateTimePicker.
Delphi's VCL has a control named TDateTimePicker, which I find very useful for editing dates. LCL, however, does not have this control. Instead, for editing dates LCL has a control named TDateEdit, but I prefer the VCL's TDateTimePicker. Therefore, I tried to create a cross-platform Lazarus control which would resemble VCL's TDateTimePicker as much as possible. The TDateTimePicker control does not use native Win control, but it descends from LCL's TCustomControl to be cross-platform.
TDBDateTimePicker is a data-aware version of TDateTimePicker, with nice way of handling null database values.
Author: Zoran Vučenović
License: Modified LGPL, same as Lazarus component library.