Changeset 4 for trunk/UMainForm.pas
- Timestamp:
- Feb 9, 2012, 1:43:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMainForm.pas
r3 r4 42 42 MenuItem8: TMenuItem; 43 43 MenuItem9: TMenuItem; 44 OpenDialog1: TOpenDialog; 45 SaveDialog1: TSaveDialog; 44 46 StatusBar1: TStatusBar; 45 47 TabControl1: TTabControl; … … 53 55 ToolButton7: TToolButton; 54 56 procedure AExitExecute(Sender: TObject); 57 procedure AProjectCloseExecute(Sender: TObject); 58 procedure AProjectNewExecute(Sender: TObject); 59 procedure AProjectOpenExecute(Sender: TObject); 60 procedure AProjectSaveAsExecute(Sender: TObject); 61 procedure AProjectSaveExecute(Sender: TObject); 55 62 procedure ARunExecute(Sender: TObject); 63 procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); 56 64 procedure FormCreate(Sender: TObject); 57 65 procedure FormDestroy(Sender: TObject); 58 66 procedure FormShow(Sender: TObject); 67 procedure MemoSourceChange(Sender: TObject); 59 68 private 60 69 { private declarations } 61 70 public 71 Modified: Boolean; 72 ProjectFileName: string; 62 73 BrainFuckInterpreter: TBrainFuckInterpreter; 74 procedure UpdateInterface; 63 75 end; 64 76 … … 71 83 72 84 uses 73 UInterpreterForm ;85 UInterpreterForm, UApplicationInfo; 74 86 75 87 { TMainForm } … … 77 89 procedure TMainForm.FormShow(Sender: TObject); 78 90 begin 91 UpdateInterface; 92 end; 79 93 94 procedure TMainForm.MemoSourceChange(Sender: TObject); 95 begin 96 Modified := True; 97 UpdateInterface; 98 end; 99 100 procedure TMainForm.UpdateInterface; 101 var 102 Title: string; 103 begin 104 AProjectSave.Enabled := Modified; 105 Title := ApplicationInfo.Name; 106 if ProjectFileName <> '' then Title := ProjectFileName + ' - ' + Title; 107 if Modified then Title := Title + ' *'; 108 Caption := Title; 109 MemoSource.Enabled := ProjectFileName <> ''; 110 AProjectClose.Enabled := ProjectFileName <> ''; 111 ARun.Enabled := ProjectFileName <> ''; 112 ACompile.Enabled := ProjectFileName <> ''; 80 113 end; 81 114 … … 99 132 end; 100 133 134 procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean); 135 begin 136 end; 137 101 138 procedure TMainForm.AExitExecute(Sender: TObject); 102 139 begin … … 104 141 end; 105 142 143 procedure TMainForm.AProjectCloseExecute(Sender: TObject); 144 begin 145 Modified := False; 146 ProjectFileName := ''; 147 MemoSource.Clear; 148 UpdateInterface; 149 end; 150 151 procedure TMainForm.AProjectNewExecute(Sender: TObject); 152 begin 153 ProjectFileName := 'Project.bf'; 154 MemoSource.Clear; 155 UpdateInterface; 156 end; 157 158 procedure TMainForm.AProjectOpenExecute(Sender: TObject); 159 begin 160 OpenDialog1.FileName := ProjectFileName; 161 if OpenDialog1.Execute then begin 162 MemoSource.Lines.LoadFromFile(OpenDialog1.FileName); 163 ProjectFileName := OpenDialog1.FileName; 164 UpdateInterface; 165 end; 166 end; 167 168 procedure TMainForm.AProjectSaveAsExecute(Sender: TObject); 169 begin 170 SaveDialog1.FileName := ProjectFileName; 171 if SaveDialog1.Execute then begin 172 MemoSource.Lines.SaveToFile(SaveDialog1.FileName); 173 ProjectFileName := SaveDialog1.FileName; 174 Modified := False; 175 UpdateInterface; 176 end; 177 end; 178 179 procedure TMainForm.AProjectSaveExecute(Sender: TObject); 180 begin 181 if Modified then AProjectSaveAs.Execute; 182 end; 183 106 184 end. 107 185
Note:
See TracChangeset
for help on using the changeset viewer.