Changeset 228


Ignore:
Timestamp:
Jun 24, 2023, 12:33:35 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Use TFormEx for all forms.
  • Modified: Test forms moved into Common package.
Location:
branches/xpascal
Files:
10 added
9 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Forms/FormMain.lfm

    r227 r228  
    11object FormMain: TFormMain
    2   Left = 515
     2  Left = 482
    33  Height = 993
    4   Top = 67
     4  Top = 205
    55  Width = 1491
    66  Caption = 'Interpreter'
     
    1010  Menu = MainMenu1
    1111  OnActivate = FormActivate
    12   OnClose = FormClose
    1312  OnCreate = FormCreate
    1413  OnDestroy = FormDestroy
  • branches/xpascal/Forms/FormMain.pas

    r227 r228  
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus,
    77  ActnList, ExtCtrls, SynHighlighterPas, SynEdit, Source, Optimizer,
    8   Generator, FormSource, FormMessages, FormOutput;
     8  Generator, FormSource, FormMessages, FormOutput, FormEx;
    99
    1010type
     
    1212  { TFormMain }
    1313
    14   TFormMain = class(TForm)
     14  TFormMain = class(TFormEx)
    1515    ACompile: TAction;
    1616    ATest: TAction;
     
    4646    procedure AGenerateXmlExecute(Sender: TObject);
    4747    procedure ATestExecute(Sender: TObject);
    48     procedure FormCreate(Sender: TObject);
    4948    procedure Optimize(Features: TOptimizeFeatures);
    5049    procedure ARunExecute(Sender: TObject);
    5150    procedure FormActivate(Sender: TObject);
    52     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     51    procedure FormCreate(Sender: TObject);
    5352    procedure FormDestroy(Sender: TObject);
    5453    procedure FormShow(Sender: TObject);
     
    7574
    7675uses
    77   Parser, Executor, GeneratorPascal, GeneratorPhp, FormTests,
     76  Parser, Executor, GeneratorPascal, GeneratorPhp, FormTests, Translator,
    7877  GeneratorCSharp, GeneratorXml, ParserPascal;
    7978
     
    8988end;
    9089
    91 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    92 begin
    93 end;
    94 
    9590procedure TFormMain.FormDestroy(Sender: TObject);
    9691begin
    9792  if Assigned(Prog) then FreeAndNil(Prog);
    98   FreeAndNil(FormSource);
    99   FreeAndNil(FormMessages);
    100   FreeAndNil(FormOutput);
     93  if Assigned(FormSource) then FreeAndNil(FormSource);
     94  if Assigned(FormMessages) then FreeAndNil(FormMessages);
     95  if Assigned(FormOutput) then FreeAndNil(FormOutput);
    10196end;
    10297
     
    211206procedure TFormMain.FormCreate(Sender: TObject);
    212207begin
     208  Translator.POFilesFolder := 'Languages;Packages/Common/Languages';
     209  Translator.Language := Translator.Languages.SearchByCode('');
    213210end;
    214211
  • branches/xpascal/Languages/xpascal.cs.po

    r227 r228  
    113113msgstr "Zdroj:"
    114114
    115 #: tformtest.arun.caption
    116 msgctxt "tformtest.arun.caption"
    117 msgid "Run"
    118 msgstr "Spustit"
    119 
    120 #: tformtest.ashow.caption
    121 msgid "Show"
    122 msgstr "Ukázat"
    123 
    124 #: tformtest.buttonrun.caption
    125 msgctxt "tformtest.buttonrun.caption"
    126 msgid "Run"
    127 msgstr "Spustit"
    128 
    129 #: tformtest.caption
    130 msgctxt "tformtest.caption"
    131 msgid "Test"
    132 msgstr "Test"
    133 
    134 #: tformtest.labelresult.caption
    135 msgid "   "
    136 msgstr "   "
    137 
    138 #: tformtest.listviewtestcases.columns[0].caption
    139 msgid "Name"
    140 msgstr "Jméno"
    141 
    142 #: tformtest.listviewtestcases.columns[1].caption
    143 msgid "Result"
    144 msgstr "VÃœsledek"
    145 
    146 #: tformtestcase.caption
    147 msgid "Test case"
    148 msgstr "TestovÃœ případ"
  • branches/xpascal/Languages/xpascal.pot

    r227 r228  
    103103msgstr ""
    104104
    105 #: tformtest.arun.caption
    106 msgctxt "tformtest.arun.caption"
    107 msgid "Run"
    108 msgstr ""
    109 
    110 #: tformtest.ashow.caption
    111 msgid "Show"
    112 msgstr ""
    113 
    114 #: tformtest.buttonrun.caption
    115 msgctxt "tformtest.buttonrun.caption"
    116 msgid "Run"
    117 msgstr ""
    118 
    119 #: tformtest.caption
    120 msgctxt "tformtest.caption"
    121 msgid "Test"
    122 msgstr ""
    123 
    124 #: tformtest.labelresult.caption
    125 msgid "   "
    126 msgstr ""
    127 
    128 #: tformtest.listviewtestcases.columns[0].caption
    129 msgid "Name"
    130 msgstr ""
    131 
    132 #: tformtest.listviewtestcases.columns[1].caption
    133 msgid "Result"
    134 msgstr ""
    135 
    136 #: tformtestcase.caption
    137 msgid "Test case"
    138 msgstr ""
    139 
  • branches/xpascal/Packages/Common/Common.lpk

    r227 r228  
    1111      <PathDelim Value="\"/>
    1212      <SearchPaths>
     13        <OtherUnitFiles Value="Forms"/>
    1314        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    1415      </SearchPaths>
     
    4243    <License Value="Copy left."/>
    4344    <Version Minor="11"/>
    44     <Files Count="35">
     45    <Files Count="37">
    4546      <Item1>
    4647        <Filename Value="StopWatch.pas"/>
     
    159160      </Item26>
    160161      <Item27>
    161         <Filename Value="FormAbout.pas"/>
    162         <UnitName Value="FormAbout"/>
     162        <Filename Value="AboutDialog.pas"/>
     163        <HasRegisterProc Value="True"/>
     164        <UnitName Value="AboutDialog"/>
    163165      </Item27>
    164166      <Item28>
    165         <Filename Value="AboutDialog.pas"/>
    166         <HasRegisterProc Value="True"/>
    167         <UnitName Value="AboutDialog"/>
     167        <Filename Value="PixelPointer.pas"/>
     168        <UnitName Value="PixelPointer"/>
    168169      </Item28>
    169170      <Item29>
    170         <Filename Value="PixelPointer.pas"/>
    171         <UnitName Value="PixelPointer"/>
     171        <Filename Value="DataFile.pas"/>
     172        <UnitName Value="DataFile"/>
    172173      </Item29>
    173174      <Item30>
    174         <Filename Value="DataFile.pas"/>
    175         <UnitName Value="DataFile"/>
     175        <Filename Value="TestCase.pas"/>
     176        <UnitName Value="TestCase"/>
    176177      </Item30>
    177178      <Item31>
    178         <Filename Value="TestCase.pas"/>
    179         <UnitName Value="TestCase"/>
     179        <Filename Value="Generics.pas"/>
     180        <UnitName Value="Generics"/>
    180181      </Item31>
    181182      <Item32>
    182         <Filename Value="Generics.pas"/>
    183         <UnitName Value="Generics"/>
    184       </Item32>
    185       <Item33>
    186183        <Filename Value="CommonPackage.pas"/>
    187184        <Type Value="Main Unit"/>
    188185        <UnitName Value="CommonPackage"/>
     186      </Item32>
     187      <Item33>
     188        <Filename Value="Table.pas"/>
     189        <UnitName Value="Table"/>
    189190      </Item33>
    190191      <Item34>
    191         <Filename Value="Table.pas"/>
    192         <UnitName Value="Table"/>
     192        <Filename Value="FormEx.pas"/>
     193        <HasRegisterProc Value="True"/>
     194        <UnitName Value="FormEx"/>
    193195      </Item34>
    194196      <Item35>
    195         <Filename Value="FormEx.pas"/>
    196         <HasRegisterProc Value="True"/>
    197         <UnitName Value="FormEx"/>
     197        <Filename Value="Forms\FormTests.pas"/>
     198        <UnitName Value="FormTests"/>
    198199      </Item35>
     200      <Item36>
     201        <Filename Value="Forms\FormTest.pas"/>
     202        <UnitName Value="FormTest"/>
     203      </Item36>
     204      <Item37>
     205        <Filename Value="Forms\FormAbout.pas"/>
     206        <UnitName Value="FormAbout"/>
     207      </Item37>
    199208    </Files>
    200209    <CompatibilityMode Value="True"/>
  • branches/xpascal/Packages/Common/CommonPackage.pas

    r227 r228  
    1313  XML, ApplicationInfo, SyncCounter, ListViewSort, PersistentForm, FindFile,
    1414  ScaleDPI, Theme, StringTable, MetaCanvas, Geometric, Translator, Languages,
    15   FormAbout, AboutDialog, PixelPointer, DataFile, TestCase, Generics, Table,
    16   FormEx, LazarusPackageIntf;
     15  AboutDialog, PixelPointer, DataFile, TestCase, Generics, Table, FormEx,
     16  FormTests, FormTest, FormAbout, LazarusPackageIntf;
    1717
    1818implementation
  • branches/xpascal/Packages/Common/FormEx.pas

    r227 r228  
    1111
    1212  TFormEx = class(TForm)
     13  private
     14    FCounter: Integer; static;
     15  public
    1316    PersistentForm: TPersistentForm; static;
    14     ThemeManager: TThemeManager;
    15     Translator: TTranslator;
     17    ThemeManager: TThemeManager; static;
     18    Translator: TTranslator; static;
    1619    procedure DoShow; override;
    1720    procedure DoCreate; override;
     
    2730procedure Register;
    2831begin
    29   RegisterClass(TFormEx);
     32  RegisterNoIcon([TFormEx]);
    3033end;
    3134
     
    3437procedure TFormEx.DoShow;
    3538begin
     39  inherited;
    3640  PersistentForm.Load(Self);
    37   inherited;
    3841end;
    3942
    4043procedure TFormEx.DoCreate;
    4144begin
    42   inherited;
    4345  if not Assigned(PersistentForm) then
    4446    PersistentForm := TPersistentForm.Create(nil);
     
    5254  Translator.TranslateComponentRecursive(Self);
    5355  ThemeManager.UseTheme(Self);
     56  Inc(FCounter);
     57  inherited;
    5458end;
    5559
     
    6266procedure TFormEx.DoDestroy;
    6367begin
    64   FreeAndNil(PersistentForm);
    65   FreeAndNil(ThemeManager);
    66   FreeAndNil(Translator);
     68  Dec(FCounter);
     69  if FCounter <= 0 then begin
     70    FreeAndNil(PersistentForm);
     71    FreeAndNil(ThemeManager);
     72    FreeAndNil(Translator);
     73  end;
    6774  inherited;
    6875end;
  • branches/xpascal/Packages/Common/Translator.pas

    r227 r228  
    173173begin
    174174  FPoFiles.Clear;
    175   if Assigned(FLanguage) then
    176   try
     175  if Assigned(FLanguage) then begin
    177176    LocaleShort := GetLocaleShort;
    178     //ShowMessage(ExtractFileDir(Application.ExeName) +
    179     //  DirectorySeparator + 'Languages' + ' ' + '*.' + LocaleShort + '.po');
    180177    SearchMask := '*';
    181178    if LocaleShort <> '' then SearchMask := SearchMask + '.' + LocaleShort;
     
    184181    for J := 0 to LangDirs.Count - 1 do begin
    185182      FileList := FindAllFiles(LangDirs[J], SearchMask);
    186       for I := 0 to FileList.Count - 1 do begin
    187         FileName := FileList[I];
    188         //FileName := FindLocaleFileName('.po');
    189         if FileExists(FileName) and (
    190         ((LocaleShort = '') and (Pos('.', FileName) = Pos(PoExt, FileName))) or
    191         (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
     183      try
     184        for I := 0 to FileList.Count - 1 do begin
     185          FileName := FileList[I];
     186          //FileName := FindLocaleFileName('.po');
     187           if FileExists(FileName) and (
     188          ((LocaleShort = '') and (Pos('.', FileName) = Pos(PoExt, FileName))) or
     189          (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
     190        end;
     191      finally
     192        FileList.Free;
    192193      end;
    193194    end;
    194195    LangDirs.Free;
    195   finally
    196     FileList.Free;
    197196  end;
    198197end;
  • branches/xpascal/xpascal.lpi

    r227 r228  
    6161        </CompilerOptions>
    6262      </Item2>
     63      <SharedMatrixOptions Count="2">
     64        <Item1 ID="376528892696" Targets="Common" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
     65        <Item2 ID="434607938817" Targets="Common" Modes="Release" Value="-CX -XX -O3"/>
     66      </SharedMatrixOptions>
    6367    </BuildModes>
    6468    <PublishOptions>
     
    8185      </Item3>
    8286    </RequiredPackages>
    83     <Units Count="19">
     87    <Units Count="17">
    8488      <Unit0>
    8589        <Filename Value="xpascal.lpr"/>
     
    162166        <IsPartOfProject Value="True"/>
    163167      </Unit16>
    164       <Unit17>
    165         <Filename Value="Forms/FormTests.pas"/>
    166         <IsPartOfProject Value="True"/>
    167         <ComponentName Value="FormTests"/>
    168         <HasResources Value="True"/>
    169         <ResourceBaseClass Value="Form"/>
    170       </Unit17>
    171       <Unit18>
    172         <Filename Value="Forms/FormTest.pas"/>
    173         <IsPartOfProject Value="True"/>
    174         <ComponentName Value="FormTestCase"/>
    175         <HasResources Value="True"/>
    176         <ResourceBaseClass Value="Form"/>
    177       </Unit18>
    178168    </Units>
    179169  </ProjectOptions>
  • branches/xpascal/xpascal.lpr

    r227 r228  
    1010  Forms, Parser, Tokenizer, Source, Executor, Interpreter, Generator,
    1111  FormMessages, FormSource, Optimizer, FormOutput, FormMain,
    12   FormTests, FormTest, ParserPascal;
     12  ParserPascal;
    1313
    1414{$R *.res}
Note: See TracChangeset for help on using the changeset viewer.