From 02eed0c903e14a33c95b4abded0c66d193678d70 Mon Sep 17 00:00:00 2001 From: Juha Date: Mon, 4 Oct 2021 11:28:13 +0300 Subject: [PATCH] LCL: A new angle bracket option for TreeViewExpandSignType. Issue #39361, patch by Alexey T. --- lcl/comctrls.pp | 12 +++++++---- lcl/include/treeview.inc | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index f19044156e..5fec4451eb 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -3318,10 +3318,11 @@ const type TTreeViewExpandSignType = ( - tvestTheme, // use themed sign - tvestPlusMinus, // use +/- sign - tvestArrow, // use blank arrow - tvestArrowFill // use filled arrow + tvestTheme, // use themed sign + tvestPlusMinus, // use +/- sign + tvestArrow, // use blank arrow + tvestArrowFill, // use filled arrow + tvestAngleBracket // use > symbol ); TTreeViewInsertMarkType = ( @@ -3340,6 +3341,7 @@ type FEditingItem: TTreeNode; FExpandSignType: TTreeViewExpandSignType; FExpandSignSize: integer; + FExpandSignWidth: integer; FThemeExpandSignSize: integer; FDefItemHeight: integer; FDefItemSpace: Integer; @@ -3494,6 +3496,7 @@ type function AllowMultiSelectWithCtrl(AState: TShiftState): Boolean; function AllowMultiSelectWithShift(AState: TShiftState): Boolean; procedure SetExpandSignSize(const AExpandSignSize: integer); + procedure SetExpandSignWidth(const AValue: integer); protected FChangeTimer: TTimer; FEditor: TEdit; @@ -3701,6 +3704,7 @@ type property DropTarget: TTreeNode read GetDropTarget write SetDropTarget; property ExpandSignColor: TColor read FExpandSignColor write FExpandSignColor default clWindowFrame; property ExpandSignSize: integer read GetExpandSignSize write SetExpandSignSize stored ExpandSignSizeIsStored; + property ExpandSignWidth: integer read FExpandSignWidth write SetExpandSignWidth default 2; property ExpandSignType: TTreeViewExpandSignType read FExpandSignType write SetExpandSignType default tvestTheme; property Images: TCustomImageList read FImages write SetImages; diff --git a/lcl/include/treeview.inc b/lcl/include/treeview.inc index de40fbbbcc..dfd6beadab 100644 --- a/lcl/include/treeview.inc +++ b/lcl/include/treeview.inc @@ -3277,6 +3277,7 @@ begin FDefItemSpace := ScaleY(2, 96); FExpandSignType := tvestTheme; FExpandSignSize := -1; + FExpandSignWidth := 2; Details := ThemeServices.GetElementDetails(ttGlyphOpened); FThemeExpandSignSize := ThemeServices.GetDetailSize(Details).cx; FTreeNodes := CreateNodes; @@ -4697,6 +4698,13 @@ begin Invalidate; end; +procedure TCustomTreeView.SetExpandSignWidth(const AValue: integer); +begin + if FExpandSignWidth = AValue then Exit; + FExpandSignWidth := AValue; + Invalidate; +end; + function TCustomTreeView.IsEditing: Boolean; begin Result:=tvsIsEditing in FStates; @@ -5175,6 +5183,43 @@ var Brush.Color := PrevColor; end; end; + tvestAngleBracket: + begin + // draw an arrow. down for collapse and right for expand + R := Rect(ALeft, ATop, ARight+1, ABottom+1); //+1 for simmetry of arrow + if CollapseSign then + begin + // draw an arrow down + Points[0] := Point(R.Left, MidY - cShiftHorzArrow); + Points[1] := Point(R.Right - 1, MidY - cShiftHorzArrow); + Points[2] := Point(MidX, R.Bottom - 1 - cShiftHorzArrow); + end else + begin + // draw an arrow right + Points[0] := Point(MidX - 2, ATop); + Points[1] := Point(MidX - 2, R.Bottom - 1); + Points[2] := Point(R.Right - 3, MidY); + end; + + for SmallIndent := 1 to FExpandSignWidth do + begin + Line(Points[2], Points[0]); + Line(Points[2], Points[1]); + + if CollapseSign then + begin + Dec(Points[0].Y); + Dec(Points[1].Y); + Dec(Points[2].Y); + end + else + begin + Dec(Points[0].X); + Dec(Points[1].X); + Dec(Points[2].X); + end; + end; + end; end; end; end;