lcl: rewrite PopupMode/PopupParent

- unify code for PopupMode/PopupParent in one function TCustomForm.GetRealPopupParent for all WS.
- change TWSCustomFormClass.SetPopupParent to TWSCustomFormClass.SetRealPopupParent without PopupMode parameter.
- Fix TPopupMode documentation.
Issue #29247

git-svn-id: trunk@51032 -
This commit is contained in:
ondrej 2015-12-25 15:37:10 +00:00
parent 629feb6d13
commit 81733b2e74
13 changed files with 118 additions and 196 deletions

View File

@ -1500,13 +1500,13 @@
</notes> </notes>
</element> </element>
<element name="TPopupMode.pmNone"> <element name="TPopupMode.pmNone">
<short>default behavior - popup to mainform/taskbar window</short> <short>modal: popup to mainform/taskbar window; non-modal: no window parent</short>
</element> </element>
<element name="TPopupMode.pmAuto"> <element name="TPopupMode.pmAuto">
<short>popup to active form, and same as pmNone if no active form</short> <short>modal &amp; non-modal: popup to active form or if not available, to main form</short>
</element> </element>
<element name="TPopupMode.pmExplicit"> <element name="TPopupMode.pmExplicit">
<short>popup to PopupParent, and same as pmNone if not exists</short> <short>modal &amp; non-modal: popup to PopupParent or if not available, to main form</short>
</element> </element>
<!-- procedure type Visibility: default --> <!-- procedure type Visibility: default -->
<element name="TCloseEvent"> <element name="TCloseEvent">

View File

@ -388,9 +388,9 @@ type
); );
TPopupMode = ( TPopupMode = (
pmNone, // default behavior - popup to mainform/taskbar window pmNone, // modal: popup to mainform/taskbar window; non-modal: no window parent
pmAuto, // popup to active form and same as pmNone if no active form pmAuto, // modal & non-modal: popup to active form or if not available, to main form
pmExplicit // popup to PopupParent and same as pmNone if not exists pmExplicit // modal & non-modal: popup to PopupParent or if not available, to main form
); );
TCloseEvent = procedure(Sender: TObject; var CloseAction: TCloseAction) of object; TCloseEvent = procedure(Sender: TObject; var CloseAction: TCloseAction) of object;
@ -595,6 +595,7 @@ type
function FormIsUpdating: boolean; override; function FormIsUpdating: boolean; override;
function GetFormImage: TBitmap; function GetFormImage: TBitmap;
function GetRolesForControl(AControl: TControl): TControlRolesForForm; function GetRolesForControl(AControl: TControl): TControlRolesForForm;
function GetRealPopupParent: TCustomForm;
procedure Hide; procedure Hide;
procedure IntfDropFiles(const FileNames: array of String); procedure IntfDropFiles(const FileNames: array of String);
procedure IntfHelp(AComponent: TComponent); procedure IntfHelp(AComponent: TComponent);

View File

