mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-22 21:46:24 +02:00
LCL: TCoolbar- proper vertical mode. Issue #27168, patch from Vojtech Cihak.
git-svn-id: trunk@47204 -
This commit is contained in:
parent
01cb0be6e0
commit
11b7a200a1
@ -2407,6 +2407,8 @@ type
|
|||||||
protected const
|
protected const
|
||||||
cDefGrabStyle = gsDouble;
|
cDefGrabStyle = gsDouble;
|
||||||
cDefGrabWidth = 10;
|
cDefGrabWidth = 10;
|
||||||
|
cNewRowBelow: SmallInt = -1;
|
||||||
|
cNewRowAbove: SmallInt = -2;
|
||||||
protected
|
protected
|
||||||
FBorderEdges: TEdgeBorders;
|
FBorderEdges: TEdgeBorders;
|
||||||
FBorderLeft, FBorderTop, FBorderRight, FBorderBottom: SmallInt;
|
FBorderLeft, FBorderTop, FBorderRight, FBorderBottom: SmallInt;
|
||||||
|
@ -73,33 +73,47 @@ var h, w: Integer;
|
|||||||
begin
|
begin
|
||||||
if Assigned(FControl) and FControl.AutoSize then begin
|
if Assigned(FControl) and FControl.AutoSize then begin
|
||||||
FControl.GetPreferredSize(w, h);
|
FControl.GetPreferredSize(w, h);
|
||||||
|
if FCoolBar.Vertical then w := h;
|
||||||
inc(w, CalcControlLeft+cHorSpacing+cDivider);
|
inc(w, CalcControlLeft+cHorSpacing+cDivider);
|
||||||
Width := Math.max(FMinWidth, w);
|
Width := Math.max(FMinWidth, w);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCoolBand.CalcControlLeft: Integer;
|
function TCoolBand.CalcControlLeft: Integer;
|
||||||
var xHelp: Integer;
|
var aImageSize, xHelp: Integer;
|
||||||
begin
|
begin
|
||||||
Result := cGrabIndent+FCoolBar.GrabWidth+cHorSpacing;
|
Result := cGrabIndent+FCoolBar.GrabWidth+cHorSpacing;
|
||||||
xHelp := Result;
|
xHelp := Result;
|
||||||
if (Text <> '') and FCoolBar.ShowText then
|
if (Text <> '') and FCoolBar.ShowText then
|
||||||
inc(Result, FCoolBar.Canvas.TextWidth(Text)+cHorSpacing);
|
inc(Result, FTextWidth+cHorSpacing);
|
||||||
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
if Assigned(FCoolBar.Images) then begin
|
||||||
inc(Result, FCoolBar.Images.Width+cHorSpacing);
|
if not FCoolBar.Vertical then
|
||||||
|
aImageSize := FCoolBar.Images.Width
|
||||||
|
else
|
||||||
|
aImageSize := FCoolBar.Images.Height;
|
||||||
|
if ImageIndex >= 0 then
|
||||||
|
inc(Result, aImageSize+cHorSpacing);
|
||||||
|
end;
|
||||||
if Result = xHelp then inc(Result, cHorSpacing);
|
if Result = xHelp then inc(Result, cHorSpacing);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCoolBand.CalcPreferredHeight: Integer;
|
function TCoolBand.CalcPreferredHeight: Integer;
|
||||||
begin
|
begin
|
||||||
Result := FMinHeight;
|
Result := FMinHeight;
|
||||||
if Assigned(FControl) then
|
if not FCoolBar.Vertical then begin
|
||||||
Result := max(Result, FControl.Height+2*cVertSpacing);
|
if Assigned(FControl) then
|
||||||
|
Result := max(Result, FControl.Height+2*cVertSpacing);
|
||||||
|
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
||||||
|
Result := max(Result, FCoolBar.Images.Height+2*cVertSpacing);
|
||||||
|
end else begin
|
||||||
|
if Assigned(FControl) then
|
||||||
|
Result := max(Result, FControl.Width+2*cVertSpacing);
|
||||||
|
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
||||||
|
Result := max(Result, FCoolBar.Images.Width+2*cVertSpacing);
|
||||||
|
end;
|
||||||
if FCoolBar.FShowText then
|
if FCoolBar.FShowText then
|
||||||
Result := max(Result, FCoolBar.FTextHeight+2*cVertSpacing);
|
Result := max(Result, FCoolBar.FTextHeight+2*cVertSpacing);
|
||||||
if Assigned(FCoolBar.Images) and (ImageIndex >= 0) then
|
//DebugLn('CalcPreferredHeight ', CalcPreferredHeightHor);
|
||||||
Result := max(Result, FCoolBar.Images.Height+2*cVertSpacing);
|
|
||||||
//DebugLn('CalcPreferredHeight ', CalcPreferredHeight);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCoolBand.CalcPreferredWidth: Integer;
|
function TCoolBand.CalcPreferredWidth: Integer;
|
||||||
@ -112,7 +126,8 @@ end;
|
|||||||
|
|
||||||
procedure TCoolBand.CalcTextWidth;
|
procedure TCoolBand.CalcTextWidth;
|
||||||
begin
|
begin
|
||||||
FTextWidth := FCoolBar.Canvas.TextWidth(FText);
|
if Assigned(FCoolBar) and not (csLoading in FCoolBar.ComponentState) then
|
||||||
|
FTextWidth := FCoolBar.Canvas.TextWidth(FText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCoolBand.GetDisplayName: string;
|
function TCoolBand.GetDisplayName: string;
|
||||||
@ -374,6 +389,7 @@ procedure TCustomCoolBar.SetAutoSize(Value: Boolean);
|
|||||||
begin
|
begin
|
||||||
inherited SetAutoSize(Value);
|
inherited SetAutoSize(Value);
|
||||||
if Value then CalculateAndAlign;
|
if Value then CalculateAndAlign;
|
||||||
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.SetBandBorderStyle(AValue: TBorderStyle);
|
procedure TCustomCoolBar.SetBandBorderStyle(AValue: TBorderStyle);
|
||||||
@ -436,31 +452,39 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.SetVertical(AValue: Boolean);
|
procedure TCustomCoolBar.SetVertical(AValue: Boolean);
|
||||||
|
var aRect: TRect;
|
||||||
begin
|
begin
|
||||||
if FVertical = aValue then Exit;
|
if FVertical = aValue then Exit;
|
||||||
FVertical := AValue;
|
FVertical := AValue;
|
||||||
|
AdjustSize;
|
||||||
|
CalculateAndAlign;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.AlignControls(AControl: TControl; var RemainingClientRect: TRect);
|
procedure TCustomCoolBar.AlignControls(AControl: TControl; var RemainingClientRect: TRect);
|
||||||
var i: Integer;
|
var aAnchor: TAnchorKind;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if wcfAligningControls in FWinControlFlags then exit;
|
|
||||||
//DebugLn('AlignControls');
|
//DebugLn('AlignControls');
|
||||||
for i:=0 to Bands.Count-1 do
|
if wcfAligningControls in FWinControlFlags then Exit;
|
||||||
|
if not FRightToLeft then
|
||||||
|
aAnchor := akLeft
|
||||||
|
else
|
||||||
|
aAnchor := akRight;
|
||||||
|
for i := 0 to Bands.Count-1 do
|
||||||
if Assigned(Bands[i].FControl) then begin
|
if Assigned(Bands[i].FControl) then begin
|
||||||
Bands[i].FControl.Align:=alNone;
|
Bands[i].Control.Align := alNone;
|
||||||
Bands[i].FControl.BorderSpacing.Around:=0;
|
Bands[i].FControl.BorderSpacing.Around := 0;
|
||||||
if not FRightToLeft then begin
|
Bands[i].FControl.Anchors := [akTop, aAnchor];
|
||||||
Bands[i].FControl.Anchors:=[akTop, akLeft];
|
if not Vertical then begin
|
||||||
Bands[i].FControl.AnchorParallel(akLeft, Bands[i].FControlLeft, Self);
|
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
|
end else begin
|
||||||
Bands[i].FControl.Anchors:=[akTop, akRight];
|
Bands[i].FControl.AnchorParallel(akTop, Bands[i].FControlLeft, Self);
|
||||||
Bands[i].FControl.AnchorParallel(akRight,
|
//if Bands[i].FControl.Left <> (Bands[i].FControlTop+FBorderLeft) then
|
||||||
Width-Bands[i].FControlLeft-Bands[i].FControl.Width-FBorderLeft-FBorderRight, Self);
|
Bands[i].FControl.AnchorParallel(aAnchor, Bands[i].FControlTop, Self);
|
||||||
end;
|
end;
|
||||||
if Bands[i].FControl.Top <> (Bands[i].FControlTop+FBorderTop) then
|
|
||||||
Bands[i].FControl.AnchorParallel(akTop, Bands[i].FControlTop, Self);
|
|
||||||
end;
|
end;
|
||||||
inherited AlignControls(AControl, RemainingClientRect);
|
inherited AlignControls(AControl, RemainingClientRect);
|
||||||
end;
|
end;
|
||||||
@ -480,11 +504,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.CalculateAndAlign;
|
procedure TCustomCoolBar.CalculateAndAlign;
|
||||||
var i, x, y, aBorder, aCountM1, aHeight, aLeft, aStartIndex, aTop, aWidth: Integer;
|
var i, x, y, aBandHeight, aBorderLeft, aCountM1, aLeft,
|
||||||
|
aPrefSize, aStartIndex, aTop, aWidth: Integer;
|
||||||
aRowEnd: Boolean;
|
aRowEnd: Boolean;
|
||||||
begin
|
begin
|
||||||
if (FUpdateCount > 0) or ([csLoading, csDestroying] * ComponentState <> []) then exit;
|
|
||||||
//DebugLn('CalculateAndAlign');
|
//DebugLn('CalculateAndAlign');
|
||||||
|
if (FUpdateCount > 0) or ([csLoading, csDestroying] * ComponentState <> []) then Exit;
|
||||||
aCountM1 := FBands.Count-1;
|
aCountM1 := FBands.Count-1;
|
||||||
x := 0;
|
x := 0;
|
||||||
for i := 0 to aCountM1 do
|
for i := 0 to aCountM1 do
|
||||||
@ -497,14 +522,109 @@ begin
|
|||||||
inc(x);
|
inc(x);
|
||||||
end;
|
end;
|
||||||
aCountM1 := x-1;
|
aCountM1 := x-1;
|
||||||
if not FRightToLeft then
|
if not Vertical then begin
|
||||||
aBorder := FBorderLeft
|
if not FRightToLeft then
|
||||||
else
|
aBorderLeft := FBorderLeft
|
||||||
aBorder := FBorderRight;
|
else
|
||||||
|
aBorderLeft := FBorderRight;
|
||||||
|
aPrefSize := FBorderTop+FBorderBottom;
|
||||||
|
end else begin
|
||||||
|
aBorderLeft := FBorderTop;
|
||||||
|
aPrefSize := FBorderLeft+FBorderRight-TCoolBand.cDivider;
|
||||||
|
end;
|
||||||
//do not use FBands from this point, only FVisiBands
|
//do not use FBands from this point, only FVisiBands
|
||||||
aHeight := 0;
|
aBandHeight := 0;
|
||||||
aStartIndex := 0;
|
aStartIndex := 0;
|
||||||
|
//set all Bands in row to uniform height
|
||||||
aRowEnd := True;
|
aRowEnd := True;
|
||||||
|
for i := 0 to aCountM1 do begin
|
||||||
|
if aRowEnd or FVisiBands[i].Break then aLeft := aBorderLeft;
|
||||||
|
aBandHeight := Max(aBandHeight, FVisiBands[i].CalcPreferredHeight);
|
||||||
|
aRowEnd := (i = aCountM1);
|
||||||
|
inc(aLeft, FVisiBands[i].Width);
|
||||||
|
aRowEnd := aRowEnd or ((i < aCountM1) and RowEndHelper(ALeft, i));
|
||||||
|
if aRowEnd then begin
|
||||||
|
inc(aPrefSize, aBandHeight+TCoolBand.cDivider);
|
||||||
|
for y := aStartIndex to i do
|
||||||
|
FVisiBands[y].FHeight := aBandHeight;
|
||||||
|
aBandHeight := 0;
|
||||||
|
aStartIndex := i+1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if not Vertical then
|
||||||
|
aTop := FBorderTop
|
||||||
|
else begin
|
||||||
|
if not FRightToLeft then
|
||||||
|
aTop := FBorderLeft
|
||||||
|
else begin
|
||||||
|
aTop := FBorderRight;
|
||||||
|
if not AutoSize then aPrefSize := Width;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
aRowEnd := True;
|
||||||
|
include(FWinControlFlags, wcfAligningControls);
|
||||||
|
for i := 0 to aCountM1 do begin
|
||||||
|
if aRowEnd or FVisiBands[i].Break then aLeft := aBorderLeft;
|
||||||
|
if not FRightToLeft or Vertical then
|
||||||
|
FVisiBands[i].FLeft := aLeft
|
||||||
|
else
|
||||||
|
FVisiBands[i].FLeft := Width-aLeft-FVisiBands[i].Width;
|
||||||
|
FVisiBands[i].FRealLeft := FVisiBands[i].FLeft;
|
||||||
|
if not Vertical or not FRightToLeft then
|
||||||
|
FVisiBands[i].FTop := aTop
|
||||||
|
else
|
||||||
|
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;
|
||||||
|
if not FRightToLeft then begin
|
||||||
|
inc(x, aLeft);
|
||||||
|
if not Vertical then
|
||||||
|
FVisiBands[i].Control.Left := x
|
||||||
|
else
|
||||||
|
FVisiBands[i].Control.Top := x;
|
||||||
|
FVisiBands[i].FControlLeft := x-aBorderLeft;
|
||||||
|
end else begin
|
||||||
|
if not Vertical then begin
|
||||||
|
x := FVisiBands[i].FLeft+TCoolBand.cDivider+TCoolBand.cHorSpacing;
|
||||||
|
FVisiBands[i].Control.Left := x;
|
||||||
|
FVisiBands[i].FControlLeft := Width-x-Bands[i].FControl.Width-aBorderLeft;
|
||||||
|
end else begin
|
||||||
|
inc(x, aLeft);
|
||||||
|
FVisiBands[i].Control.Top := x;
|
||||||
|
FVisiBands[i].FControlLeft := x-aBorderLeft;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if not Vertical then begin
|
||||||
|
y := aTop+(FVisiBands[i].FHeight-FVisiBands[i].Control.Height) div 2;
|
||||||
|
FVisiBands[i].FControlTop := y-FBorderTop;
|
||||||
|
FVisiBands[i].Control.Top := FVisiBands[i].FControlTop+FBorderTop;
|
||||||
|
FVisiBands[i].Control.Width := aWidth;
|
||||||
|
end else begin
|
||||||
|
y := aTop+(FVisiBands[i].FHeight-FVisiBands[i].Control.Width) div 2;
|
||||||
|
if not FRightToLeft then begin
|
||||||
|
FVisiBands[i].Control.Left := y;
|
||||||
|
FVisiBands[i].FControlTop := y-FBorderLeft;
|
||||||
|
end else begin
|
||||||
|
FVisiBands[i].Control.Left := aPrefSize-y-FVisiBands[i].Control.Width;
|
||||||
|
FVisiBands[i].FControlTop := y-FBorderRight;
|
||||||
|
end;
|
||||||
|
FVisiBands[i].Control.Height := aWidth;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
x := FVisiBands[i].Width;
|
||||||
|
inc(aLeft, x);
|
||||||
|
aRowEnd := IsRowEnd(aLeft, i);
|
||||||
|
if aRowEnd or (i = aCountM1) then begin
|
||||||
|
if not Vertical then begin
|
||||||
|
FVisiBands[i].FRealWidth := x+Width-aLeft-FBorderRight;
|
||||||
|
if FRightToLeft then FVisiBands[i].FRealLeft := FBorderLeft;
|
||||||
|
end else
|
||||||
|
FVisiBands[i].FRealWidth := x+Height-aLeft-FBorderBottom;
|
||||||
|
end else
|
||||||
|
FVisiBands[i].FRealWidth := x;
|
||||||
|
if aRowEnd then inc(aTop, FVisiBands[i].FHeight+TCoolBand.cDivider);
|
||||||
|
end;
|
||||||
if AutoSize then begin
|
if AutoSize then begin
|
||||||
if aCountM1 >= 0 then DisableAutoSizing;
|
if aCountM1 >= 0 then DisableAutoSizing;
|
||||||
inc(FUpdateCount);
|
inc(FUpdateCount);
|
||||||
@ -513,79 +633,33 @@ begin
|
|||||||
if aCountM1 >= 0 then EnableAutoSizing;
|
if aCountM1 >= 0 then EnableAutoSizing;
|
||||||
dec(FUpdateCount);
|
dec(FUpdateCount);
|
||||||
end;
|
end;
|
||||||
for i := 0 to aCountM1 do begin
|
|
||||||
if (FVisiBands[i].Break or Vertical) or aRowEnd then aLeft := aBorder;
|
|
||||||
aHeight := Max(aHeight, FVisiBands[i].CalcPreferredHeight);
|
|
||||||
aRowEnd := (i = aCountM1);
|
|
||||||
inc(aLeft, FVisiBands[i].Width);
|
|
||||||
aRowEnd := aRowEnd or ((i < aCountM1) and RowEndHelper(ALeft, i));
|
|
||||||
//set all Bands in row to uniform height
|
|
||||||
if aRowEnd then begin
|
|
||||||
for y := aStartIndex to i do
|
|
||||||
FVisiBands[y].FHeight := aHeight;
|
|
||||||
aHeight := 0;
|
|
||||||
aStartIndex := i+1;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
aTop := FBorderTop;
|
|
||||||
aRowEnd := True;
|
|
||||||
include(FWinControlFlags, wcfAligningControls);
|
|
||||||
for i := 0 to aCountM1 do begin
|
|
||||||
if aRowEnd or (FVisiBands[i].Break or Vertical) then aLeft := aBorder;
|
|
||||||
if not FRightToLeft then
|
|
||||||
FVisiBands[i].FLeft := aLeft
|
|
||||||
else
|
|
||||||
FVisiBands[i].FLeft := Width-aLeft-FVisiBands[i].Width;
|
|
||||||
FVisiBands[i].FRealLeft := FVisiBands[i].FLeft;
|
|
||||||
FVisiBands[i].FTop := aTop;
|
|
||||||
if Assigned(FVisiBands[i].Control) then begin
|
|
||||||
x := FVisiBands[i].CalcControlLeft;
|
|
||||||
aWidth := FVisiBands[i].Width-x-TCoolBand.cHorSpacing-TCoolBand.cDivider;
|
|
||||||
y := aTop+(FVisiBands[i].FHeight-FVisiBands[i].Control.Height) div 2;
|
|
||||||
if not FRightToLeft then begin
|
|
||||||
inc(x, aLeft);
|
|
||||||
FVisiBands[i].Control.Left := x;
|
|
||||||
FVisiBands[i].FControlLeft := x-aBorder;
|
|
||||||
end else begin
|
|
||||||
x := FVisiBands[i].FLeft+TCoolBand.cDivider+TCoolBand.cHorSpacing;
|
|
||||||
FVisiBands[i].Control.Left := x;
|
|
||||||
FVisiBands[i].FControlLeft := x-FBorderLeft;
|
|
||||||
end;
|
|
||||||
FVisiBands[i].FControlTop := y-FBorderTop;
|
|
||||||
FVisiBands[i].Control.Top := FVisiBands[i].FControlTop+FBorderTop;
|
|
||||||
FVisiBands[i].Control.Width := aWidth;
|
|
||||||
end;
|
|
||||||
x := FVisiBands[i].Width;
|
|
||||||
inc(aLeft, x);
|
|
||||||
aRowEnd := IsRowEnd(aLeft, i);
|
|
||||||
if aRowEnd or (i = aCountM1) then begin
|
|
||||||
FVisiBands[i].FRealWidth := x+Width-aLeft-FBorderRight;
|
|
||||||
if FRightToLeft then FVisiBands[i].FRealLeft := FBorderLeft;
|
|
||||||
end else
|
|
||||||
FVisiBands[i].FRealWidth := x;
|
|
||||||
if aRowEnd then
|
|
||||||
inc(aTop, FVisiBands[i].FHeight+TCoolBand.cDivider);
|
|
||||||
end;
|
|
||||||
exclude(FWinControlFlags, wcfAligningControls);
|
exclude(FWinControlFlags, wcfAligningControls);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.CalculatePreferredSize(var PreferredWidth, PreferredHeight: Integer;
|
procedure TCustomCoolBar.CalculatePreferredSize(var PreferredWidth,
|
||||||
WithThemeSpace: Boolean);
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
var i, aCountM1, aPrefWidth: Integer;
|
var i, x, aCountM1: Integer;
|
||||||
begin
|
begin
|
||||||
aCountM1 := length(FVisiBands)-1;
|
aCountM1 := length(FVisiBands)-1;
|
||||||
if aCountM1 >= 0 then
|
if not Vertical then begin
|
||||||
PreferredHeight := FVisiBands[aCountM1].FTop+FVisiBands[aCountM1].FHeight+FBorderBottom
|
if aCountM1 >= 0 then
|
||||||
else
|
PreferredHeight := FVisiBands[aCountM1].FTop+FVisiBands[aCountM1].FHeight+FBorderBottom
|
||||||
PreferredHeight := TCoolBand.cDefMinHeight+FBorderTop+FBorderBottom;
|
else
|
||||||
if not FVertical then
|
PreferredHeight := FBorderTop+TCoolBand.cDefMinHeight+FBorderBottom;
|
||||||
PreferredWidth := 0
|
PreferredWidth := 0
|
||||||
else begin
|
end else begin
|
||||||
aPrefWidth := TCoolBand.cDefMinHeight; //min. Width is ~ 25 pixels
|
PreferredHeight := 0;
|
||||||
for i := 0 to aCountM1 do
|
if aCountM1 >= 0 then begin
|
||||||
aPrefWidth := max(aPrefWidth, FVisiBands[i].Width);
|
if not FRightToLeft then
|
||||||
inc(aPrefWidth, FBorderLeft+FBorderRight);
|
PreferredWidth := FVisiBands[aCountM1].FTop+FVisiBands[aCountM1].FHeight+FBorderRight
|
||||||
PreferredWidth := aPrefWidth;
|
else begin
|
||||||
|
PreferredWidth := FBorderLeft+FVisiBands[0].FTop+FVisiBands[0].FHeight-FVisiBands[aCountM1].FTop+FBorderRight;
|
||||||
|
x := FVisiBands[aCountM1].FTop-FBorderLeft;
|
||||||
|
for i := 0 to aCountM1 do
|
||||||
|
FVisiBands[i].FTop := FVisiBands[i].FTop-x;
|
||||||
|
end;
|
||||||
|
end else
|
||||||
|
PreferredWidth := FBorderLeft+TCoolBand.cDefMinHeight+FBorderRight;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -611,7 +685,10 @@ begin
|
|||||||
if not AGrabber then
|
if not AGrabber then
|
||||||
Cursor := crDrag
|
Cursor := crDrag
|
||||||
else
|
else
|
||||||
Cursor := crHSplit;
|
if not Vertical then
|
||||||
|
Cursor := crHSplit
|
||||||
|
else
|
||||||
|
Cursor := crVSplit;
|
||||||
end else
|
end else
|
||||||
Cursor := FCursorBkgnd;
|
Cursor := FCursorBkgnd;
|
||||||
FLockCursor := False;
|
FLockCursor := False;
|
||||||
@ -727,10 +804,13 @@ end;
|
|||||||
|
|
||||||
function TCustomCoolBar.IsFirstAtRow(ABand: Integer): Boolean;
|
function TCustomCoolBar.IsFirstAtRow(ABand: Integer): Boolean;
|
||||||
begin
|
begin
|
||||||
if not FRightToLeft then
|
if not Vertical then begin
|
||||||
Result := (FVisiBands[ABand].FLeft = FBorderLeft)
|
if not FRightToLeft then
|
||||||
else
|
Result := (FVisiBands[ABand].FLeft = FBorderLeft)
|
||||||
Result := (FVisiBands[ABand].Right = Width-FBorderRight);
|
else
|
||||||
|
Result := (FVisiBands[ABand].Right = Width-FBorderRight);
|
||||||
|
end else
|
||||||
|
Result := (FVisiBands[ABand].FLeft = FBorderTop);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCoolBar.IsRowEnd(ALeft, AVisibleIndex: Integer): Boolean;
|
function TCustomCoolBar.IsRowEnd(ALeft, AVisibleIndex: Integer): Boolean;
|
||||||
@ -752,17 +832,20 @@ begin
|
|||||||
inherited MouseDown(Button, Shift, X, Y);
|
inherited MouseDown(Button, Shift, X, Y);
|
||||||
MouseToBandPos(X, Y, aBand, aGrabber);
|
MouseToBandPos(X, Y, aBand, aGrabber);
|
||||||
FDraggedBandIndex := aBand;
|
FDraggedBandIndex := aBand;
|
||||||
if aBand >= 0 then begin //hit any Band
|
if (aBand >= 0) and (length(FVisiBands) > 1) then begin //hit any Band
|
||||||
if not aGrabber or IsFirstAtRow(aBand)
|
if not aGrabber or IsFirstAtRow(aBand)
|
||||||
or FFixedSize or FVisiBands[aBand-1].FFixedSize then begin
|
or FFixedSize or FVisiBands[aBand-1].FFixedSize then begin
|
||||||
if not FFixedOrder then FDragBand := dbMove; //move Band
|
if not FFixedOrder then FDragBand := dbMove; //move Band
|
||||||
end else begin //resize Band
|
end else begin //resize Band
|
||||||
if not FFixedSize and not FVisiBands[aBand-1].FFixedSize then begin
|
if not FFixedSize and not FVisiBands[aBand-1].FFixedSize then begin
|
||||||
FDragBand := dbResize;
|
FDragBand := dbResize;
|
||||||
if not FRightToLeft then
|
if not Vertical then begin
|
||||||
FDragInitPos := X-FVisiBands[aBand-1].FWidth-FVisiBands[aBand-1].FLeft
|
if not FRightToLeft then
|
||||||
else
|
FDragInitPos := X-FVisiBands[aBand-1].FWidth-FVisiBands[aBand-1].FLeft
|
||||||
FDragInitPos := FVisiBands[aBand-1].FLeft-X;
|
else
|
||||||
|
FDragInitPos := FVisiBands[aBand-1].FLeft-X;
|
||||||
|
end else
|
||||||
|
FDragInitPos := Y-FVisiBands[aBand-1].FWidth-FVisiBands[aBand-1].FLeft;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -787,10 +870,16 @@ begin
|
|||||||
ChangeCursor(False, False);
|
ChangeCursor(False, False);
|
||||||
end;
|
end;
|
||||||
dbResize: begin
|
dbResize: begin
|
||||||
if not FRightToLeft then
|
if not Vertical then begin
|
||||||
FVisiBands[FDraggedBandIndex-1].Width := X-FDragInitPos-FVisiBands[FDraggedBandIndex-1].FLeft
|
if not FRightToLeft then
|
||||||
else
|
FVisiBands[FDraggedBandIndex-1].Width :=
|
||||||
FVisiBands[FDraggedBandIndex-1].Width := -X-FDragInitPos+FVisiBands[FDraggedBandIndex-1].FLeft+FVisiBands[FDraggedBandIndex-1].FWidth;
|
X-FDragInitPos-FVisiBands[FDraggedBandIndex-1].FLeft
|
||||||
|
else
|
||||||
|
FVisiBands[FDraggedBandIndex-1].Width :=
|
||||||
|
-X-FDragInitPos+FVisiBands[FDraggedBandIndex-1].Right;
|
||||||
|
end else
|
||||||
|
FVisiBands[FDraggedBandIndex-1].Width :=
|
||||||
|
Y-FDragInitPos-FVisiBands[FDraggedBandIndex-1].FLeft
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -802,23 +891,37 @@ begin
|
|||||||
ABand := low(Integer);
|
ABand := low(Integer);
|
||||||
AGrabber := False;
|
AGrabber := False;
|
||||||
aCountM1 := length(FVisiBands)-1;
|
aCountM1 := length(FVisiBands)-1;
|
||||||
|
if Vertical then begin
|
||||||
|
i := Y;
|
||||||
|
Y := X;
|
||||||
|
X := i;
|
||||||
|
end;
|
||||||
if aCountM1 >= 0 then begin
|
if aCountM1 >= 0 then begin
|
||||||
if Y > (FVisiBands[aCountM1].Top+FVisiBands[aCountM1].Height+TCoolBand.cDivider) then
|
if not Vertical or not FRightToLeft then begin
|
||||||
ABand := -1 //new row, i.e. free space below the last row
|
if Y > (FVisiBands[aCountM1].Top+FVisiBands[aCountM1].Height+TCoolBand.cDivider) then
|
||||||
else
|
ABand := cNewRowBelow //new row, i.e. free space below the last row
|
||||||
|
else
|
||||||
|
if Y < 0 then ABand := cNewRowAbove; //new row, i.e. free space above the first row
|
||||||
|
end else begin
|
||||||
|
if Y < (FVisiBands[aCountM1].Top) then
|
||||||
|
ABand := cNewRowBelow //new row, i.e. free space below the last row
|
||||||
|
else
|
||||||
|
if Y > Width then ABand := cNewRowAbove; //new row, i.e. free space space above the first row
|
||||||
|
end;
|
||||||
|
if ABand = low(Integer) then
|
||||||
for i := 0 to aCountM1 do begin
|
for i := 0 to aCountM1 do begin
|
||||||
aLeft := FVisiBands[i].FRealLeft;
|
aLeft := FVisiBands[i].FRealLeft;
|
||||||
aTop := FVisiBands[i].FTop;
|
aTop := FVisiBands[i].FTop;
|
||||||
if PtInRect(Rect(aLeft, aTop, aLeft+FVisiBands[i].FRealWidth,
|
if PtInRect(Rect(aLeft, aTop, aLeft+FVisiBands[i].FRealWidth,
|
||||||
aTop+FVisiBands[i].FHeight), Point(X, Y)) then begin
|
aTop+FVisiBands[i].FHeight), Point(X, Y)) then begin
|
||||||
ABand := i;
|
ABand := i;
|
||||||
//DebugLn('Mouse over Band ', i);
|
//DebugLn('Mouse over Band ', i);
|
||||||
if not FRightToLeft then
|
if not FRightToLeft or Vertical then
|
||||||
AGrabber := (X <= (aLeft+GrabWidth+1))
|
AGrabber := (X <= (aLeft+GrabWidth+1))
|
||||||
else
|
else
|
||||||
AGrabber := (X >= (FVisiBands[i].FLeft+FVisiBands[i].Width-GrabWidth-1));
|
AGrabber := (X >= (FVisiBands[i].FLeft+FVisiBands[i].Width-GrabWidth-1));
|
||||||
//DebugLn('Grabber '+BoolToStr(AGrabber), ' hit', ' not hit');
|
//DebugLn('Grabber '+BoolToStr(AGrabber), ' hit', ' not hit');
|
||||||
exit; //Exit!
|
Exit; //Exit!
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -826,75 +929,67 @@ end;
|
|||||||
|
|
||||||
procedure TCustomCoolBar.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TCustomCoolBar.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
var aBand: Integer;
|
var aBand: Integer;
|
||||||
newRow, needRecalc: Boolean;
|
newRowBelow, needRecalc: Boolean;
|
||||||
begin
|
begin
|
||||||
inherited MouseUp(Button, Shift, X, Y);
|
inherited MouseUp(Button, Shift, X, Y);
|
||||||
if FDragBand = dbMove then begin
|
if FDragBand = dbMove then begin
|
||||||
needRecalc := False;
|
needRecalc := False;
|
||||||
MouseToBandPos(X, Y, aBand, newRow); //newRow is NOT used here
|
MouseToBandPos(X, Y, aBand, newRowBelow); //newRowBelow is NOT used here
|
||||||
if aBand >= -1 then begin
|
if aBand >= cNewRowAbove then begin
|
||||||
newRow := (aBand = -1);
|
if aBand = cNewRowAbove then begin
|
||||||
if newRow then aBand := length(FVisiBands)-1;
|
if FDraggedBandIndex = 0 then begin
|
||||||
if aBand <> FDraggedBandIndex then begin //move to new position
|
if FVisiBands[0].FTop = FVisiBands[1].FTop then begin
|
||||||
if (FVisiBands[FDraggedBandIndex].Break or Vertical)
|
FVisiBands[1].FBreak := True;
|
||||||
and (FDraggedBandIndex < (length(FVisiBands)-1))
|
needRecalc := True;
|
||||||
then FVisiBands[FDraggedBandIndex+1].FBreak := True;
|
end;
|
||||||
if (not FRightToLeft and (X > (FVisiBands[aBand].FLeft+FVisiBands[aBand].Width)))
|
end else begin
|
||||||
or (FRightToLeft and (X < FVisiBands[aBand].FLeft)) then begin //beyond the last band in row
|
FVisiBands[1].FBreak := True;
|
||||||
FVisiBands[FDraggedBandIndex].FBreak := False;
|
FVisiBands[FDraggedBandIndex].Index := 0;
|
||||||
if FDraggedBandIndex > aBand then
|
end;
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand+1)
|
end else begin
|
||||||
else
|
newRowBelow := (aBand = cNewRowBelow);
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
if newRowBelow then aBand := length(FVisiBands)-1;
|
||||||
needRecalc := (FDraggedBandIndex = (aBand+1));
|
if Vertical then X := Y;
|
||||||
end else begin //on another Band
|
if aBand <> FDraggedBandIndex then begin //move to new position
|
||||||
FVisiBands[FDraggedBandIndex].FBreak := FVisiBands[aBand].Break;
|
if FVisiBands[FDraggedBandIndex].FBreak and (FDraggedBandIndex < (length(FVisiBands)-1))
|
||||||
if FDraggedBandIndex > aBand then begin //move up or left
|
then FVisiBands[FDraggedBandIndex+1].FBreak := True;
|
||||||
FVisiBands[aBand].FBreak := False;
|
if not newRowBelow and (((not FRightToLeft or Vertical)
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
and (X > (FVisiBands[aBand].FLeft+FVisiBands[aBand].Width)))
|
||||||
end else begin //move down or right
|
or ((FRightToLeft and not Vertical)
|
||||||
if not newRow then begin
|
and (X < FVisiBands[aBand].FLeft))) then begin //beyond the last band in row
|
||||||
if (FVisiBands[FDraggedBandIndex].FTop = FVisiBands[aBand].FTop) then begin //the same row
|
FVisiBands[FDraggedBandIndex].FBreak := False;
|
||||||
FVisiBands[FDraggedBandIndex].FBreak := False;
|
if FDraggedBandIndex > aBand then
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand+1)
|
||||||
end else begin //other row
|
else
|
||||||
if not FRightToLeft then begin
|
|
||||||
if (not FVertical) and (FVisiBands[FDraggedBandIndex].Left > FBorderLeft) then
|
|
||||||
FVisiBands[aBand].FBreak := False;
|
|
||||||
if (FVisiBands[FDraggedBandIndex].FLeft = FBorderLeft)
|
|
||||||
and (FVisiBands[aBand].FLeft = FBorderLeft)
|
|
||||||
and (FVertical or ((aBand-FDraggedBandIndex) = 1)
|
|
||||||
or (length(FVisiBands) = (aBand+1))
|
|
||||||
or (FVisiBands[aBand+1].FLeft = FBorderLeft)) then
|
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand)
|
|
||||||
else
|
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand-1);
|
|
||||||
end else begin
|
|
||||||
if (not FVertical) and
|
|
||||||
(FVisiBands[FDraggedBandIndex].Right < (Width-FBorderRight)) then
|
|
||||||
FVisiBands[aBand].FBreak := False;
|
|
||||||
if (FVisiBands[FDraggedBandIndex].Right = (Width-FBorderRight))
|
|
||||||
and (FVisiBands[aBand].Right = (Width-FBorderRight))
|
|
||||||
and (FVertical or ((aBand-FDraggedBandIndex) = 1)
|
|
||||||
or (length(FVisiBands) = (aBand+1))
|
|
||||||
or (FVisiBands[aBand+1].FLeft = FBorderLeft)) then
|
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand)
|
|
||||||
else
|
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand-1);
|
|
||||||
end;
|
|
||||||
needRecalc := (FDraggedBandIndex = (aBand-1));
|
|
||||||
end;
|
|
||||||
end else begin //new row
|
|
||||||
FVisiBands[FDraggedBandIndex].FBreak := True;
|
|
||||||
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
||||||
|
needRecalc := (FDraggedBandIndex = (aBand+1));
|
||||||
|
end else begin //on another Band
|
||||||
|
FVisiBands[FDraggedBandIndex].FBreak := FVisiBands[aBand].Break;
|
||||||
|
if FDraggedBandIndex > aBand then begin //move up or left
|
||||||
|
FVisiBands[aBand].FBreak := False;
|
||||||
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
||||||
|
end else begin //move down or right
|
||||||
|
if not newRowBelow then begin
|
||||||
|
if (FVisiBands[FDraggedBandIndex].FTop = FVisiBands[aBand].FTop) then begin //the same row
|
||||||
|
FVisiBands[FDraggedBandIndex].FBreak := False;
|
||||||
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
||||||
|
end else begin //other row
|
||||||
|
FVisiBands[aBand].FBreak := False;
|
||||||
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand-1);
|
||||||
|
needRecalc := (FDraggedBandIndex = (aBand-1));
|
||||||
|
end;
|
||||||
|
end else begin //new row
|
||||||
|
FVisiBands[FDraggedBandIndex].FBreak := True;
|
||||||
|
FVisiBands[FDraggedBandIndex].Index := CalculateRealIndex(aBand);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end else
|
||||||
end else
|
if newRowBelow then begin //last Band in last row moved to new row
|
||||||
if newRow then begin //last Band in last row moved to new row
|
FVisiBands[aBand].FBreak := True;
|
||||||
FVisiBands[aBand].FBreak := True;
|
needRecalc:= True;
|
||||||
needRecalc:= True;
|
end;
|
||||||
end;
|
end;
|
||||||
if needRecalc then begin //necessary only when no Index is changed
|
if needRecalc then begin //necessary only when no Index is changed
|
||||||
CalculateAndAlign;
|
CalculateAndAlign;
|
||||||
Invalidate;
|
Invalidate;
|
||||||
@ -915,19 +1010,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.Paint;
|
procedure TCustomCoolBar.Paint;
|
||||||
var i, x, aCountM1, aLeft, aTop: Integer;
|
var i: Integer;
|
||||||
aRowEnd, aRaisedBevel: Boolean;
|
aGrabDetails: TThemedElementDetails;
|
||||||
aColor: TColor;
|
aGrabStyle: TGrabStyle;
|
||||||
aDetails, aGrabDetails: TThemedElementDetails;
|
aRaisedBevel: Boolean;
|
||||||
aFlags: Cardinal;
|
|
||||||
aRect: TRect;
|
aRect: TRect;
|
||||||
|
|
||||||
const arBevel: array[False..True] of TColor = (clBtnShadow, clBtnHighlight);
|
const arBevel: array[False..True] of TColor = (clBtnShadow, clBtnHighlight);
|
||||||
|
|
||||||
|
function GetCaptionColorDisabled: TColor;
|
||||||
|
var r1, g1, b1: Byte;
|
||||||
|
aColor: TColor;
|
||||||
|
begin
|
||||||
|
aColor := Font.Color;
|
||||||
|
if aColor = clDefault then aColor := clBtnText;
|
||||||
|
GetRGBValues(ColorToRGB(aColor), r1, g1, b1);
|
||||||
|
i := r1 div 3 + g1 div 3 + b1 div 3;
|
||||||
|
GetRGBValues(ColorToRGB(Brush.Color), r1, g1, b1);
|
||||||
|
i := (i+(r1 div 3 + g1 div 3 + b1 div 3)) div 2;
|
||||||
|
Result := RGBToColor(i, i, i);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure PaintGrabber(aRect: TRect);
|
procedure PaintGrabber(aRect: TRect);
|
||||||
var l, w: SmallInt;
|
var l, w: SmallInt;
|
||||||
begin
|
begin
|
||||||
case FGrabStyle of
|
case aGrabStyle of
|
||||||
gsSimple: begin
|
gsSimple: begin
|
||||||
Canvas.Pen.Color := clBtnHighlight;
|
Canvas.Pen.Color := clBtnHighlight;
|
||||||
Canvas.Line(aRect.Left, aRect.Top, aRect.Right, aRect.Top);
|
Canvas.Line(aRect.Left, aRect.Top, aRect.Right, aRect.Top);
|
||||||
@ -939,15 +1045,29 @@ const arBevel: array[False..True] of TColor = (clBtnShadow, clBtnHighlight);
|
|||||||
gsDouble: begin
|
gsDouble: begin
|
||||||
w := (FGrabWidth-2) div 2;
|
w := (FGrabWidth-2) div 2;
|
||||||
Canvas.Pen.Color := clBtnHighlight;
|
Canvas.Pen.Color := clBtnHighlight;
|
||||||
Canvas.Line(aRect.Left, aRect.Top, aRect.Left+w, aRect.Top);
|
if not Vertical then begin
|
||||||
Canvas.Line(aRect.Left, aRect.Top, aRect.Left, aRect.Bottom+1);
|
Canvas.Line(aRect.Left, aRect.Top, aRect.Left+w, aRect.Top);
|
||||||
Canvas.Line(aRect.Right-w, aRect.Top, aRect.Right, aRect.Top);
|
Canvas.Line(aRect.Left, aRect.Top, aRect.Left, aRect.Bottom+1);
|
||||||
Canvas.Line(aRect.Right-w, aRect.Top, aRect.Right-w, aRect.Bottom+1);
|
Canvas.Line(aRect.Right-w, aRect.Top, aRect.Right, aRect.Top);
|
||||||
|
Canvas.Line(aRect.Right-w, aRect.Top, aRect.Right-w, aRect.Bottom+1);
|
||||||
|
end else begin
|
||||||
|
Canvas.Line(aRect.Left, aRect.Top, aRect.Left, aRect.Top+w);
|
||||||
|
Canvas.Line(aRect.Left, aRect.Top, aRect.Right+1, aRect.Top);
|
||||||
|
Canvas.Line(aRect.Left, aRect.Bottom-w, aRect.Right, aRect.Bottom-w);
|
||||||
|
Canvas.Line(aRect.Left, aRect.Bottom-w, aRect.Left, aRect.Bottom+1);
|
||||||
|
end;
|
||||||
Canvas.Pen.Color := clBtnShadow;
|
Canvas.Pen.Color := clBtnShadow;
|
||||||
Canvas.Line(aRect.Left, aRect.Bottom, aRect.Left+w, aRect.Bottom);
|
if not Vertical then begin
|
||||||
Canvas.Line(aRect.Left+w, aRect.Top, aRect.Left+w, aRect.Bottom+1);
|
Canvas.Line(aRect.Left, aRect.Bottom, aRect.Left+w, aRect.Bottom);
|
||||||
Canvas.Line(aRect.Right-w, aRect.Bottom, aRect.Right, aRect.Bottom);
|
Canvas.Line(aRect.Left+w, aRect.Top, aRect.Left+w, aRect.Bottom+1);
|
||||||
Canvas.Line(aRect.Right, aRect.Top, aRect.Right, aRect.Bottom+1);
|
Canvas.Line(aRect.Right-w, aRect.Bottom, aRect.Right, aRect.Bottom);
|
||||||
|
Canvas.Line(aRect.Right, aRect.Top, aRect.Right, aRect.Bottom+1);
|
||||||
|
end else begin
|
||||||
|
Canvas.Line(aRect.Left, aRect.Top+w, aRect.Right, aRect.Top+w);
|
||||||
|
Canvas.Line(aRect.Right, aRect.Top, aRect.Right, aRect.Top+w+1);
|
||||||
|
Canvas.Line(aRect.Left, aRect.Bottom, aRect.Right, aRect.Bottom);
|
||||||
|
Canvas.Line(aRect.Right, aRect.Bottom-w, aRect.Right, aRect.Bottom+1);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
gsHorLines: begin
|
gsHorLines: begin
|
||||||
l := (aRect.Bottom-aRect.Top+1) div 3;
|
l := (aRect.Bottom-aRect.Top+1) div 3;
|
||||||
@ -990,13 +1110,26 @@ const arBevel: array[False..True] of TColor = (clBtnShadow, clBtnHighlight);
|
|||||||
procedure PaintSeparator(Y: Integer);
|
procedure PaintSeparator(Y: Integer);
|
||||||
begin
|
begin
|
||||||
//DebugLn('PaintSeparator');
|
//DebugLn('PaintSeparator');
|
||||||
Canvas.Pen.Color := arBevel[aRaisedBevel];
|
if not Vertical then begin
|
||||||
Canvas.Line(FBorderLeft, Y, Width-FBorderRight, Y);
|
Canvas.Pen.Color := arBevel[aRaisedBevel];
|
||||||
inc(Y);
|
Canvas.Line(FBorderLeft, Y, Width-FBorderRight, Y);
|
||||||
Canvas.Pen.Color := arBevel[not aRaisedBevel];
|
inc(Y);
|
||||||
Canvas.Line(FBorderLeft, Y, Width-FBorderRight, Y);
|
Canvas.Pen.Color := arBevel[not aRaisedBevel];
|
||||||
|
Canvas.Line(FBorderLeft, Y, Width-FBorderRight, Y);
|
||||||
|
end else begin
|
||||||
|
Canvas.Pen.Color := arBevel[aRaisedBevel];
|
||||||
|
Canvas.Line(Y, FBorderTop, Y, Height-FBorderBottom);
|
||||||
|
inc(Y);
|
||||||
|
Canvas.Pen.Color := arBevel[not aRaisedBevel];
|
||||||
|
Canvas.Line(Y, FBorderTop, Y, Height-FBorderBottom);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var k, x, aCountM1, aLeft, aTop: Integer;
|
||||||
|
aRowEnd: Boolean;
|
||||||
|
aColor: TColor;
|
||||||
|
aDetails: TThemedElementDetails;
|
||||||
|
aFlags: Cardinal;
|
||||||
begin
|
begin
|
||||||
inherited Paint;
|
inherited Paint;
|
||||||
//DebugLn('TCoolBar.Paint');
|
//DebugLn('TCoolBar.Paint');
|
||||||
@ -1007,9 +1140,18 @@ begin
|
|||||||
if FBandBorderStyle = bsSingle then
|
if FBandBorderStyle = bsSingle then
|
||||||
aRaisedBevel := ((EdgeInner = esLowered) and (EdgeOuter = esRaised));
|
aRaisedBevel := ((EdgeInner = esLowered) and (EdgeOuter = esRaised));
|
||||||
aRowEnd := False;
|
aRowEnd := False;
|
||||||
case GrabStyle of
|
aGrabStyle := GrabStyle;
|
||||||
gsGripper: aGrabDetails := ThemeServices.GetElementDetails(trGripper);
|
if Vertical then
|
||||||
gsButton: aGrabDetails := ThemeServices.GetElementDetails(tbPushButtonDisabled);
|
case aGrabStyle of
|
||||||
|
gsHorLines: aGrabStyle := gsVerLines;
|
||||||
|
gsVerLines: aGrabStyle := gsHorLines;
|
||||||
|
end;
|
||||||
|
case aGrabStyle of
|
||||||
|
gsGripper: if not Vertical then
|
||||||
|
aGrabDetails := ThemeServices.GetElementDetails(trGripper)
|
||||||
|
else
|
||||||
|
aGrabDetails := ThemeServices.GetElementDetails(trGripperVert);
|
||||||
|
gsButton: aGrabDetails := ThemeServices.GetElementDetails(tbPushButtonNormal);
|
||||||
end;
|
end;
|
||||||
if FShowText or Assigned(FImages) then begin
|
if FShowText or Assigned(FImages) then begin
|
||||||
if IsEnabled then
|
if IsEnabled then
|
||||||
@ -1019,14 +1161,20 @@ begin
|
|||||||
aFlags := DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX;
|
aFlags := DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX;
|
||||||
if FRightToLeft then aFlags := aFlags or DT_RTLREADING;
|
if FRightToLeft then aFlags := aFlags or DT_RTLREADING;
|
||||||
end;
|
end;
|
||||||
|
if FShowText then begin
|
||||||
|
if IsEnabled then
|
||||||
|
Canvas.Font.Color := Font.Color
|
||||||
|
else
|
||||||
|
Canvas.Font.Color := GetCaptionColorDisabled;
|
||||||
|
end;
|
||||||
for i := 0 to aCountM1 do begin
|
for i := 0 to aCountM1 do begin
|
||||||
aLeft := FVisiBands[i].FLeft;
|
aLeft := FVisiBands[i].FLeft;
|
||||||
aTop := FVisiBands[i].FTop;
|
aTop := FVisiBands[i].FTop;
|
||||||
aRect := Rect(aLeft, aTop, aLeft+FVisiBands[i].FRealWidth+1, aTop+FVisiBands[i].FHeight);
|
aRect := Rect(aLeft, aTop, aLeft+FVisiBands[i].FRealWidth+1, aTop+FVisiBands[i].FHeight);
|
||||||
//paint Band Background
|
//paint Band Background
|
||||||
if FVisiBands[i].Bitmap.Width > 0 then begin
|
if FVisiBands[i].Bitmap.Width > 0 then
|
||||||
DrawTiledBitmap(aRect, FVisiBands[i].Bitmap);
|
DrawTiledBitmap(aRect, FVisiBands[i].Bitmap)
|
||||||
end else begin
|
else begin
|
||||||
if not FVisiBands[i].FixedBackground and FVisiBands[i].ParentBitmap
|
if not FVisiBands[i].FixedBackground and FVisiBands[i].ParentBitmap
|
||||||
and (Bitmap.Width > 0) then
|
and (Bitmap.Width > 0) then
|
||||||
DrawTiledBitmap(aRect, Bitmap)
|
DrawTiledBitmap(aRect, Bitmap)
|
||||||
@ -1039,49 +1187,76 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
//paint a Grabber
|
//paint a Grabber
|
||||||
if not FRightToLeft then
|
if not FRightToLeft or Vertical then
|
||||||
x := aLeft+TCoolBand.cGrabIndent
|
x := aLeft+TCoolBand.cGrabIndent
|
||||||
else
|
else
|
||||||
x := aLeft+FVisiBands[i].Width-GrabWidth-TCoolBand.cGrabIndent;
|
x := aLeft+FVisiBands[i].Width-GrabWidth-TCoolBand.cGrabIndent;
|
||||||
PaintGrabber(Rect(x, aTop+2, x+GrabWidth-1, aTop+FVisiBands[i].FHeight-3));
|
if not Vertical then
|
||||||
if not FRightToLeft then
|
PaintGrabber(Rect(x, aTop+2, x+GrabWidth-1, aTop+FVisiBands[i].FHeight-3))
|
||||||
|
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+TCoolBand.cHorSpacing
|
||||||
else
|
else
|
||||||
x := x-TCoolBand.cHorSpacing;
|
x := x-TCoolBand.cHorSpacing;
|
||||||
//paint Image
|
//paint Image
|
||||||
if Assigned(FImages) and (FVisiBands[i].ImageIndex >= 0) then begin
|
if Assigned(FImages) and (FVisiBands[i].ImageIndex >= 0) then begin
|
||||||
if FRightToLeft then dec(x, FImages.Width);
|
if FRightToLeft and not Vertical then dec(x, FImages.Width);
|
||||||
ThemeServices.DrawIcon(Canvas, aDetails,
|
if not Vertical then
|
||||||
Point(x, aTop+(FVisiBands[i].FHeight-FImages.Height) div 2),
|
ThemeServices.DrawIcon(Canvas, aDetails,
|
||||||
FImages, FVisiBands[i].ImageIndex);
|
Point(x, aTop+(FVisiBands[i].FHeight-FImages.Height) div 2),
|
||||||
if not FRightToLeft then
|
FImages, FVisiBands[i].ImageIndex)
|
||||||
|
else
|
||||||
|
ThemeServices.DrawIcon(Canvas, aDetails,
|
||||||
|
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+TCoolBand.cHorSpacing)
|
||||||
else
|
else
|
||||||
dec(x, TCoolBand.cHorSpacing);
|
dec(x, TCoolBand.cHorSpacing);
|
||||||
end;
|
end;
|
||||||
//paint Text
|
//paint Text
|
||||||
if FShowText then begin
|
if FShowText then begin
|
||||||
if FRightToLeft then dec(x, FVisiBands[i].FTextWidth);
|
k := aTop + (FVisiBands[i].FHeight - FTextHeight) div 2;
|
||||||
aRect := Rect(x, aTop, x+FVisiBands[i].FTextWidth, aTop+FVisiBands[i].FHeight);
|
if not Vertical then begin
|
||||||
ThemeServices.DrawText(Canvas, aDetails, FVisiBands[i].Text, aRect, aFlags, 0);
|
if FRightToLeft then dec(x, FVisiBands[i].FTextWidth);
|
||||||
|
Canvas.Font.Orientation := 0;
|
||||||
|
aRect := Rect(x, k, x+FVisiBands[i].FTextWidth, k+FTextHeight);
|
||||||
|
end else begin
|
||||||
|
Canvas.Font.Orientation := 900;
|
||||||
|
aRect := Rect(k, x+FVisiBands[i].FTextWidth, k+FVisiBands[i].FTextWidth, x+2*FVisiBands[i].FTextWidth);
|
||||||
|
end;
|
||||||
|
Canvas.Brush.Style := bsClear;
|
||||||
|
Canvas.TextOut(aRect.Left, aRect.Top, FVisiBands[i].Text);
|
||||||
end;
|
end;
|
||||||
//paint a Separator border below the row of bands ____
|
if BandBorderStyle = bsSingle then begin
|
||||||
x := aLeft;
|
//paint a Separator border below the row of bands ____
|
||||||
inc(aLeft, FVisiBands[i].Width);
|
x := aLeft;
|
||||||
if not FRightToLeft then
|
inc(aLeft, FVisiBands[i].Width);
|
||||||
aRowEnd := IsRowEnd(aLeft, i)
|
if not FRightToLeft or Vertical then
|
||||||
else
|
aRowEnd := IsRowEnd(aLeft, i)
|
||||||
aRowEnd := IsRowEnd(Width-x, i);
|
else
|
||||||
if (aRowEnd or ((i = aCountM1) and not AutoSize) or (Align in [alLeft, alRight]))
|
aRowEnd := IsRowEnd(Width-x, i);
|
||||||
and (FBandBorderStyle = bsSingle)
|
if (aRowEnd or ((i = aCountM1) and not AutoSize)) then begin
|
||||||
then PaintSeparator(aTop+FVisiBands[i].FHeight);
|
if not Vertical or not FRightToLeft then
|
||||||
if not aRowEnd and (i < aCountM1) and (FBandBorderStyle = bsSingle) then begin
|
PaintSeparator(aTop+FVisiBands[i].FHeight)
|
||||||
//paint Divider |
|
else
|
||||||
if not FRightToLeft then x := aLeft-TCoolBand.cDivider;
|
PaintSeparator(aTop-TCoolBand.cDivider);
|
||||||
Canvas.Pen.Color := arBevel[not aRaisedBevel];
|
end;
|
||||||
Canvas.Line(x+1, aTop+1, x+1, aTop+FVisiBands[i].FHeight-1);
|
if not aRowEnd and (i < aCountM1) then begin
|
||||||
Canvas.Pen.Color := arBevel[aRaisedBevel];
|
//paint Divider |
|
||||||
Canvas.Line(x, aTop+1, x, aTop+FVisiBands[i].FHeight-1);
|
if not FRightToLeft or Vertical then x := aLeft-TCoolBand.cDivider;
|
||||||
|
Canvas.Pen.Color := arBevel[not aRaisedBevel];
|
||||||
|
if not Vertical then
|
||||||
|
Canvas.Line(x+1, aTop+1, x+1, aTop+FVisiBands[i].FHeight-1)
|
||||||
|
else
|
||||||
|
Canvas.Line(aTop+1, x+1, aTop+FVisiBands[i].FHeight-1, x+1);
|
||||||
|
Canvas.Pen.Color := arBevel[aRaisedBevel];
|
||||||
|
if not Vertical then
|
||||||
|
Canvas.Line(x, aTop+1, x, aTop+FVisiBands[i].FHeight-1)
|
||||||
|
else
|
||||||
|
Canvas.Line(aTop+1, x, aTop+FVisiBands[i].FHeight-1, x);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1101,9 +1276,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCoolBar.RowEndHelper(ALeft, AVisibleIdx: Integer): Boolean;
|
function TCustomCoolBar.RowEndHelper(ALeft, AVisibleIdx: Integer): Boolean;
|
||||||
|
var aLimit: Integer;
|
||||||
begin
|
begin
|
||||||
Result := FVisiBands[AVisibleIdx+1].Break or Vertical
|
if not Vertical then
|
||||||
or (ALeft+FVisiBands[AVisibleIdx+1].Width-TCoolBand.cDivider >= Width);
|
aLimit := Width
|
||||||
|
else
|
||||||
|
aLimit := Height;
|
||||||
|
Result := FVisiBands[AVisibleIdx+1].Break or
|
||||||
|
(ALeft+FVisiBands[AVisibleIdx+1].Width-TCoolBand.cDivider >= aLimit);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCoolBar.WMSize(var Message: TLMSize);
|
procedure TCustomCoolBar.WMSize(var Message: TLMSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user