gtk: implement TCustomForm.PopupParent

git-svn-id: trunk@23739 -
This commit is contained in:
paul 2010-02-19 07:22:18 +00:00
parent 7d223ed75b
commit 6265a0532d
2 changed files with 50 additions and 1 deletions

View File

@ -85,6 +85,8 @@ type
class procedure SetBorderIcons(const AForm: TCustomForm;
const ABorderIcons: TBorderIcons); override;
class procedure SetColor(const AWinControl: TWinControl); override;
class procedure SetPopupParent(const ACustomForm: TCustomForm;
const APopupMode: TPopupMode; const APopupParent: TCustomForm); override;
end;
{ TGtkWSForm }
@ -282,6 +284,7 @@ var
WindowType: TGtkWindowType;
ACustomForm: TCustomForm;
AResizable: gint;
PopupParent: TCustomForm;
begin
// Start of old CreateForm method
@ -297,6 +300,15 @@ begin
else
ABorderStyle:=bsNone;
case ACustomForm.PopupMode of
pmNone:
PopupParent := nil;
pmAuto:
PopupParent := Screen.ActiveForm;
pmExplicit:
PopupParent := ACustomForm.PopupParent;
end;
// Maps the border style
WindowType := FormStyleMap[ABorderStyle];
if (ABorderStyle=bsNone) and (ACustomForm.FormStyle in fsAllStayOnTop) then
@ -324,6 +336,9 @@ begin
// Sets the title
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
if (ClipboardWidget = nil) then
GtkWidgetSet.SetClipboardWidget(P);
@ -454,6 +469,27 @@ begin
TGtkWSWinControl.SetColor(AWinControl);
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 }
class procedure TGtkWSHintWindow.SetCallbacks(const AWidget: PGtkWidget;

View File

@ -139,6 +139,7 @@ var
WindowType: TGtkWindowType;
ACustomForm: TCustomForm;
AResizable: gint;
PopupParent: TCustomForm;
begin
// Start of old CreateForm method
@ -154,9 +155,18 @@ begin
else
ABorderStyle:=bsNone;
case ACustomForm.PopupMode of
pmNone:
PopupParent := nil;
pmAuto:
PopupParent := Screen.ActiveForm;
pmExplicit:
PopupParent := ACustomForm.PopupParent;
end;
// Maps the border style
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;
if (csDesigning in ACustomForm.ComponentState) then
WindowType := GTK_WINDOW_TOPLEVEL;
@ -179,6 +189,9 @@ begin
// Sets the title
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
if (ClipboardWidget = nil) then
Gtk2WidgetSet.SetClipboardWidget(P);