@ -360,10 +360,11 @@ begin
if FPopupMode <> AValue then if FPopupMode <> AValue then
begin begin
FPopupMode := AValue; FPopupMode := AValue;
if FPopupMode = pmAuto then if (FPopupMode = pmAuto) and (PopupParent <> nil) then
PopupParent := nil; PopupParent := nil
else
if not (csDesigning in ComponentState) and HandleAllocated then if not (csDesigning in ComponentState) and HandleAllocated then
TWSCustomFormClass(WidgetSetClass).SetPopupParent(Self, PopupMode, PopupParent); TWSCustomFormClass(WidgetSetClass).SetRealPopupParent(Self, GetRealPopupParent);
end; end;
end; end;
@ -380,7 +381,7 @@ begin
FPopupMode := pmExplicit; FPopupMode := pmExplicit;
end; end;
if not (csDesigning in ComponentState) and HandleAllocated then if not (csDesigning in ComponentState) and HandleAllocated then
TWSCustomFormClass(WidgetSetClass).SetPopupParent(Self, PopupMode, PopupParent); TWSCustomFormClass(WidgetSetClass).SetRealPopupParent(Self, GetRealPopupParent);
end; end;
end; end;
@ -1475,6 +1476,31 @@ begin
end; end;
end; end;
function TCustomForm.GetRealPopupParent: TCustomForm;
begin
Result := nil;
if (fsModal in FormState) or // always set WndParent of modal windows
(PopupMode in [pmAuto, pmExplicit]) // set WndParent of non-modal windows only for pmAuto, pmExplicit
then
begin
case PopupMode of
pmAuto:
begin
Result := Screen.ActiveForm;
if (Result<>nil) and (Result.FormStyle = fsSplash) then // ignore fsSplash
Result := nil;
end;
pmExplicit: Result := PopupParent;
end;
if (Result = nil) or not Result.HandleAllocated then
Result := Application.MainForm;
end;
if (Result <> nil) and not Result.HandleAllocated then
Result := nil;
if (Result = Self) then
Result := nil;
end;
procedure TCustomForm.DoAutoSize; procedure TCustomForm.DoAutoSize;
begin begin
//DebugLn(['TCustomForm.DoAutoSize ',DbgSName(Self),' ',WindowState=wsNormal,' ',fsDisableAutoSize in FFormState,' ',dbgs(BoundsRect),' ',dbgs(ClientRect)]); //DebugLn(['TCustomForm.DoAutoSize ',DbgSName(Self),' ',WindowState=wsNormal,' ',fsDisableAutoSize in FFormState,' ',dbgs(BoundsRect),' ',dbgs(ClientRect)]);
@ -2044,6 +2070,8 @@ end;
TCustomForm CreateParams TCustomForm CreateParams
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomForm.CreateParams(var Params : TCreateParams); procedure TCustomForm.CreateParams(var Params : TCreateParams);
var
APopupParent: TCustomForm;
begin begin
inherited CreateParams(Params); inherited CreateParams(Params);
with Params do with Params do
@ -2055,15 +2083,9 @@ begin
begin begin
if (Application.MainForm <> Self) then if (Application.MainForm <> Self) then
begin begin
case PopupMode of APopupParent := GetRealPopupParent;
pmNone:; if APopupParent <> nil then
pmAuto: WndParent := APopupParent.Handle;
if (Screen.ActiveForm <> nil) then
WndParent := Screen.ActiveForm.Handle;
pmExplicit:
if (PopupParent <> nil) then
WndParent := PopupParent.Handle;
end;
end; end;
if (WndParent = 0) and if (WndParent = 0) and
(((Self = Application.MainForm) and Application.MainFormOnTaskBar) or (GetEffectiveShowInTaskBar = stAlways)) then (((Self = Application.MainForm) and Application.MainFormOnTaskBar) or (GetEffectiveShowInTaskBar = stAlways)) then

View File

