Gtk2: implemented TGtk2WSCustomForm.SetFormBorderStyle so it does not recreate handle for nothing also fixes #16407

git-svn-id: trunk@25369 -
This commit is contained in:
zeljko 2010-05-13 15:07:11 +00:00
parent ed7ddf13b4
commit c4a4395865
2 changed files with 36 additions and 0 deletions

View File

@ -479,6 +479,7 @@ type
PaintDepth: integer; // increased/decreased by Begin/EndPaint
DataOwner: Boolean; // Set if the UserData should be freed when the info is freed
UserData: Pointer;
FormBorderStyle: Integer; // used only for forms
end;
//TODO: remove

View File

@ -77,6 +77,8 @@ type
class procedure SetIcon(const AForm: TCustomForm; const Small, Big: HICON); override;
class procedure SetAlphaBlend(const ACustomForm: TCustomForm;
const AlphaBlend: Boolean; const Alpha: Byte); override;
class procedure SetFormBorderStyle(const AForm: TCustomForm;
const AFormBorderStyle: TFormBorderStyle); override;
{ class function GetDefaultClientRect(const AWinControl: TWinControl;
const aLeft, aTop, aWidth, aHeight: integer; var aClientRect: TRect
): boolean; override;
@ -205,6 +207,7 @@ begin
end;
WidgetInfo := CreateWidgetInfo(P, AWinControl, AParams);
WidgetInfo^.FormBorderStyle := Ord(ABorderStyle);
Box := CreateFormContents(ACustomForm, P, WidgetInfo);
gtk_container_add(PGtkContainer(P), Box);
@ -269,6 +272,38 @@ begin
gtk_window_set_opacity(PGtkWindow(ACustomForm.Handle), 1);
end;
class procedure TGtk2WSCustomForm.SetFormBorderStyle(const AForm: TCustomForm;
const AFormBorderStyle: TFormBorderStyle);
var
Widget: PGtkWidget;
WidgetInfo: PWidgetInfo;
// WindowType: TGtkWindowType;
Resizable: gint;
begin
if not WSCheckHandleAllocated(AForm, 'SetFormBorderStyle') then
exit;
if (csDesigning in AForm.ComponentState) then
exit;
Widget := PGtkWidget(AForm.Handle);
WidgetInfo := GetWidgetInfo(Widget);
if (WidgetInfo^.FormBorderStyle <> Ord(AFormBorderStyle)) then
begin
if (AForm.Parent <> nil) or (AFormBorderStyle <> bsNone) then
RecreateWnd(AForm)
else
begin
// TODO: set window hint WindowType := FormStyleMap[AFormBorderStyle];
Resizable := FormResizableMap[AFormBorderStyle];
if (AFormBorderStyle = bsNone) then
gtk_window_set_decorated(PGtkWindow(Widget), False);
gtk_window_set_resizable(GTK_WINDOW(Widget), gboolean(Resizable));
WidgetInfo^.FormBorderStyle := Ord(AFormBorderStyle);
end;
end;
end;
{class function TGtk2WSCustomForm.GetDefaultClientRect(
const AWinControl: TWinControl; const aLeft, aTop, aWidth, aHeight: integer;
var aClientRect: TRect): boolean;