Changeset 110 for branches/generator/Forms
- Timestamp:
- Aug 8, 2017, 11:15:41 PM (7 years ago)
- Location:
- branches/generator/Forms
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormMain.lfm
r109 r110 5 5 Width = 1050 6 6 Caption = 'Language generator' 7 ClientHeight = 646 8 ClientWidth = 1050 7 9 Menu = MainMenu1 10 OnShow = FormShow 8 11 LCLVersion = '1.6.4.0' 12 object MemoBNF: TMemo 13 Left = 0 14 Height = 646 15 Top = 0 16 Width = 1050 17 Align = alClient 18 TabOrder = 0 19 end 9 20 object MainMenu1: TMainMenu 10 21 left = 240 -
branches/generator/Forms/UFormMain.pas
r109 r110 20 20 ActionList1: TActionList; 21 21 MainMenu1: TMainMenu; 22 MemoBNF: TMemo; 22 23 MenuItem1: TMenuItem; 23 24 MenuItem2: TMenuItem; … … 33 34 procedure ARulesExecute(Sender: TObject); 34 35 procedure ASaveAsExecute(Sender: TObject); 36 procedure FormShow(Sender: TObject); 35 37 private 36 38 { private declarations } … … 55 57 begin 56 58 FormRules.Rules := Core.Rules; 57 FormRules.Show; 59 FormRules.ShowModal; 60 MemoBNF.Lines.Text := Core.Rules.GetBNF; 58 61 end; 59 62 60 63 procedure TFormMain.ASaveAsExecute(Sender: TObject); 61 64 begin 65 SaveDialog1.FileName := Core.Rules.FileName; 62 66 if SaveDialog1.Execute then begin 63 67 Core.Rules.SaveToXmlFile(SaveDialog1.FileName); 64 68 end; 69 end; 70 71 procedure TFormMain.FormShow(Sender: TObject); 72 begin 73 MemoBNF.Lines.Text := Core.Rules.GetBNF; 65 74 end; 66 75 … … 72 81 procedure TFormMain.AOpenExecute(Sender: TObject); 73 82 begin 83 OpenDialog1.FileName := Core.Rules.FileName; 74 84 if OpenDialog1.Execute then begin 75 85 Core.Rules.LoadFromXmlFile(OpenDialog1.FileName); -
branches/generator/Forms/UFormRule.lfm
r109 r110 13 13 Left = 376 14 14 Height = 25 15 Top = 3 2815 Top = 360 16 16 Width = 75 17 Anchors = [akLeft, akBottom] 17 18 Caption = 'Ok' 18 19 ModalResult = 1 … … 20 21 end 21 22 object ButtonCancel: TButton 22 Left = 1 7623 Left = 168 23 24 Height = 25 24 Top = 3 2825 Top = 360 25 26 Width = 75 27 Anchors = [akLeft, akBottom] 26 28 Caption = 'Cancel' 27 29 ModalResult = 2 … … 43 45 TabOrder = 2 44 46 end 47 object ListView: TListView 48 Left = 16 49 Height = 264 50 Top = 80 51 Width = 624 52 Anchors = [akTop, akLeft, akBottom] 53 Columns = < 54 item 55 Caption = 'Name' 56 Width = 604 57 end> 58 MultiSelect = True 59 OwnerData = True 60 PopupMenu = PopupMenu1 61 ReadOnly = True 62 RowSelect = True 63 TabOrder = 3 64 ViewStyle = vsReport 65 OnData = ListViewData 66 OnDblClick = ListViewDblClick 67 OnKeyPress = ListViewKeyPress 68 OnSelectItem = ListViewSelectItem 69 end 70 object ActionList1: TActionList 71 left = 347 72 top = 187 73 object AAdd: TAction 74 Caption = 'Add' 75 OnExecute = AAddExecute 76 end 77 object AModify: TAction 78 Caption = 'Modify' 79 OnExecute = AModifyExecute 80 end 81 object ARemove: TAction 82 Caption = 'Remove' 83 OnExecute = ARemoveExecute 84 end 85 end 86 object PopupMenu1: TPopupMenu 87 left = 118 88 top = 185 89 object MenuItem1: TMenuItem 90 Action = AAdd 91 end 92 object MenuItem2: TMenuItem 93 Action = AModify 94 end 95 object MenuItem3: TMenuItem 96 Action = ARemove 97 end 98 end 45 99 end -
branches/generator/Forms/UFormRule.pas
r109 r110 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 URules;9 ComCtrls, ActnList, Menus, URules; 10 10 11 11 type … … 14 14 15 15 TFormRule = class(TForm) 16 AAdd: TAction; 17 AModify: TAction; 18 ARemove: TAction; 19 ActionList1: TActionList; 16 20 ButtonOk: TButton; 17 21 ButtonCancel: TButton; 18 22 EditName: TEdit; 19 23 Label1: TLabel; 24 ListView: TListView; 25 MenuItem1: TMenuItem; 26 MenuItem2: TMenuItem; 27 MenuItem3: TMenuItem; 28 PopupMenu1: TPopupMenu; 29 procedure AAddExecute(Sender: TObject); 30 procedure AModifyExecute(Sender: TObject); 31 procedure ARemoveExecute(Sender: TObject); 20 32 procedure FormShow(Sender: TObject); 33 procedure ListViewData(Sender: TObject; Item: TListItem); 34 procedure ListViewDblClick(Sender: TObject); 35 procedure ListViewKeyPress(Sender: TObject; var Key: char); 36 procedure ListViewSelectItem(Sender: TObject; Item: TListItem; 37 Selected: Boolean); 21 38 private 22 39 { private declarations } 23 40 public 41 RuleItems: TRuleItems; 42 procedure UpdateInterface; 43 procedure ReloadList; 24 44 procedure LoadData(Rule: TRule); 25 45 procedure SaveData(Rule: TRule); … … 29 49 FormRule: TFormRule; 30 50 51 31 52 implementation 32 53 33 54 {$R *.lfm} 55 56 uses 57 UFormRuleItem; 34 58 35 59 { TFormRule } … … 38 62 begin 39 63 EditName.SetFocus; 64 ReloadList; 65 UpdateInterface; 66 end; 67 68 procedure TFormRule.ListViewData(Sender: TObject; Item: TListItem); 69 begin 70 if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin 71 Item.Caption := RuleItems[Item.Index].Name; 72 Item.Data := RuleItems[Item.Index]; 73 end; 74 end; 75 76 procedure TFormRule.ListViewDblClick(Sender: TObject); 77 begin 78 AModify.Execute; 79 end; 80 81 procedure TFormRule.ListViewKeyPress(Sender: TObject; var Key: char); 82 begin 83 if Key = #13 then AModify.Execute; 84 end; 85 86 procedure TFormRule.ListViewSelectItem(Sender: TObject; Item: TListItem; 87 Selected: Boolean); 88 begin 89 UpdateInterface; 90 end; 91 92 procedure TFormRule.AAddExecute(Sender: TObject); 93 var 94 NewRuleItem: TRuleItem; 95 begin 96 NewRuleItem := TRuleItem.Create; 97 FormRuleItem.LoadData(NewRuleItem); 98 if FormRuleItem.ShowModal = mrOk then begin 99 FormRuleItem.SaveData(NewRuleItem); 100 RuleItems.Add(NewRuleItem); 101 ReloadList; 102 end else FreeAndNil(NewRuleItem); 103 end; 104 105 procedure TFormRule.AModifyExecute(Sender: TObject); 106 var 107 RuleItem: TRuleItem; 108 begin 109 RuleItem := TRuleItem(ListView.Selected.Data); 110 FormRuleItem.LoadData(RuleItem); 111 if FormRuleItem.ShowModal = mrOk then begin 112 FormRuleItem.SaveData(RuleItem); 113 ReloadList; 114 end; 115 end; 116 117 procedure TFormRule.ARemoveExecute(Sender: TObject); 118 var 119 Item: TListItem; 120 begin 121 for Item in ListView.Items do 122 if Item.Selected then 123 RuleItems.Remove(TRuleItem(Item.Data)); 124 ReloadList; 125 end; 126 127 procedure TFormRule.UpdateInterface; 128 begin 129 AModify.Enabled := Assigned(ListView.Selected); 130 ARemove.Enabled := Assigned(ListView.Selected); 131 end; 132 133 procedure TFormRule.ReloadList; 134 begin 135 ListView.Items.Count := RuleItems.Count; 136 ListView.Refresh; 40 137 end; 41 138 … … 43 140 begin 44 141 EditName.Text := Rule.Name; 142 RuleItems := Rule.Items; 45 143 end; 46 144
Note:
See TracChangeset
for help on using the changeset viewer.