@ -76,8 +76,8 @@ type
class procedure SetAlphaBlend(const ACustomForm: TCustomForm; const AlphaBlend: Boolean; const Alpha: Byte); override; class procedure SetAlphaBlend(const ACustomForm: TCustomForm; const AlphaBlend: Boolean; const Alpha: Byte); override;
class procedure SetFormStyle(const ACustomForm: TCustomForm; const ANewFormStyle, {%H-}AOldFormStyle: TFormStyle); override; class procedure SetFormStyle(const ACustomForm: TCustomForm; const ANewFormStyle, {%H-}AOldFormStyle: TFormStyle); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const {%H-}APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
end; end;
{ TCarbonWSForm } { TCarbonWSForm }
@ -338,10 +338,9 @@ begin
Self, 'SetFormStyle', 'SetWindowGroup'); Self, 'SetFormStyle', 'SetWindowGroup');
end; end;
class procedure TCarbonWSCustomForm.SetPopupParent(const ACustomForm:TCustomForm; class procedure TCarbonWSCustomForm.SetRealPopupParent(
const APopupMode:TPopupMode;const APopupParent:TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
begin begin
//todo: better "popup-parent" hanlding
if Assigned(APopupParent) and (APopupParent.Handle<>0) then if Assigned(APopupParent) and (APopupParent.Handle<>0) then
begin begin
SetWindowGroup( TCarbonWindow(ACustomForm.Handle).Window, GetWindowGroupOfClass(kHelpWindowClass)); SetWindowGroup( TCarbonWindow(ACustomForm.Handle).Window, GetWindowGroupOfClass(kHelpWindowClass));

View File

@ -112,8 +112,8 @@ type
class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override; class procedure SetBorderIcons(const AForm: TCustomForm; const ABorderIcons: TBorderIcons); override;
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override; class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override; class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
{need to override these } {need to override these }
class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override; class function GetClientBounds(const AWincontrol: TWinControl; var ARect: TRect): Boolean; override;
@ -660,30 +660,17 @@ begin
end; end;
end; end;
class procedure TCocoaWSCustomForm.SetPopupParent( class procedure TCocoaWSCustomForm.SetRealPopupParent(
const ACustomForm: TCustomForm; const APopupMode: TPopupMode; const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
const APopupParent: TCustomForm);
var
PopupParent: TCustomForm;
begin begin
if not ACustomForm.HandleAllocated then Exit;
case APopupMode of
pmNone:
PopupParent := nil;
pmAuto:
PopupParent := Screen.ActiveForm;
pmExplicit:
PopupParent := APopupParent;
end;
if Assigned(PopupParent) then
NSWindow(PopupParent.Handle).addChildWindow_ordered(NSWindow(ACustomForm.Handle), NSWindowAbove)
else
if Assigned(NSWindow(ACustomForm.Handle).parentWindow) then if Assigned(NSWindow(ACustomForm.Handle).parentWindow) then
NSWindow(ACustomForm.Handle).parentWindow.removeChildWindow(NSWindow(ACustomForm.Handle)); NSWindow(ACustomForm.Handle).parentWindow.removeChildWindow(NSWindow(ACustomForm.Handle));
if Assigned(APopupParent) then
NSWindow(APopupParent.Handle).addChildWindow_ordered(NSWindow(ACustomForm.Handle), NSWindowAbove);
end; end;
class function TCocoaWSCustomForm.GetClientBounds(const AWinControl: TWinControl; var ARect: TRect): Boolean; class function TCocoaWSCustomForm.GetClientBounds(
const AWincontrol: TWinControl; var ARect: TRect): Boolean;
begin begin
Result := False; Result := False;
if not AWinControl.HandleAllocated then Exit; if not AWinControl.HandleAllocated then Exit;
@ -691,7 +678,8 @@ begin
Result := True; Result := True;
end; end;
class function TCocoaWSCustomForm.GetClientRect(const AWinControl: TWinControl; var ARect: TRect): Boolean; class function TCocoaWSCustomForm.GetClientRect(const AWincontrol: TWinControl;
var ARect: TRect): Boolean;
var var
x, y: Integer; x, y: Integer;
begin begin

View File

@ -141,8 +141,8 @@ type
class procedure SetFormBorderStyle(const AForm: TCustomForm; class procedure SetFormBorderStyle(const AForm: TCustomForm;
const AFormBorderStyle: TFormBorderStyle); override; const AFormBorderStyle: TFormBorderStyle); override;
// class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override; // class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
// class procedure SetPopupParent(const ACustomForm: TCustomForm; // class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
// const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; // const APopupParent: TCustomForm); override;
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override; class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
class procedure ShowModal(const ACustomForm: TCustomForm); override; class procedure ShowModal(const ACustomForm: TCustomForm); override;

View File

@ -79,8 +79,8 @@ type
class procedure SetBorderIcons(const AForm: TCustomForm; class procedure SetBorderIcons(const AForm: TCustomForm;
const ABorderIcons: TBorderIcons); override; const ABorderIcons: TBorderIcons); override;
class procedure SetColor(const AWinControl: TWinControl); override; class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
end; end;
{ TGtkWSForm } { TGtkWSForm }
@ -526,23 +526,13 @@ begin
TGtkWSWinControl.SetColor(AWinControl); TGtkWSWinControl.SetColor(AWinControl);
end; end;
class procedure TGtkWSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TGtkWSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
var
PopupParent: TCustomForm;
begin begin
if not WSCheckHandleAllocated(ACustomForm, 'SetPopupParent') then Exit; if not WSCheckHandleAllocated(ACustomForm, 'SetRealPopupParent') then Exit;
case APopupMode of if APopupParent <> nil then
pmNone: gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), PGtkWindow(APopupParent.Handle))
PopupParent := nil;
pmAuto:
PopupParent := Screen.ActiveForm;
pmExplicit:
PopupParent := APopupParent;
end;
if PopupParent <> nil then
gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), PGtkWindow(PopupParent.Handle))
else else
gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), nil); gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), nil);
end; end;

View File

