-
Notifications
You must be signed in to change notification settings - Fork 14
/
Tray.Notify.Controls.pas
128 lines (111 loc) · 3.54 KB
/
Tray.Notify.Controls.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
unit Tray.Notify.Controls;
interface
uses
Winapi.Windows, Winapi.Messages,
System.Classes,
Vcl.Graphics, Vcl.Themes,
Core.UI.Controls,
Versions.Helpers;
type
TFlyOutPanelStyle = (tfpsDefault, tfpsLinkArea, tfpsHeader, tfpsBody, tfpsBrightness);
TPanel = class(Core.UI.Controls.TPanel)
private
IsShellWindows7: Boolean;
FStyle: TFlyOutPanelStyle;
procedure SetStyle(const Value: TFlyOutPanelStyle);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
property Style: TFlyOutPanelStyle read FStyle write SetStyle;
end;
TStaticText = class(Core.UI.Controls.TStaticText)
protected
function GetLinkStyleColor(Style: TLinkStyle): TColor; override;
end;
implementation
{ TPanel }
constructor TPanel.Create(AOwner: TComponent);
begin
inherited;
IsShellWindows7 := IsWindows7OrGreater;
FStyle := tfpsDefault;
end;
procedure TPanel.Paint;
var
Details: TThemedElementDetails;
DividerSize: TSize;
DividerColor: TColor;
begin
if not StyleServices.Enabled then begin
inherited;
Exit;
end;
case FStyle of
tfpsDefault:
begin
inherited;
Exit;
end;
tfpsHeader:
begin
Details := StyleServices.GetElementDetails(tfFlyOutWindow);
if not StyleServices.DrawElement(Canvas.Handle, Details, Rect(0, 0, Width, Height)) then begin
inherited;
Exit;
end;
end;
tfpsBody:
begin
Details := StyleServices.GetElementDetails(tfFlyOutWindow);
if not StyleServices.DrawElement(Canvas.Handle, Details, Rect(0, 0, Width, Height)) then begin
inherited;
Exit;
end;
Details := StyleServices.GetElementDetails(tfFlyOutDivider);
StyleServices.GetElementSize(Canvas.Handle, Details, esActual, DividerSize);
StyleServices.DrawElement(Canvas.Handle, Details, Rect(0, 0, Width, DividerSize.cy));
end;
tfpsLinkArea:
begin
Details := StyleServices.GetElementDetails(tfFlyOutLinkArea);
if not StyleServices.DrawElement(Canvas.Handle, Details, Rect(0, 0, Width, Height)) then begin
inherited;
Exit;
end;
if not IsShellWindows7 then begin
Details := StyleServices.GetElementDetails(tfFlyOutDivider);
StyleServices.GetElementSize(Canvas.Handle, Details, esActual, DividerSize);
StyleServices.DrawElement(Canvas.Handle, Details, Rect(0, 0, Width, DividerSize.cy));
end;
end;
tfpsBrightness:
begin
Details := StyleServices.GetElementDetails(tfFlyOutDivider);
if StyleServices.GetElementColor(Details, ecEdgeFillColor, DividerColor) then
ShapeColor := DividerColor;
inherited;
end;
end;
end;
procedure TPanel.SetStyle(const Value: TFlyOutPanelStyle);
begin
if not IsWindowsVistaOrGreater then Exit;
FStyle := Value;
Repaint;
end;
{ TStaticText }
function TStaticText.GetLinkStyleColor(Style: TLinkStyle): TColor;
var
Details: TThemedElementDetails;
begin
if not (IsWindowsVistaOrGreater and StyleServices.Enabled) then
Exit(inherited GetLinkStyleColor(Style));
case Style of
lsHover: Details := StyleServices.GetElementDetails(tfFlyOutLinkHover);
else Details := StyleServices.GetElementDetails(tfFlyOutLinkNormal);
end;
if not StyleServices.GetElementColor(Details, ecTextColor, Result) then
Exit(inherited GetLinkStyleColor(Style));
end;
end.