mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 12:39:15 +02:00
LCL calendar dialog:
+ added DialogPosition property (#8885) + double clicking the calendar closes the dialog git-svn-id: trunk@11150 -
This commit is contained in:
parent
a9fb0409fa
commit
bd03f62f68
@ -194,9 +194,11 @@ function CreateCalculatorForm(AOwner: TComponent; ALayout : TCalculatorLayout; A
|
|||||||
Type
|
Type
|
||||||
{ TCalendarDialog }
|
{ TCalendarDialog }
|
||||||
TCalendarDialog = class(TCommonDialog)
|
TCalendarDialog = class(TCommonDialog)
|
||||||
|
procedure CalendarDblClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
FDate: TDateTime;
|
FDate: TDateTime;
|
||||||
FDayChanged: TNotifyEvent;
|
FDayChanged: TNotifyEvent;
|
||||||
|
FDialogPosition: TPosition;
|
||||||
FDisplaySettings: TDisplaySettings;
|
FDisplaySettings: TDisplaySettings;
|
||||||
FHelpContext: THelpContext;
|
FHelpContext: THelpContext;
|
||||||
FMonthChanged: TNotifyEvent;
|
FMonthChanged: TNotifyEvent;
|
||||||
@ -219,6 +221,7 @@ Type
|
|||||||
property HelpContext: THelpContext read FHelpContext write FHelpContext default 0;
|
property HelpContext: THelpContext read FHelpContext write FHelpContext default 0;
|
||||||
property OnMonthChanged: TNotifyEvent read FMonthChanged write FMonthChanged;
|
property OnMonthChanged: TNotifyEvent read FMonthChanged write FMonthChanged;
|
||||||
property OnYearChanged: TNotifyEvent read FYearChanged write FYearChanged;
|
property OnYearChanged: TNotifyEvent read FYearChanged write FYearChanged;
|
||||||
|
property DialogPosition: TPosition read FDialogPosition write FDialogPosition default poMainFormCenter;
|
||||||
property DialogTitle:TCaption Read FDialogTitle Write FDialogTitle Stored IsTitleStored;
|
property DialogTitle:TCaption Read FDialogTitle Write FDialogTitle Stored IsTitleStored;
|
||||||
property OKCaption:TCaption Read FOKCaption Write FOKCaption;
|
property OKCaption:TCaption Read FOKCaption Write FOKCaption;
|
||||||
property CancelCaption:TCaption Read FCancelCaption Write FCancelCaption;
|
property CancelCaption:TCaption Read FCancelCaption Write FCancelCaption;
|
||||||
@ -1155,8 +1158,8 @@ end;
|
|||||||
constructor TCalendarDialog.Create(AOwner: TComponent);
|
constructor TCalendarDialog.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FDate:=Now;
|
Date:=trunc(Now);
|
||||||
Date:=trunc(FDate);
|
DialogPosition:=poMainFormCenter;
|
||||||
DialogTitle:=rsPickDate;
|
DialogTitle:=rsPickDate;
|
||||||
OKCaption:=rsMbOK;
|
OKCaption:=rsMbOK;
|
||||||
CancelCaption:=rsMbCancel;
|
CancelCaption:=rsMbCancel;
|
||||||
@ -1172,6 +1175,16 @@ begin
|
|||||||
Date:=FCalendar.DateTime;
|
Date:=FCalendar.DateTime;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCalendarDialog.CalendarDblClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
CalendarForm: TForm;
|
||||||
|
begin
|
||||||
|
GetNewDate(Sender);
|
||||||
|
CalendarForm:=TForm(TComponent(Sender).Owner);
|
||||||
|
// close the calendar dialog
|
||||||
|
CalendarForm.ModalResult:=mrOk;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCalendarDialog.IsTitleStored: Boolean;
|
function TCalendarDialog.IsTitleStored: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=DialogTitle<>rsPickDate;//controllare
|
Result:=DialogTitle<>rsPickDate;//controllare
|
||||||
@ -1183,13 +1196,13 @@ var DF:TForm;
|
|||||||
okButton,cancelButton:TButton;
|
okButton,cancelButton:TButton;
|
||||||
panel:TPanel;
|
panel:TPanel;
|
||||||
begin
|
begin
|
||||||
DF:=TForm.Create(Self);
|
DF:=TForm.Create(Self.Owner); // Self.Owner, so that poOwnerFormCenter works
|
||||||
DF.Caption:=FDialogTitle;
|
DF.Caption:=DialogTitle;
|
||||||
DF.Position:=poMainFormCenter;
|
DF.Position:=DialogPosition;
|
||||||
DF.BorderStyle:=bsDialog;
|
DF.BorderStyle:=bsDialog;
|
||||||
//DF.AutoSize:=true;
|
//DF.AutoSize:=true;
|
||||||
|
|
||||||
FCalendar:=TCalendar.Create(Self);
|
FCalendar:=TCalendar.Create(DF);
|
||||||
with FCalendar do begin
|
with FCalendar do begin
|
||||||
Parent:=DF;
|
Parent:=DF;
|
||||||
Align:=alTop;
|
Align:=alTop;
|
||||||
@ -1198,9 +1211,10 @@ begin
|
|||||||
OnDayChanged:=Self.OnDayChanged;
|
OnDayChanged:=Self.OnDayChanged;
|
||||||
OnMonthChanged:=Self.OnMonthChanged;
|
OnMonthChanged:=Self.OnMonthChanged;
|
||||||
OnYearChanged:=Self.OnYearChanged;
|
OnYearChanged:=Self.OnYearChanged;
|
||||||
|
OnDblClick:=@CalendarDblClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
panel:=TPanel.Create(Self);
|
panel:=TPanel.Create(DF);
|
||||||
with panel do begin
|
with panel do begin
|
||||||
Parent:=DF;
|
Parent:=DF;
|
||||||
Caption:='';
|
Caption:='';
|
||||||
@ -1209,7 +1223,7 @@ begin
|
|||||||
BevelOuter:=bvLowered;
|
BevelOuter:=bvLowered;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
okButton:=TButton.Create(Self);
|
okButton:=TButton.Create(DF);
|
||||||
with okButton do begin
|
with okButton do begin
|
||||||
Parent:=panel;
|
Parent:=panel;
|
||||||
Caption:=OKCaption;
|
Caption:=OKCaption;
|
||||||
@ -1222,7 +1236,7 @@ begin
|
|||||||
Default:=True;
|
Default:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
cancelButton:=TButton.Create(Self);
|
cancelButton:=TButton.Create(DF);
|
||||||
with cancelButton do begin
|
with cancelButton do begin
|
||||||
Parent:=panel;
|
Parent:=panel;
|
||||||
Caption:=CancelCaption;
|
Caption:=CancelCaption;
|
||||||
@ -1237,10 +1251,6 @@ begin
|
|||||||
DF.ClientHeight := panel.Top+panel.Height;
|
DF.ClientHeight := panel.Top+panel.Height;
|
||||||
|
|
||||||
Result:=DF.ShowModal=mrOK;
|
Result:=DF.ShowModal=mrOK;
|
||||||
FreeAndNil(FCalendar);
|
|
||||||
FreeAndNil(panel);
|
|
||||||
FreeAndNil(okButton);
|
|
||||||
FreeAndNil(cancelButton);
|
|
||||||
FreeAndNil(DF);
|
FreeAndNil(DF);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user