@ -84,8 +84,8 @@ type
class procedure SetBorderIcons(const AForm: TCustomForm; class procedure SetBorderIcons(const AForm: TCustomForm;
const ABorderIcons: TBorderIcons); override; const ABorderIcons: TBorderIcons); override;
class procedure SetColor(const AWinControl: TWinControl); override; class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
end; end;
{ TGtk2WSForm } { TGtk2WSForm }
@ -680,7 +680,7 @@ var
{$IFDEF HASX} {$IFDEF HASX}
TempGdkWindow: PGdkWindow; TempGdkWindow: PGdkWindow;
{$ENDIF} {$ENDIF}
AForm: TCustomForm; AForm, APopupParent: TCustomForm;
GtkWindow: PGtkWindow; GtkWindow: PGtkWindow;
Geometry: TGdkGeometry; Geometry: TGdkGeometry;
@ -778,17 +778,11 @@ begin
if AWinControl.HandleObjectShouldBeVisible and if AWinControl.HandleObjectShouldBeVisible and
not (csDesigning in AForm.ComponentState) and not (csDesigning in AForm.ComponentState) and
not (AForm.FormStyle in fsAllStayOnTop) and not (AForm.FormStyle in fsAllStayOnTop) and
not (fsModal in AForm.FormState) and not (fsModal in AForm.FormState) then
(((AForm.PopupMode = pmAuto) and
(Screen.ActiveCustomForm <> nil)) or
((AForm.PopupMode = pmExplicit) and
(AForm.PopupParent <> nil)))
then
begin begin
if (AForm.PopupMode = pmAuto) then APopupParent := AForm.GetRealPopupParent;
SetPopupParent(AForm, AForm.PopupMode, Screen.ActiveCustomForm) if (APopupParent <> nil) then
else SetRealPopupParent(AForm, APopupParent);
SetPopupParent(AForm, AForm.PopupMode, AForm.PopupParent);
end; end;
{$ENDIF} {$ENDIF}
@ -848,27 +842,13 @@ begin
TGtk2WSWinControl.SetColor(AWinControl); TGtk2WSWinControl.SetColor(AWinControl);
end; end;
class procedure TGtk2WSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TGtk2WSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
var
PopupParent: TCustomForm;
begin begin
if not WSCheckHandleAllocated(ACustomForm, 'SetPopupParent') then Exit; if not WSCheckHandleAllocated(ACustomForm, 'SetRealPopupParent') then Exit;
case APopupMode of if APopupParent <> nil then
pmNone: gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), {%H-}PGtkWindow(APopupParent.Handle))
PopupParent := nil;
pmAuto:
PopupParent := Screen.ActiveForm;
pmExplicit:
begin
PopupParent := APopupParent;
if PopupParent = nil then
PopupParent := Application.MainForm;
end;
end;
if PopupParent <> nil then
gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), {%H-}PGtkWindow(PopupParent.Handle))
else else
gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), nil); gtk_window_set_transient_for({%H-}PGtkWindow(ACustomForm.Handle), nil);
end; end;

View File

@ -95,8 +95,8 @@ type
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override; class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override; class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
class procedure ShowModal(const ACustomForm: TCustomForm); override; class procedure ShowModal(const ACustomForm: TCustomForm); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
class procedure SetZPosition(const AWinControl: TWinControl; const APosition: TWSZPosition); override; class procedure SetZPosition(const AWinControl: TWinControl; const APosition: TWSZPosition); override;
class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override; class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
@ -387,20 +387,20 @@ begin
{$ENDIF} {$ENDIF}
end; end;
class procedure TGtk3WSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TGtk3WSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
begin begin
if not WSCheckHandleAllocated(ACustomForm, 'ShowPopupParent') then if not WSCheckHandleAllocated(ACustomForm, 'SetRealPopupParent') then
Exit; Exit;
{$IFDEF GTK3DEBUGCORE} {$IFDEF GTK3DEBUGCORE}
DebugLn('TGtk3WSCustomForm.SetPopupParent'); DebugLn('TGtk3WSCustomForm.SetRealPopupParent');
{$ENDIF} {$ENDIF}
end; end;
class procedure TGtk3WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm; class procedure TGtk3WSCustomForm.SetAlphaBlend(const ACustomForm: TCustomForm;
const AlphaBlend: Boolean; const Alpha: Byte); const AlphaBlend: Boolean; const Alpha: Byte);
begin begin
if not WSCheckHandleAllocated(ACustomForm, 'ShowAlphaBlend') then if not WSCheckHandleAllocated(ACustomForm, 'SetAlphaBlend') then
Exit; Exit;
{$IFDEF GTK3DEBUGCORE} {$IFDEF GTK3DEBUGCORE}
DebugLn('TGtk3WSCustomForm.SetAlphaBlend'); DebugLn('TGtk3WSCustomForm.SetAlphaBlend');

