Ignore:
Timestamp:
Dec 24, 2017, 3:54:08 PM (7 years ago)
Author:
chronos
Message:
  • Added: Open recent files menu action.
  • Added: Generate BNF and EBNF output separately.
  • Added: Allow to hide main toolbar.
Location:
branches/generator/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/generator/Forms/UFormMain.lfm

    r130 r131  
    2929      Height = 28
    3030      Top = 5
    31       Width = 125
     31      Width = 171
    3232      Align = alNone
    3333      AutoSize = True
     
    4242      Transparent = True
    4343      object ToolButton2: TToolButton
    44         Left = 96
     44        Left = 142
    4545        Top = 0
    4646        Action = ABuildCompiler
     
    5555        Top = 0
    5656        Action = AProjectOpen
     57        DropdownMenu = PopupMenuOpenRecent
     58        Style = tbsButtonDrop
    5759      end
    5860      object ToolButton5: TToolButton
    59         Left = 59
     61        Left = 76
    6062        Top = 0
    6163        Action = AProjectSave
    6264      end
    6365      object ToolButton6: TToolButton
    64         Left = 88
     66        Left = 134
    6567        Height = 28
    6668        Top = 0
    6769        Style = tbsSeparator
     70      end
     71      object ToolButton1: TToolButton
     72        Left = 105
     73        Top = 0
     74        Action = AGrammerSettings
    6875      end
    6976    end
     
    124131        Action = AProjectOpen
    125132      end
     133      object MenuItemRecent: TMenuItem
     134        Caption = 'Open recent'
     135      end
    126136      object MenuItem10: TMenuItem
    127137        Action = AProjectSave
     
    151161    object MenuItem1: TMenuItem
    152162      Caption = 'View'
     163      object MenuItemToolbar: TMenuItem
     164        Action = AToolbarVisible
     165        AutoCheck = True
     166      end
    153167    end
    154168  end
     
    175189      OnExecute = AProjectOpenExecute
    176190    end
     191    object AProjectOpenRecent: TAction
     192      Caption = 'Open recent'
     193      OnExecute = AProjectOpenRecentExecute
     194    end
    177195    object AProjectSaveAs: TAction
    178196      Caption = 'Save as...'
     
    181199      OnExecute = AProjectSaveAsExecute
    182200    end
     201    object AProjectSave: TAction
     202      Caption = 'Save'
     203      ImageIndex = 5
     204      OnExecute = AProjectSaveExecute
     205    end
     206    object AProjectNew: TAction
     207      Caption = 'New'
     208      ImageIndex = 10
     209      OnExecute = AProjectNewExecute
     210    end
     211    object AProjectClose: TAction
     212      Caption = 'Close'
     213      OnExecute = AProjectCloseExecute
     214    end
     215    object AGrammerSettings: TAction
     216      Caption = 'Settings'
     217      ImageIndex = 3
     218      OnExecute = AGrammerSettingsExecute
     219    end
    183220    object ABuildCompiler: TAction
    184221      Caption = 'Build compiler'
     
    186223      OnExecute = ABuildCompilerExecute
    187224    end
    188     object AProjectSave: TAction
    189       Caption = 'Save'
    190       ImageIndex = 5
    191       OnExecute = AProjectSaveExecute
    192     end
    193     object AProjectNew: TAction
    194       Caption = 'New'
    195       ImageIndex = 10
    196       OnExecute = AProjectNewExecute
    197     end
    198     object AGrammerSettings: TAction
    199       Caption = 'Settings'
    200       OnExecute = AGrammerSettingsExecute
    201     end
    202     object AProjectClose: TAction
    203       Caption = 'Close'
    204       OnExecute = AProjectCloseExecute
     225    object AToolbarVisible: TAction
     226      AutoCheck = True
     227      Caption = 'Toolbar'
     228      OnExecute = AToolbarVisibleExecute
    205229    end
    206230  end
     
    217241    top = 414
    218242  end
     243  object LastOpenedList1: TLastOpenedList
     244    MaxCount = 10
     245    OnChange = LastOpenedList1Change
     246    left = 155
     247    top = 131
     248  end
     249  object PopupMenuOpenRecent: TPopupMenu
     250    left = 149
     251    top = 234
     252  end
    219253end
  • branches/generator/Forms/UFormMain.pas

    r130 r131  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   Menus, ActnList, ComCtrls, UPersistentForm, UGrammer;
     9  Menus, ActnList, ComCtrls, UPersistentForm, ULastOpenedList, UGrammer,
     10  XMLConf;
    1011
    1112type
     
    1516  TFormMain = class(TForm)
    1617    ABuildCompiler: TAction;
     18    AToolbarVisible: TAction;
     19    AProjectOpenRecent: TAction;
    1720    AProjectClose: TAction;
    1821    AGrammerSettings: TAction;
     
    2528    ActionList1: TActionList;
    2629    CoolBar1: TCoolBar;
     30    LastOpenedList1: TLastOpenedList;
    2731    MainMenu1: TMainMenu;
    2832    MemoEbnf: TMemo;
     
    3438    MenuItem13: TMenuItem;
    3539    MenuItem2: TMenuItem;
     40    MenuItemRecent: TMenuItem;
     41    MenuItemToolbar: TMenuItem;
    3642    MenuItem4: TMenuItem;
    3743    MenuItem5: TMenuItem;
     
    4248    OpenDialog1: TOpenDialog;
    4349    PageControl1: TPageControl;
     50    PopupMenuOpenRecent: TPopupMenu;
    4451    SaveDialog1: TSaveDialog;
    4552    TabSheetRules: TTabSheet;
     
    4754    TabSheetEbnf: TTabSheet;
    4855    ToolBar1: TToolBar;
     56    ToolButton1: TToolButton;
    4957    ToolButton2: TToolButton;
    5058    ToolButton3: TToolButton;
     
    5361    ToolButton6: TToolButton;
    5462    procedure ABuildCompilerExecute(Sender: TObject);
     63    procedure AToolbarVisibleExecute(Sender: TObject);
    5564    procedure AExitExecute(Sender: TObject);
    5665    procedure AGrammerSettingsExecute(Sender: TObject);
     
    5867    procedure AProjectNewExecute(Sender: TObject);
    5968    procedure AProjectOpenExecute(Sender: TObject);
     69    procedure AProjectOpenRecentExecute(Sender: TObject);
    6070    procedure AProjectCloseExecute(Sender: TObject);
    6171    procedure AProjectSaveAsExecute(Sender: TObject);
     
    6474    procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
    6575    procedure FormShow(Sender: TObject);
     76    procedure LastOpenedList1Change(Sender: TObject);
    6677  private
    67     procedure ReloadMemo;
    68     procedure UpdateInterface;
    6978    procedure GrammerChange(Sender: TObject);
    7079    procedure GrammerDestroy(Sender: TObject);
    7180  public
    72     { public declarations }
     81    procedure ReloadMemo;
     82    procedure UpdateInterface;
     83    procedure ProjectOpen(FileName: string);
     84    procedure ProjectNew;
     85    procedure LoadConfig(XmlConfig: TXmlConfig);
     86    procedure SaveConfig(XmlConfig: TXmlConfig);
    7387  end;
    7488
     
    108122  SaveDialog1.FileName := ExtractFileName(Core.Grammer.FileName);
    109123  if SaveDialog1.Execute then begin
    110     Core.LastOpenedFile := SaveDialog1.FileName;
     124    LastOpenedList1.AddItem(SaveDialog1.FileName);
    111125    Core.Grammer.SaveToXmlFile(SaveDialog1.FileName);
    112126    UpdateInterface;
     
    123137begin
    124138  Core.PersistentForm1.Save(Self);
     139  Core.Finalize;
    125140end;
    126141
     
    145160end;
    146161
     162procedure TFormMain.LastOpenedList1Change(Sender: TObject);
     163begin
     164  LastOpenedList1.LoadToMenuItem(MenuItemRecent, AProjectOpenRecentExecute);
     165  LastOpenedList1.LoadToMenuItem(PopupMenuOpenRecent.Items, AProjectOpenRecentExecute);
     166end;
     167
    147168procedure TFormMain.ReloadMemo;
    148169begin
    149170  if Assigned(Core.Grammer) then begin
    150     MemoBnf.Lines.Text := Core.Grammer.GetString;
    151     MemoEbnf.Lines.Text := Core.Grammer.GetString;
     171    MemoBnf.Lines.Text := Core.Grammer.ExportAsString(gnBnf);
     172    MemoEbnf.Lines.Text := Core.Grammer.ExportAsString(gnEbnf);
    152173  end else begin
    153174    MemoBnf.Lines.Clear;
     
    172193  ABuildCompiler.Enabled := Assigned(Core.Grammer);
    173194  ARules.Enabled := Assigned(Core.Grammer);
     195  CoolBar1.Visible := AToolbarVisible.Checked;
    174196end;
    175197
     
    194216    FormRules.UpdateInterface;
    195217  end;
     218end;
     219
     220procedure TFormMain.ProjectOpen(FileName: string);
     221begin
     222  if Assigned(Core.Grammer) then FreeAndNil(Core.Grammer);
     223  LastOpenedList1.AddItem(FileName);
     224  Core.Grammer := TGrammer.Create;
     225  Core.Grammer.OnChange := GrammerChange;
     226  Core.Grammer.OnDestroy := GrammerDestroy;
     227  Core.Grammer.LoadFromXmlFile(FileName);
     228  Core.Grammer.Change;
     229end;
     230
     231procedure TFormMain.ProjectNew;
     232begin
     233  if Assigned(Core.Grammer) then FreeAndNil(Core.Grammer);
     234  Core.Grammer := TGrammer.Create;
     235  Core.Grammer.OnChange := GrammerChange;
     236  Core.Grammer.OnDestroy := GrammerDestroy;
     237  Core.Grammer.FileName := SNewGrammer;
     238  Core.Grammer.Change;
     239end;
     240
     241procedure TFormMain.LoadConfig(XmlConfig: TXmlConfig);
     242begin
     243  AToolbarVisible.Checked := XmlConfig.GetValue('ToolbarVisible', True);
     244  LastOpenedList1.LoadFromXMLConfig(XMLConfig, 'LastOpenedFiles');
     245end;
     246
     247procedure TFormMain.SaveConfig(XmlConfig: TXmlConfig);
     248begin
     249  XmlConfig.SetValue('ToolbarVisible', AToolbarVisible.Checked);
     250  LastOpenedList1.SaveToXMLConfig(XMLConfig, 'LastOpenedFiles');
    196251end;
    197252
     
    214269end;
    215270
     271procedure TFormMain.AProjectOpenRecentExecute(Sender: TObject);
     272begin
     273  if Sender is TMenuItem then ProjectOpen(TMenuItem(Sender).Caption);
     274end;
     275
    216276procedure TFormMain.AProjectNewExecute(Sender: TObject);
    217277begin
    218278  AProjectClose.Execute;
    219279  if not Assigned(Core.Grammer) then begin
    220     Core.Grammer := TGrammer.Create;
    221     Core.Grammer.FileName := SNewGrammer;
    222     Core.Grammer.OnChange := GrammerChange;
    223     Core.Grammer.OnDestroy := GrammerDestroy;
    224     Core.Grammer.Change;
     280    ProjectNew;
    225281  end;
    226282end;
     
    239295end;
    240296
     297procedure TFormMain.AToolbarVisibleExecute(Sender: TObject);
     298begin
     299  UpdateInterface;
     300end;
     301
    241302procedure TFormMain.AProjectOpenExecute(Sender: TObject);
    242303begin
    243304  AProjectClose.Execute;
    244305  if not Assigned(Core.Grammer) then begin
    245     OpenDialog1.InitialDir := ExtractFileDir(Core.LastOpenedFile);
    246     OpenDialog1.FileName := ExtractFileName(Core.LastOpenedFile);
     306    OpenDialog1.InitialDir := ExtractFileDir(LastOpenedList1.GetFirstFileName);
     307    OpenDialog1.FileName := ExtractFileName(LastOpenedList1.GetFirstFileName);
    247308    if OpenDialog1.Execute then begin
    248       Core.LastOpenedFile := OpenDialog1.FileName;
    249       Core.Grammer := TGrammer.Create;
    250       Core.Grammer.OnChange := GrammerChange;
    251       Core.Grammer.OnDestroy := GrammerDestroy;
    252       Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName);
    253       Core.Grammer.Change;
     309      ProjectOpen(OpenDialog1.FileName);
    254310    end;
    255311  end;
  • branches/generator/Forms/UFormRule.lfm

    r129 r131  
    88  ClientHeight = 514
    99  ClientWidth = 663
    10   DesignTimePPI = 120
    1110  OnCreate = FormCreate
    1211  OnDestroy = FormDestroy
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.0.6'
     13  LCLVersion = '1.8.0.4'
    1514  object ButtonOk: TButton
    1615    Left = 376
     
    3534  object Label1: TLabel
    3635    Left = 16
    37     Height = 20
     36    Height = 23
    3837    Top = 16
    39     Width = 43
     38    Width = 49
    4039    Caption = 'Name:'
    4140    ParentColor = False
     
    5857    object TabSheetUsedBy: TTabSheet
    5958      Caption = 'Used by'
    60       ClientHeight = 359
    61       ClientWidth = 632
     59      ClientHeight = 351
     60      ClientWidth = 634
    6261      object ListView1: TListView
    6362        Left = 0
     
    6968          item
    7069            Caption = 'Name'
    71             Width = 200
     70            Width = 612
    7271          end>
    7372        OwnerData = True
     
    8281  object EditName: TEdit
    8382    Left = 135
    84     Height = 28
     83    Height = 33
    8584    Top = 11
    8685    Width = 433
     
    8988  object CheckBoxCreateNode: TCheckBox
    9089    Left = 16
    91     Height = 24
     90    Height = 27
    9291    Top = 48
    93     Width = 152
     92    Width = 173
    9493    Caption = 'Create source node'
    9594    TabOrder = 4
     
    9796  object Label2: TLabel
    9897    Left = 312
    99     Height = 20
     98    Height = 23
    10099    Top = 52
    101     Width = 37
    102     Caption = 'Lavel:'
     100    Width = 42
     101    Caption = 'Level:'
    103102    ParentColor = False
    104103  end
    105104  object ComboBoxLevel: TComboBox
    106105    Left = 376
    107     Height = 28
     106    Height = 37
    108107    Top = 48
    109108    Width = 125
    110     ItemHeight = 20
     109    ItemHeight = 0
    111110    Style = csDropDownList
    112111    TabOrder = 5
  • branches/generator/Forms/UFormRuleItem.lfm

    r129 r131  
    77  ClientHeight = 400
    88  ClientWidth = 656
    9   DesignTimePPI = 120
    109  OnClose = FormClose
    1110  OnCreate = FormCreate
    1211  OnDestroy = FormDestroy
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.0.6'
     13  LCLVersion = '1.8.0.4'
    1514  object ButtonCancel: TButton
    1615    Left = 176
     
    3534  object ComboBoxType: TComboBox
    3635    Left = 160
    37     Height = 28
     36    Height = 33
    3837    Top = 16
    3938    Width = 400
    40     ItemHeight = 20
     39    ItemHeight = 0
    4140    Items.Strings = (
    4241      'Terminal'
     
    5150  object Label2: TLabel
    5251    Left = 16
    53     Height = 20
     52    Height = 23
    5453    Top = 24
    55     Width = 35
     54    Width = 40
    5655    Caption = 'Type:'
    5756    ParentColor = False
     
    6261    Top = 88
    6362    Width = 632
    64     ActivePage = TabSheetTerminal
     63    ActivePage = TabSheetTerminalRange
    6564    Anchors = [akTop, akLeft, akRight, akBottom]
    6665    ShowTabs = False
    67     TabIndex = 0
     66    TabIndex = 3
    6867    TabOrder = 3
    6968    object TabSheetTerminal: TTabSheet
    7069      Caption = 'Terminal'
    71       ClientHeight = 258
    72       ClientWidth = 624
     70      ClientHeight = 260
     71      ClientWidth = 626
    7372      object EditTerminal: TEdit
    7473        Left = 152
    75         Height = 28
     74        Height = 33
    7675        Top = 16
    7776        Width = 400
     
    8180      object LabelTerminal: TLabel
    8281        Left = 8
    83         Height = 20
     82        Height = 23
    8483        Top = 16
    85         Width = 61
     84        Width = 70
    8685        Caption = 'Terminal:'
    8786        ParentColor = False
     
    9089    object TabSheetNonTerminal: TTabSheet
    9190      Caption = 'NonTerminal'
    92       ClientHeight = 258
    93       ClientWidth = 624
     91      ClientHeight = 260
     92      ClientWidth = 626
    9493      object LabelNonTerminal: TLabel
    9594        Left = 8
     
    107106        Anchors = [akTop, akLeft, akRight, akBottom]
    108107        ItemHeight = 0
     108        ScrollWidth = 482
    109109        TabOrder = 0
     110        TopIndex = -1
    110111      end
    111112    end
     
    114115    end
    115116    object TabSheetTerminalRange: TTabSheet
    116       Caption = 'TabSheetTerminalRange'
    117       ClientHeight = 258
    118       ClientWidth = 624
     117      Caption = 'Terminal range'
     118      ClientHeight = 260
     119      ClientWidth = 626
    119120      object LabelTerminal1: TLabel
    120121        Left = 8
    121         Height = 20
     122        Height = 23
    122123        Top = 16
    123         Width = 97
     124        Width = 112
    124125        Caption = 'Terminal from:'
    125126        ParentColor = False
     
    127128      object EditTerminalFrom: TEdit
    128129        Left = 152
    129         Height = 28
     130        Height = 33
    130131        Top = 16
    131132        Width = 400
     
    135136      object LabelTerminal2: TLabel
    136137        Left = 8
    137         Height = 20
     138        Height = 23
    138139        Top = 56
    139         Width = 79
     140        Width = 90
    140141        Caption = 'Terminal to:'
    141142        ParentColor = False
     
    143144      object EditTerminalTo: TEdit
    144145        Left = 152
    145         Height = 28
     146        Height = 33
    146147        Top = 56
    147148        Width = 400
     
    153154  object CheckBoxOptional: TCheckBox
    154155    Left = 16
    155     Height = 24
     156    Height = 27
    156157    Top = 56
    157     Width = 82
     158    Width = 90
    158159    Caption = 'Optional'
    159160    TabOrder = 4
     
    161162  object CheckBoxRepetitive: TCheckBox
    162163    Left = 216
    163     Height = 24
     164    Height = 27
    164165    Top = 56
    165     Width = 91
     166    Width = 99
    166167    Caption = 'Repetitive'
    167168    TabOrder = 5
     
    169170  object CheckBoxAnyExcept: TCheckBox
    170171    Left = 400
    171     Height = 24
     172    Height = 27
    172173    Top = 56
    173     Width = 97
     174    Width = 106
    174175    Caption = 'Any except'
    175176    TabOrder = 6
Note: See TracChangeset for help on using the changeset viewer.