Changeset 507


Ignore:
Timestamp:
Mar 29, 2018, 10:11:06 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Update Common package.
  • Added: Support for color theme.
Location:
ProjectTemplates/FileMenuProject
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • ProjectTemplates/FileMenuProject/Forms/UFormAbout.lfm

    r497 r507  
    1111  OnShow = FormShow
    1212  Position = poScreenCenter
    13   LCLVersion = '1.8.0.6'
     13  LCLVersion = '1.8.2.0'
    1414  object LabelDescription: TLabel
    1515    Left = 25
  • ProjectTemplates/FileMenuProject/Forms/UFormAbout.pas

    r497 r507  
    4949procedure TFormAbout.FormShow(Sender: TObject);
    5050begin
     51  Core.ThemeManager1.UseTheme(Self);
    5152  if Assigned(ApplicationInfo) then begin
    5253    LabelAppName.Caption := ApplicationInfo.AppName;
  • ProjectTemplates/FileMenuProject/Forms/UFormMain.lfm

    r497 r507  
    1313  OnCreate = FormCreate
    1414  OnShow = FormShow
    15   LCLVersion = '1.8.0.6'
     15  LCLVersion = '1.8.2.0'
    1616  object CoolBar1: TCoolBar
    1717    Left = 0
  • ProjectTemplates/FileMenuProject/Forms/UFormMain.pas

    r499 r507  
    4646    procedure MenuItemToolbarClick(Sender: TObject);
    4747  private
     48    procedure SetToolbarHints;
    4849    procedure UpdateFormTitle;
    4950  public
     
    7071begin
    7172  Core.PersistentForm1.Save(Self);
     73  Core.Finalize;
    7274end;
    7375
     
    7880end;
    7981
    80 procedure TFormMain.FormCreate(Sender: TObject);
     82procedure TFormMain.SetToolbarHints;
    8183var
    8284  I: Integer;
     85  J: Integer;
     86  Control: TControl;
    8387begin
    84   for I := 0 to ToolBarFile.ButtonCount - 1 do
    85     ToolBarFile.Buttons[I].Hint := ToolBarFile.Buttons[I].Caption;
     88 for J := 0 to CoolBar1.ControlCount - 1 do begin
     89    Control := CoolBar1.Controls[J];
     90    if Control is TToolBar then begin
     91      for I := 0 to TToolBar(Control).ButtonCount - 1 do begin
     92        TToolBar(Control).Buttons[I].ShowHint := True;
     93        TToolBar(Control).Buttons[I].Hint := TToolBar(Control).Buttons[I].Caption;
     94      end;
     95    end;
     96  end;
     97end;
     98
     99procedure TFormMain.FormCreate(Sender: TObject);
     100begin
    86101end;
    87102
    88103procedure TFormMain.FormShow(Sender: TObject);
    89104begin
     105  Core.Initialize;
    90106  Core.PersistentForm1.Load(Self);
    91   Core.Initialize;
     107  Core.ThemeManager1.UseTheme(Self);
     108  SetToolbarHints;
    92109end;
    93110
  • ProjectTemplates/FileMenuProject/Forms/UFormSettings.lfm

    r497 r507  
    11object FormSettings: TFormSettings
    2   Left = 798
    3   Height = 300
    4   Top = 367
    5   Width = 481
     2  Left = 429
     3  Height = 336
     4  Top = 289
     5  Width = 530
    66  Caption = 'Settings'
    7   ClientHeight = 300
    8   ClientWidth = 481
     7  ClientHeight = 336
     8  ClientWidth = 530
    99  Constraints.MinHeight = 300
    1010  Constraints.MinWidth = 400
    1111  DesignTimePPI = 120
     12  OnClose = FormClose
    1213  OnCreate = FormCreate
    1314  OnShow = FormShow
    1415  Position = poScreenCenter
    15   LCLVersion = '1.8.0.6'
    16   object ComboBoxLanguage: TComboBox
    17     Left = 160
    18     Height = 28
    19     Top = 30
    20     Width = 260
    21     ItemHeight = 20
    22     Style = csDropDownList
    23     TabOrder = 0
    24   end
    25   object Label1: TLabel
    26     Left = 20
    27     Height = 20
    28     Top = 30
    29     Width = 68
    30     Caption = 'Language:'
    31     ParentColor = False
    32   end
     16  LCLVersion = '1.8.2.0'
    3317  object ButtonOk: TButton
    34     Left = 376
     18    Left = 425
    3519    Height = 31
    36     Top = 256
     20    Top = 292
    3721    Width = 94
    3822    Anchors = [akRight, akBottom]
     
    4024    ModalResult = 1
    4125    OnClick = ButtonOkClick
    42     TabOrder = 2
     26    TabOrder = 1
    4327  end
    4428  object ButtonCancel: TButton
    45     Left = 256
     29    Left = 305
    4630    Height = 31
    47     Top = 256
     31    Top = 292
    4832    Width = 94
    4933    Anchors = [akRight, akBottom]
    5034    Caption = 'Cancel'
    5135    ModalResult = 2
    52     TabOrder = 1
     36    TabOrder = 0
    5337  end
    54   object CheckBoxAutomaticDPI: TCheckBox
    55     Left = 16
    56     Height = 24
    57     Top = 104
    58     Width = 120
    59     Caption = 'Automatic DPI'
    60     OnChange = CheckBoxAutomaticDPIChange
    61     TabOrder = 3
    62     Visible = False
    63   end
    64   object SpinEditDPI: TSpinEdit
    65     Left = 152
    66     Height = 28
    67     Top = 144
    68     Width = 121
    69     MaxValue = 300
    70     MinValue = 96
    71     TabOrder = 4
    72     Value = 96
    73     Visible = False
    74   end
    75   object LabelDPI: TLabel
    76     Left = 80
    77     Height = 20
    78     Top = 152
    79     Width = 26
    80     Caption = 'DPI:'
    81     ParentColor = False
    82     Visible = False
    83   end
    84   object CheckBoxReopenLastFileOnStart: TCheckBox
    85     Left = 16
    86     Height = 24
    87     Top = 72
    88     Width = 181
    89     Caption = 'Reopen last file on start'
    90     TabOrder = 5
    91   end
    92   object Bevel1: TBevel
    93     Left = 10
    94     Height = 2
    95     Top = 240
    96     Width = 456
    97     Anchors = [akLeft, akRight, akBottom]
     38  object PageControl1: TPageControl
     39    Left = 8
     40    Height = 278
     41    Top = 8
     42    Width = 513
     43    ActivePage = TabSheetGeneral
     44    Anchors = [akTop, akLeft, akRight, akBottom]
     45    TabIndex = 0
     46    TabOrder = 2
     47    object TabSheetGeneral: TTabSheet
     48      Caption = 'General'
     49      ClientHeight = 245
     50      ClientWidth = 505
     51      object ComboBoxLanguage: TComboBox
     52        Left = 160
     53        Height = 28
     54        Top = 30
     55        Width = 260
     56        ItemHeight = 20
     57        Style = csDropDownList
     58        TabOrder = 0
     59      end
     60      object Label1: TLabel
     61        Left = 20
     62        Height = 20
     63        Top = 30
     64        Width = 68
     65        Caption = 'Language:'
     66        ParentColor = False
     67      end
     68      object CheckBoxAutomaticDPI: TCheckBox
     69        Left = 16
     70        Height = 24
     71        Top = 104
     72        Width = 120
     73        Caption = 'Automatic DPI'
     74        OnChange = CheckBoxAutomaticDPIChange
     75        TabOrder = 1
     76        Visible = False
     77      end
     78      object SpinEditDPI: TSpinEdit
     79        Left = 152
     80        Height = 28
     81        Top = 144
     82        Width = 121
     83        MaxValue = 300
     84        MinValue = 96
     85        TabOrder = 2
     86        Value = 96
     87        Visible = False
     88      end
     89      object LabelDPI: TLabel
     90        Left = 80
     91        Height = 20
     92        Top = 146
     93        Width = 26
     94        Caption = 'DPI:'
     95        ParentColor = False
     96        Visible = False
     97      end
     98      object CheckBoxReopenLastFileOnStart: TCheckBox
     99        Left = 16
     100        Height = 24
     101        Top = 72
     102        Width = 181
     103        Caption = 'Reopen last file on start'
     104        TabOrder = 3
     105      end
     106      object Label2: TLabel
     107        Left = 20
     108        Height = 20
     109        Top = 184
     110        Width = 48
     111        Caption = 'Theme:'
     112        ParentColor = False
     113      end
     114      object ComboBoxTheme: TComboBox
     115        Left = 160
     116        Height = 28
     117        Top = 184
     118        Width = 260
     119        ItemHeight = 20
     120        Style = csDropDownList
     121        TabOrder = 4
     122      end
     123    end
    98124  end
    99125end
  • ProjectTemplates/FileMenuProject/Forms/UFormSettings.pas

    r497 r507  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Menus, Spin, ExtCtrls, ULanguages;
     9  Menus, Spin, ExtCtrls, ComCtrls, ULanguages;
    1010
    1111type
     
    1414
    1515  TFormSettings = class(TForm)
    16     Bevel1: TBevel;
    1716    ButtonOk: TButton;
    1817    ButtonCancel: TButton;
     18    CheckBoxAutomaticDPI: TCheckBox;
    1919    CheckBoxReopenLastFileOnStart: TCheckBox;
    20     CheckBoxAutomaticDPI: TCheckBox;
    2120    ComboBoxLanguage: TComboBox;
     21    ComboBoxTheme: TComboBox;
    2222    Label1: TLabel;
     23    Label2: TLabel;
    2324    LabelDPI: TLabel;
     25    PageControl1: TPageControl;
    2426    SpinEditDPI: TSpinEdit;
     27    TabSheetGeneral: TTabSheet;
    2528    procedure ButtonOkClick(Sender: TObject);
    2629    procedure CheckBoxAutomaticDPIChange(Sender: TObject);
    2730    procedure CheckBoxStartOnLogonChange(Sender: TObject);
     31    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2832    procedure FormCreate(Sender: TObject);
    2933    procedure FormShow(Sender: TObject);
     
    4448
    4549uses
    46   UCore;
     50  UCore, UTheme;
    4751
    4852{ TFormSettings }
     
    5054procedure TFormSettings.FormShow(Sender: TObject);
    5155begin
    52   Core.CoolTranslator1.LanguageListToStrings(ComboBoxLanguage.Items);
    53   ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
    54   if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
     56  Core.PersistentForm1.Load(Self);
     57  Core.ThemeManager1.UseTheme(Self);
    5558end;
    5659
    5760procedure TFormSettings.ButtonOkClick(Sender: TObject);
    5861begin
    59   if ComboBoxLanguage.ItemIndex <> -1 then
    60     Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
    6162end;
    6263
     
    7172end;
    7273
     74procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction
     75  );
     76begin
     77  Core.PersistentForm1.Save(Self);
     78end;
     79
    7380procedure TFormSettings.FormCreate(Sender: TObject);
    7481begin
     
    8188  SpinEditDPI.Value := Core.ScaleDPI1.DPI.X;
    8289  CheckBoxReopenLastFileOnStart.Checked := Core.ReopenLastFileOnStart;
     90
     91  Core.CoolTranslator1.LanguageListToStrings(ComboBoxLanguage.Items);
     92  ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
     93  if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
     94
     95  Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
     96  ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.ThemeManager1.Theme);
     97  if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
     98
    8399  UpdateInterface;
    84100end;
     
    89105  Core.ScaleDPI1.DPI := Point(SpinEditDPI.Value, SpinEditDPI.Value);
    90106  Core.ReopenLastFileOnStart := CheckBoxReopenLastFileOnStart.Checked;
     107  if ComboBoxLanguage.ItemIndex <> -1 then
     108    Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
     109  if ComboBoxTheme.ItemIndex <> -1 then
     110    Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
    91111end;
    92112
  • ProjectTemplates/FileMenuProject/Languages/FileMenuProject.cs.po

    r498 r507  
    131131msgstr "Jazyk:"
    132132
     133#: tformsettings.label2.caption
     134msgid "Theme:"
     135msgstr "Téma:"
     136
    133137#: tformsettings.labeldpi.caption
    134138msgid "DPI:"
    135139msgstr "DPI:"
     140
     141#: tformsettings.tabsheetgeneral.caption
     142msgid "General"
     143msgstr "Obecné"
    136144
    137145#: ucore.sappexit
     
    143151msgstr "Soubor byl upraven. Chcete jej uložit před ukončením?"
    144152
     153#: udatafile.sallfiles
     154msgid "All files"
     155msgstr "Všechny soubory"
     156
    145157#: udatafile.sdatafilename
    146158msgctxt "udatafile.sdatafilename"
    147159msgid "File"
    148160msgstr "Soubor"
     161
     162#: udatafile.sdatafiles
     163msgid "Data files"
     164msgstr "Datové soubory"
    149165
    150166#: uformabout.slicense
     
    163179msgid "Modified"
    164180msgstr "Upraveno"
     181
     182#: uproject.sprojectfiles
     183msgid "Project files"
     184msgstr "Projektové soubory"
     185
     186#: uproject.sprojectname
     187msgid "New project"
     188msgstr "Nový projekt"
  • ProjectTemplates/FileMenuProject/Languages/FileMenuProject.po

    r497 r507  
    121121msgstr ""
    122122
     123#: tformsettings.label2.caption
     124msgid "Theme:"
     125msgstr ""
     126
    123127#: tformsettings.labeldpi.caption
    124128msgid "DPI:"
     129msgstr ""
     130
     131#: tformsettings.tabsheetgeneral.caption
     132msgid "General"
    125133msgstr ""
    126134
     
    133141msgstr ""
    134142
     143#: udatafile.sallfiles
     144msgid "All files"
     145msgstr ""
     146
    135147#: udatafile.sdatafilename
    136148msgctxt "udatafile.sdatafilename"
    137149msgid "File"
     150msgstr ""
     151
     152#: udatafile.sdatafiles
     153msgid "Data files"
    138154msgstr ""
    139155
     
    154170msgstr ""
    155171
     172#: uproject.sprojectfiles
     173msgid "Project files"
     174msgstr ""
     175
     176#: uproject.sprojectname
     177msgid "New project"
     178msgstr ""
     179
  • ProjectTemplates/FileMenuProject/Packages/Common/Common.lpk

    r498 r507  
    1111      <PathDelim Value="\"/>
    1212      <SearchPaths>
    13         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     13        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    1414      </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>
    1538    </CompilerOptions>
    1639    <Description Value="Various libraries"/>
    1740    <License Value="GNU/GPL"/>
    1841    <Version Minor="7"/>
    19     <Files Count="20">
     42    <Files Count="21">
    2043      <Item1>
    2144        <Filename Value="StopWatch.pas"/>
     
    106129        <UnitName Value="UScaleDPI"/>
    107130      </Item20>
     131      <Item21>
     132        <Filename Value="UTheme.pas"/>
     133        <HasRegisterProc Value="True"/>
     134        <UnitName Value="UTheme"/>
     135      </Item21>
    108136    </Files>
    109137    <i18n>
  • ProjectTemplates/FileMenuProject/Packages/Common/Common.pas

    r498 r507  
    88
    99uses
    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;
    1414
    1515implementation
     
    2525  RegisterUnit('UFindFile', @UFindFile.Register);
    2626  RegisterUnit('UScaleDPI', @UScaleDPI.Register);
     27  RegisterUnit('UTheme', @UTheme.Register);
    2728end;
    2829
  • ProjectTemplates/FileMenuProject/Packages/Common/UCommon.pas

    r498 r507  
    2828    unfDNSDomainName = 11);
    2929
     30  TFilterMethodMethod = function (FileName: string): Boolean of object;
    3031var
    3132  ExceptionHandler: TExceptionEvent;
     
    6364procedure OpenWebPage(URL: string);
    6465procedure OpenFileInShell(FileName: string);
    65 procedure ExecuteProgram(CommandLine: string);
     66procedure ExecuteProgram(Executable: string; Parameters: array of string);
    6667procedure FreeThenNil(var Obj);
    6768function RemoveQuotes(Text: string): string;
     
    7071function GetDirCount(Dir: string): Integer;
    7172function MergeArray(A, B: array of string): TArrayOfString;
     73function LoadFileToStr(const FileName: TFileName): AnsiString;
     74procedure SearchFiles(AList: TStrings; Dir: string;
     75  FilterMethod: TFilterMethodMethod);
    7276
    7377
     
    111115  Path := IncludeTrailingPathDelimiter(APath);
    112116
    113   Find := FindFirst(UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec);
     117  Find := FindFirst(Path + AFileSpec, faAnyFile xor faDirectory, SearchRec);
    114118  while Find = 0 do begin
    115     DeleteFile(Path + UTF8Encode(SearchRec.Name));
     119    DeleteFile(Path + SearchRec.Name);
    116120
    117121    Find := SysUtils.FindNext(SearchRec);
     
    428432end;
    429433
    430 procedure ExecuteProgram(CommandLine: string);
     434procedure ExecuteProgram(Executable: string; Parameters: array of string);
    431435var
    432436  Process: TProcess;
     437  I: Integer;
    433438begin
    434439  try
    435440    Process := TProcess.Create(nil);
    436     Process.CommandLine := CommandLine;
     441    Process.Executable := Executable;
     442    for I := 0 to Length(Parameters) - 1 do
     443      Process.Parameters.Add(Parameters[I]);
    437444    Process.Options := [poNoConsole];
    438445    Process.Execute;
     
    455462procedure OpenFileInShell(FileName: string);
    456463begin
    457   ExecuteProgram('cmd.exe /c start "' + FileName + '"');
     464  ExecuteProgram('cmd.exe', ['/c', 'start', FileName]);
    458465end;
    459466
     
    492499end;
    493500
     501function LoadFileToStr(const FileName: TFileName): AnsiString;
     502var
     503  FileStream: TFileStream;
     504  Read: Integer;
     505begin
     506  Result := '';
     507  FileStream := TFileStream.Create(FileName, fmOpenRead);
     508  try
     509    if FileStream.Size > 0 then begin
     510      SetLength(Result, FileStream.Size);
     511      Read := FileStream.Read(Pointer(Result)^, FileStream.Size);
     512      SetLength(Result, Read);
     513    end;
     514  finally
     515    FileStream.Free;
     516  end;
     517end;
     518
     519function DefaultSearchFilter(const FileName: string): Boolean;
     520begin
     521  Result := True;
     522end;
     523
     524procedure SearchFiles(AList: TStrings; Dir: string;
     525  FilterMethod: TFilterMethodMethod);
     526var
     527  SR: TSearchRec;
     528begin
     529  Dir := IncludeTrailingPathDelimiter(Dir);
     530  if FindFirst(Dir + '*', faAnyFile, SR) = 0 then
     531    try
     532      repeat
     533        if (SR.Name = '.') or (SR.Name = '..') or not FilterMethod(SR.Name) then Continue;
     534        AList.Add(Dir + SR.Name);
     535        if (SR.Attr and faDirectory) <> 0 then
     536          SearchFiles(AList, Dir + SR.Name, FilterMethod);
     537      until FindNext(SR) <> 0;
     538    finally
     539      FindClose(SR);
     540    end;
     541end;
    494542
    495543
  • ProjectTemplates/FileMenuProject/Packages/Common/UJobProgressView.lfm

    r498 r507  
    11object FormJobProgressView: TFormJobProgressView
    2   Left = 656
     2  Left = 467
    33  Height = 246
    4   Top = 354
     4  Top = 252
    55  Width = 328
    66  BorderIcons = [biSystemMenu]
  • ProjectTemplates/FileMenuProject/Packages/Common/UListViewSort.pas

    r498 r507  
    8181    FOnChange: TNotifyEvent;
    8282    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);
    8585  public
    8686    constructor Create(AOwner: TComponent); override;
     
    110110{ TListViewFilter }
    111111
    112 procedure TListViewFilter.DoOnKeyUp(Sender: TObject; var Key: Word;
     112procedure TListViewFilter.GridDoOnKeyUp(Sender: TObject; var Key: Word;
    113113  Shift: TShiftState);
    114114begin
     
    117117end;
    118118
    119 procedure TListViewFilter.DoOnResize(Sender: TObject);
     119procedure TListViewFilter.GridDoOnResize(Sender: TObject);
    120120begin
    121121  FStringGrid1.DefaultRowHeight := FStringGrid1.Height;
     
    135135  FStringGrid1.Options := [goFixedHorzLine, goFixedVertLine, goVertLine,
    136136    goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll];
    137   FStringGrid1.OnKeyUp := DoOnKeyUp;
    138   FStringGrid1.OnResize := DoOnResize;
     137  FStringGrid1.OnKeyUp := GridDoOnKeyUp;
     138  FStringGrid1.OnResize := GridDoOnResize;
    139139end;
    140140
     
    144144begin
    145145  with FStringGrid1 do begin
     146    Options := Options - [goEditing, goAlwaysShowEditor];
    146147    //Columns.Clear;
    147148    while Columns.Count > ListView.Columns.Count do Columns.Delete(Columns.Count - 1);
     
    150151      Columns[I].Width := ListView.Columns[I].Width;
    151152    end;
     153    Options := Options + [goEditing, goAlwaysShowEditor];
    152154  end;
    153155end;
     
    197199  if AMsg.Msg = WM_NOTIFY then
    198200  begin
    199     Code := PHDNotify(vMsgNotify.NMHdr)^.Hdr.Code;
     201    Code := NMHDR(PHDNotify(vMsgNotify.NMHdr)^.Hdr).Code;
    200202    case Code of
    201203      HDN_ENDTRACKA, HDN_ENDTRACKW:
     
    353355  TP1: TPoint;
    354356  XBias, YBias: Integer;
    355   OldColor: TColor;
     357  PenColor: TColor;
     358  BrushColor: TColor;
    356359  BiasTop, BiasLeft: Integer;
    357360  Rect1: TRect;
     
    365368  Item.Left := 0;
    366369  GetCheckBias(XBias, YBias, BiasTop, BiasLeft, ListView);
    367   OldColor := ListView.Canvas.Pen.Color;
     370  PenColor := ListView.Canvas.Pen.Color;
     371  BrushColor := ListView.Canvas.Brush.Color;
    368372  //TP1 := Item.GetPosition;
    369373  lRect := Item.DisplayRect(drBounds); // Windows 7 workaround
     
    408412  end;
    409413  //ListView.Canvas.Brush.Color := ListView.Color;
    410   ListView.Canvas.Brush.Color := clWindow;
    411   ListView.Canvas.Pen.Color := OldColor;
     414  ListView.Canvas.Brush.Color := BrushColor;
     415  ListView.Canvas.Pen.Color := PenColor;
    412416end;
    413417
  • ProjectTemplates/FileMenuProject/UCore.lfm

    r497 r507  
    99  PPI = 120
    1010  object ImageList1: TImageList
    11     left = 160
    12     top = 231
     11    left = 280
     12    top = 120
    1313    Bitmap = {
    1414      4C69090000001000000010000000000000000000000000000000000000000000
     
    305305  object ActionList1: TActionList
    306306    Images = ImageList1
    307     left = 340
    308     top = 233
     307    left = 280
     308    top = 56
    309309    object AExit: TAction
    310310      Caption = 'Exit'
     
    369369    MaxCount = 10
    370370    OnChange = LastOpenedList1Change
    371     left = 509
    372     top = 231
     371    left = 88
     372    top = 312
    373373  end
    374374  object OpenDialog1: TOpenDialog
    375     left = 520
    376     top = 322
     375    left = 280
     376    top = 184
    377377  end
    378378  object SaveDialog1: TSaveDialog
    379     left = 375
    380     top = 329
     379    left = 280
     380    top = 248
    381381  end
    382382  object ApplicationInfo1: TApplicationInfo
     
    394394    RegistryRoot = rrKeyCurrentUser
    395395    License = 'CC0'
    396     left = 191
    397     top = 329
     396    left = 88
     397    top = 184
    398398  end
    399399  object PersistentForm1: TPersistentForm
    400400    MinVisiblePart = 50
    401401    EntireVisible = False
    402     left = 520
    403     top = 72
     402    left = 88
     403    top = 248
    404404  end
    405405  object CoolTranslator1: TCoolTranslator
    406406    POFilesFolder = 'Languages'
    407     left = 239
    408     top = 72
     407    left = 88
     408    top = 56
    409409  end
    410410  object ScaleDPI1: TScaleDPI
    411411    AutoDetect = False
    412     left = 376
    413     top = 72
     412    left = 88
     413    top = 128
     414  end
     415  object ThemeManager1: TThemeManager
     416    left = 280
     417    top = 312
    414418  end
    415419end
  • ProjectTemplates/FileMenuProject/UCore.pas

    r499 r507  
    88  Classes, SysUtils, FileUtil, Controls, ActnList, Forms, Dialogs,
    99  ULastOpenedList, UApplicationInfo, UPersistentForm, UScaleDPI, UCommon,
    10   UCoolTranslator, UDataFile, Menus, URegistry, Registry;
     10  UCoolTranslator, UDataFile, Menus, URegistry, UTheme, Registry;
    1111
    1212type
     
    3434    SaveDialog1: TSaveDialog;
    3535    ScaleDPI1: TScaleDPI;
     36    ThemeManager1: TThemeManager;
    3637    procedure AAboutExecute(Sender: TObject);
    3738    procedure AExitExecute(Sender: TObject);
     
    5758  public
    5859    DataFile: TDataFile;
     60    DataFileClass: TDataFileClass;
     61
    5962    FileClosed: Boolean;
    6063    ReopenLastFileOnStart: Boolean;
     
    6467    procedure FileClose;
    6568    procedure Initialize;
     69    procedure Finalize;
    6670    procedure UpdateInterface;
    6771  end;
     
    130134
    131135procedure TCore.AFileOpenExecute(Sender: TObject);
     136var
     137  TempFile: TDataFile;
    132138begin
    133139  OpenDialog1.DefaultExt := '';
     140  TempFile := DataFileClass.Create;
     141  try
     142    OpenDialog1.Filter := TempFile.GetFileDialogFilter;
     143    OpenDialog1.DefaultExt := TempFile.GetFileExt;
     144  finally
     145    TempFile.Free;
     146  end;
    134147  if Assigned(DataFile) then begin
    135148    OpenDialog1.InitialDir := ExtractFileDir(DataFile.FileName);
     
    153166  SaveDialog1.InitialDir := ExtractFileDir(DataFile.FileName);
    154167  SaveDialog1.FileName := ExtractFileName(DataFile.FileName);
     168  SaveDialog1.Filter := DataFile.GetFileDialogFilter;
    155169  if SaveDialog1.Execute then begin
    156170    DataFile.SaveToFile(SaveDialog1.FileName);
     
    173187  DataFile := nil;
    174188  FileClosed := True;
     189  DataFileClass := TDataFile;
    175190end;
    176191
    177192procedure TCore.DataModuleDestroy(Sender: TObject);
    178193begin
    179   SaveConfig;
    180194end;
    181195
     
    255269    FormMain.MenuItemToolbar.Checked := ReadBoolWithDefault('ToolBarVisible', True);
    256270    ReopenLastFileOnStart := ReadBoolWithDefault('ReopenLastFileOnStart', True);
     271    ThemeManager1.Theme := ThemeManager1.Themes.FindByName(ReadStringWithDefault('Theme', 'System'));
    257272  finally
    258273    Free;
     
    273288    WriteBool('ToolBarVisible', FormMain.MenuItemToolbar.Checked);
    274289    WriteBool('ReopenLastFileOnStart', ReopenLastFileOnStart);
     290    WriteString('Theme', ThemeManager1.Theme.Name);
    275291  finally
    276292    Free;
     
    311327end;
    312328
     329procedure TCore.Finalize;
     330begin
     331  SaveConfig;
     332end;
     333
    313334function TCore.FindFirstNonOption: string;
    314335var
  • ProjectTemplates/FileMenuProject/UDataFile.pas

    r497 r507  
    2020  public
    2121    function GetFileExt: string; virtual;
     22    function GetFileDialogFilter: string; virtual;
    2223    procedure LoadFromFile(FileName: string); virtual;
    2324    procedure SaveToFile(FileName: string); virtual;
     
    2829  end;
    2930
     31  TDataFileClass = class of TDataFile;
     32
    3033  TDataFiles = class(TObjectList)
    3134  end;
    3235
     36
     37resourcestring
     38  SAllFiles = 'All files';
    3339
    3440implementation
     
    3642resourcestring
    3743  SDataFileName = 'File';
     44  SDataFiles = 'Data files';
     45
    3846
    3947{ TDataFile }
     
    4856begin
    4957  Result := '.dat';
     58end;
     59
     60function TDataFile.GetFileDialogFilter: string;
     61begin
     62  Result := SDataFiles + ' (' + GetFileExt + ')|*' + GetFileExt + '|' +
     63    SAllFiles + '|*.*';
    5064end;
    5165
  • ProjectTemplates/FileMenuProject/UProject.pas

    r497 r507  
    1717    constructor Create; override;
    1818    function GetFileExt: string; override;
     19    function GetFileDialogFilter: string; override;
    1920  end;
    2021
    2122
    2223implementation
     24
     25resourcestring
     26  SProjectName = 'New project';
     27  SProjectFiles = 'Project files';
    2328
    2429
     
    2833begin
    2934  inherited Create;
     35  FileName := SProjectName + GetFileExt;
    3036end;
    3137
     
    3541end;
    3642
     43function TProject.GetFileDialogFilter: string;
     44begin
     45  Result := SProjectFiles + ' (' + GetFileExt + ')|*' + GetFileExt + '|' +
     46    SAllFiles + '|*.*';
     47end;
     48
    3749end.
    3850
Note: See TracChangeset for help on using the changeset viewer.