Changeset 137 for branches/generator/Forms/UFormRuleItem.pas
- Timestamp:
- Dec 27, 2017, 6:05:11 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormRuleItem.pas
r136 r137 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 CheckBoxLookupTable: TCheckBox; 18 19 CheckBoxAnyExcept: TCheckBox; 19 20 CheckBoxEscapedString: TCheckBox; 20 21 CheckBoxOptional: TCheckBox; 21 22 CheckBoxRepetitive: TCheckBox; 23 ComboBoxLookupTableAction: TComboBox; 22 24 ComboBoxType: TComboBox; 23 25 EditTerminal: TEdit; 24 26 EditTerminalFrom: TEdit; 25 27 EditTerminalTo: TEdit; 28 Label1: TLabel; 26 29 Label2: TLabel; 27 30 LabelNonTerminal: TLabel; … … 29 32 LabelTerminal1: TLabel; 30 33 LabelTerminal2: TLabel; 31 ListBox1: TListBox; 34 ListBoxNonTerminals: TListBox; 35 ListBoxLookupTable: TListBox; 32 36 PageControl1: TPageControl; 33 37 TabSheetTerminalRange: TTabSheet; … … 35 39 TabSheetNonTerminal: TTabSheet; 36 40 TabSheetSubItems: TTabSheet; 41 procedure CheckBoxLookupTableChange(Sender: TObject); 37 42 procedure ComboBoxTypeChange(Sender: TObject); 38 43 procedure EditTerminalKeyPress(Sender: TObject; var Key: char); … … 44 49 FormRuleItems: TForm; 45 50 procedure ReloadNonTerminals(Grammer: TGrammer); 51 procedure ReloadLookupTables(Grammer: TGrammer); 46 52 public 47 53 RuleItem: TRuleItem; … … 70 76 end; 71 77 78 procedure TFormRuleItem.CheckBoxLookupTableChange(Sender: TObject); 79 begin 80 UpdateInterface; 81 end; 82 72 83 procedure TFormRuleItem.EditTerminalKeyPress(Sender: TObject; var Key: char); 73 84 begin … … 99 110 case RuleItem.RuleItemType of 100 111 ritTerminal: EditTerminal.SetFocus; 101 ritNonTerminal: ListBox 1.SetFocus;112 ritNonTerminal: ListBoxNonTerminals.SetFocus; 102 113 ritSubItems: TFormRuleItems(FormRuleItems).ListView1.SetFocus; 103 114 ritTerminalRange: EditTerminalFrom.SetFocus; … … 110 121 Rule: TRule; 111 122 begin 112 ListBox 1.Items.Clear;123 ListBoxNonTerminals.Items.Clear; 113 124 for Rule in Grammer.Rules do begin 114 ListBox1.Items.AddObject(Rule.Name, Rule); 115 end; 116 ListBox1.Sorted := True; 125 ListBoxNonTerminals.Items.AddObject(Rule.Name, Rule); 126 end; 127 ListBoxNonTerminals.Sorted := True; 128 end; 129 130 procedure TFormRuleItem.ReloadLookupTables(Grammer: TGrammer); 131 var 132 Item: TLookupTable; 133 begin 134 ListBoxLookupTable.Items.Clear; 135 for Item in Grammer.LookupTables do begin 136 ListBoxLookupTable.Items.AddObject(Item.Name, Item); 137 end; 138 ListBoxLookupTable.Sorted := True; 117 139 end; 118 140 … … 122 144 EditTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 123 145 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 124 ListBox 1.Visible := RuleItem.RuleItemType = ritNonTerminal;146 ListBoxNonTerminals.Visible := RuleItem.RuleItemType = ritNonTerminal; 125 147 LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 126 148 CheckBoxOptional.Enabled := RuleItem.ParentRule.Items.RuleType = rtAnd; … … 128 150 CheckBoxEscapedString.Enabled := (RuleItem.RuleItemType = ritTerminal) or 129 151 (RuleItem.RuleItemType = ritTerminalRange); 152 ListBoxLookupTable.Enabled := CheckBoxLookupTable.Checked; 153 ComboBoxLookupTableAction.Enabled := CheckBoxLookupTable.Checked; 130 154 end; 131 155 … … 135 159 ReloadNonTerminals(RuleItem.Grammer); 136 160 ComboBoxType.ItemIndex := Integer(RuleItem.RuleItemType); 137 ListBox 1.ItemIndex := ListBox1.Items.IndexOfObject(RuleItem.NonTerminal);161 ListBoxNonTerminals.ItemIndex := ListBoxNonTerminals.Items.IndexOfObject(RuleItem.NonTerminal); 138 162 EditTerminal.Text := RuleItem.Terminal; 139 163 EditTerminalFrom.Text := RuleItem.TerminalFrom; … … 144 168 TFormRuleItems(FormRuleItems).LoadData(RuleItem.SubItems); 145 169 CheckBoxEscapedString.Checked := RuleItem.EscapedStrings; 170 // Lookup table 171 CheckBoxLookupTable.Checked := RuleItem.LookupTableUsed; 172 ReloadLookupTables(RuleItem.Grammer); 173 ComboBoxLookupTableAction.ItemIndex := Integer(RuleItem.LookupTableAction); 174 ListBoxLookupTable.ItemIndex := ListBoxLookupTable.Items.IndexOfObject(RuleItem.LookupTable); 146 175 UpdateInterface; 147 176 end; … … 155 184 RuleItem.TerminalFrom := EditTerminalFrom.Text; 156 185 RuleItem.TerminalTo := EditTerminalTo.Text; 157 if ListBox 1.ItemIndex <> -1 then158 RuleItem.NonTerminal := TRule(ListBox 1.Items.Objects[ListBox1.ItemIndex])186 if ListBoxNonTerminals.ItemIndex <> -1 then 187 RuleItem.NonTerminal := TRule(ListBoxNonTerminals.Items.Objects[ListBoxNonTerminals.ItemIndex]) 159 188 else RuleItem.NonTerminal := nil; 160 189 RuleItem.Optional := CheckBoxOptional.Checked; … … 162 191 RuleItem.AnyExcept := CheckBoxAnyExcept.Checked; 163 192 RuleItem.EscapedStrings := CheckBoxEscapedString.Checked; 193 // Lookup table 194 RuleItem.LookupTableUsed := CheckBoxLookupTable.Checked; 195 RuleItem.LookupTableAction := TLookupTableAction(ComboBoxLookupTableAction.ItemIndex); 196 if ListBoxLookupTable.ItemIndex <> -1 then 197 RuleItem.LookupTable := TLookupTable(ListBoxLookupTable.Items.Objects[ListBoxLookupTable.ItemIndex]) 198 else RuleItem.LookupTable := nil; 164 199 end; 165 200
Note:
See TracChangeset
for help on using the changeset viewer.