DateTimeCtrls: TDateTimePicker: add Options property with dtpoDoChangeOnSetDateTime (not default). Issue #31679

git-svn-id: trunk@55133 -
This commit is contained in:
ondrej 2017-05-31 16:31:59 +00:00
parent d66ffb290b
commit 7e3c4d39df

View File

@ -119,9 +119,15 @@ type
dtaDefault means it is determined by BiDiMode } dtaDefault means it is determined by BiDiMode }
TDTCalAlignment = (dtaLeft, dtaRight, dtaDefault); TDTCalAlignment = (dtaLeft, dtaRight, dtaDefault);
TDateTimePickerOption = (
dtpoDoChangeOnSetDateTime);
TDateTimePickerOptions = set of TDateTimePickerOption;
{ TCustomDateTimePicker } { TCustomDateTimePicker }
TCustomDateTimePicker = class(TCustomControl) TCustomDateTimePicker = class(TCustomControl)
private const
cDefOptions = [];
private private
FAutoAdvance: Boolean; FAutoAdvance: Boolean;
FAutoButtonSize: Boolean; FAutoButtonSize: Boolean;
@ -191,6 +197,7 @@ type
FEnableWhenUnchecked: Boolean; FEnableWhenUnchecked: Boolean;
FAutoCheck: Boolean; FAutoCheck: Boolean;
FSkipChangeInUpdateDate: Integer; FSkipChangeInUpdateDate: Integer;
FOptions: TDateTimePickerOptions;
function AreSeparatorsStored: Boolean; function AreSeparatorsStored: Boolean;
function GetChecked: Boolean; function GetChecked: Boolean;
@ -407,6 +414,7 @@ type
property CalAlignment: TDTCalAlignment read FCalAlignment write SetCalAlignment default dtaDefault; property CalAlignment: TDTCalAlignment read FCalAlignment write SetCalAlignment default dtaDefault;
property FlatButton: Boolean read GetFlatButton write SetFlatButton default False; property FlatButton: Boolean read GetFlatButton write SetFlatButton default False;
property EnableWhenUnchecked: Boolean read FEnableWhenUnchecked write SetEnableWhenUnchecked default False; property EnableWhenUnchecked: Boolean read FEnableWhenUnchecked write SetEnableWhenUnchecked default False;
property Options: TDateTimePickerOptions read FOptions write FOptions default cDefOptions;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -486,6 +494,7 @@ type
property CalAlignment; property CalAlignment;
property FlatButton; property FlatButton;
property EnableWhenUnchecked; property EnableWhenUnchecked;
property Options;
// events: // events:
property OnChange; property OnChange;
property OnCheckBoxChange; property OnCheckBoxChange;
@ -1057,14 +1066,29 @@ begin
end; end;
procedure TCustomDateTimePicker.SetDateTime(const AValue: TDateTime); procedure TCustomDateTimePicker.SetDateTime(const AValue: TDateTime);
var
CallChange: Boolean;
begin begin
if not EqualDateTime(AValue, FDateTime) then begin if not EqualDateTime(AValue, FDateTime) then begin
if IsNullDate(AValue) then if IsNullDate(AValue) then
FDateTime := NullDate FDateTime := NullDate
else else
FDateTime := AValue; FDateTime := AValue;
CallChange := dtpoDoChangeOnSetDateTime in FOptions;
end else
CallChange := False;
if CallChange then
begin
Change;
Inc(FSkipChangeInUpdateDate);
end;
try
UpdateDate;
finally
if CallChange then
Dec(FSkipChangeInUpdateDate);
end; end;
UpdateDate;
end; end;
procedure TCustomDateTimePicker.SetDateSeparator(const AValue: String); procedure TCustomDateTimePicker.SetDateSeparator(const AValue: String);
@ -3831,6 +3855,7 @@ begin
FKind := dtkDate; FKind := dtkDate;
FNullInputAllowed := True; FNullInputAllowed := True;
FOptions := cDefOptions;
{ Thanks to Luiz Américo for this: { Thanks to Luiz Américo for this:
Lazarus ignores empty string when saving to lrs. Therefore, the problem Lazarus ignores empty string when saving to lrs. Therefore, the problem