Changeset 122 for branches/generator/Forms/UFormRuleItem.pas
- Timestamp:
- Nov 29, 2017, 2:03:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.