From cfe715b953af5bbca9fcb3aa0d9d20fdfa8d6c20 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 22 Apr 2008 00:16:26 +0000 Subject: [PATCH] Adds minimum height for ProgressBar under win32. Fixes #10626 git-svn-id: trunk@14926 - --- lcl/interfaces/gtk/gtklclintf.inc | 17 ++++++++------- lcl/interfaces/win32/win32lclintf.inc | 30 +++++++++++++++++++++------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/lcl/interfaces/gtk/gtklclintf.inc b/lcl/interfaces/gtk/gtklclintf.inc index cc98c2866b..dc40417cd7 100644 --- a/lcl/interfaces/gtk/gtklclintf.inc +++ b/lcl/interfaces/gtk/gtklclintf.inc @@ -622,20 +622,21 @@ end; ------------------------------------------------------------------------------} function TGtkWidgetSet.GetControlConstraints(Constraints: TObject): boolean; var - SizeConstraints: TSizeConstraints; + SizeConstraints: TSizeConstraints absolute Constraints; Widget: PGtkWidget; MinWidth: Integer; MinHeight: Integer; MaxWidth: Integer; MaxHeight: Integer; begin - Result:=true; - if Constraints is TSizeConstraints then begin - MinWidth:=1; - MinHeight:=1; - MaxWidth:=0; - MaxHeight:=0; - SizeConstraints:=TSizeConstraints(Constraints); + Result := True; + + if Constraints is TSizeConstraints then + begin + MinWidth := 1; + MinHeight := 1; + MaxWidth := 0; + MaxHeight := 0; if (SizeConstraints.Control=nil) then exit; diff --git a/lcl/interfaces/win32/win32lclintf.inc b/lcl/interfaces/win32/win32lclintf.inc index 707fa9543d..cb7ca60375 100644 --- a/lcl/interfaces/win32/win32lclintf.inc +++ b/lcl/interfaces/win32/win32lclintf.inc @@ -338,35 +338,52 @@ end; ------------------------------------------------------------------------------} function TWin32WidgetSet.GetControlConstraints(Constraints: TObject): boolean; var - SizeConstraints: TSizeConstraints; + SizeConstraints: TSizeConstraints absolute Constraints; SizeRect: TRect; Height, Width: Integer; FixedHeight, FixedWidth: boolean; + MinWidth, MinHeight, MaxWidth, MaxHeight: Integer; begin - Result:=true; - if Constraints is TSizeConstraints then begin - SizeConstraints:=TSizeConstraints(Constraints); + Result := True; + if Constraints is TSizeConstraints then + begin if (SizeConstraints.Control=nil) then exit; FixedHeight := false; FixedWidth := false; + + MinWidth := 1; + MinHeight := 1; + MaxWidth := 0; + MaxHeight := 0; + if SizeConstraints.Control is TCustomCalendar then begin FixedHeight := true; FixedWidth := true; end - else - if SizeConstraints.Control is TCustomComboBox then + else if SizeConstraints.Control is TCustomComboBox then begin // win32 combo (but not csSimple) has fixed height FixedHeight := TCustomComboBox(SizeConstraints.Control).Style <> csSimple; + end + // The ProgressBar needs a minimum Height of 10 when themed, + // as required by Windows, otherwise it's image is corrupted + // For consistency, we add the constrain even when not themed. + else if SizeConstraints.Control is TCustomProgressBar then + begin + MinHeight := 10; + + SizeConstraints.SetInterfaceConstraints( + MinWidth, MinHeight, MaxWidth, MaxHeight); end; if (FixedHeight or FixedWidth) and TWinControl(SizeConstraints.Control).HandleAllocated then begin Windows.GetWindowRect(TWinControl(SizeConstraints.Control).Handle, @SizeRect); + if FixedHeight then Height := SizeRect.Bottom - SizeRect.Top else @@ -375,6 +392,7 @@ begin Width := SizeRect.Right - SizeRect.Left else Width := 0; + SizeConstraints.SetInterfaceConstraints(Width, Height, Width, Height); end; end;