View File

@ -622,7 +622,6 @@ type
LayoutWidget: QBoxLayoutH; LayoutWidget: QBoxLayoutH;
FCWEventHook: QObject_hookH; FCWEventHook: QObject_hookH;
FShowOnTaskBar: Boolean; FShowOnTaskBar: Boolean;
FPopupMode: TPopupMode;
FPopupParent: QWidgetH; FPopupParent: QWidgetH;
FMDIStateHook: QMdiSubWindow_hookH; FMDIStateHook: QMdiSubWindow_hookH;
protected protected
@ -669,7 +668,7 @@ type
procedure SlotActivateWindow(vActivate: Boolean); cdecl; procedure SlotActivateWindow(vActivate: Boolean); cdecl;
procedure slotWindowStateChange; cdecl; procedure slotWindowStateChange; cdecl;
procedure setShowInTaskBar(AValue: Boolean); procedure setShowInTaskBar(AValue: Boolean);
procedure setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH); procedure setRealPopupParent(NewParent: QWidgetH);
property Blocked: Boolean read FBlocked write FBlocked; property Blocked: Boolean read FBlocked write FBlocked;
property ShowOnTaskBar: Boolean read FShowOnTaskBar; property ShowOnTaskBar: Boolean read FShowOnTaskBar;
public public
@ -6569,7 +6568,6 @@ begin
QtFormBorderStyle := Ord(bsSizeable); QtFormBorderStyle := Ord(bsSizeable);
QtFormStyle := Ord(fsNormal); QtFormStyle := Ord(fsNormal);
FHasPaint := True; FHasPaint := True;
FPopupMode := pmNone;
FPopupParent := nil; FPopupParent := nil;
MDIAreaHandle := nil; MDIAreaHandle := nil;
MDIChildArea := nil; MDIChildArea := nil;
@ -6711,42 +6709,8 @@ begin
end; end;
procedure TQtMainWindow.UpdateParent; procedure TQtMainWindow.UpdateParent;
var
NewParent: QWidgetH;
begin begin
NewParent := nil; ChangeParent(FPopupParent);
case FPopupMode of
pmNone: ;// no popup parent
pmAuto:
// active form is parent
if Screen.ActiveForm <> nil then
NewParent := TQtWidget(Screen.ActiveForm.Handle).Widget;
pmExplicit:
begin
// parent is FPopupParent
if FPopupParent <> nil then
NewParent := FPopupParent
{$IFDEF HASX11}
else
begin
if not IsMainForm then
begin
NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
setWindowFlags(windowFlags or QtSheet);
end;
end;
{$ENDIF}
end;
end;
if (NewParent = nil) and (FPopupMode <> pmNone) and
not FShowOnTaskBar and not IsMainForm then
NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
{$IFDEF MSWINDOWS}
if (NewParent = nil) and (FPopupMode = pmNone) and
not FShowOnTaskBar and not IsMainForm then
NewParent := TQtMainWindow(Application.MainForm.Handle).Widget;
{$ENDIF}
ChangeParent(NewParent);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -7367,9 +7331,8 @@ begin
{$ENDIF} {$ENDIF}
end; end;
procedure TQtMainWindow.setPopupParent(APopupMode: TPopupMode; NewParent: QWidgetH); procedure TQtMainWindow.setRealPopupParent(NewParent: QWidgetH);
begin begin
FPopupMode := APopupMode;
FPopupParent := NewParent; FPopupParent := NewParent;
UpdateParent; UpdateParent;
end; end;

View File

