3
3
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
4
* obtain one at https://mozilla.org/MPL/2.0/
5
5
*
6
- * Copyright (C) 2012-2021 , Peter Johnson (gravatar.com/delphidabbler).
6
+ * Copyright (C) 2012-2024 , Peter Johnson (gravatar.com/delphidabbler).
7
7
*
8
- * Provides various class helpers for VCL classes.
8
+ * Provides class helpers for VCL image classes.
9
+ *
10
+ * Extracted from in 2024 original UClassHelpers unit (2012-2021).
9
11
}
10
12
11
-
12
- unit UClassHelpers;
13
-
14
- { TODO: Separate different helpers into their own units, within a ClassHelpers
15
- scope. E.g. ClassHelpers.Controls, ClassHelper.Graphics }
13
+ unit ClassHelpers.UGraphics;
16
14
17
15
interface
18
16
19
-
20
17
uses
21
18
// Delphi
22
- Controls, Menus, ImgList, Graphics, ActnList, GIFImg;
23
-
24
-
25
- type
26
- // / <summary>Class helper that adds functionality to TControl.</summary>
27
- TControlHelper = class helper for TControl
28
- public
29
- // / <summary>Gets reference to pop-up menu assigned to protected PopupMenu
30
- // / property.</summary>
31
- function GetPopupMenu : TPopupMenu;
32
- // / <summary>Checks if protected PopupMenu property is assigned.</summary>
33
- function HasPopupMenu : Boolean;
34
- // / <summary>Refreshes control's action. Any changes in action that affect
35
- // / state of control are reflected in control.</summary>
36
- procedure RefreshAction ;
37
- // / <summary>Refreshes all owned controls to reflect any changes in their
38
- // / associated actions.</summary>
39
- procedure RefreshActions ;
40
- end ;
19
+ ImgList, Graphics, GIFImg;
41
20
42
21
type
43
22
// / <summary>Class helper that adds a method to TCustomImageList that can
@@ -62,16 +41,6 @@ TImageListHelper = class helper for TCustomImageList
62
41
Size: Integer; MaskColour: TColor);
63
42
end ;
64
43
65
- type
66
- // / <summary>Class helper that adds a method to TCustomActionList that can
67
- // / update all the actions in the list.</summary>
68
- TActionListHelper = class helper for TCustomActionList
69
- public
70
- // / <summary>Updates all actions in the action list by calling their Update
71
- // / methods.</summary>
72
- procedure Update ;
73
- end ;
74
-
75
44
type
76
45
// / <summary>Class helper that adds a method to TGIFImage that adds a similar
77
46
// / method to one present in 3rd party TGIFImage to load an image from
@@ -87,42 +56,12 @@ TGIFImageHelper = class helper for TGIFImage
87
56
const ResType: PChar);
88
57
end ;
89
58
90
-
91
59
implementation
92
60
93
-
94
61
uses
95
62
// Delphi
96
63
Classes;
97
64
98
-
99
- { TControlHelper }
100
-
101
- function TControlHelper.GetPopupMenu : TPopupMenu;
102
- begin
103
- Result := PopupMenu;
104
- end ;
105
-
106
- function TControlHelper.HasPopupMenu : Boolean;
107
- begin
108
- Result := Assigned(PopupMenu);
109
- end ;
110
-
111
- procedure TControlHelper.RefreshAction ;
112
- begin
113
- if Assigned(Action) then
114
- ActionChange(Action, False);
115
- end ;
116
-
117
- procedure TControlHelper.RefreshActions ;
118
- var
119
- Idx: Integer; // loops through all controls
120
- begin
121
- for Idx := 0 to Pred(ComponentCount) do
122
- if Components[Idx] is TControl then
123
- (Components[Idx] as TControl).RefreshAction;
124
- end ;
125
-
126
65
{ TImageListHelper }
127
66
128
67
procedure TImageListHelper.LoadFromResource (ResType: PChar;
@@ -181,16 +120,6 @@ procedure TImageListHelper.LoadFromResource(ResType: PChar;
181
120
end ;
182
121
end ;
183
122
184
- { TActionListHelper }
185
-
186
- procedure TActionListHelper.Update ;
187
- var
188
- Action: TContainedAction; // each action in list
189
- begin
190
- for Action in Self do
191
- Action.Update;
192
- end ;
193
-
194
123
{ TGIFImageHelper }
195
124
196
125
procedure TGIFImageHelper.LoadFromResource (const Module : HMODULE;
@@ -207,4 +136,3 @@ procedure TGIFImageHelper.LoadFromResource(const Module: HMODULE;
207
136
end ;
208
137
209
138
end .
210
-
0 commit comments