Changeset 130 for branches/generator


Ignore:
Timestamp:
Dec 24, 2017, 11:13:05 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Show rules list docked directly to main form.
Location:
branches/generator
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/generator

    • Property svn:ignore
      •  

        old new  
         1generator
        12generator.exe
        23generator.lps
        34lib
        45heaptrclog.trc
         6Generated
  • branches/generator/Forms

    • Property svn:ignore set to
      *.lrj
  • branches/generator/Forms/UFormMain.lfm

    r129 r130  
    55  Width = 1050
    66  Caption = 'Language generator'
    7   ClientHeight = 653
     7  ClientHeight = 647
    88  ClientWidth = 1050
    9   DesignTimePPI = 120
    109  Menu = MainMenu1
    1110  OnClose = FormClose
    1211  OnCloseQuery = FormCloseQuery
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.0.6'
    15   object MemoBNF: TMemo
    16     Left = 0
    17     Height = 618
    18     Top = 35
    19     Width = 1050
    20     Align = alClient
    21     ReadOnly = True
    22     ScrollBars = ssAutoBoth
    23     TabOrder = 0
    24   end
     13  LCLVersion = '1.8.0.4'
    2514  object CoolBar1: TCoolBar
    2615    Left = 0
     
    3827      AnchorSideTop.Control = CoolBar1
    3928      Left = 24
    40       Height = 22
     29      Height = 28
    4130      Top = 5
    42       Width = 124
     31      Width = 125
    4332      Align = alNone
    4433      AutoSize = True
     
    5241      TabOrder = 0
    5342      Transparent = True
    54       object ToolButton1: TToolButton
    55         Left = 78
    56         Top = 0
    57         Action = ARules
    58       end
    5943      object ToolButton2: TToolButton
    60         Left = 101
     44        Left = 96
    6145        Top = 0
    6246        Action = ABuildCompiler
     
    6852      end
    6953      object ToolButton4: TToolButton
    70         Left = 24
     54        Left = 30
    7155        Top = 0
    7256        Action = AProjectOpen
    7357      end
    7458      object ToolButton5: TToolButton
    75         Left = 47
     59        Left = 59
    7660        Top = 0
    7761        Action = AProjectSave
    7862      end
    7963      object ToolButton6: TToolButton
    80         Left = 70
    81         Height = 22
     64        Left = 88
     65        Height = 28
    8266        Top = 0
    8367        Style = tbsSeparator
     68      end
     69    end
     70  end
     71  object PageControl1: TPageControl
     72    Left = 0
     73    Height = 612
     74    Top = 35
     75    Width = 1050
     76    ActivePage = TabSheetEbnf
     77    Align = alClient
     78    TabIndex = 2
     79    TabOrder = 1
     80    object TabSheetRules: TTabSheet
     81      Caption = 'Rules'
     82    end
     83    object TabSheetBnf: TTabSheet
     84      Caption = 'BNF'
     85      ClientHeight = 571
     86      ClientWidth = 1044
     87      object MemoBnf: TMemo
     88        Left = 0
     89        Height = 571
     90        Top = 0
     91        Width = 1044
     92        Align = alClient
     93        ReadOnly = True
     94        ScrollBars = ssAutoBoth
     95        TabOrder = 0
     96      end
     97    end
     98    object TabSheetEbnf: TTabSheet
     99      Caption = 'EBNF'
     100      ClientHeight = 571
     101      ClientWidth = 1044
     102      object MemoEbnf: TMemo
     103        Left = 0
     104        Height = 571
     105        Top = 0
     106        Width = 1044
     107        Align = alClient
     108        ReadOnly = True
     109        ScrollBars = ssAutoBoth
     110        TabOrder = 0
    84111      end
    85112    end
     
    124151    object MenuItem1: TMenuItem
    125152      Caption = 'View'
    126       object MenuItem3: TMenuItem
    127         Action = ARules
    128       end
    129153    end
    130154  end
  • branches/generator/Forms/UFormMain.pas

    r129 r130  
    2626    CoolBar1: TCoolBar;
    2727    MainMenu1: TMainMenu;
    28     MemoBNF: TMemo;
     28    MemoEbnf: TMemo;
     29    MemoBnf: TMemo;
    2930    MenuItem1: TMenuItem;
    3031    MenuItem10: TMenuItem;
     
    3334    MenuItem13: TMenuItem;
    3435    MenuItem2: TMenuItem;
    35     MenuItem3: TMenuItem;
    3636    MenuItem4: TMenuItem;
    3737    MenuItem5: TMenuItem;
     
    4141    MenuItem9: TMenuItem;
    4242    OpenDialog1: TOpenDialog;
     43    PageControl1: TPageControl;
    4344    SaveDialog1: TSaveDialog;
     45    TabSheetRules: TTabSheet;
     46    TabSheetBnf: TTabSheet;
     47    TabSheetEbnf: TTabSheet;
    4448    ToolBar1: TToolBar;
    45     ToolButton1: TToolButton;
    4649    ToolButton2: TToolButton;
    4750    ToolButton3: TToolButton;
     
    6467    procedure ReloadMemo;
    6568    procedure UpdateInterface;
     69    procedure GrammerChange(Sender: TObject);
     70    procedure GrammerDestroy(Sender: TObject);
    6671  public
    6772    { public declarations }
     
    130135  Core.PersistentForm1.Load(Self, True);
    131136  Core.Initialize;
    132   ReloadMemo;
    133   UpdateInterface;
     137  PageControl1.TabIndex := 0;
     138  ReloadMemo;
     139  UpdateInterface;
     140
     141  FormRules.Rules := Core.Grammer.Rules;
     142  FormRules.ManualDock(TabSheetRules, nil, alClient);
     143  FormRules.Align := alClient;
     144  FormRules.Show;
    134145end;
    135146
    136147procedure TFormMain.ReloadMemo;
    137148begin
    138   if Assigned(Core.Grammer) then
    139     MemoBNF.Lines.Text := Core.Grammer.GetString
    140     else MemoBNF.Lines.Clear;
     149  if Assigned(Core.Grammer) then begin
     150    MemoBnf.Lines.Text := Core.Grammer.GetString;
     151    MemoEbnf.Lines.Text := Core.Grammer.GetString;
     152  end else begin
     153    MemoBnf.Lines.Clear;
     154    MemoEbnf.Lines.Clear;
     155  end;
    141156end;
    142157
     
    159174end;
    160175
     176procedure TFormMain.GrammerChange(Sender: TObject);
     177begin
     178  ReloadMemo;
     179  UpdateInterface;
     180  if Assigned(FormRules) then begin
     181    FormRules.Rules := Core.Grammer.Rules;
     182    FormRules.ReloadList;
     183    FormRules.UpdateInterface;
     184  end;
     185end;
     186
     187procedure TFormMain.GrammerDestroy(Sender: TObject);
     188begin
     189  ReloadMemo;
     190  UpdateInterface;
     191  if Assigned(FormRules) then begin
     192    FormRules.Rules := nil;
     193    FormRules.ReloadList;
     194    FormRules.UpdateInterface;
     195  end;
     196end;
     197
    161198procedure TFormMain.AExitExecute(Sender: TObject);
    162199begin
     
    183220    Core.Grammer := TGrammer.Create;
    184221    Core.Grammer.FileName := SNewGrammer;
    185     ReloadMemo;
    186     UpdateInterface;
     222    Core.Grammer.OnChange := GrammerChange;
     223    Core.Grammer.OnDestroy := GrammerDestroy;
     224    Core.Grammer.Change;
    187225  end;
    188226end;
     
    210248      Core.LastOpenedFile := OpenDialog1.FileName;
    211249      Core.Grammer := TGrammer.Create;
     250      Core.Grammer.OnChange := GrammerChange;
     251      Core.Grammer.OnDestroy := GrammerDestroy;
    212252      Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName);
    213       ReloadMemo;
    214       UpdateInterface;
     253      Core.Grammer.Change;
    215254    end;
    216255  end;
     
    232271  if (DialogResult = mrNo) or (DialogResult = mrYes) then begin
    233272    FreeAndNil(Core.Grammer);
    234     ReloadMemo;
    235     UpdateInterface;
    236273  end;
    237274end;
  • branches/generator/Forms/UFormRules.pas

    r129 r130  
    189189  I: Integer;
    190190begin
    191   ListViewSort1.List.Count := Rules.Count;
    192   for I := 0 to Rules.Count - 1 do
    193     ListViewSort1.List[I] := Rules[I];
    194   //FilterList(ListViewSort1.List);
     191  if Assigned(Rules) then begin
     192    ListViewSort1.List.Count := Rules.Count;
     193    for I := 0 to Rules.Count - 1 do
     194      ListViewSort1.List[I] := Rules[I];
     195    //FilterList(ListViewSort1.List);
     196  end else ListViewSort1.List.Count := 0;
    195197end;
    196198
    197199procedure TFormRules.UpdateInterface;
    198200begin
    199   AModify.Enabled := Assigned(ListView1.Selected);
    200   ARemove.Enabled := Assigned(ListView1.Selected);
     201  AAdd.Enabled := Assigned(Rules);
     202  AModify.Enabled := Assigned(Rules) and Assigned(ListView1.Selected);
     203  ARemove.Enabled := Assigned(Rules) and Assigned(ListView1.Selected);
    201204end;
    202205
    203206procedure TFormRules.ReloadList;
    204207begin
    205   if Assigned(Rules) then ListViewSort1.Refresh
    206     else ListViewSort1.List.Count := 0;
     208  ListViewSort1.Refresh;
    207209  ListView1.Refresh;
    208210end;
  • branches/generator/Languages/generator.cs.po

    r129 r130  
    105105msgstr "Nástroje"
    106106
     107#: tformmain.tabsheetbnf.caption
     108msgid "BNF"
     109msgstr ""
     110
     111#: tformmain.tabsheetebnf.caption
     112msgid "EBNF"
     113msgstr ""
     114
     115#: tformmain.tabsheetrules.caption
     116#, fuzzy
     117msgctxt "tformmain.tabsheetrules.caption"
     118msgid "Rules"
     119msgstr "Pravidla"
     120
    107121#: tformrule.buttoncancel.caption
    108122msgctxt "tformrule.buttoncancel.caption"
  • branches/generator/Languages/generator.po

    r129 r130  
    9595msgstr ""
    9696
     97#: tformmain.tabsheetbnf.caption
     98msgid "BNF"
     99msgstr ""
     100
     101#: tformmain.tabsheetebnf.caption
     102msgid "EBNF"
     103msgstr ""
     104
     105#: tformmain.tabsheetrules.caption
     106msgctxt "tformmain.tabsheetrules.caption"
     107msgid "Rules"
     108msgstr ""
     109
    97110#: tformrule.buttoncancel.caption
    98111msgctxt "tformrule.buttoncancel.caption"
  • branches/generator/UGrammer.pas

    r129 r130  
    113113  private
    114114    FModified: Boolean;
     115    FOnChange: TNotifyEvent;
     116    FOnDestroy: TNotifyEvent;
    115117    procedure SetModified(AValue: Boolean);
     118    procedure DoChange;
     119    procedure DoDestroy;
    116120  public
    117121    FileName: string;
     
    125129    procedure GetUsedByRule(RefRule: TRule; UsedByRules: TStrings);
    126130    function GetString: string;
     131    procedure Change;
    127132    property Modified: Boolean read FModified write SetModified;
     133    property OnChange: TNotifyEvent read FOnChange write FOnChange;
     134    property OnDestroy: TNotifyEvent read FOnDestroy write FOnDestroy;
    128135  end;
    129136
     
    141148  if FModified = AValue then Exit;
    142149  FModified := AValue;
     150  if AValue then DoChange;
     151end;
     152
     153procedure TGrammer.DoChange;
     154begin
     155  if Assigned(FOnChange) then FOnChange(Self);
     156end;
     157
     158procedure TGrammer.DoDestroy;
     159begin
     160  if Assigned(FOnDestroy) then FOnDestroy(Self);
    143161end;
    144162
     
    165183    end;
    166184  finally
    167     Doc.Free;
     185    FreeAndNil(Doc);
    168186  end;
    169187
     
    195213    Modified := False;
    196214  finally
    197     Doc.Free;
     215    FreeAndNil(Doc);
    198216  end;
    199217end;
     
    213231destructor TGrammer.Destroy;
    214232begin
     233  DoDestroy;
    215234  FreeAndNil(Rules);
    216235  inherited Destroy;
     
    229248begin
    230249  Result := Rules.GetString;
     250end;
     251
     252procedure TGrammer.Change;
     253begin
     254  DoChange;
    231255end;
    232256
  • branches/generator/generator.lpr

    r129 r130  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UCore, Common, TemplateGenerics, UFormMain, SysUtils, UBuilder
     10  Forms, UCore, Common, TemplateGenerics, UFormMain, SysUtils, UBuilder,
     11  UFormRules
    1112  { you can add units after this };
    1213
     
    3031  Application.CreateForm(TCore, Core);
    3132  Application.CreateForm(TFormMain, FormMain);
     33  Application.CreateForm(TFormRules, FormRules);
    3234  Application.Run;
    3335end.
Note: See TracChangeset for help on using the changeset viewer.