@ -80,8 +80,8 @@ type
class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override; class procedure SetFormBorderStyle(const AForm: TCustomForm; const AFormBorderStyle: TFormBorderStyle); override;
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override; class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override; class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible) class procedure ShowHide(const AWinControl: TWinControl); override; //TODO: rename to SetVisible(control, visible)
class procedure ShowModal(const ACustomForm: TCustomForm); override; class procedure ShowModal(const ACustomForm: TCustomForm); override;
@ -145,7 +145,7 @@ class function TQtWSCustomForm.CreateHandle(const AWinControl: TWinControl;
var var
QtMainWindow: TQtMainWindow; QtMainWindow: TQtMainWindow;
Str: WideString; Str: WideString;
PopupParent: QWidgetH; APopupParent: TCustomForm;
AForm: TCustomForm; AForm: TCustomForm;
begin begin
{$ifdef VerboseQt} {$ifdef VerboseQt}
@ -191,11 +191,9 @@ begin
not (csDesigning in AForm.ComponentState)) not (csDesigning in AForm.ComponentState))
{$endif} then {$endif} then
QtMainWindow.setShowInTaskBar(False); QtMainWindow.setShowInTaskBar(False);
if Assigned(AForm.PopupParent) and AForm.PopupParent.HandleAllocated then APopupParent := AForm.GetRealPopupParent;
PopupParent := TQtWidget(AForm.PopupParent.Handle).Widget if APopupParent<>nil then
else QtMainWindow.setRealPopupParent(TQtWidget(APopupParent.Handle).Widget);
PopupParent := nil;
QtMainWindow.setPopupParent(AForm.PopupMode, PopupParent);
end; end;
{$IFDEF HASX11} {$IFDEF HASX11}
@ -329,18 +327,18 @@ begin
TQtWidget(AForm.Handle).setWindowIcon(nil); TQtWidget(AForm.Handle).setWindowIcon(nil);
end; end;
class procedure TQtWSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TQtWSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
var var
PopupParent: QWidgetH; PopupParent: QWidgetH;
begin begin
if not ACustomForm.HandleAllocated or (csDestroying in ACustomForm.ComponentState) then if not ACustomForm.HandleAllocated or (csDestroying in ACustomForm.ComponentState) then
exit; exit;
if Assigned(APopupParent) and APopupParent.HandleAllocated then if Assigned(APopupParent) then
PopupParent := TQtWidget(APopupParent.Handle).Widget PopupParent := TQtWidget(APopupParent.Handle).Widget
else else
PopupParent := nil; PopupParent := nil;
TQtMainWindow(ACustomForm.Handle).setPopupParent(APopupMode, PopupParent); TQtMainWindow(ACustomForm.Handle).setRealPopupParent(PopupParent);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -382,8 +380,7 @@ var
Widget: TQtMainWindow; Widget: TQtMainWindow;
R: TRect; R: TRect;
{$IFDEF HASX11} {$IFDEF HASX11}
ActiveWin: HWND; APopupParent: TCustomForm;
W: QWidgetH;
{$ENDIF} {$ENDIF}
Flags: Cardinal; Flags: Cardinal;
@ -444,23 +441,9 @@ begin
(QtWidgetSet.WindowManagerName = 'xfwm4') or (QtWidgetSet.WindowManagerName = 'xfwm4') or
(QtWidgetSet.WindowManagerName = 'metacity') then (QtWidgetSet.WindowManagerName = 'metacity') then
begin begin
W := nil; APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
ActiveWin := GetActiveWindow; if APopupParent <> nil then
if ActiveWin <> 0 then QWidget_setParent(Widget.Widget, TQtWidget(APopupParent.Handle).Widget);
begin
if Assigned(TQtWidget(ActiveWin).LCLObject) then
begin
if (TQtWidget(ActiveWin).LCLObject is TCustomForm) then
begin
with TCustomForm(TQtWidget(ActiveWin).LCLObject) do
begin
if Visible and (FormStyle <> fsSplash) then
W := TQtWidget(Handle).Widget;
end;
end;
end;
end;
QWidget_setParent(Widget.Widget, W);
end else end else
QWidget_setParent(Widget.Widget, QApplication_desktop()); QWidget_setParent(Widget.Widget, QApplication_desktop());
{$endif} {$endif}
@ -524,7 +507,7 @@ begin
not (fsModal in TForm(AWinControl).FormState) and not (fsModal in TForm(AWinControl).FormState) and
(TForm(AWinControl).FormStyle <> fsMDIChild) and (TForm(AWinControl).FormStyle <> fsMDIChild) and
(QApplication_activeModalWidget() <> nil) then (QApplication_activeModalWidget() <> nil) then
TQtMainWindow(Widget).setPopupParent(pmExplicit, TQtMainWindow(Widget).setRealPopupParent(
QApplication_activeModalWidget()); QApplication_activeModalWidget());
end else end else
begin begin
@ -542,19 +525,15 @@ begin
if AWinControl.HandleObjectShouldBeVisible and if AWinControl.HandleObjectShouldBeVisible and
not (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop) and not (TCustomForm(AWinControl).FormStyle in fsAllStayOnTop) and
not (fsModal in TCustomForm(AWinControl).FormState) and not (fsModal in TCustomForm(AWinControl).FormState) and
(TCustomForm(AWinControl).FormStyle <> fsMDIChild) and (TCustomForm(AWinControl).FormStyle <> fsMDIChild) then
(((TCustomForm(AWinControl).PopupMode = pmAuto) and
(QApplication_activeWindow <> nil)) or
((TCustomForm(AWinControl).PopupMode = pmExplicit) and
(TCustomForm(AWinControl).PopupParent <> nil))) then
begin begin
if (TCustomForm(AWinControl).PopupMode = pmAuto) then APopupParent := TCustomForm(AWinControl).GetRealPopupParent;
W := QApplication_activeWindow if (APopupParent <> nil) then
else begin
W := TQtWidget(TCustomForm(AWinControl).PopupParent.Handle).Widget; Flags := Widget.windowFlags;
Flags := Widget.windowFlags; Widget.setParent(TQtWidget(APopupParent.Handle).Widget);
Widget.setParent(W); Widget.setWindowFlags(Flags or QtTool);
Widget.setWindowFlags(Flags or QtTool); end;
end; end;
{$ENDIF} {$ENDIF}
end; end;

