mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 06:38:06 +02:00
Merged revision(s) 51767 #fbc63768e7 from trunk:
gtk2: fixed reizing form with constraints applied. issue #29563 ........ git-svn-id: branches/fixes_1_6@52051 -
This commit is contained in:
parent
108a18848a
commit
44cd0e201d
@ -663,6 +663,8 @@ class procedure TGtk2WSWinControl.SetBounds(const AWinControl: TWinControl;
|
||||
var
|
||||
AForm: TCustomForm;
|
||||
Geometry: TGdkGeometry;
|
||||
AHints: TGdkWindowHints;
|
||||
AFixedWidthHeight: Boolean;
|
||||
begin
|
||||
if not WSCheckHandleAllocated(AWinControl, 'SetBounds')
|
||||
then Exit;
|
||||
@ -679,13 +681,27 @@ begin
|
||||
AForm.HandleObjectShouldBeVisible then
|
||||
begin
|
||||
// we must set fixed size, gtk_window_set_resizable does not work
|
||||
// as expected for some reason.issue #20741
|
||||
// as expected for some reason.issue #20741.
|
||||
// Constraints fix issue #29563
|
||||
AFixedWidthHeight := AForm.BorderStyle in [bsDialog, bsSingle, bsToolWindow];
|
||||
with Geometry do
|
||||
begin
|
||||
min_width := AForm.Width;
|
||||
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;
|
||||
min_height := AForm.Height;
|
||||
max_height := AForm.Height;
|
||||
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;
|
||||
@ -696,14 +712,22 @@ begin
|
||||
win_gravity := gtk_window_get_gravity({%H-}PGtkWindow(AForm.Handle));
|
||||
end;
|
||||
//debugln('TGtk2WSWinControl.ConstraintsChange A ',GetWidgetDebugReport(Widget),' max=',dbgs(Geometry.max_width),'x',dbgs(Geometry.max_height));
|
||||
if (AForm.BorderStyle in [bsDialog, bsSingle, bsToolWindow]) then
|
||||
if AFixedWidthHeight then
|
||||
gtk_window_set_geometry_hints({%H-}PGtkWindow(AForm.Handle), 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;
|
||||
|
||||
gtk_window_set_geometry_hints({%H-}PGtkWindow(AForm.Handle), nil, @Geometry,
|
||||
GDK_HINT_POS or GDK_HINT_BASE_SIZE);
|
||||
AHints);
|
||||
end;
|
||||
gtk_window_resize({%H-}PGtkWindow(AForm.Handle), AForm.Width, AForm.Height);
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user