mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:19:23 +02:00
Dialogs:
- implement a mechanisme to query the widgetset how and when to handle DoShow, DoCanClose and DoClose. - implement QueryWSEventCapabilities for Win32 widgetset git-svn-id: trunk@52850 -
This commit is contained in:
parent
e2d9b0ef94
commit
4213e0848c
@ -58,6 +58,10 @@ type
|
|||||||
|
|
||||||
{ TCommonDialog }
|
{ TCommonDialog }
|
||||||
|
|
||||||
|
TCDWSEventCapability = (cdecWSPerformsDoShow, cdecWSPerformsDoCanClose, cdecWSPerformsDoClose,
|
||||||
|
cdecWSNOCanCloseSupport);
|
||||||
|
TCDWSEventCapabilities = set of TCDWSEventCapability;
|
||||||
|
|
||||||
TCommonDialog = class(TLCLComponent)
|
TCommonDialog = class(TLCLComponent)
|
||||||
private
|
private
|
||||||
FHandle : THandle;
|
FHandle : THandle;
|
||||||
@ -72,6 +76,7 @@ type
|
|||||||
FDoShowCalled: Boolean;
|
FDoShowCalled: Boolean;
|
||||||
FDoCloseCalled: Boolean;
|
FDoCloseCalled: Boolean;
|
||||||
FClosing: boolean;
|
FClosing: boolean;
|
||||||
|
FWSEventCapabilities :TCDWSEventCapabilities;
|
||||||
procedure SetHandle(const AValue: THandle);
|
procedure SetHandle(const AValue: THandle);
|
||||||
function IsTitleStored: boolean;
|
function IsTitleStored: boolean;
|
||||||
protected
|
protected
|
||||||
|
@ -36,6 +36,7 @@ begin
|
|||||||
try
|
try
|
||||||
FUserChoice := mrNone;
|
FUserChoice := mrNone;
|
||||||
ResetShowCloseFlags;
|
ResetShowCloseFlags;
|
||||||
|
FWSEventCapabilities := TWSCommonDialogClass(WidgetSetClass).QueryWSEventCapabilities(Self);
|
||||||
Handle := TWSCommonDialogClass(WidgetSetClass).CreateHandle(Self);
|
Handle := TWSCommonDialogClass(WidgetSetClass).CreateHandle(Self);
|
||||||
Result:= DoExecute;
|
Result:= DoExecute;
|
||||||
Close;
|
Close;
|
||||||
@ -55,7 +56,7 @@ procedure TCommonDialog.Close;
|
|||||||
begin
|
begin
|
||||||
if HandleAllocated and not FClosing then begin
|
if HandleAllocated and not FClosing then begin
|
||||||
FClosing := true;
|
FClosing := true;
|
||||||
if not FDoCloseCalled then
|
if (not FDoCloseCalled) and (not (cdecWSPerformsDoClose in FWSEventCapabilities)) then
|
||||||
DoClose;
|
DoClose;
|
||||||
TWSCommonDialogClass(WidgetSetClass).DestroyHandle(Self);
|
TWSCommonDialogClass(WidgetSetClass).DestroyHandle(Self);
|
||||||
FHandle := 0;
|
FHandle := 0;
|
||||||
@ -73,7 +74,7 @@ end;
|
|||||||
procedure TCommonDialog.DoCanClose(var CanClose: Boolean);
|
procedure TCommonDialog.DoCanClose(var CanClose: Boolean);
|
||||||
begin
|
begin
|
||||||
FDoCanCloseCalled := True;
|
FDoCanCloseCalled := True;
|
||||||
if Assigned(FOnCanClose) then
|
if Assigned(FOnCanClose) and (not (cdecWSNOCanCloseSupport in FWSEventCapabilities)) then
|
||||||
OnCanClose(Self, CanClose);
|
OnCanClose(Self, CanClose);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -128,10 +129,17 @@ function TCommonDialog.DoExecute : boolean;
|
|||||||
var
|
var
|
||||||
CanClose: boolean;
|
CanClose: boolean;
|
||||||
begin
|
begin
|
||||||
|
{
|
||||||
|
Various widgetsets may or may not call DoShow, DoCanClose or DoClose from within
|
||||||
|
the WS implementation.
|
||||||
|
If the WS calls any of these, we assume that we should NOT call them from here.
|
||||||
|
Checking for FDoShowCalled (etc) alone is not enough, since it may very well be that
|
||||||
|
the WS wants to (deiberately) call the methos at a later point in time.
|
||||||
|
}
|
||||||
{$ifdef DebugCommonDialogEvents}
|
{$ifdef DebugCommonDialogEvents}
|
||||||
debugln(['TCommonDialog.DoExecute A']);
|
debugln(['TCommonDialog.DoExecute A']);
|
||||||
{$endif}
|
{$endif}
|
||||||
if not FDoShowCalled then
|
if (not FDoShowCalled) and (not (cdecWSPerformsDoShow in FWSEventCapabilities)) then
|
||||||
begin
|
begin
|
||||||
{$ifdef DebugCommonDialogEvents}
|
{$ifdef DebugCommonDialogEvents}
|
||||||
debugln(['TCommonDialog.DoExecute calling DoShow']);
|
debugln(['TCommonDialog.DoExecute calling DoShow']);
|
||||||
@ -146,7 +154,7 @@ begin
|
|||||||
debugln(['TCommonDialog.DoExecute after WS_ShowModal, FCanCloseCalled=',FDoCanCloseCalled,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
debugln(['TCommonDialog.DoExecute after WS_ShowModal, FCanCloseCalled=',FDoCanCloseCalled,' FUserChoice=',ModalResultStr[FUserChoice]]);
|
||||||
{$endif}
|
{$endif}
|
||||||
// can close was called from widgetset loop
|
// can close was called from widgetset loop
|
||||||
if not FDoCanCloseCalled then
|
if (not FDoCanCloseCalled) and ((FWSEventCapabilities * [cdecWSPerformsDoCanClose,cdecWSNOCanCloseSupport]) = []) then
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
{$ifdef DebugCommonDialogEvents}
|
{$ifdef DebugCommonDialogEvents}
|
||||||
|
@ -82,6 +82,7 @@ type
|
|||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
||||||
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32WSSaveDialog }
|
{ TWin32WSSaveDialog }
|
||||||
@ -91,6 +92,7 @@ type
|
|||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
||||||
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32WSSelectDirectoryDialog }
|
{ TWin32WSSelectDirectoryDialog }
|
||||||
@ -100,6 +102,7 @@ type
|
|||||||
class function CreateOldHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function CreateOldHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
published
|
published
|
||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32WSColorDialog }
|
{ TWin32WSColorDialog }
|
||||||
@ -109,6 +112,7 @@ type
|
|||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
||||||
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); override;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWin32WSColorButton }
|
{ TWin32WSColorButton }
|
||||||
@ -122,6 +126,7 @@ type
|
|||||||
TWin32WSFontDialog = class(TWSFontDialog)
|
TWin32WSFontDialog = class(TWSFontDialog)
|
||||||
published
|
published
|
||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -411,6 +416,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSColorDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
Result := [cdecWSNoCanCloseSupport];
|
||||||
|
end;
|
||||||
|
|
||||||
procedure UpdateStorage(Wnd: HWND; OpenFile: LPOPENFILENAME);
|
procedure UpdateStorage(Wnd: HWND; OpenFile: LPOPENFILENAME);
|
||||||
var
|
var
|
||||||
FilesSize: SizeInt;
|
FilesSize: SizeInt;
|
||||||
@ -997,6 +1008,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSOpenDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
Result := [cdecWSPerformsDoShow,cdecWSPerformsDoCanClose];
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWin32WSSaveDialog }
|
{ TWin32WSSaveDialog }
|
||||||
|
|
||||||
class function TWin32WSSaveDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TWin32WSSaveDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
@ -1065,6 +1082,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSSaveDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
Result := [cdecWSPerformsDoShow,cdecWSPerformsDoCanClose];
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWin32WSFontDialog }
|
{ TWin32WSFontDialog }
|
||||||
|
|
||||||
class function TWin32WSFontDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TWin32WSFontDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
@ -1150,6 +1173,12 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSFontDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
Result := [cdecWSPerformsDoShow, cdecWSPerformsDoClose, cdecWSNoCanCloseSupport];
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWin32WSCommonDialog }
|
{ TWin32WSCommonDialog }
|
||||||
|
|
||||||
class function TWin32WSCommonDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TWin32WSCommonDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
@ -1208,6 +1237,15 @@ begin
|
|||||||
Result := CreateOldHandle(ACommonDialog);
|
Result := CreateOldHandle(ACommonDialog);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSSelectDirectoryDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
if CanUseVistaDialogs(TSelectDirectoryDialog(ACommonDialog)) then
|
||||||
|
Result := [cdecWSPerformsDoShow,cdecWSPerformsDoCanClose]
|
||||||
|
else
|
||||||
|
Result := [cdecWSPerformsDoShow, cdecWSPerformsDoClose, cdecWSNoCanCloseSupport];
|
||||||
|
end;
|
||||||
|
|
||||||
class function TWin32WSSelectDirectoryDialog.CreateOldHandle(
|
class function TWin32WSSelectDirectoryDialog.CreateOldHandle(
|
||||||
const ACommonDialog: TCommonDialog): THandle;
|
const ACommonDialog: TCommonDialog): THandle;
|
||||||
var
|
var
|
||||||
|
@ -51,6 +51,7 @@ type
|
|||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; virtual;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; virtual;
|
||||||
class procedure ShowModal(const ACommonDialog: TCommonDialog); virtual;
|
class procedure ShowModal(const ACommonDialog: TCommonDialog); virtual;
|
||||||
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); virtual;
|
class procedure DestroyHandle(const ACommonDialog: TCommonDialog); virtual;
|
||||||
|
class function QueryWSEventCapabilities(const ACommonDialog: TCommonDialog): TCDWSEventCapabilities; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWSFileDialog }
|
{ TWSFileDialog }
|
||||||
@ -120,6 +121,12 @@ class procedure TWSCommonDialog.DestroyHandle(const ACommonDialog: TCommonDialog
|
|||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWSCommonDialog.QueryWSEventCapabilities(
|
||||||
|
const ACommonDialog: TCommonDialog): TCDWSEventCapabilities;
|
||||||
|
begin
|
||||||
|
Result := [];
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TWSCommonDialog.ShowModal(const ACommonDialog: TCommonDialog);
|
class procedure TWSCommonDialog.ShowModal(const ACommonDialog: TCommonDialog);
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user