Skip to content

Commit 892204e

Browse files
committed
Reintroduce toUseExplorerTheme (only for Windows platform)
1 parent 3232c7f commit 892204e

File tree

1 file changed

+58
-43
lines changed

1 file changed

+58
-43
lines changed

Source/VirtualTrees.pas

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ interface
6464
Windows,
6565
ActiveX,
6666
CommCtrl,
67+
UxTheme,
6768
{$else}
6869
FakeActiveX,
6970
{$endif}
@@ -244,6 +245,17 @@ interface
244245
DEFAULT_NODE_HEIGHT = 18;
245246
DEFAULT_SPACING = 3;
246247

248+
LIS_NORMAL = 1;
249+
{$EXTERNALSYM LIS_NORMAL}
250+
LIS_HOT = 2;
251+
{$EXTERNALSYM LIS_HOT}
252+
LIS_SELECTED = 3;
253+
{$EXTERNALSYM LIS_SELECTED}
254+
LIS_DISABLED = 4;
255+
{$EXTERNALSYM LIS_DISABLED}
256+
LIS_SELECTEDNOTFOCUS = 5;
257+
{$EXTERNALSYM LIS_SELECTEDNOTFOCUS}
258+
247259
var // Clipboard format IDs used in OLE drag'n drop and clipboard transfers.
248260
CF_VIRTUALTREE,
249261
CF_VTREFERENCE,
@@ -7422,8 +7434,9 @@ procedure TVirtualTreeColumn.ComputeHeaderLayout(DC: HDC; const Client: TRect; U
74227434
TextSpacing: Integer;
74237435
UseText: Boolean;
74247436
R: TRect;
7425-
//todo
7426-
//Theme: HTHEME;
7437+
{$ifdef Windows}
7438+
Theme: HTHEME;
7439+
{$endif}
74277440

74287441
begin
74297442
UseText := Length(FText) > 0;
@@ -7460,9 +7473,12 @@ procedure TVirtualTreeColumn.ComputeHeaderLayout(DC: HDC; const Client: TRect; U
74607473
if tsUseExplorerTheme in FHeader.Treeview.FStates then
74617474
begin
74627475
R := Rect(0, 0, 100, 100);
7463-
//Theme := OpenThemeData(FHeader.Treeview.Handle, 'HEADER');
7464-
//GetThemePartSize(Theme, DC, HP_HEADERSORTARROW, HSAS_SORTEDUP, @R, TS_TRUE, SortGlyphSize);
7465-
//CloseThemeData(Theme);
7476+
7477+
{$ifdef Windows}
7478+
Theme := OpenThemeData(FHeader.Treeview.Handle, 'HEADER');
7479+
GetThemePartSize(Theme, DC, HP_HEADERSORTARROW, HSAS_SORTEDUP, @R, TS_TRUE, SortGlyphSize);
7480+
CloseThemeData(Theme);
7481+
{$endif}
74667482
end
74677483
else
74687484
begin
@@ -14255,7 +14271,9 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1425514271
Bits: Pointer;
1425614272
Size: TSize;
1425714273
{$ifdef ThemeSupport}
14258-
//Theme: HTHEME;
14274+
{$ifdef Windows}
14275+
Theme: HTHEME;
14276+
{$endif}
1425914277
{$EndIf ThemeSupport}
1426014278
R: TRect;
1426114279

@@ -14309,8 +14327,7 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1430914327
Size.cy := Size.cx;
1431014328

1431114329
{$ifdef ThemeSupport}
14312-
//todo
14313-
{
14330+
{$ifdef Windows}
1431414331
if tsUseThemes in FStates then
1431514332
begin
1431614333
Theme := OpenThemeData(Handle, 'TREEVIEW');
@@ -14322,7 +14339,7 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1432214339
end
1432314340
else
1432414341
Theme := 0;
14325-
}
14342+
{$endif}
1432614343
{$endif ThemeSupport}
1432714344

1432814345
if NeedButtons then
@@ -14421,9 +14438,8 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1442114438
end;
1442214439

1442314440
{$ifdef ThemeSupport}
14424-
//todo
14441+
{$ifdef Windows}
1442514442
// Overwrite glyph images if theme is active.
14426-
{
1442714443
if (tsUseThemes in FStates) and (Theme <> 0) then
1442814444
begin
1442914445
R := Rect(0, 0, Size.cx, Size.cy);
@@ -14440,7 +14456,7 @@ procedure TBaseVirtualTree.PrepareBitmaps(NeedButtons, NeedLines: Boolean);
1444014456
FHotMinusBM.Canvas.Draw(0, 0, FMinusBM);
1444114457
end;
1444214458
end;
14443-
}
14459+
{$endif}
1444414460
{$endif ThemeSupport}
1444514461
end;
1444614462

@@ -15624,8 +15640,10 @@ procedure TBaseVirtualTree.SetWindowTheme(const Theme: String);
1562415640

1562515641
begin
1562615642
FChangingTheme := True;
15627-
//lcl: todo
15628-
//UxTheme.SetWindowTheme(Handle, PAnsiChar(Theme), nil);
15643+
15644+
{$ifdef Windows}
15645+
UxTheme.SetWindowTheme(Handle, PWideChar(Theme), nil);
15646+
{$endif}
1562915647
end;
1563015648

1563115649

@@ -24426,7 +24444,9 @@ procedure TBaseVirtualTree.PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode;
2442624444
Bitmap: TBitmap;
2442724445
XPos: Integer;
2442824446
IsHot: Boolean;
24429-
//Theme: HTHEME;
24447+
{$ifdef Windows}
24448+
Theme: HTHEME;
24449+
{$endif}
2443024450
Glyph: Integer;
2443124451
State: Integer;
2443224452
Pos: TRect;
@@ -24445,11 +24465,12 @@ procedure TBaseVirtualTree.PaintNodeButton(Canvas: TCanvas; Node: PVirtualNode;
2444524465
Glyph := IfThen(IsHot, TVP_HOTGLYPH, TVP_GLYPH);
2444624466
State := IfThen(vsExpanded in Node.States, GLPS_OPENED, GLPS_CLOSED);
2444724467
Pos := Rect(XPos, R.Top + ButtonY, XPos + FPlusBM.Width, R.Top + ButtonY + FPlusBM.Height);
24448-
{
24468+
24469+
{$ifdef Windows}
2444924470
Theme := OpenThemeData(Handle, 'TREEVIEW');
2445024471
DrawThemeBackground(Theme, Canvas.Handle, Glyph, State, Pos, nil);
2445124472
CloseThemeData(Theme);
24452-
}
24473+
{$endif}
2445324474
end
2445424475
else
2445524476
begin
@@ -24615,8 +24636,10 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2461524636
FocusRect,
2461624637
InnerRect: TRect;
2461724638
{$ifdef ThemeSupport}
24618-
//RowRect: TRect;
24619-
//Theme: HTHEME;
24639+
{$ifdef Windows}
24640+
Theme: HTHEME;
24641+
RowRect: TRect;
24642+
{$endif}
2462024643
{$endif ThemeSupport}
2462124644

2462224645
//--------------- local functions -------------------------------------------
@@ -24642,8 +24665,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2464224665
end;
2464324666

2464424667
//---------------------------------------------------------------------------
24645-
//lcl: todo
24646-
{
24668+
{$ifdef Windows}
2464724669
procedure DrawBackground(State: Integer);
2464824670
begin
2464924671
// if the full row selection is disabled or toGridExtensions is in the MiscOptions, draw the selection
@@ -24665,14 +24687,13 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2466524687
DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, LVP_LISTDETAIL, State, RowRect, nil);
2466624688
CloseThemeData(Theme);
2466724689
end;
24668-
}
24690+
{$endif}
2466924691

2467024692
//--------------- end local functions ---------------------------------------
2467124693

2467224694
begin
2467324695
{$ifdef ThemeSupport}
24674-
//todo
24675-
{
24696+
{$ifdef Windows}
2467624697
if tsUseExplorerTheme in FStates then
2467724698
begin
2467824699
Theme := OpenThemeData(Application.Handle, 'Explorer::TreeView');
@@ -24682,7 +24703,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2468224703
if toShowVertGridLines in FOptions.PaintOptions then
2468324704
Dec(RowRect.Right);
2468424705
end;
24685-
}
24706+
{$endif}
2468624707
{$endif ThemeSupport}
2468724708

2468824709
with PaintInfo, Canvas do
@@ -24741,12 +24762,11 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2474124762
(toFullRowSelect in FOptions.FSelectionOptions) then
2474224763
InnerRect := CellRect;
2474324764
if not IsRectEmpty(InnerRect) then
24744-
//todo
24745-
{
24765+
{$ifdef Windows}
2474624766
if tsUseExplorerTheme in FStates then
2474724767
DrawBackground(TREIS_SELECTED)
2474824768
else
24749-
}
24769+
{$endif}
2475024770
if MMXAvailable and (toUseBlendedSelection in FOptions.PaintOptions) then
2475124771
AlphaBlendSelection(Brush.Color)
2475224772
else
@@ -24777,8 +24797,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2477724797
InnerRect := CellRect;
2477824798
if not IsRectEmpty(InnerRect) then
2477924799
{$ifdef ThemeSupport}
24780-
//todo
24781-
{
24800+
{$ifdef Windows}
2478224801
if Theme <> 0 then
2478324802
begin
2478424803
// If the node is also hot, its background will be drawn later.
@@ -24787,7 +24806,7 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2478724806
DrawBackground(IfThen(Self.Focused, TREIS_SELECTED, TREIS_SELECTEDNOTFOCUS));
2478824807
end
2478924808
else
24790-
}
24809+
{$endif}
2479124810
{$endif ThemeSupport}
2479224811
if MMXAvailable and (toUseBlendedSelection in FOptions.PaintOptions) then
2479324812
AlphaBlendSelection(Brush.Color)
@@ -24799,13 +24818,12 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2479924818
end;
2480024819

2480124820
{$ifdef ThemeSupport}
24802-
//todo
24803-
{
24821+
{$ifdef Windows}
2480424822
if (Theme <> 0) and (toHotTrack in FOptions.FPaintOptions) and (Node = FCurrentHotNode) and
2480524823
((Column = FCurrentHotColumn) or (toFullRowSelect in FOptions.FSelectionOptions)) then
2480624824
DrawBackground(IfThen((vsSelected in Node.States) and not (toAlwaysHideSelection in FOptions.FPaintOptions),
2480724825
TREIS_HOTSELECTED, TREIS_HOT));
24808-
}
24826+
{$endif}
2480924827
{$endif ThemeSupport}
2481024828

2481124829
if (Column = FFocusedColumn) or (toFullRowSelect in FOptions.FSelectionOptions) then
@@ -24824,37 +24842,34 @@ procedure TBaseVirtualTree.PrepareCell(var PaintInfo: TVTPaintInfo; WindowOrgX,
2482424842
SetBkColor(Handle, 0);
2482524843

2482624844
{$ifdef ThemeSupport}
24827-
//todo
24828-
{
24845+
{$ifdef Windows}
2482924846
if not (toExtendedFocus in FOptions.FSelectionOptions) and (toFullRowSelect in FOptions.FSelectionOptions) and
2483024847
(Theme <> 0) then
2483124848
FocusRect := RowRect
2483224849
else
24833-
}
24850+
{$endif}
2483424851
{$endif ThemeSupport}
2483524852
if toGridExtensions in FOptions.FMiscOptions then
2483624853
FocusRect := CellRect
2483724854
else
2483824855
FocusRect := InnerRect;
2483924856

2484024857
{$ifdef ThemeSupport}
24841-
//todo
24842-
{
24858+
{$ifdef Windows}
2484324859
if tsUseExplorerTheme in FStates then
2484424860
InflateRect(FocusRect, -1, -1);
24845-
}
24861+
{$endif}
2484624862
{$endif ThemeSupport}
2484724863

2484824864
if (tsUseExplorerTheme in FStates) and IsWinVistaOrAbove then
2484924865
begin
2485024866
//Draw focused unselected style like Windows 7 Explorer
24851-
//lcl: todo
24852-
{
24867+
{$ifdef Windows}
2485324868
if not (vsSelected in Node.States) then
2485424869
DrawThemedFocusRect(LIS_NORMAL)
2485524870
else
2485624871
DrawBackground(TREIS_HOTSELECTED);
24857-
}
24872+
{$endif}
2485824873
end
2485924874
else
2486024875
LCLIntf.DrawFocusRect(Handle, FocusRect);

0 commit comments

Comments
 (0)