Changeset 463 for branches/highdpi/Packages/Common/Theme.pas
- Timestamp:
- Nov 29, 2023, 2:35:44 PM (12 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Packages/Common/Theme.pas
r462 r463 1 unit UTheme;1 unit Theme; 2 2 3 3 interface … … 5 5 uses 6 6 UDpiControls, Classes, SysUtils, Graphics, ComCtrls, Controls, ExtCtrls, Menus, StdCtrls, 7 Spin, Forms, Contnrs, Grids;7 Spin, Forms, Generics.Collections, Grids; 8 8 9 9 type … … 19 19 { TThemes } 20 20 21 TThemes = class(TObjectList )21 TThemes = class(TObjectList<TTheme>) 22 22 function AddNew(Name: string): TTheme; 23 23 function FindByName(Name: string): TTheme; … … 42 42 end; 43 43 44 const 45 ThemeNameSystem = 'System'; 46 ThemeNameLight = 'Light'; 47 ThemeNameDark = 'Dark'; 48 44 49 procedure Register; 50 45 51 46 52 implementation … … 74 80 procedure TThemes.LoadToStrings(Strings: TStrings); 75 81 var 76 Theme: TTheme;82 I: Integer; 77 83 begin 78 Strings.Clear; 79 for Theme in Self do 80 Strings.AddObject(Theme.Name, Theme); 84 Strings.BeginUpdate; 85 try 86 while Strings.Count < Count do Strings.Add(''); 87 while Strings.Count > Count do Strings.Delete(Strings.Count - 1); 88 for I := 0 to Count - 1 do begin 89 Strings[I] := Items[I].Name; 90 Strings.Objects[I] := Items[I]; 91 end; 92 finally 93 Strings.EndUpdate; 94 end; 81 95 end; 82 96 … … 97 111 inherited; 98 112 Themes := TThemes.Create; 99 with Themes.AddNew( 'System') do begin113 with Themes.AddNew(ThemeNameSystem) do begin 100 114 ColorWindow := clWindow; 101 115 ColorWindowText := clWindowText; … … 105 119 end; 106 120 Theme := TTheme(Themes.First); 107 with Themes.AddNew( 'Dark') do begin121 with Themes.AddNew(ThemeNameDark) do begin 108 122 ColorWindow := RGBToColor($20, $20, $20); 109 123 ColorWindowText := clWhite; … … 112 126 ColorControlSelected := RGBToColor(96, 125, 155); 113 127 end; 114 with Themes.AddNew( 'Light') do begin128 with Themes.AddNew(ThemeNameLight) do begin 115 129 ColorWindow := clWhite; 116 130 ColorWindowText := clBlack; … … 123 137 destructor TThemeManager.Destroy; 124 138 begin 125 Themes.Free;126 inherited Destroy;139 FreeAndNil(Themes); 140 inherited; 127 141 end; 128 142 … … 167 181 procedure TThemeManager.UseTheme(Form: TDpiForm); 168 182 begin 169 if not Used and (FTheme.Name = 'System') then Exit;183 if not Used and (FTheme.Name = ThemeNameSystem) then Exit; 170 184 ApplyTheme(Form); 171 185 Used := True; 172 186 end; 173 187 188 end. 174 189 175 end.
Note:
See TracChangeset
for help on using the changeset viewer.