Adds minimum height for ProgressBar under win32. Fixes #10626

git-svn-id: trunk@14926 -
This commit is contained in:
sekelsenmat 2008-04-22 00:16:26 +00:00
parent 4e1373d30e
commit cfe715b953
2 changed files with 33 additions and 14 deletions

View File

@ -622,20 +622,21 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TGtkWidgetSet.GetControlConstraints(Constraints: TObject): boolean; function TGtkWidgetSet.GetControlConstraints(Constraints: TObject): boolean;
var var
SizeConstraints: TSizeConstraints; SizeConstraints: TSizeConstraints absolute Constraints;
Widget: PGtkWidget; Widget: PGtkWidget;
MinWidth: Integer; MinWidth: Integer;
MinHeight: Integer; MinHeight: Integer;
MaxWidth: Integer; MaxWidth: Integer;
MaxHeight: Integer; MaxHeight: Integer;
begin begin
Result:=true; Result := True;
if Constraints is TSizeConstraints then begin
MinWidth:=1; if Constraints is TSizeConstraints then
MinHeight:=1; begin
MaxWidth:=0; MinWidth := 1;
MaxHeight:=0; MinHeight := 1;
SizeConstraints:=TSizeConstraints(Constraints); MaxWidth := 0;
MaxHeight := 0;
if (SizeConstraints.Control=nil) then exit; if (SizeConstraints.Control=nil) then exit;

View File

@ -338,35 +338,52 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TWin32WidgetSet.GetControlConstraints(Constraints: TObject): boolean; function TWin32WidgetSet.GetControlConstraints(Constraints: TObject): boolean;
var var
SizeConstraints: TSizeConstraints; SizeConstraints: TSizeConstraints absolute Constraints;
SizeRect: TRect; SizeRect: TRect;
Height, Width: Integer; Height, Width: Integer;
FixedHeight, FixedWidth: boolean; FixedHeight, FixedWidth: boolean;
MinWidth, MinHeight, MaxWidth, MaxHeight: Integer;
begin begin
Result:=true; Result := True;
if Constraints is TSizeConstraints then begin
SizeConstraints:=TSizeConstraints(Constraints);
if Constraints is TSizeConstraints then
begin
if (SizeConstraints.Control=nil) then exit; if (SizeConstraints.Control=nil) then exit;
FixedHeight := false; FixedHeight := false;
FixedWidth := false; FixedWidth := false;
MinWidth := 1;
MinHeight := 1;
MaxWidth := 0;
MaxHeight := 0;
if SizeConstraints.Control is TCustomCalendar then if SizeConstraints.Control is TCustomCalendar then
begin begin
FixedHeight := true; FixedHeight := true;
FixedWidth := true; FixedWidth := true;
end end
else else if SizeConstraints.Control is TCustomComboBox then
if SizeConstraints.Control is TCustomComboBox then
begin begin
// win32 combo (but not csSimple) has fixed height // win32 combo (but not csSimple) has fixed height
FixedHeight := TCustomComboBox(SizeConstraints.Control).Style <> csSimple; 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; end;
if (FixedHeight or FixedWidth) if (FixedHeight or FixedWidth)
and TWinControl(SizeConstraints.Control).HandleAllocated then and TWinControl(SizeConstraints.Control).HandleAllocated then
begin begin
Windows.GetWindowRect(TWinControl(SizeConstraints.Control).Handle, @SizeRect); Windows.GetWindowRect(TWinControl(SizeConstraints.Control).Handle, @SizeRect);
if FixedHeight then if FixedHeight then
Height := SizeRect.Bottom - SizeRect.Top Height := SizeRect.Bottom - SizeRect.Top
else else
@ -375,6 +392,7 @@ begin
Width := SizeRect.Right - SizeRect.Left Width := SizeRect.Right - SizeRect.Left
else else
Width := 0; Width := 0;
SizeConstraints.SetInterfaceConstraints(Width, Height, Width, Height); SizeConstraints.SetInterfaceConstraints(Width, Height, Width, Height);
end; end;
end; end;