mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 11:00:37 +02:00
LCL: Horizontal and Vertical Spacing for TCoolBar. Issue #27523, patch from Vojtech Cihak
git-svn-id: trunk@47982 -
This commit is contained in:
parent
e89f096e51
commit
f130692a93
@ -2331,8 +2331,6 @@ type
|
||||
cDefWidth = 180;
|
||||
cDivider: SmallInt = 2;
|
||||
cGrabIndent: SmallInt = 2;
|
||||
cHorSpacing = 5;
|
||||
cVertSpacing = 3;
|
||||
protected
|
||||
FControlLeft: Integer;
|
||||
FControlTop: Integer;
|
||||
@ -2405,11 +2403,13 @@ type
|
||||
FFixedOrder: Boolean;
|
||||
FGrabStyle: TGrabStyle;
|
||||
FGrabWidth: Integer;
|
||||
FHorizontalSpacing: Integer;
|
||||
FImages: TCustomImageList;
|
||||
FImageChangeLink: TChangeLink;
|
||||
FOnChange: TNotifyEvent;
|
||||
FShowText: Boolean;
|
||||
FVertical: Boolean;
|
||||
FOnChange: TNotifyEvent;
|
||||
FVerticalSpacing: Integer;
|
||||
function GetAlign: TAlign;
|
||||
function RowEndHelper(ALeft, AVisibleIdx: Integer): Boolean;
|
||||
procedure SetBandBorderStyle(AValue: TBorderStyle);
|
||||
@ -2417,12 +2417,16 @@ type
|
||||
procedure SetBitmap(AValue: TBitmap);
|
||||
procedure SetGrabStyle(AValue: TGrabStyle);
|
||||
procedure SetGrabWidth(AValue: Integer);
|
||||
procedure SetHorizontalSpacing(AValue: Integer);
|
||||
procedure SetImages(AValue: TCustomImageList);
|
||||
procedure SetShowText(AValue: Boolean);
|
||||
procedure SetVertical(AValue: Boolean);
|
||||
procedure SetVerticalSpacing(AValue: Integer);
|
||||
protected const
|
||||
cDefGrabStyle = gsDouble;
|
||||
cDefGrabWidth = 10;
|
||||
cDefHorSpacing = 5;
|
||||
cDefVertSpacing = 3;
|
||||
cNewRowBelow: SmallInt = -1;
|
||||
cNewRowAbove: SmallInt = -2;
|
||||
protected
|
||||
@ -2479,9 +2483,11 @@ type
|
||||
property FixedOrder: Boolean read FFixedOrder write FFixedOrder default False;
|
||||
property GrabStyle: TGrabStyle read FGrabStyle write SetGrabStyle default cDefGrabStyle;
|
||||
property GrabWidth: Integer read FGrabWidth write SetGrabWidth default cDefGrabWidth;
|
||||
property HorizontalSpacing: Integer read FHorizontalSpacing write SetHorizontalSpacing default cDefHorSpacing;
|
||||
property Images: TCustomImageList read FImages write SetImages;
|
||||
property ShowText: Boolean read FShowText write SetShowText default True;
|
||||
property Vertical: Boolean read FVertical write SetVertical default False;
|
||||
property VerticalSpacing: Integer read FVerticalSpacing write SetVerticalSpacing default cDefVertSpacing;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
end;
|
||||
|
||||
@ -2512,6 +2518,7 @@ type
|
||||
property Font;
|
||||
property GrabStyle;
|
||||
property GrabWidth;
|
||||
property HorizontalSpacing;
|
||||
property Images;
|
||||
property ParentColor;
|
||||
property ParentFont;
|
||||
@ -2521,6 +2528,7 @@ type
|
||||
property ShowHint;
|
||||
property ShowText;
|
||||
property Vertical;
|
||||
property VerticalSpacing;
|
||||
property Visible;
|
||||
property OnChange;
|
||||
property OnClick;
|
||||
|
@ -74,7 +74,7 @@ begin
|
||||
if Assigned(FControl) and FControl.AutoSize then begin
|
||||
FControl.GetPreferredSize(w, h);
|
||||
if FCoolBar.Vertical then w := h;
|
||||
inc(w, CalcControlLeft+cHorSpacing+cDivider);
|
||||
inc(w, CalcControlLeft+FCoolBar.HorizontalSpacing+cDivider);
|
||||
Width := Math.max(FMinWidth, w);
|
||||
end;
|
||||
end;
|
||||
@ -82,19 +82,19 @@ end;
|
||||
function TCoolBand.CalcControlLeft: Integer;
|
||||
var aImageSize, xHelp: Integer;
|
||||
begin
|
||||
Result := cGrabIndent+FCoolBar.GrabWidth+cHorSpacing;
|
||||
Result := cGrabIndent+FCoolBar.GrabWidth+FCoolBar.HorizontalSpacing;
|
||||
xHelp := Result;
|
||||
if (Text <> '') and FCoolBar.ShowText then
|
||||
inc(Result, FTextWidth+cHorSpacing);
|
||||
inc(Result, FTextWidth+FCoolBar.HorizontalSpacing);
|
||||
if Assigned(FCoolBar.Images) then begin
|
||||
if not FCoolBar.Vertical then
|
||||
aImageSize := FCoolBar.Images.Width
|
||||
else
|
||||
aImageSize := FCoolBar.Images.Height;
|
||||
if ImageIndex >= 0 then
|
||||
inc(Result, aImageSize+cHorSpacing);
|
||||
inc(Result, aImageSize+FCoolBar.HorizontalSpacing);
|
||||
end;
|
||||
if Result = xHelp then inc(Result, cHorSpacing);
|
||||
if Result = xHelp then inc(Result, FCoolBar.HorizontalSpacing);
|
||||
end;
|
||||
|
||||
function TCoolBand.CalcPreferredHeight: Integer;
|
||||
@ -102,24 +102,24 @@ begin
|
||||
Result := FMinHeight;
|
||||
if not FCoolBar.Vertical then begin
|
||||
if Assigned(FControl) then
|
||||
Result := max(Result, FControl.Height+2*cVertSpacing);
|
||||
Result := max(Result, FControl.Height+2*FCoolBar.VerticalSpacing);
|
||||
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
||||
Result := max(Result, FCoolBar.Images.Height+2*cVertSpacing);
|
||||
Result := max(Result, FCoolBar.Images.Height+2*FCoolBar.VerticalSpacing);
|
||||
end else begin
|
||||
if Assigned(FControl) then
|
||||
Result := max(Result, FControl.Width+2*cVertSpacing);
|
||||
Result := max(Result, FControl.Width+2*FCoolBar.VerticalSpacing);
|
||||
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
||||
Result := max(Result, FCoolBar.Images.Width+2*cVertSpacing);
|
||||
Result := max(Result, FCoolBar.Images.Width+2*FCoolBar.VerticalSpacing);
|
||||
end;
|
||||
if FCoolBar.FShowText then
|
||||
Result := max(Result, FCoolBar.FTextHeight+2*cVertSpacing);
|
||||
Result := max(Result, FCoolBar.FTextHeight+2*FCoolBar.VerticalSpacing);
|
||||
//DebugLn('CalcPreferredHeight ', CalcPreferredHeightHor);
|
||||
end;
|
||||
|
||||
function TCoolBand.CalcPreferredWidth: Integer;
|
||||
begin
|
||||
Result := CalcControlLeft;
|
||||
if Assigned(Control) then inc(Result, Control.Width+cHorSpacing);
|
||||
if Assigned(Control) then inc(Result, Control.Width+FCoolBar.HorizontalSpacing);
|
||||
inc(Result, cDivider);
|
||||
Result := max(FMinWidth, Result);
|
||||
end;
|
||||
@ -357,9 +357,11 @@ begin
|
||||
FBorderWidth := 2;
|
||||
FGrabStyle := cDefGrabStyle;
|
||||
FGrabWidth := cDefGrabWidth;
|
||||
FHorizontalSpacing := cDefHorSpacing;
|
||||
FImageChangeLink := TChangeLink.Create;
|
||||
FImageChangeLink.OnChange := @BitmapOrImageListChange;
|
||||
FShowText := True;
|
||||
FVerticalSpacing := cDefVertSpacing;
|
||||
end;
|
||||
|
||||
destructor TCustomCoolBar.Destroy;
|
||||
@ -430,6 +432,14 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomCoolBar.SetHorizontalSpacing(AValue: Integer);
|
||||
begin
|
||||
if FHorizontalSpacing=AValue then Exit;
|
||||
FHorizontalSpacing:=AValue;
|
||||
CalculateAndAlign;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomCoolBar.SetImages(AValue: TCustomImageList);
|
||||
begin
|
||||
if Assigned(FImages) then
|
||||
@ -461,6 +471,14 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomCoolBar.SetVerticalSpacing(AValue: Integer);
|
||||
begin
|
||||
if FVerticalSpacing=AValue then Exit;
|
||||
FVerticalSpacing:=AValue;
|
||||
CalculateAndAlign;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TCustomCoolBar.AlignControls(AControl: TControl; var RemainingClientRect: TRect);
|
||||
var aAnchor: TAnchorKind;
|
||||
i: Integer;
|
||||
@ -478,11 +496,9 @@ begin
|
||||
Bands[i].FControl.Anchors := [akTop, aAnchor];
|
||||
if not Vertical then begin
|
||||
Bands[i].FControl.AnchorParallel(aAnchor, Bands[i].FControlLeft, Self);
|
||||
//if Bands[i].FControl.Top <> (Bands[i].FControlTop+FBorderTop) then
|
||||
Bands[i].FControl.AnchorParallel(akTop, Bands[i].FControlTop, Self);
|
||||
end else begin
|
||||
Bands[i].FControl.AnchorParallel(akTop, Bands[i].FControlLeft, Self);
|
||||
//if Bands[i].FControl.Left <> (Bands[i].FControlTop+FBorderLeft) then
|
||||
Bands[i].FControl.AnchorParallel(aAnchor, Bands[i].FControlTop, Self);
|
||||
end;
|
||||
end;
|
||||
@ -576,7 +592,7 @@ begin
|
||||
FVisiBands[i].FTop := Width-aTop-FVisiBands[i].Height;
|
||||
if Assigned(FVisiBands[i].Control) then begin
|
||||
x := FVisiBands[i].CalcControlLeft;
|
||||
aWidth := FVisiBands[i].Width-x-TCoolBand.cHorSpacing-TCoolBand.cDivider;
|
||||
aWidth := FVisiBands[i].Width-x-HorizontalSpacing-TCoolBand.cDivider;
|
||||
if not FRightToLeft then begin
|
||||
inc(x, aLeft);
|
||||
if not Vertical then
|
||||
@ -586,7 +602,7 @@ begin
|
||||
FVisiBands[i].FControlLeft := x-aBorderLeft;
|
||||
end else begin
|
||||
if not Vertical then begin
|
||||
x := FVisiBands[i].FLeft+TCoolBand.cDivider+TCoolBand.cHorSpacing;
|
||||
x := FVisiBands[i].FLeft+TCoolBand.cDivider+HorizontalSpacing;
|
||||
FVisiBands[i].Control.Left := x;
|
||||
FVisiBands[i].FControlLeft := Width-x-Bands[i].FControl.Width-aBorderLeft;
|
||||
end else begin
|
||||
@ -1195,9 +1211,9 @@ begin
|
||||
else
|
||||
PaintGrabber(Rect(aTop+2, x, aTop+FVisiBands[i].FHeight-3, x+GrabWidth-1));
|
||||
if not FRightToLeft or Vertical then
|
||||
x := x+GrabWidth+TCoolBand.cHorSpacing
|
||||
x := x+GrabWidth+HorizontalSpacing
|
||||
else
|
||||
x := x-TCoolBand.cHorSpacing;
|
||||
x := x-HorizontalSpacing;
|
||||
//paint Image
|
||||
if Assigned(FImages) and (FVisiBands[i].ImageIndex >= 0) then begin
|
||||
if FRightToLeft and not Vertical then dec(x, FImages.Width);
|
||||
@ -1210,9 +1226,9 @@ begin
|
||||
Point(aTop+(FVisiBands[i].FHeight-FImages.Width) div 2, x),
|
||||
FImages, FVisiBands[i].ImageIndex);
|
||||
if not FRightToLeft or Vertical then
|
||||
inc(x, FImages.Width+TCoolBand.cHorSpacing)
|
||||
inc(x, FImages.Width+HorizontalSpacing)
|
||||
else
|
||||
dec(x, TCoolBand.cHorSpacing);
|
||||
dec(x, HorizontalSpacing);
|
||||
end;
|
||||
//paint Text
|
||||
if FShowText then begin
|
||||
|
Loading…
Reference in New Issue
Block a user