33 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
44 * obtain one at https://mozilla.org/MPL/2.0/
55 *
6- * Copyright (C) 2012-2021 , Peter Johnson (gravatar.com/delphidabbler).
6+ * Copyright (C) 2012-2024 , Peter Johnson (gravatar.com/delphidabbler).
77 *
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).
911}
1012
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;
1614
1715interface
1816
19-
2017uses
2118 // 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;
4120
4221type
4322 // / <summary>Class helper that adds a method to TCustomImageList that can
@@ -62,16 +41,6 @@ TImageListHelper = class helper for TCustomImageList
6241 Size: Integer; MaskColour: TColor);
6342 end ;
6443
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-
7544type
7645 // / <summary>Class helper that adds a method to TGIFImage that adds a similar
7746 // / method to one present in 3rd party TGIFImage to load an image from
@@ -87,42 +56,12 @@ TGIFImageHelper = class helper for TGIFImage
8756 const ResType: PChar);
8857 end ;
8958
90-
9159implementation
9260
93-
9461uses
9562 // Delphi
9663 Classes;
9764
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-
12665{ TImageListHelper }
12766
12867procedure TImageListHelper.LoadFromResource (ResType: PChar;
@@ -181,16 +120,6 @@ procedure TImageListHelper.LoadFromResource(ResType: PChar;
181120 end ;
182121end ;
183122
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-
194123{ TGIFImageHelper }
195124
196125procedure TGIFImageHelper.LoadFromResource (const Module : HMODULE;
@@ -207,4 +136,3 @@ procedure TGIFImageHelper.LoadFromResource(const Module: HMODULE;
207136end ;
208137
209138end .
210-
0 commit comments