LCL: Improve TreeView.HotTrack with a color. Issue #32677, patch from AlexeyT.

git-svn-id: trunk@56378 -
This commit is contained in:
juha 2017-11-12 22:02:20 +00:00
parent 847397914f
commit e5da480946
2 changed files with 11 additions and 0 deletions

View File

@ -3270,6 +3270,7 @@ type
FMaxRight: integer; // maximum text width of all nodes (needed for horizontal scrolling)
fMouseDownPos: TPoint;
FMultiSelectStyle: TMultiSelectStyle;
FHotTrackColor: TColor;
FOnAddition: TTVExpandedEvent;
FOnAdvancedCustomDraw: TTVAdvancedCustomDrawEvent;
FOnAdvancedCustomDrawItem: TTVAdvancedCustomDrawItemEvent;
@ -3490,6 +3491,7 @@ type
property HideSelection: Boolean
read GetHideSelection write SetHideSelection default True;
property HotTrack: Boolean read GetHotTrack write SetHotTrack default False;
property HotTrackColor: TColor read FHotTrackColor write FHotTrackColor default clNone;
property Indent: Integer read GetIndent write SetIndent stored IndentIsStored;
property MultiSelect: Boolean read GetMultiSelect write SetMultiSelect default False;
property OnAddition: TTVExpandedEvent read FOnAddition write FOnAddition;
@ -3637,6 +3639,7 @@ type
property Font;
property HideSelection;
property HotTrack;
property HotTrackColor;
property Images;
property Indent;
property MultiSelect;

View File

@ -3269,6 +3269,7 @@ begin
FTreeLinePenPattern[0] := 1;
FTreeLinePenPattern[1] := 1;
FExpandSignColor := clWindowFrame;
FHotTrackColor := clNone;
// Accessibility
AccessibleDescription := rsTTreeViewAccessibilityDescription;
AccessibleRole := larTreeView;
@ -5162,6 +5163,7 @@ var
Details: TThemedElementDetails;
NeedUnderline: Boolean;
PrevFontStyle: TFontStyles;
PrevFontColor: TColor;
begin
if IsSelected then
begin
@ -5193,7 +5195,10 @@ var
if NeedUnderline then
begin
PrevFontStyle := Canvas.Font.Style;
PrevFontColor := Canvas.Font.Color;
Canvas.Font.Style := [fsUnderline];
if FHotTrackColor<>clNone then
Canvas.Font.Color := FHotTrackColor;
end;
if (tvoThemedDraw in Options) then
@ -5202,7 +5207,10 @@ var
DrawText(Canvas.Handle, PChar(AText), -1, NodeRect, DT_CENTER or DT_VCENTER or DT_SINGLELINE or DT_NOPREFIX);
if NeedUnderline then
begin
Canvas.Font.Style := PrevFontStyle;
Canvas.Font.Color := PrevFontColor;
end;
end;