mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 09:19:32 +02:00
gtk3: fixed setBounds() for forms with constraints.
git-svn-id: trunk@51768 -
This commit is contained in:
parent
fbc63768e7
commit
a6cd2fe67f
@ -37,7 +37,7 @@ uses
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
Graphics, Controls, Forms, LCLType, LCLProc,
|
||||
Classes, Graphics, Controls, Forms, LCLType, LCLProc,
|
||||
////////////////////////////////////////////////////
|
||||
WSLCLClasses, WSControls, Gtk3WSControls, WSFactory, WSForms, WSProc,
|
||||
LazGtk3, LazGdk3, LazGLib2, gtk3widgets, gtk3int, gtk3objects;
|
||||
@ -195,6 +195,10 @@ class procedure TGtk3WSCustomForm.SetBounds(const AWinControl: TWinControl;
|
||||
var
|
||||
AWidget: PGtkWidget;
|
||||
ARect: TGdkRectangle;
|
||||
Geometry: TGdkGeometry;
|
||||
AHints: TGdkWindowHints;
|
||||
AFixedWidthHeight: Boolean;
|
||||
AForm: TCustomForm;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'SetBounds') then
|
||||
Exit;
|
||||
@ -202,6 +206,7 @@ begin
|
||||
DebugLn('TGtk3WSCustomForm.SetBounds ',dbgsName(AWinControl),Format(' ALeft %d ATop %d AWidth %d AHeight %d',[ALeft, ATop, AWidth, AHeight]));
|
||||
{$ENDIF}
|
||||
AWidget := TGtk3Widget(AWinControl.Handle).Widget;
|
||||
AForm := TCustomForm(AWinControl);
|
||||
TGtk3Widget(AWinControl.Handle).BeginUpdate;
|
||||
ARect.x := ALeft;
|
||||
ARect.y := ATop;
|
||||
@ -209,6 +214,54 @@ begin
|
||||
ARect.Height := AHeight;
|
||||
try
|
||||
AWidget^.size_allocate(@ARect);
|
||||
if not (csDesigning in AForm.ComponentState) and (AForm.Parent = nil) and (AForm.ParentWindow = 0) then
|
||||
begin
|
||||
AFixedWidthHeight := AForm.BorderStyle in [bsDialog, bsSingle, bsToolWindow];
|
||||
with Geometry do
|
||||
begin
|
||||
if not AFixedWidthHeight and (AForm.Constraints.MinWidth > 0) then
|
||||
min_width := AForm.Constraints.MinWidth
|
||||
else
|
||||
min_width := AForm.Width;
|
||||
if not AFixedWidthHeight and (AForm.Constraints.MaxWidth > 0) then
|
||||
max_width := AForm.Constraints.MaxWidth
|
||||
else
|
||||
max_width := AForm.Width;
|
||||
if not AFixedWidthHeight and (AForm.Constraints.MinHeight > 0) then
|
||||
min_height := AForm.Constraints.MinHeight
|
||||
else
|
||||
min_height := AForm.Height;
|
||||
if not AFixedWidthHeight and (AForm.Constraints.MaxHeight > 0) then
|
||||
max_height := AForm.Constraints.MaxHeight
|
||||
else
|
||||
max_height := AForm.Height;
|
||||
|
||||
base_width := AForm.Width;
|
||||
base_height := AForm.Height;
|
||||
width_inc := 1;
|
||||
height_inc := 1;
|
||||
min_aspect := 0;
|
||||
max_aspect := 1;
|
||||
win_gravity := PGtkWindow(AWidget)^.get_gravity;
|
||||
end;
|
||||
|
||||
if AFixedWidthHeight then
|
||||
PGtkWindow(AWidget)^.set_geometry_hints(nil, @Geometry,
|
||||
GDK_HINT_POS or GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE)
|
||||
else
|
||||
begin
|
||||
if AForm.BorderStyle <> bsNone then
|
||||
begin
|
||||
AHints := GDK_HINT_POS or GDK_HINT_BASE_SIZE;
|
||||
if (AForm.Constraints.MinHeight > 0) or (AForm.Constraints.MinWidth > 0) then
|
||||
AHints := AHints or GDK_HINT_MIN_SIZE;
|
||||
if (AForm.Constraints.MaxHeight > 0) or (AForm.Constraints.MaxWidth > 0) then
|
||||
AHints := AHints or GDK_HINT_MAX_SIZE;
|
||||
|
||||
PGtkWindow(AWidget)^.set_geometry_hints(nil, @Geometry, AHints);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
PGtkWindow(AWidget)^.resize(AWidth, AHeight);
|
||||
PGtkWindow(AWidget)^.move(ALeft, ATop);
|
||||
finally
|
||||
|
Loading…
Reference in New Issue
Block a user