LCL: Support user defined SelectionFontColor in Treeview. Publish SeparatorColor. Issue #28666, patch from Alexey Torgashin.

git-svn-id: trunk@49894 -
This commit is contained in:
juha 2015-09-29 17:41:26 +00:00
parent 337e3a4589
commit 114e2e8efc
2 changed files with 20 additions and 3 deletions

View File

@ -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;

View File

@ -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