Changeset 131 for trunk/Packages/Common/UTheme.pas
- Timestamp:
- Mar 18, 2022, 1:37:03 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UTheme.pas
r122 r131 5 5 uses 6 6 Classes, SysUtils, Graphics, ComCtrls, Controls, ExtCtrls, Menus, StdCtrls, 7 Spin, Forms, Contnrs, Grids;7 Spin, Forms, fgl, Grids; 8 8 9 9 type … … 19 19 { TThemes } 20 20 21 TThemes = class(T ObjectList)21 TThemes = class(TFPGObjectList<TTheme>) 22 22 function AddNew(Name: string): TTheme; 23 23 function FindByName(Name: string): TTheme; … … 41 41 property Theme: TTheme read FTheme write SetTheme; 42 42 end; 43 44 const 45 ThemeNameSystem = 'System'; 46 ThemeNameLight = 'Light'; 47 ThemeNameDark = 'Dark'; 43 48 44 49 procedure Register; … … 74 79 procedure TThemes.LoadToStrings(Strings: TStrings); 75 80 var 76 Theme: TTheme;81 I: Integer; 77 82 begin 78 Strings.Clear; 79 for Theme in Self do 80 Strings.AddObject(Theme.Name, Theme); 83 Strings.BeginUpdate; 84 try 85 while Strings.Count < Count do Strings.Add(''); 86 while Strings.Count > Count do Strings.Delete(Strings.Count - 1); 87 for I := 0 to Count - 1 do begin 88 Strings[I] := Items[I].Name; 89 Strings.Objects[I] := Items[I]; 90 end; 91 finally 92 Strings.EndUpdate; 93 end; 81 94 end; 82 95 … … 97 110 inherited; 98 111 Themes := TThemes.Create; 99 with Themes.AddNew( 'System') do begin112 with Themes.AddNew(ThemeNameSystem) do begin 100 113 ColorWindow := clWindow; 101 114 ColorWindowText := clWindowText; … … 105 118 end; 106 119 Theme := TTheme(Themes.First); 107 with Themes.AddNew( 'Dark') do begin120 with Themes.AddNew(ThemeNameDark) do begin 108 121 ColorWindow := RGBToColor($20, $20, $20); 109 122 ColorWindowText := clWhite; … … 112 125 ColorControlSelected := RGBToColor(96, 125, 155); 113 126 end; 114 with Themes.AddNew( 'Light') do begin127 with Themes.AddNew(ThemeNameLight) do begin 115 128 ColorWindow := clWhite; 116 129 ColorWindowText := clBlack; … … 123 136 destructor TThemeManager.Destroy; 124 137 begin 125 Themes.Free;126 inherited Destroy;138 FreeAndNil(Themes); 139 inherited; 127 140 end; 128 141 … … 167 180 procedure TThemeManager.UseTheme(Form: TForm); 168 181 begin 169 if not Used and (FTheme.Name = 'System') then Exit;182 if not Used and (FTheme.Name = ThemeNameSystem) then Exit; 170 183 ApplyTheme(Form); 171 184 Used := True;
Note:
See TracChangeset
for help on using the changeset viewer.