Changeset 117 for branches/generator/Forms
- Timestamp:
- Nov 27, 2017, 1:09:38 PM (7 years ago)
- Location:
- branches/generator
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator
- Property svn:ignore
-
old new 2 2 generator.lps 3 3 lib 4 heaptrclog.trc
-
- Property svn:ignore
-
branches/generator/Forms/UFormMain.lfm
r115 r117 1 1 object FormMain: TFormMain 2 Left = 6202 Left = 382 3 3 Height = 678 4 Top = 4274 Top = 195 5 5 Width = 1050 6 6 Caption = 'Language generator' -
branches/generator/Forms/UFormMain.pas
r114 r117 59 59 60 60 procedure TFormMain.ARulesExecute(Sender: TObject); 61 var 62 FormRules: TFormRules; 61 63 begin 64 FormRules := TFormRules.Create(nil); 62 65 FormRules.Rules := Core.Grammer.Rules; 63 66 FormRules.ShowModal; 64 67 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 68 FreeAndNil(FormRules); 65 69 end; 66 70 -
branches/generator/Forms/UFormRule.lfm
r116 r117 9 9 ClientWidth = 663 10 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 11 12 OnShow = FormShow 12 13 LCLVersion = '1.6.4.0' -
branches/generator/Forms/UFormRule.pas
r116 r117 22 22 TabSheet2: TTabSheet; 23 23 procedure FormCreate(Sender: TObject); 24 procedure FormDestroy(Sender: TObject); 24 25 procedure FormShow(Sender: TObject); 25 26 private … … 39 40 {$R *.lfm} 40 41 41 uses42 UFormRuleItem;43 44 42 { TFormRule } 45 43 … … 55 53 FormRuleItems.Align := alClient; 56 54 FormRuleItems.Show; 55 end; 56 57 procedure TFormRule.FormDestroy(Sender: TObject); 58 begin 59 FreeAndNil(FormRuleItems); 57 60 end; 58 61 -
branches/generator/Forms/UFormRuleItem.lfm
r114 r117 1 1 object FormRuleItem: TFormRuleItem 2 2 Left = 474 3 Height = 2783 Height = 400 4 4 Top = 386 5 5 Width = 656 6 ActiveControl = EditName7 6 Caption = 'Rule item' 8 ClientHeight = 2787 ClientHeight = 400 9 8 ClientWidth = 656 9 OnClose = FormClose 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 12 OnShow = FormShow 10 13 LCLVersion = '1.6.4.0' 11 object LabelTerminal: TLabel 12 Left = 16 13 Height = 20 14 Top = 64 15 Width = 61 16 Caption = 'Terminal:' 17 ParentColor = False 18 end 19 object EditName: TEdit 20 Left = 160 21 Height = 28 22 Top = 64 23 Width = 400 14 object ButtonCancel: TButton 15 Left = 176 16 Height = 25 17 Top = 362 18 Width = 75 19 Anchors = [akLeft, akBottom] 20 Caption = 'Cancel' 21 ModalResult = 2 24 22 TabOrder = 0 25 23 end 26 object Button Cancel: TButton27 Left = 23224 object ButtonOk: TButton 25 Left = 352 28 26 Height = 25 29 Top = 20827 Top = 362 30 28 Width = 75 31 Caption = 'Cancel' 32 ModalResult = 2 33 TabOrder = 1 34 end 35 object ButtonOk: TButton 36 Left = 408 37 Height = 25 38 Top = 208 39 Width = 75 29 Anchors = [akLeft, akBottom] 40 30 Caption = 'Ok' 41 31 ModalResult = 1 42 TabOrder = 232 TabOrder = 1 43 33 end 44 34 object ComboBoxType: TComboBox … … 51 41 'Terminal' 52 42 'Non-terminal' 43 'Subitems' 53 44 ) 54 45 OnChange = ComboBoxTypeChange 55 46 Style = csDropDownList 56 TabOrder = 347 TabOrder = 2 57 48 end 58 49 object Label2: TLabel … … 64 55 ParentColor = False 65 56 end 66 object LabelNonTerminal: TLabel57 object PageControl1: TPageControl 67 58 Left = 16 68 Height = 20 69 Top = 112 70 Width = 92 71 Caption = 'Non-terminal:' 72 ParentColor = False 59 Height = 266 60 Top = 88 61 Width = 632 62 ActivePage = TabSheetSubItems 63 Anchors = [akTop, akLeft, akRight, akBottom] 64 ShowTabs = False 65 TabIndex = 2 66 TabOrder = 3 67 object TabSheetTerminal: TTabSheet 68 Caption = 'Terminal' 69 ClientHeight = 168 70 ClientWidth = 624 71 object EditName: TEdit 72 Left = 152 73 Height = 28 74 Top = 16 75 Width = 400 76 TabOrder = 0 77 end 78 object LabelTerminal: TLabel 79 Left = 8 80 Height = 20 81 Top = 24 82 Width = 61 83 Caption = 'Terminal:' 84 ParentColor = False 85 end 86 end 87 object TabSheetNonTerminal: TTabSheet 88 Caption = 'NonTerminal' 89 ClientHeight = 168 90 ClientWidth = 624 91 object ComboBoxNonTerminal: TComboBox 92 Left = 152 93 Height = 28 94 Top = 16 95 Width = 404 96 ItemHeight = 20 97 Style = csDropDownList 98 TabOrder = 0 99 end 100 object LabelNonTerminal: TLabel 101 Left = 8 102 Height = 20 103 Top = 24 104 Width = 92 105 Caption = 'Non-terminal:' 106 ParentColor = False 107 end 108 end 109 object TabSheetSubItems: TTabSheet 110 Caption = 'SubItems' 111 end 73 112 end 74 object ComboBoxNonTerminal: TComboBox 75 Left = 160 76 Height = 28 77 Top = 104 78 Width = 404 79 ItemHeight = 20 80 Style = csDropDownList 113 object CheckBoxOptional: TCheckBox 114 Left = 16 115 Height = 24 116 Top = 56 117 Width = 82 118 Caption = 'Optional' 81 119 TabOrder = 4 82 120 end 121 object CheckBoxRepetitive: TCheckBox 122 Left = 336 123 Height = 24 124 Top = 56 125 Width = 91 126 Caption = 'Repetitive' 127 TabOrder = 5 128 end 83 129 end -
branches/generator/Forms/UFormRuleItem.pas
r111 r117 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 URules;9 ComCtrls, URules; 10 10 11 11 type … … 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 CheckBoxOptional: TCheckBox; 19 CheckBoxRepetitive: TCheckBox; 20 ComboBoxNonTerminal: TComboBox; 18 21 ComboBoxType: TComboBox; 19 ComboBoxNonTerminal: TComboBox;20 22 EditName: TEdit; 21 LabelTerminal: TLabel;22 23 Label2: TLabel; 23 24 LabelNonTerminal: TLabel; 25 LabelTerminal: TLabel; 26 PageControl1: TPageControl; 27 TabSheetTerminal: TTabSheet; 28 TabSheetNonTerminal: TTabSheet; 29 TabSheetSubItems: TTabSheet; 24 30 procedure ComboBoxTypeChange(Sender: TObject); 31 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 32 procedure FormCreate(Sender: TObject); 33 procedure FormDestroy(Sender: TObject); 34 procedure FormShow(Sender: TObject); 25 35 private 36 FormRuleItems: TForm; 26 37 procedure ReloadNonTerminals(Grammer: TGrammer); 27 38 public … … 35 46 FormRuleItem: TFormRuleItem; 36 47 48 37 49 implementation 50 51 uses 52 UCore, UFormRuleItems; 38 53 39 54 {$R *.lfm} … … 45 60 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 46 61 UpdateInterface; 62 end; 63 64 procedure TFormRuleItem.FormClose(Sender: TObject; var CloseAction: TCloseAction 65 ); 66 begin 67 Core.PersistentForm1.Save(Self); 68 end; 69 70 procedure TFormRuleItem.FormCreate(Sender: TObject); 71 begin 72 FormRuleItems := TFormRuleItems.Create(nil); 73 FormRuleItems.ManualDock(TabSheetSubItems); 74 FormRuleItems.Align := alClient; 75 FormRuleItems.Show; 76 end; 77 78 procedure TFormRuleItem.FormDestroy(Sender: TObject); 79 begin 80 FreeAndNil(FormRuleItems); 81 end; 82 83 procedure TFormRuleItem.FormShow(Sender: TObject); 84 begin 85 Core.PersistentForm1.Load(Self); 47 86 end; 48 87 … … 59 98 procedure TFormRuleItem.UpdateInterface; 60 99 begin 100 PageControl1.PageIndex := Integer(RuleItem.RuleItemType); 61 101 EditName.Visible := RuleItem.RuleItemType = ritTerminal; 62 102 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; … … 72 112 ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal); 73 113 EditName.Text := RuleItem.Terminal; 114 CheckBoxOptional.Checked := RuleItem.Optional; 115 CheckBoxRepetitive.Checked := RuleItem.Repetitive; 116 TFormRuleItems(FormRuleItems).LoadData(RuleItem.SubItems); 74 117 UpdateInterface; 75 118 end; … … 77 120 procedure TFormRuleItem.SaveData(RuleItem: TRuleItem); 78 121 begin 122 TFormRuleItems(FormRuleItems).SaveData(RuleItem.SubItems); 79 123 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 80 124 if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text 81 125 else if RuleItem.RuleItemType = ritNonTerminal then 82 126 RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]); 127 RuleItem.Optional := CheckBoxOptional.Checked; 128 RuleItem.Repetitive := CheckBoxRepetitive.Checked; 83 129 end; 84 130 -
branches/generator/Forms/UFormRuleItems.pas
r116 r117 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 Menus, ActnList, StdCtrls, URules ;9 Menus, ActnList, StdCtrls, URules, UFormRuleItem; 10 10 11 11 type … … 48 48 Selected: Boolean); 49 49 private 50 { private declarations }50 FormRuleItem: TFormRuleItem; 51 51 public 52 52 RuleItems: TRuleItems; … … 63 63 implementation 64 64 65 uses66 UFormRuleItem;67 65 68 66 {$R *.lfm} … … 84 82 NewRuleItem := TRuleItem.Create; 85 83 NewRuleItem.Grammer := RuleItems.Grammer; 84 FormRuleItem := TFormRuleItem.Create(nil); 86 85 FormRuleItem.LoadData(NewRuleItem); 87 86 if FormRuleItem.ShowModal = mrOk then begin … … 91 90 ReloadList; 92 91 end else FreeAndNil(NewRuleItem); 92 FreeAndNil(FormRuleItem); 93 93 end; 94 94 … … 98 98 begin 99 99 RuleItem := TRuleItem(ListView.Selected.Data); 100 FormRuleItem := TFormRuleItem.Create(nil); 100 101 FormRuleItem.LoadData(RuleItem); 101 102 if FormRuleItem.ShowModal = mrOk then begin … … 103 104 ReloadList; 104 105 end; 106 FreeAndNil(FormRuleItem); 105 107 end; 106 108 -
branches/generator/Forms/UFormRules.pas
r116 r117 73 73 NewRule := TRule.Create; 74 74 NewRule.Grammer := Rules.Grammer; 75 FormRule := TFormRule.Create(nil); 75 76 FormRule.LoadData(NewRule); 76 77 if FormRule.ShowModal = mrOk then begin … … 79 80 ReloadList; 80 81 end else FreeAndNil(NewRule); 82 FreeAndNil(FormRule); 81 83 end; 82 84 … … 84 86 var 85 87 Rule: TRule; 88 FormRule: TFormRule; 86 89 begin 87 90 Rule := TRule(ListView1.Selected.Data); 91 FormRule := TFormRule.Create(nil); 88 92 FormRule.LoadData(Rule); 89 93 if FormRule.ShowModal = mrOk then begin … … 91 95 ReloadList; 92 96 end; 97 FreeAndNil(FormRule); 93 98 end; 94 99 … … 118 123 Item.Caption := Rules[Item.Index].Name; 119 124 Item.Data := Rules[Item.Index]; 120 Item.SubItems.Add(Rules[Item.Index].Items.GetBNF (Rules[Item.Index].Items.RuleType));125 Item.SubItems.Add(Rules[Item.Index].Items.GetBNF); 121 126 end; 122 127 end;
Note:
See TracChangeset
for help on using the changeset viewer.