mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 11:49:24 +02:00
gtk: implement TCustomForm.PopupParent
git-svn-id: trunk@23739 -
This commit is contained in:
parent
7d223ed75b
commit
6265a0532d
@ -85,6 +85,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;
|
||||||
|
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGtkWSForm }
|
{ TGtkWSForm }
|
||||||
@ -282,6 +284,7 @@ var
|
|||||||
WindowType: TGtkWindowType;
|
WindowType: TGtkWindowType;
|
||||||
ACustomForm: TCustomForm;
|
ACustomForm: TCustomForm;
|
||||||
AResizable: gint;
|
AResizable: gint;
|
||||||
|
PopupParent: TCustomForm;
|
||||||
begin
|
begin
|
||||||
// Start of old CreateForm method
|
// Start of old CreateForm method
|
||||||
|
|
||||||
@ -297,6 +300,15 @@ begin
|
|||||||
else
|
else
|
||||||
ABorderStyle:=bsNone;
|
ABorderStyle:=bsNone;
|
||||||
|
|
||||||
|
case ACustomForm.PopupMode of
|
||||||
|
pmNone:
|
||||||
|
PopupParent := nil;
|
||||||
|
pmAuto:
|
||||||
|
PopupParent := Screen.ActiveForm;
|
||||||
|
pmExplicit:
|
||||||
|
PopupParent := ACustomForm.PopupParent;
|
||||||
|
end;
|
||||||
|
|
||||||
// Maps the border style
|
// Maps the border style
|
||||||
WindowType := FormStyleMap[ABorderStyle];
|
WindowType := FormStyleMap[ABorderStyle];
|
||||||
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
||||||
@ -324,6 +336,9 @@ begin
|
|||||||
// Sets the title
|
// Sets the title
|
||||||
gtk_window_set_title(PGtkWindow(P), AParams.Caption);
|
gtk_window_set_title(PGtkWindow(P), AParams.Caption);
|
||||||
|
|
||||||
|
if PopupParent <> nil then
|
||||||
|
gtk_window_set_transient_for(PGtkWindow(P), PGtkWindow(PopupParent.Handle));
|
||||||
|
|
||||||
// the clipboard needs a widget
|
// the clipboard needs a widget
|
||||||
if (ClipboardWidget = nil) then
|
if (ClipboardWidget = nil) then
|
||||||
GtkWidgetSet.SetClipboardWidget(P);
|
GtkWidgetSet.SetClipboardWidget(P);
|
||||||
@ -454,6 +469,27 @@ begin
|
|||||||
TGtkWSWinControl.SetColor(AWinControl);
|
TGtkWSWinControl.SetColor(AWinControl);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TGtkWSCustomForm.SetPopupParent(const ACustomForm: TCustomForm;
|
||||||
|
const APopupMode: TPopupMode; const APopupParent: TCustomForm);
|
||||||
|
var
|
||||||
|
PopupParent: TCustomForm;
|
||||||
|
begin
|
||||||
|
if not WSCheckHandleAllocated(ACustomForm, 'SetPopupParent') then Exit;
|
||||||
|
|
||||||
|
case APopupMode of
|
||||||
|
pmNone:
|
||||||
|
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
|
||||||
|
gtk_window_set_transient_for(PGtkWindow(ACustomForm.Handle), nil);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TGtkWSHintWindow }
|
{ TGtkWSHintWindow }
|
||||||
|
|
||||||
class procedure TGtkWSHintWindow.SetCallbacks(const AWidget: PGtkWidget;
|
class procedure TGtkWSHintWindow.SetCallbacks(const AWidget: PGtkWidget;
|
||||||
|
@ -139,6 +139,7 @@ var
|
|||||||
WindowType: TGtkWindowType;
|
WindowType: TGtkWindowType;
|
||||||
ACustomForm: TCustomForm;
|
ACustomForm: TCustomForm;
|
||||||
AResizable: gint;
|
AResizable: gint;
|
||||||
|
PopupParent: TCustomForm;
|
||||||
begin
|
begin
|
||||||
// Start of old CreateForm method
|
// Start of old CreateForm method
|
||||||
|
|
||||||
@ -154,9 +155,18 @@ begin
|
|||||||
else
|
else
|
||||||
ABorderStyle:=bsNone;
|
ABorderStyle:=bsNone;
|
||||||
|
|
||||||
|
case ACustomForm.PopupMode of
|
||||||
|
pmNone:
|
||||||
|
PopupParent := nil;
|
||||||
|
pmAuto:
|
||||||
|
PopupParent := Screen.ActiveForm;
|
||||||
|
pmExplicit:
|
||||||
|
PopupParent := ACustomForm.PopupParent;
|
||||||
|
end;
|
||||||
|
|
||||||
// Maps the border style
|
// Maps the border style
|
||||||
WindowType := FormStyleMap[ABorderStyle];
|
WindowType := FormStyleMap[ABorderStyle];
|
||||||
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
if (ABorderStyle = bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
|
||||||
WindowType := GTK_WINDOW_POPUP;
|
WindowType := GTK_WINDOW_POPUP;
|
||||||
if (csDesigning in ACustomForm.ComponentState) then
|
if (csDesigning in ACustomForm.ComponentState) then
|
||||||
WindowType := GTK_WINDOW_TOPLEVEL;
|
WindowType := GTK_WINDOW_TOPLEVEL;
|
||||||
@ -179,6 +189,9 @@ begin
|
|||||||
// Sets the title
|
// Sets the title
|
||||||
gtk_window_set_title(PGtkWindow(P), AParams.Caption);
|
gtk_window_set_title(PGtkWindow(P), AParams.Caption);
|
||||||
|
|
||||||
|
if PopupParent <> nil then
|
||||||
|
gtk_window_set_transient_for(PGtkWindow(P), PGtkWindow(PopupParent.Handle));
|
||||||
|
|
||||||
// the clipboard needs a widget
|
// the clipboard needs a widget
|
||||||
if (ClipboardWidget = nil) then
|
if (ClipboardWidget = nil) then
|
||||||
Gtk2WidgetSet.SetClipboardWidget(P);
|
Gtk2WidgetSet.SetClipboardWidget(P);
|
||||||
|
Loading…
Reference in New Issue
Block a user