Changeset 122 for branches/generator/Forms
- Timestamp:
- Nov 29, 2017, 2:03:17 PM (7 years ago)
- Location:
- branches/generator/Forms
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormRule.lfm
r120 r122 45 45 Top = 80 46 46 Width = 640 47 ActivePage = TabSheet UsedBy47 ActivePage = TabSheet1 48 48 Anchors = [akTop, akLeft, akRight, akBottom] 49 TabIndex = 249 TabIndex = 0 50 50 TabOrder = 2 51 51 object TabSheet1: TTabSheet -
branches/generator/Forms/UFormRuleItem.lfm
r117 r122 42 42 'Non-terminal' 43 43 'Subitems' 44 'Terminal range' 44 45 ) 45 46 OnChange = ComboBoxTypeChange … … 60 61 Top = 88 61 62 Width = 632 62 ActivePage = TabSheet SubItems63 ActivePage = TabSheetTerminal 63 64 Anchors = [akTop, akLeft, akRight, akBottom] 64 65 ShowTabs = False 65 TabIndex = 266 TabIndex = 0 66 67 TabOrder = 3 67 68 object TabSheetTerminal: TTabSheet 68 69 Caption = 'Terminal' 69 ClientHeight = 16870 ClientHeight = 258 70 71 ClientWidth = 624 71 object Edit Name: TEdit72 object EditTerminal: TEdit 72 73 Left = 152 73 74 Height = 28 74 75 Top = 16 75 76 Width = 400 77 OnKeyPress = EditTerminalKeyPress 76 78 TabOrder = 0 77 79 end … … 79 81 Left = 8 80 82 Height = 20 81 Top = 2483 Top = 16 82 84 Width = 61 83 85 Caption = 'Terminal:' … … 87 89 object TabSheetNonTerminal: TTabSheet 88 90 Caption = 'NonTerminal' 89 ClientHeight = 16891 ClientHeight = 258 90 92 ClientWidth = 624 91 object ComboBoxNonTerminal: TComboBox92 Left = 15293 Height = 2894 Top = 1695 Width = 40496 ItemHeight = 2097 Style = csDropDownList98 TabOrder = 099 end100 93 object LabelNonTerminal: TLabel 101 94 Left = 8 102 95 Height = 20 103 Top = 2496 Top = 16 104 97 Width = 92 105 98 Caption = 'Non-terminal:' 106 99 ParentColor = False 107 100 end 101 object ListBox1: TListBox 102 Left = 128 103 Height = 232 104 Top = 16 105 Width = 484 106 Anchors = [akTop, akLeft, akRight, akBottom] 107 ItemHeight = 0 108 TabOrder = 0 109 end 108 110 end 109 111 object TabSheetSubItems: TTabSheet 110 112 Caption = 'SubItems' 113 end 114 object TabSheetTerminalRange: TTabSheet 115 Caption = 'TabSheetTerminalRange' 116 ClientHeight = 258 117 ClientWidth = 624 118 object LabelTerminal1: TLabel 119 Left = 8 120 Height = 20 121 Top = 16 122 Width = 97 123 Caption = 'Terminal from:' 124 ParentColor = False 125 end 126 object EditTerminalFrom: TEdit 127 Left = 152 128 Height = 28 129 Top = 16 130 Width = 400 131 OnKeyPress = EditTerminalKeyPress 132 TabOrder = 0 133 end 134 object LabelTerminal2: TLabel 135 Left = 8 136 Height = 20 137 Top = 56 138 Width = 79 139 Caption = 'Terminal to:' 140 ParentColor = False 141 end 142 object EditTerminalTo: TEdit 143 Left = 152 144 Height = 28 145 Top = 56 146 Width = 400 147 OnKeyPress = EditTerminalKeyPress 148 TabOrder = 1 149 end 111 150 end 112 151 end -
branches/generator/Forms/UFormRuleItem.pas
r118 r122 18 18 CheckBoxOptional: TCheckBox; 19 19 CheckBoxRepetitive: TCheckBox; 20 ComboBoxNonTerminal: TComboBox;21 20 ComboBoxType: TComboBox; 22 EditName: TEdit; 21 EditTerminal: TEdit; 22 EditTerminalFrom: TEdit; 23 EditTerminalTo: TEdit; 23 24 Label2: TLabel; 24 25 LabelNonTerminal: TLabel; 25 26 LabelTerminal: TLabel; 27 LabelTerminal1: TLabel; 28 LabelTerminal2: TLabel; 29 ListBox1: TListBox; 26 30 PageControl1: TPageControl; 31 TabSheetTerminalRange: TTabSheet; 27 32 TabSheetTerminal: TTabSheet; 28 33 TabSheetNonTerminal: TTabSheet; 29 34 TabSheetSubItems: TTabSheet; 30 35 procedure ComboBoxTypeChange(Sender: TObject); 36 procedure EditTerminalKeyPress(Sender: TObject; var Key: char); 31 37 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 32 38 procedure FormCreate(Sender: TObject); … … 62 68 end; 63 69 70 procedure TFormRuleItem.EditTerminalKeyPress(Sender: TObject; var Key: char); 71 begin 72 if Key = #13 then ButtonOk.Click; 73 end; 74 64 75 procedure TFormRuleItem.FormClose(Sender: TObject; var CloseAction: TCloseAction 65 76 ); … … 84 95 begin 85 96 Core.PersistentForm1.Load(Self); 97 case RuleItem.RuleItemType of 98 ritTerminal: EditTerminal.SetFocus; 99 ritNonTerminal: ListBox1.SetFocus; 100 ritSubItems: TFormRuleItems(FormRuleItems).ListView1.SetFocus; 101 end; 86 102 end; 103 87 104 88 105 procedure TFormRuleItem.ReloadNonTerminals(Grammer: TGrammer); … … 90 107 Rule: TRule; 91 108 begin 92 ComboBoxNonTerminal.Items.Clear;109 ListBox1.Items.Clear; 93 110 for Rule in Grammer.Rules do begin 94 ComboBoxNonTerminal.Items.AddObject(Rule.Name, Rule);111 ListBox1.Items.AddObject(Rule.Name, Rule); 95 112 end; 96 ComboBoxNonTerminal.Sorted := True;113 ListBox1.Sorted := True; 97 114 end; 98 115 … … 100 117 begin 101 118 PageControl1.PageIndex := Integer(RuleItem.RuleItemType); 102 Edit Name.Visible := RuleItem.RuleItemType = ritTerminal;119 EditTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 103 120 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 104 ComboBoxNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal;121 ListBox1.Visible := RuleItem.RuleItemType = ritNonTerminal; 105 122 LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 106 123 end; … … 111 128 ReloadNonTerminals(RuleItem.Grammer); 112 129 ComboBoxType.ItemIndex := Integer(RuleItem.RuleItemType); 113 ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal); 114 EditName.Text := RuleItem.Terminal; 130 ListBox1.ItemIndex := ListBox1.Items.IndexOfObject(RuleItem.NonTerminal); 131 EditTerminal.Text := RuleItem.Terminal; 132 EditTerminalFrom.Text := RuleItem.TerminalFrom; 133 EditTerminalTo.Text := RuleItem.TerminalTo; 115 134 CheckBoxOptional.Checked := RuleItem.Optional; 116 135 CheckBoxRepetitive.Checked := RuleItem.Repetitive; … … 123 142 TFormRuleItems(FormRuleItems).SaveData(RuleItem.SubItems); 124 143 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 125 if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text 126 else if RuleItem.RuleItemType = ritNonTerminal then 127 RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]); 144 RuleItem.Terminal := EditTerminal.Text; 145 RuleItem.TerminalFrom := EditTerminalFrom.Text; 146 RuleItem.TerminalTo := EditTerminalTo.Text; 147 if ListBox1.ItemIndex <> -1 then 148 RuleItem.NonTerminal := TRule(ListBox1.Items.Objects[ListBox1.ItemIndex]) 149 else RuleItem.NonTerminal := nil; 128 150 RuleItem.Optional := CheckBoxOptional.Checked; 129 151 RuleItem.Repetitive := CheckBoxRepetitive.Checked; -
branches/generator/Forms/UFormRuleItems.lfm
r116 r122 10 10 OnShow = FormShow 11 11 LCLVersion = '1.6.4.0' 12 object ListView : TListView12 object ListView1: TListView 13 13 Left = 8 14 14 Height = 392 … … 28 28 TabOrder = 0 29 29 ViewStyle = vsReport 30 OnData = ListView Data31 OnDblClick = ListView DblClick32 OnKeyPress = ListView KeyPress33 OnSelectItem = ListView SelectItem30 OnData = ListView1Data 31 OnDblClick = ListView1DblClick 32 OnKeyPress = ListView1KeyPress 33 OnSelectItem = ListView1SelectItem 34 34 end 35 35 object ToolBar1: TToolBar … … 299 299 ImageIndex = 0 300 300 OnExecute = AAddExecute 301 ShortCut = 45 301 302 end 302 303 object AModify: TAction … … 309 310 ImageIndex = 1 310 311 OnExecute = ARemoveExecute 312 ShortCut = 46 311 313 end 312 314 object AMoveUp: TAction … … 314 316 ImageIndex = 7 315 317 OnExecute = AMoveUpExecute 318 ShortCut = 16422 316 319 end 317 320 object AMoveDown: TAction … … 319 322 ImageIndex = 6 320 323 OnExecute = AMoveDownExecute 324 ShortCut = 16424 321 325 end 322 326 end -
branches/generator/Forms/UFormRuleItems.pas
r119 r122 22 22 ComboBox1: TComboBox; 23 23 Label1: TLabel; 24 ListView : TListView;24 ListView1: TListView; 25 25 MenuItem1: TMenuItem; 26 26 MenuItem2: TMenuItem; … … 42 42 procedure FormCreate(Sender: TObject); 43 43 procedure FormShow(Sender: TObject); 44 procedure ListView Data(Sender: TObject; Item: TListItem);45 procedure ListView DblClick(Sender: TObject);46 procedure ListView KeyPress(Sender: TObject; var Key: char);47 procedure ListView SelectItem(Sender: TObject; Item: TListItem;44 procedure ListView1Data(Sender: TObject; Item: TListItem); 45 procedure ListView1DblClick(Sender: TObject); 46 procedure ListView1KeyPress(Sender: TObject; var Key: char); 47 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 48 48 Selected: Boolean); 49 49 private … … 68 68 { TFormRuleItems } 69 69 70 procedure TFormRuleItems.ListView Data(Sender: TObject; Item: TListItem);70 procedure TFormRuleItems.ListView1Data(Sender: TObject; Item: TListItem); 71 71 begin 72 72 if (Item.Index >= 0) and (Item.Index < RuleItems.Count) then begin … … 97 97 RuleItem: TRuleItem; 98 98 begin 99 if Assigned(ListView .Selected) then begin100 RuleItem := TRuleItem(ListView .Selected.Data);99 if Assigned(ListView1.Selected) then begin 100 RuleItem := TRuleItem(ListView1.Selected.Data); 101 101 FormRuleItem := TFormRuleItem.Create(nil); 102 102 FormRuleItem.LoadData(RuleItem); … … 111 111 procedure TFormRuleItems.AMoveDownExecute(Sender: TObject); 112 112 begin 113 RuleItems.ParentRule.Items.Move(ListView .Selected.Index, ListView.Selected.Index + 1);114 ListView .ItemIndex := ListView.Selected.Index + 1;113 RuleItems.ParentRule.Items.Move(ListView1.Selected.Index, ListView1.Selected.Index + 1); 114 ListView1.ItemIndex := ListView1.Selected.Index + 1; 115 115 ReloadList; 116 116 end; … … 118 118 procedure TFormRuleItems.AMoveUpExecute(Sender: TObject); 119 119 begin 120 RuleItems.ParentRule.Items.Move(ListView .Selected.Index, ListView.Selected.Index - 1);121 ListView .ItemIndex := ListView.Selected.Index - 1;120 RuleItems.ParentRule.Items.Move(ListView1.Selected.Index, ListView1.Selected.Index - 1); 121 ListView1.ItemIndex := ListView1.Selected.Index - 1; 122 122 ReloadList; 123 123 end; … … 125 125 procedure TFormRuleItems.ARemoveExecute(Sender: TObject); 126 126 var 127 I tem: TListItem;127 I: Integer; 128 128 begin 129 for Item in ListView.Items do 130 if Item.Selected then 131 RuleItems.ParentRule.Items.Remove(TRuleItem(Item.Data)); 129 if MessageDlg('Remove item(s)', 'Do you want to remove selected item(s)?', 130 mtConfirmation, mbYesNo, 0) = mrYes then 131 for I := ListView1.Items.Count - 1 downto 0 do 132 if ListView1.Items[I].Selected then 133 RuleItems.ParentRule.Items.Remove(TRuleItem(ListView1.Items[I].Data)); 132 134 ReloadList; 133 135 end; … … 144 146 end; 145 147 146 procedure TFormRuleItems.ListView DblClick(Sender: TObject);148 procedure TFormRuleItems.ListView1DblClick(Sender: TObject); 147 149 begin 148 150 AModify.Execute; 149 151 end; 150 152 151 procedure TFormRuleItems.ListView KeyPress(Sender: TObject; var Key: char);153 procedure TFormRuleItems.ListView1KeyPress(Sender: TObject; var Key: char); 152 154 begin 153 155 if Key = #13 then AModify.Execute; 154 156 end; 155 157 156 procedure TFormRuleItems.ListView SelectItem(Sender: TObject; Item: TListItem;158 procedure TFormRuleItems.ListView1SelectItem(Sender: TObject; Item: TListItem; 157 159 Selected: Boolean); 158 160 begin … … 162 164 procedure TFormRuleItems.UpdateInterface; 163 165 begin 164 AModify.Enabled := Assigned(ListView .Selected);165 ARemove.Enabled := Assigned(ListView .Selected);166 AMoveUp.Enabled := Assigned(ListView .Selected) and (ListView.Selected.Index > 0);167 AMoveDown.Enabled := Assigned(ListView .Selected) and (ListView.Selected.Index < (ListView.Items.Count - 1));166 AModify.Enabled := Assigned(ListView1.Selected); 167 ARemove.Enabled := Assigned(ListView1.Selected); 168 AMoveUp.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index > 0); 169 AMoveDown.Enabled := Assigned(ListView1.Selected) and (ListView1.Selected.Index < (ListView1.Items.Count - 1)); 168 170 end; 169 171 170 172 procedure TFormRuleItems.ReloadList; 171 173 begin 172 if Assigned(RuleItems) then ListView .Items.Count := RuleItems.Count173 else ListView .Items.Count := 0;174 ListView .Refresh;174 if Assigned(RuleItems) then ListView1.Items.Count := RuleItems.Count 175 else ListView1.Items.Count := 0; 176 ListView1.Refresh; 175 177 end; 176 178 -
branches/generator/Forms/UFormRules.lfm
r121 r122 1 1 object FormRules: TFormRules 2 Left = 3 862 Left = 348 3 3 Height = 611 4 Top = 2 214 Top = 230 5 5 Width = 857 6 6 Caption = 'Rules' … … 101 101 ImageIndex = 0 102 102 OnExecute = AAddExecute 103 ShortCut = 45 103 104 end 104 105 object AModify: TAction -
branches/generator/Forms/UFormRules.pas
r121 r122 116 116 procedure TFormRules.ARemoveExecute(Sender: TObject); 117 117 var 118 Item: TListItem; 119 begin 120 for Item in ListView1.Items do 121 if Item.Selected then 122 Rules.Remove(TRule(Item.Data)); 118 I: Integer; 119 begin 120 if MessageDlg('Remove item(s)', 'Do you want to remove selected item(s)?', 121 mtConfirmation, mbYesNo, 0) = mrYes then 122 for I := ListView1.Items.Count - 1 downto 0 do 123 if ListView1.Items[I].Selected then 124 Rules.Remove(TRule(ListView1.Items[I].Data)); 123 125 ReloadList; 124 126 end;
Note:
See TracChangeset
for help on using the changeset viewer.