Changeset 111 for branches/generator/Forms/UFormRuleItem.pas
- Timestamp:
- Aug 9, 2017, 12:09:47 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormRuleItem.pas
r110 r111 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 ComboBoxType: TComboBox; 19 ComboBoxNonTerminal: TComboBox; 18 20 EditName: TEdit; 19 Label1: TLabel; 21 LabelTerminal: TLabel; 22 Label2: TLabel; 23 LabelNonTerminal: TLabel; 24 procedure ComboBoxTypeChange(Sender: TObject); 20 25 private 21 { private declarations }26 procedure ReloadNonTerminals(Grammer: TGrammer); 22 27 public 28 RuleItem: TRuleItem; 29 procedure UpdateInterface; 23 30 procedure LoadData(RuleItem: TRuleItem); 24 31 procedure SaveData(RuleItem: TRuleItem); … … 34 41 { TFormRuleItem } 35 42 43 procedure TFormRuleItem.ComboBoxTypeChange(Sender: TObject); 44 begin 45 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 46 UpdateInterface; 47 end; 48 49 procedure TFormRuleItem.ReloadNonTerminals(Grammer: TGrammer); 50 var 51 Rule: TRule; 52 begin 53 ComboBoxNonTerminal.Items.Clear; 54 for Rule in Grammer.Rules do begin 55 ComboBoxNonTerminal.Items.AddObject(Rule.Name, Rule); 56 end; 57 end; 58 59 procedure TFormRuleItem.UpdateInterface; 60 begin 61 EditName.Visible := RuleItem.RuleItemType = ritTerminal; 62 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 63 ComboBoxNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 64 LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 65 end; 66 36 67 procedure TFormRuleItem.LoadData(RuleItem: TRuleItem); 37 68 begin 38 EditName.Text := RuleItem.Name; 69 Self.RuleItem := RuleItem; 70 ReloadNonTerminals(RuleItem.Grammer); 71 ComboBoxType.ItemIndex := Integer(RuleItem.RuleItemType); 72 ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal); 73 EditName.Text := RuleItem.Terminal; 74 UpdateInterface; 39 75 end; 40 76 41 77 procedure TFormRuleItem.SaveData(RuleItem: TRuleItem); 42 78 begin 43 RuleItem.Name := EditName.Text; 79 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 80 if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text 81 else if RuleItem.RuleItemType = ritNonTerminal then 82 RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]); 44 83 end; 45 84
Note:
See TracChangeset
for help on using the changeset viewer.