Changeset 504
- Timestamp:
- Feb 14, 2018, 10:40:52 AM (7 years ago)
- Location:
- Common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Common.lpk
r486 r504 11 11 <PathDelim Value="\"/> 12 12 <SearchPaths> 13 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS) "/>13 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/> 14 14 </SearchPaths> 15 <Parsing> 16 <SyntaxOptions> 17 <SyntaxMode Value="Delphi"/> 18 <CStyleOperator Value="False"/> 19 <AllowLabel Value="False"/> 20 <CPPInline Value="False"/> 21 </SyntaxOptions> 22 </Parsing> 23 <CodeGeneration> 24 <Optimizations> 25 <OptimizationLevel Value="0"/> 26 </Optimizations> 27 </CodeGeneration> 28 <Linking> 29 <Debugging> 30 <GenerateDebugInfo Value="False"/> 31 </Debugging> 32 </Linking> 33 <Other> 34 <CompilerMessages> 35 <IgnoredMessages idx5024="True"/> 36 </CompilerMessages> 37 </Other> 15 38 </CompilerOptions> 16 39 <Description Value="Various libraries"/> 17 40 <License Value="GNU/GPL"/> 18 41 <Version Minor="7"/> 19 <Files Count="2 0">42 <Files Count="21"> 20 43 <Item1> 21 44 <Filename Value="StopWatch.pas"/> … … 106 129 <UnitName Value="UScaleDPI"/> 107 130 </Item20> 131 <Item21> 132 <Filename Value="UTheme.pas"/> 133 <HasRegisterProc Value="True"/> 134 <UnitName Value="UTheme"/> 135 </Item21> 108 136 </Files> 109 137 <i18n> -
Common/Common.pas
r487 r504 8 8 9 9 uses 10 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, UScaleDPI, LazarusPackageIntf;10 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, UScaleDPI, UTheme, LazarusPackageIntf; 14 14 15 15 implementation … … 25 25 RegisterUnit('UFindFile', @UFindFile.Register); 26 26 RegisterUnit('UScaleDPI', @UScaleDPI.Register); 27 RegisterUnit('UTheme', @UTheme.Register); 27 28 end; 28 29 -
Common/UListViewSort.pas
r489 r504 81 81 FOnChange: TNotifyEvent; 82 82 FStringGrid1: TStringGrid; 83 procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);84 procedure DoOnResize(Sender: TObject);83 procedure GridDoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 84 procedure GridDoOnResize(Sender: TObject); 85 85 public 86 86 constructor Create(AOwner: TComponent); override; … … 110 110 { TListViewFilter } 111 111 112 procedure TListViewFilter. DoOnKeyUp(Sender: TObject; var Key: Word;112 procedure TListViewFilter.GridDoOnKeyUp(Sender: TObject; var Key: Word; 113 113 Shift: TShiftState); 114 114 begin … … 117 117 end; 118 118 119 procedure TListViewFilter. DoOnResize(Sender: TObject);119 procedure TListViewFilter.GridDoOnResize(Sender: TObject); 120 120 begin 121 121 FStringGrid1.DefaultRowHeight := FStringGrid1.Height; … … 135 135 FStringGrid1.Options := [goFixedHorzLine, goFixedVertLine, goVertLine, 136 136 goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll]; 137 FStringGrid1.OnKeyUp := DoOnKeyUp;138 FStringGrid1.OnResize := DoOnResize;137 FStringGrid1.OnKeyUp := GridDoOnKeyUp; 138 FStringGrid1.OnResize := GridDoOnResize; 139 139 end; 140 140 … … 197 197 if AMsg.Msg = WM_NOTIFY then 198 198 begin 199 Code := PHDNotify(vMsgNotify.NMHdr)^.Hdr.Code;199 Code := NMHDR(PHDNotify(vMsgNotify.NMHdr)^.Hdr).Code; 200 200 case Code of 201 201 HDN_ENDTRACKA, HDN_ENDTRACKW: … … 353 353 TP1: TPoint; 354 354 XBias, YBias: Integer; 355 OldColor: TColor; 355 PenColor: TColor; 356 BrushColor: TColor; 356 357 BiasTop, BiasLeft: Integer; 357 358 Rect1: TRect; … … 365 366 Item.Left := 0; 366 367 GetCheckBias(XBias, YBias, BiasTop, BiasLeft, ListView); 367 OldColor := ListView.Canvas.Pen.Color; 368 PenColor := ListView.Canvas.Pen.Color; 369 BrushColor := ListView.Canvas.Brush.Color; 368 370 //TP1 := Item.GetPosition; 369 371 lRect := Item.DisplayRect(drBounds); // Windows 7 workaround … … 408 410 end; 409 411 //ListView.Canvas.Brush.Color := ListView.Color; 410 ListView.Canvas.Brush.Color := clWindow;411 ListView.Canvas.Pen.Color := OldColor;412 ListView.Canvas.Brush.Color := BrushColor; 413 ListView.Canvas.Pen.Color := PenColor; 412 414 end; 413 415 -
Common/UTheme.pas
r503 r504 5 5 uses 6 6 Classes, SysUtils, Graphics, ComCtrls, Controls, ExtCtrls, Menus, StdCtrls, 7 Spin, Forms ;7 Spin, Forms, Contnrs, Grids; 8 8 9 9 type 10 TTheme = class(TComponent) 11 private 12 FThemeName: string; 13 procedure SetThemeName(AValue: string); 14 public 10 TTheme = class 11 Name: string; 15 12 ColorWindow: TColor; 16 13 ColorWindowText: TColor; … … 18 15 ColorControlText: TColor; 19 16 ColorControlSelected: TColor; 17 end; 18 19 { TThemes } 20 21 TThemes = class(TObjectList) 22 function AddNew(Name: string): TTheme; 23 function FindByName(Name: string): TTheme; 24 procedure LoadToStrings(Strings: TStrings); 25 end; 26 27 { TThemeManager } 28 29 TThemeManager = class(TComponent) 30 private 31 FTheme: TTheme; 32 procedure SetTheme(AValue: TTheme); 33 procedure SetThemeName(AValue: TTheme); 34 public 20 35 Used: Boolean; 36 Themes: TThemes; 21 37 procedure ApplyTheme(Component: TComponent); 22 38 constructor Create(AOwner: TComponent); override; 39 destructor Destroy; override; 23 40 procedure UseTheme(Form: TForm); 24 property Theme Name: string read FThemeName write SetThemeName;41 property Theme: TTheme read FTheme write SetTheme; 25 42 end; 26 43 44 procedure Register; 27 45 28 46 implementation 29 47 30 procedure TTheme.SetThemeName(AValue: string); 48 { TThemes } 49 50 procedure Register; 31 51 begin 32 if FThemeName = AValue then Exit; 33 FThemeName := AValue; 34 if AValue = 'Dark' then begin 52 RegisterComponents('Common', [TThemeManager]); 53 end; 54 55 function TThemes.AddNew(Name: string): TTheme; 56 begin 57 Result := TTheme.Create; 58 Result.Name := Name; 59 Add(Result); 60 end; 61 62 function TThemes.FindByName(Name: string): TTheme; 63 var 64 Theme: TTheme; 65 begin 66 Result := nil; 67 for Theme in Self do 68 if Theme.Name = Name then begin 69 Result := Theme; 70 Exit; 71 end; 72 end; 73 74 procedure TThemes.LoadToStrings(Strings: TStrings); 75 var 76 Theme: TTheme; 77 begin 78 Strings.Clear; 79 for Theme in Self do 80 Strings.AddObject(Theme.Name, Theme); 81 end; 82 83 procedure TThemeManager.SetThemeName(AValue: TTheme); 84 begin 85 if FTheme = AValue then Exit; 86 FTheme := AValue; 87 end; 88 89 procedure TThemeManager.SetTheme(AValue: TTheme); 90 begin 91 if FTheme = AValue then Exit; 92 FTheme := AValue; 93 end; 94 95 constructor TThemeManager.Create(AOwner: TComponent); 96 begin 97 inherited; 98 Themes := TThemes.Create; 99 with Themes.AddNew('System') do begin 100 ColorWindow := clWindow; 101 ColorWindowText := clWindowText; 102 ColorControl := clMenu; 103 ColorControlText := clWindowText; 104 ColorControlSelected := clWindow; 105 end; 106 Theme := TTheme(Themes.First); 107 with Themes.AddNew('Dark') do begin 35 108 ColorWindow := RGBToColor($20, $20, $20); 36 109 ColorWindowText := clWhite; … … 38 111 ColorControlText := clWhite; 39 112 ColorControlSelected := RGBToColor(96, 125, 155); 40 end else41 if Avalue = 'Light' thenbegin113 end; 114 with Themes.AddNew('Light') do begin 42 115 ColorWindow := clWhite; 43 116 ColorWindowText := clBlack; … … 45 118 ColorControlText := clBlack; 46 119 ColorControlSelected := RGBToColor(196, 225, 255); 47 end else begin48 FThemeName := 'System';49 50 ColorWindow := clBlack;51 ColorWindowText := clWhite;52 ColorControl := clBlack;53 ColorControlText := clWhite;54 ColorControlSelected := clWhite;55 120 end; 56 121 end; 57 122 58 constructor TTheme.Create(AOwner: TComponent);123 destructor TThemeManager.Destroy; 59 124 begin 60 inherited;61 ThemeName := 'System';125 Themes.Free; 126 inherited Destroy; 62 127 end; 63 128 64 procedure TTheme .ApplyTheme(Component: TComponent);129 procedure TThemeManager.ApplyTheme(Component: TComponent); 65 130 var 66 131 Control: TControl; … … 73 138 Control := (Component as TControl); 74 139 if (Control is TEdit) or (Control is TSpinEdit) or (Control is TComboBox) and 75 (Control is TMemo) or (Control is TListView) then begin 76 Control.Color := ColorWindow; 77 Control.Font.Color := ColorWindowText; 140 (Control is TMemo) or (Control is TListView) or (Control is TStringGrid) or 141 (Control is TCheckBox) then begin 142 Control.Color := FTheme.ColorWindow; 143 Control.Font.Color := FTheme.ColorWindowText; 78 144 end else begin 79 Control.Color := ColorControl;80 Control.Font.Color := ColorControlText;145 Control.Color := FTheme.ColorControl; 146 Control.Font.Color := FTheme.ColorControlText; 81 147 end; 82 { if ((Component as Control).ContextMenuStrip != null)83 begin84 ApplyTheme((component as Control).ContextMenuStrip);85 end;86 end;87 88 if (component is TButton) and (Name = 'System') then89 begin90 (component as TButton).UseVisualStyleBackColor := true;91 end else92 if component is LinkLabel then93 begin94 (component as LinkLabel).LinkColor = ColorControlText;95 (component as LinkLabel).ActiveLinkColor = ColorControlText;96 (component as LinkLabel).VisitedLinkColor = ColorControlText;97 end98 else99 if component is TabControl then100 begin101 foreach (TabPage tabPage in (component as TabControl).TabPages)102 begin103 ApplyTheme(tabPage);104 end;105 end else106 if component is TToolStrip then107 begin108 (component as ToolStrip).RenderMode = ToolStripRenderMode.Professional;109 (component as ToolStrip).Renderer = new ToolStripProfessionalRenderer(new ThemeColorTable());110 foreach (ToolStripItem item in (component as ToolStrip).Items)111 begin112 if item is TToolStripMenuItem then113 begin114 115 if ((item as ToolStripMenuItem).HasDropDownItems)116 foreach (ToolStripItem dropDownItem in (item as ToolStripMenuItem).DropDownItems)117 begin118 ApplyTheme(dropDownItem);119 end;120 end;121 ApplyTheme(item);122 end;123 end else124 if component is TToolStripItem then125 begin126 (component as ToolStripItem).ForeColor = ColorControlText;127 (component as ToolStripItem).BackColor = ColorControl;128 end else129 if component is TDataGridView then130 begin131 (component as DataGridView).BackgroundColor = ColorWindow;132 (component as DataGridView).DefaultCellStyle.BackColor = ColorWindow;133 (component as DataGridView).DefaultCellStyle.ForeColor = ColorWindowText;134 (component as DataGridView).ColumnHeadersDefaultCellStyle.BackColor = ColorWindow;135 (component as DataGridView).ColumnHeadersDefaultCellStyle.ForeColor = ColorWindowText;136 end;137 end;138 }139 148 end; 140 149 end; 141 150 142 procedure TTheme .UseTheme(Form: TForm);151 procedure TThemeManager.UseTheme(Form: TForm); 143 152 begin 144 if not Used and (FTheme Name = 'System') then Exit;153 if not Used and (FTheme.Name = 'System') then Exit; 145 154 ApplyTheme(Form); 146 155 Used := True;
Note:
See TracChangeset
for help on using the changeset viewer.