View File

@ -78,8 +78,8 @@ type
class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override; class procedure SetFormStyle(const AForm: TCustomform; const AFormStyle, AOldFormStyle: TFormStyle); override;
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override; class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
class procedure ShowModal(const ACustomForm: TCustomForm); override; class procedure ShowModal(const ACustomForm: TCustomForm); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override; const APopupParent: TCustomForm); override;
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); override;
class procedure ShowHide(const AWinControl: TWinControl); override; class procedure ShowHide(const AWinControl: TWinControl); override;
end; end;
@ -637,8 +637,8 @@ begin
RDW_INVALIDATE or RDW_FRAME or RDW_NOCHILDREN or RDW_ERASE); RDW_INVALIDATE or RDW_FRAME or RDW_NOCHILDREN or RDW_ERASE);
end; end;
class procedure TWin32WSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TWin32WSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
begin begin
// changing parent is not possible without handle recreation // changing parent is not possible without handle recreation
RecreateWnd(ACustomForm); RecreateWnd(ACustomForm);

View File

@ -86,8 +86,8 @@ type
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); virtual; class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); virtual;
class procedure ShowModal(const ACustomForm: TCustomForm); virtual; class procedure ShowModal(const ACustomForm: TCustomForm); virtual;
class procedure SetModalResult(const ACustomForm: TCustomForm; ANewValue: TModalResult); virtual; class procedure SetModalResult(const ACustomForm: TCustomForm; ANewValue: TModalResult); virtual;
class procedure SetPopupParent(const ACustomForm: TCustomForm; class procedure SetRealPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); virtual; const APopupParent: TCustomForm); virtual;
class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); virtual; class procedure SetShowInTaskbar(const AForm: TCustomForm; const AValue: TShowInTaskbar); virtual;
class procedure SetZPosition(const AWinControl: TWinControl; const APosition: TWSZPosition); virtual; class procedure SetZPosition(const AWinControl: TWinControl; const APosition: TWSZPosition); virtual;
class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override; class function GetDefaultColor(const AControl: TControl; const ADefaultColorType: TDefaultColorType): TColor; override;
@ -199,8 +199,8 @@ class procedure TWSCustomForm.SetModalResult(const ACustomForm: TCustomForm;
begin begin
end; end;
class procedure TWSCustomForm.SetPopupParent(const ACustomForm: TCustomForm; class procedure TWSCustomForm.SetRealPopupParent(
const APopupMode: TPopupMode; const APopupParent: TCustomForm); const ACustomForm: TCustomForm; const APopupParent: TCustomForm);
begin begin
end; end;