From 114e2e8efc2a3b8f00668b4e67372537df3bfa07 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 29 Sep 2015 17:41:26 +0000 Subject: [PATCH] LCL: Support user defined SelectionFontColor in Treeview. Publish SeparatorColor. Issue #28666, patch from Alexey Torgashin. git-svn-id: trunk@49894 - --- lcl/comctrls.pp | 8 ++++++++ lcl/include/treeview.inc | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index b0d5bcb93f..d1965bf238 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -3231,6 +3231,8 @@ type FScrolledLeft: integer; // horizontal scrolled pixels (hidden pixels at left) FScrolledTop: integer; // vertical scrolled pixels (hidden pixels at top) FSelectedColor: TColor; + FSelectedFontColor: TColor; + FSelectedFontColorUsed: boolean; FSelectedNode: TTreeNode; FSelectionChangeEventLock: integer; fSeparatorColor: TColor; @@ -3287,6 +3289,7 @@ type procedure SetScrolledLeft(AValue: integer); procedure SetScrolledTop(AValue: integer); procedure SetSelectedColor(Value: TColor); + procedure SetSelectedFontColor(Value: TColor); procedure SetSelection(Value: TTreeNode); procedure SetSeparatorColor(const AValue: TColor); procedure SetShowButton(Value: Boolean); @@ -3498,6 +3501,8 @@ type property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth; property Selected: TTreeNode read GetSelection write SetSelection; property SelectionColor: TColor read FSelectedColor write SetSelectedColor default clHighlight; + property SelectionFontColor: TColor read FSelectedFontColor write SetSelectedFontColor default clWhite; + property SelectionFontColorUsed: boolean read FSelectedFontColorUsed write FSelectedFontColorUsed default False; property SelectionCount: Cardinal read GetSelectionCount; property Selections[AIndex: Integer]: TTreeNode read GetSelections; property SeparatorColor: TColor read fSeparatorColor write SetSeparatorColor default clGray; @@ -3548,6 +3553,9 @@ type property RowSelect; property ScrollBars; property SelectionColor; + property SelectionFontColor; + property SelectionFontColorUsed; + property SeparatorColor; property ShowButtons; property ShowHint; property ShowLines; diff --git a/lcl/include/treeview.inc b/lcl/include/treeview.inc index 4daf23da52..eaafbd088d 100644 --- a/lcl/include/treeview.inc +++ b/lcl/include/treeview.inc @@ -3126,6 +3126,8 @@ begin FImageChangeLink := TChangeLink.Create; FImageChangeLink.OnChange := @ImageListChange; FSelectedColor:=clHighlight; + FSelectedFontColor:=clWhite; + FSelectedFontColorUsed:=false; fSeparatorColor:=clGray; FStateChangeLink := TChangeLink.Create; FStateChangeLink.OnChange := @ImageListChange; @@ -3382,6 +3384,14 @@ begin end; end; +procedure TCustomTreeView.SetSelectedFontColor(Value: TColor); +begin + if FSelectedFontColor<>Value then begin + FSelectedFontColor:=Value; + Invalidate; + end; +end; + procedure TCustomTreeView.Paint; begin DoPaint; @@ -4911,15 +4921,14 @@ var else begin Canvas.Brush.Color := FSelectedColor; - Canvas.Font.Color := InvertColor(Brush.Color); + Canvas.Font.Color := IfThen(FSelectedFontColorUsed, FSelectedFontColor, InvertColor(FSelectedColor)); Canvas.FillRect(NodeRect); end else if not (tvoThemedDraw in Options) then begin - //Canvas.Font.Color := Font.Color; Canvas.Brush.Color := FSelectedColor; - Canvas.Font.Color := InvertColor(Brush.Color); + Canvas.Font.Color := IfThen(FSelectedFontColorUsed, FSelectedFontColor, InvertColor(FSelectedColor)); Canvas.FillRect(NodeRect); end; end