Skip to content

Commit ac5193c

Browse files
authored
Merge pull request #19 from salvadorbs/fixExplorerTheme
Fix explorer theme
2 parents 38c2c75 + aff960b commit ac5193c

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

Source/VirtualTrees.pas

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6134,6 +6134,8 @@ function TVirtualTreeHintWindow.CalcHintRect(MaxWidth: Integer; const AHint: str
61346134
DoPaintText(Node, Self.Canvas, Column, ttNormal);
61356135
//force the default hint font color
61366136
Canvas.Font.Color := Screen.HintFont.Color;
6137+
if Canvas.Font.Color = clDefault then
6138+
Canvas.Font.Color := clInfoText;
61376139
end;
61386140

61396141
//let THintWindow do the job
@@ -8331,7 +8333,7 @@ procedure TVirtualTreeColumns.DrawButtonText(DC: HDC; Caption: String; Bounds: T
83318333
else
83328334
TextColor := FHeader.Treeview.FColors.HeaderFontColor;
83338335
if TextColor = clDefault then
8334-
TextColor := clBtnText;
8336+
TextColor := FHeader.Treeview.GetDefaultColor(dctFont);
83358337
SetTextColor(DC, ColorToRGB(TextColor));
83368338
DrawText(DC, PChar(Caption), Length(Caption), Bounds, DrawFormat);
83378339
end;
@@ -9521,8 +9523,13 @@ procedure TVirtualTreeColumns.PaintHeader(TargetCanvas: TCanvas; R: TRect; const
95219523
ColImageInfo.Index := GetCheckImage(nil, FCheckType, FCheckState, IsEnabled);
95229524
ColImageInfo.XPos := GlyphPos.X;
95239525
ColImageInfo.YPos := GlyphPos.Y;
9526+
if ColImageInfo.Images <> nil then begin
95249527
w := ColImageInfo.Images.Width;
95259528
h := ColImageInfo.Images.Height;
9529+
end else begin
9530+
w := 0;
9531+
h := 0;
9532+
end;
95269533
PaintCheckImage(TargetCanvas, ColImageInfo, False);
95279534
end;
95289535
end;
@@ -9627,6 +9634,9 @@ procedure TVirtualTreeColumns.PaintHeader(TargetCanvas: TCanvas; R: TRect; const
96279634
// Use shortcuts for the images and the font.
96289635
Images := FHeader.FImages;
96299636
Font := FHeader.FFont;
9637+
if Font.Color = clDefault then
9638+
Font.Color := FHeader.Treeview.GetDefaultColor(dctFont);
9639+
96309640
{$IF LCL_FullVersion >= 2000000}
96319641
if Images <> nil then
96329642
ImagesRes := Images.ResolutionForPPI[FHeader.ImagesWidth, Font.PixelsPerInch, Header.TreeView.GetCanvasScaleFactor];
@@ -14480,9 +14490,11 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1448014490
end;
1448114491

1448214492
{$ifdef ThemeSupport}
14483-
// if Theme <> 0 then
14484-
// CloseThemeData(Theme);
14493+
{$ifdef Windows}
14494+
if tsUseThemes in FStates then
14495+
CloseThemeData(Theme);
1448514496
{$endif}
14497+
{$endif ThemeSupport}
1448614498
end;
1448714499

1448814500
//----------------------------------------------------------------------------------------------------------------------
@@ -22765,7 +22777,7 @@ procedure TBaseVirtualTree.HandleMouseDown(var Message: TLMMouse; var HitInfo: T
2276522777
else // No MultiSelect, hence we can start a drag anywhere in the row.
2276622778
FullRowDrag := toFullRowDrag in FOptions.FMiscOptions;
2276722779

22768-
IsHeightTracking := (Message.Msg = LM_LBUTTONDOWN) and
22780+
IsHeightTracking := (Message.Msg = WM_LBUTTONDOWN) and
2276922781
(hiOnItem in HitInfo.HitPositions) and
2277022782
([hiUpperSplitter, hiLowerSplitter] * HitInfo.HitPositions <> []);
2277122783

@@ -24446,10 +24458,10 @@ procedure TBaseVirtualTree.PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode;
2444624458
IsHot: Boolean;
2444724459
{$ifdef Windows}
2444824460
Theme: HTHEME;
24449-
{$endif}
2445024461
Glyph: Integer;
2445124462
State: Integer;
2445224463
Pos: TRect;
24464+
{$endif}
2445324465

2445424466
begin
2445524467
IsHot := (toHotTrack in FOptions.FPaintOptions) and (FCurrentHotNode = Node) and FHotNodeButtonHit;
@@ -24462,11 +24474,11 @@ procedure TBaseVirtualTree.PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode;
2446224474

2446324475
if tsUseExplorerTheme in FStates then
2446424476
begin
24477+
{$ifdef Windows}
2446524478
Glyph := IfThen(IsHot, TVP_HOTGLYPH, TVP_GLYPH);
2446624479
State := IfThen(vsExpanded in Node.States, GLPS_OPENED, GLPS_CLOSED);
2446724480
Pos := Rect(XPos, R.Top + ButtonY, XPos + FPlusBM.Width, R.Top + ButtonY + FPlusBM.Height);
2446824481

24469-
{$ifdef Windows}
2447024482
Theme := OpenThemeData(Handle, 'TREEVIEW');
2447124483
DrawThemeBackground(Theme, Canvas.Handle, Glyph, State, Pos, nil);
2447224484
CloseThemeData(Theme);
@@ -24798,7 +24810,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2479824810
if not IsRectEmpty(InnerRect) then
2479924811
{$ifdef ThemeSupport}
2480024812
{$ifdef Windows}
24801-
if Theme <> 0 then
24813+
if tsUseExplorerTheme in FStates then
2480224814
begin
2480324815
// If the node is also hot, its background will be drawn later.
2480424816
if not (toHotTrack in FOptions.FPaintOptions) or (Node <> FCurrentHotNode) or
@@ -24819,7 +24831,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2481924831

2482024832
{$ifdef ThemeSupport}
2482124833
{$ifdef Windows}
24822-
if (Theme <> 0) and (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) and
24834+
if (tsUseExplorerTheme in FStates) and (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) and
2482324835
((Column = FCurrentHotColumn) or (toFullRowSelect in FOptions.FSelectionOptions)) then
2482424836
DrawBackground(IfThen((vsSelected in Node.States) and not (toAlwaysHideSelection in FOptions.FPaintOptions),
2482524837
TREIS_HOTSELECTED, TREIS_HOT));
@@ -24844,7 +24856,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2484424856
{$ifdef ThemeSupport}
2484524857
{$ifdef Windows}
2484624858
if not (toExtendedFocus in FOptions.FSelectionOptions) and (toFullRowSelect in FOptions.FSelectionOptions) and
24847-
(Theme <> 0) then
24859+
(tsUseExplorerTheme in FStates) then
2484824860
FocusRect := RowRect
2484924861
else
2485024862
{$endif}
@@ -24879,11 +24891,10 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2487924891
end;
2488024892
end;
2488124893
{$ifdef ThemeSupport}
24882-
//todo
24883-
{
24884-
if Theme <> 0 then
24894+
{$ifdef Windows}
24895+
if tsUseExplorerTheme in FStates then
2488524896
CloseThemeData(Theme);
24886-
}
24897+
{$endif}
2488724898
{$endif ThemeSupport}
2488824899
end;
2488924900

@@ -33634,7 +33645,7 @@ procedure TCustomVirtualStringTree.InitializeTextProperties(var PaintInfo: TVTPa
3363433645
end;
3363533646
end;
3363633647
if Canvas.Font.Color = clDefault then
33637-
Canvas.Font.Color := clWindowText;
33648+
Canvas.Font.Color := GetDefaultColor(dctFont);
3363833649
end;
3363933650
end;
3364033651

@@ -33748,6 +33759,8 @@ procedure TCustomVirtualStringTree.PaintStaticText(const PaintInfo: TVTPaintInfo
3374833759
with PaintInfo do
3374933760
begin
3375033761
Canvas.Font := Font;
33762+
if Font.Color = clDefault then
33763+
Canvas.Font.Color := GetDefaultColor(dctFont);
3375133764
if toFullRowSelect in FOptions.FSelectionOptions then
3375233765
begin
3375333766
if Node = FDropTargetNode then
@@ -33765,6 +33778,8 @@ procedure TCustomVirtualStringTree.PaintStaticText(const PaintInfo: TVTPaintInfo
3376533778
else
3376633779
Canvas.Font.Color := FColors.NodeFontColor;
3376733780
end;
33781+
if Canvas.Font.Color = clDefault then
33782+
Canvas.Font.Color := GetDefaultColor(dctFont);
3376833783
end;
3376933784

3377033785
DrawFormat := DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE;
@@ -34209,6 +34224,7 @@ function TCustomVirtualStringTree.DoShortenString(Canvas: TCanvas; Node: PVirtua
3420934224
Done: Boolean;
3421034225

3421134226
begin
34227+
Result := '';
3421234228
Done := False;
3421334229
if Assigned(FOnShortenString) then
3421434230
FOnShortenString(Self, Canvas, Node, Column, S, Width, Result, Done);

0 commit comments

Comments
 (0)