Changeset 35 for trunk/IDE/Forms/UMainForm.pas
- Timestamp:
- Feb 13, 2012, 3:50:17 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IDE/Forms/UMainForm.pas
r34 r35 9 9 UCompiler, Registry, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, 10 10 UCDManager, UProject, FileUtil, Menus, ActnList, UCDClient, UCDMaster, 11 UCDConjoinForm, UCDWindowList, UCDLayout, UCDCustomize, UCo mpiledForm,12 UCo deTreeForm, URegistry, ULastOpenedList, UApplicationInfo, UDebugLog,13 U Analyzer, UProducer;11 UCDConjoinForm, UCDWindowList, UCDLayout, UCDCustomize, UCoolTranslator, 12 UCompiledForm, UCodeTreeForm, URegistry, ULastOpenedList, UApplicationInfo, 13 UDebugLog, UAnalyzer, UProducer; 14 14 15 15 const 16 16 RegistryRootKey = HKEY_CURRENT_USER; 17 RegistryKey = 'Software\Transpascal';18 17 19 18 type … … 22 21 TMainForm = class(TForm) 23 22 ABuild: TAction; 23 AViewCompiledSoruce: TAction; 24 AViewCodeTree: TAction; 25 AViewOptions: TAction; 24 26 AViewMessages: TAction; 25 27 AViewSourceEditor: TAction; … … 36 38 AProjectClose: TAction; 37 39 ActionList1: TActionList; 38 Button1: TButton; 39 CheckBoxLogParsing: TCheckBox; 40 ComboBoxAnalyzer: TComboBox; 41 ComboBoxProducer: TComboBox; 40 CoolTranslator1: TCoolTranslator; 42 41 DebugLog1: TDebugLog; 43 42 ImageList1: TImageList; 44 Label1: TLabel;45 Label2: TLabel;46 43 MainMenu1: TMainMenu; 47 44 MenuItem1: TMenuItem; … … 55 52 MenuItem17: TMenuItem; 56 53 MenuItem18: TMenuItem; 54 MenuItem19: TMenuItem; 57 55 MenuItem2: TMenuItem; 56 MenuItem20: TMenuItem; 57 MenuItem21: TMenuItem; 58 MenuItem22: TMenuItem; 59 MenuItem23: TMenuItem; 60 MenuItemAnalyzer: TMenuItem; 61 MenuItemProducer: TMenuItem; 58 62 MenuItem3: TMenuItem; 59 63 MenuItem4: TMenuItem; … … 66 70 MenuItemOpenRecent: TMenuItem; 67 71 OpenDialog1: TOpenDialog; 68 PageControl 1: TPageControl;69 PageControl 2: TPageControl;72 PageControlRight: TPageControl; 73 PageControlBottom: TPageControl; 70 74 SaveDialog1: TSaveDialog; 71 75 Splitter1: TSplitter; 76 Splitter2: TSplitter; 72 77 Splitter3: TSplitter; 73 78 TabSheet1: TTabSheet; … … 76 81 TabSheet4: TTabSheet; 77 82 ToolBar1: TToolBar; 83 ToolButton1: TToolButton; 84 ToolButton2: TToolButton; 85 ToolButton3: TToolButton; 86 ToolButton4: TToolButton; 87 ToolButton5: TToolButton; 88 ToolButton6: TToolButton; 89 ToolButton7: TToolButton; 90 ToolButton8: TToolButton; 78 91 procedure AAboutExecute(Sender: TObject); 79 92 procedure AExitExecute(Sender: TObject); … … 85 98 procedure AProjectSaveExecute(Sender: TObject); 86 99 procedure ABuildExecute(Sender: TObject); 100 procedure AViewCodeTreeExecute(Sender: TObject); 101 procedure AViewCompiledSoruceExecute(Sender: TObject); 102 procedure AViewMessagesExecute(Sender: TObject); 103 procedure AViewOptionsExecute(Sender: TObject); 104 procedure AViewProjectExecute(Sender: TObject); 105 procedure AViewSourceEditorExecute(Sender: TObject); 87 106 procedure ComboBox1Change(Sender: TObject); 88 107 procedure ComboBoxProducerChange(Sender: TObject); … … 93 112 private 94 113 LastOpenedFiles: TLastOpenedList; 95 ReopenLastOpenedFile: Boolean;96 114 procedure CompilerDebugLog(Text: string); 115 procedure MenuItemAnalyzerClick(Sender: TObject); 116 procedure MenuItemProducerClick(Sender: TObject); 97 117 procedure OpenRecentClick(Sender: TObject); 98 118 procedure DockInit; 99 procedure LoadFromRegistry ;100 procedure SaveToRegistry ;119 procedure LoadFromRegistry(Root: HKEY; Key: string); 120 procedure SaveToRegistry(Root: HKEY; Key: string); 101 121 procedure OpenProject(FileName: string); 122 procedure UpdateMenu; 102 123 public 124 SelectedAnalyzerIndex: Integer; 125 SelectedProducerIndex: Integer; 126 ReopenLastOpenedFile: Boolean; 127 LogParsing: Boolean; 103 128 Project: TProject; 104 129 Compiler: TCompiler; 105 130 function GetSource(Name: string; var SourceCode: string): Boolean; 131 procedure UpdateInterface; 106 132 end; 107 133 … … 115 141 116 142 uses 117 UMessagesForm, UCodeForm, UProjectManager, UCommon, UAboutForm ;143 UMessagesForm, UCodeForm, UProjectManager, UCommon, UAboutForm, UFormOptions; 118 144 119 145 resourcestring … … 127 153 128 154 // Compile project file 129 if (ComboBoxAnalyzer.Items.Count > 0) and (ComboBoxAnalyzer.ItemIndex <> -1) and 130 (ComboBoxProducer.Items.Count > 0) and (ComboBoxProducer.ItemIndex <> -1) then begin 131 Compiler.Producer := TProducer(Compiler.Producers[ComboBoxProducer.ItemIndex]); 132 Compiler.Analyzer := TAnalyzer(Compiler.Analyzers[ComboBoxAnalyzer.ItemIndex]); 155 Compiler.Producer := TProducer(Compiler.Producers[SelectedProducerIndex]); 156 Compiler.Analyzer := TAnalyzer(Compiler.Analyzers[SelectedAnalyzerIndex]); 133 157 Compiler.Analyzer.OnGetSource := GetSource; 134 158 Compiler.Init; 135 159 136 if CheckBoxLogParsing.Checkedthen160 if LogParsing then 137 161 Compiler.Analyzer.OnDebugLog := CompilerDebugLog 138 162 else Compiler.Analyzer.OnDebugLog := nil; … … 145 169 ProjectManager.TreeViewProjectChange(Self, ProjectManager.TreeViewProject.Selected); 146 170 MessagesForm.Reload; 147 end; 171 end; 172 173 procedure TMainForm.AViewCodeTreeExecute(Sender: TObject); 174 begin 175 PageControlRight.TabIndex := 1; 176 end; 177 178 procedure TMainForm.AViewCompiledSoruceExecute(Sender: TObject); 179 begin 180 PageControlBottom.TabIndex := 1; 181 end; 182 183 procedure TMainForm.AViewMessagesExecute(Sender: TObject); 184 begin 185 PageControlBottom.TabIndex := 0; 186 end; 187 188 procedure TMainForm.AViewOptionsExecute(Sender: TObject); 189 begin 190 FormOptions.ShowModal; 191 end; 192 193 procedure TMainForm.AViewProjectExecute(Sender: TObject); 194 begin 195 PageControlRight.TabIndex := 0; 196 end; 197 198 procedure TMainForm.AViewSourceEditorExecute(Sender: TObject); 199 begin 200 148 201 end; 149 202 … … 164 217 F.Free; 165 218 end else Result := False; 219 end; 220 221 procedure TMainForm.UpdateInterface; 222 var 223 I: Integer; 224 Title: string; 225 begin 226 Title := ApplicationInfo.Name; 227 if Project.Name <> '' then Title := Project.Name + ' - ' + Title; 228 if Project.Modified then Title := Title + ' *'; 229 Caption := Title; 230 AProjectClose.Enabled := Project.Active; 231 AProjectSave.Enabled := Project.Active and Project.Modified; 232 AProjectSaveAs.Enabled := Project.Active; 233 (*AProgramRun.Enabled := Project.Active and (BrainFuckInterpreter.State = rsStopped); 234 AProgramPause.Enabled := Project.Active and (BrainFuckInterpreter.State = rsRunning); 235 AProgramStop.Enabled := Project.Active and (BrainFuckInterpreter.State <> rsStopped);*) 236 UpdateMenu; 166 237 end; 167 238 … … 222 293 end; 223 294 224 procedure TMainForm.LoadFromRegistry ;295 procedure TMainForm.LoadFromRegistry(Root: HKEY; Key: string); 225 296 begin 226 297 with TRegistryEx.Create do 227 298 try 228 RootKey := HKEY_CURRENT_USER;229 OpenKey( RegistryKey, True);299 RootKey := Root; 300 OpenKey(Key, True); 230 301 ReopenLastOpenedFile := ReadBoolWithDefault('ReopenLastOpenedFile', True); 231 ComboBoxProducer.ItemIndex := ReadIntegerWithDefault('ProducerType', 0); 232 with ComboBoxProducer do 233 if (ItemIndex = -1) and (Items.Count > 0) then ItemIndex := 0; 234 ComboBoxAnalyzer.ItemIndex := ReadIntegerWithDefault('AnalyzerType', 0); 235 with ComboBoxAnalyzer do 236 if (ItemIndex = -1) and (Items.Count > 0) then ItemIndex := 0; 237 CheckBoxLogParsing.Checked := ReadBoolWithDefault('LogParsing', False); 302 SelectedProducerIndex := ReadIntegerWithDefault('ProducerType', 0); 303 SelectedAnalyzerIndex := ReadIntegerWithDefault('AnalyzerType', 0); 304 LogParsing := ReadBoolWithDefault('LogParsing', False); 305 if ValueExists('LanguageCode') then 306 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', '')) 307 else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(''); 238 308 finally 239 309 Free; 240 310 end; 241 LastOpenedFiles.LoadFromRegistry(RegistryRootKey, RegistryKey);242 end; 243 244 procedure TMainForm.SaveToRegistry ;311 LastOpenedFiles.LoadFromRegistry(RegistryRootKey, Key); 312 end; 313 314 procedure TMainForm.SaveToRegistry(Root: HKEY; Key: string); 245 315 begin 246 316 with TRegistryEx.Create do 247 317 try 248 RootKey := R egistryRootKey;249 OpenKey( RegistryKey, True);318 RootKey := Root; 319 OpenKey(Key, True); 250 320 WriteBool('ReopenLastOpenedFile', ReopenLastOpenedFile); 251 WriteInteger('ProducerType', ComboBoxProducer.ItemIndex); 252 WriteInteger('AnalyzerType', ComboBoxAnalyzer.ItemIndex); 253 WriteBool('LogParsing', CheckBoxLogParsing.Checked); 321 WriteInteger('ProducerType', SelectedProducerIndex); 322 WriteInteger('AnalyzerType', SelectedAnalyzerIndex); 323 WriteBool('LogParsing', LogParsing); 324 if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then 325 WriteString('LanguageCode', CoolTranslator1.Language.Code) 326 else DeleteValue('LanguageCode'); 254 327 finally 255 328 Free; 256 329 end; 257 LastOpenedFiles.SaveToRegistry(RegistryRootKey, RegistryKey);330 LastOpenedFiles.SaveToRegistry(RegistryRootKey, Key); 258 331 LastOpenedFiles.ReloadMenu; 259 332 end; … … 265 338 LastOpenedFiles.ReloadMenu; 266 339 ProjectManager.UpdateProjectTree; 267 Caption := ApplicationInfo.Name + ' - ' + Project.Name; 340 UpdateInterface; 341 end; 342 343 procedure TMainForm.MenuItemAnalyzerClick(Sender: TObject); 344 begin 345 with TMenuItem(Sender) do begin 346 SelectedAnalyzerIndex := MenuIndex; 347 UpdateMenu; 348 end; 349 end; 350 351 procedure TMainForm.MenuItemProducerClick(Sender: TObject); 352 begin 353 with TMenuItem(Sender) do begin 354 SelectedProducerIndex := MenuIndex; 355 UpdateMenu; 356 end; 357 end; 358 359 procedure TMainForm.UpdateMenu; 360 var 361 I: Integer; 362 NewMenuItem: TMenuItem; 363 begin 364 MenuItemAnalyzer.Clear; 365 for I := 0 to Compiler.Analyzers.Count - 1 do begin 366 NewMenuItem := TMenuItem.Create(MenuItemAnalyzer); 367 NewMenuItem.Caption := TAnalyzer(Compiler.Analyzers[I]).Name; 368 NewMenuItem.OnClick := MenuItemAnalyzerClick; 369 if I = SelectedAnalyzerIndex then NewMenuItem.Checked := True; 370 MenuItemAnalyzer.Add(NewMenuItem); 371 end; 372 MenuItemProducer.Clear; 373 for I := 0 to Compiler.Producers.Count - 1 do begin 374 NewMenuItem := TMenuItem.Create(MenuItemProducer); 375 NewMenuItem.Caption := TProducer(Compiler.Producers[I]).Name; 376 NewMenuItem.OnClick := MenuItemProducerClick; 377 if I = SelectedProducerIndex then NewMenuItem.Checked := True; 378 MenuItemProducer.Add(NewMenuItem); 379 end; 268 380 end; 269 381 … … 271 383 begin 272 384 Project.Save; 273 SaveToRegistry ;385 SaveToRegistry(RegistryRootKey, ApplicationInfo.RegistryKey); 274 386 end; 275 387 … … 284 396 LastOpenedFiles.MenuItem := MenuItemOpenRecent; 285 397 LastOpenedFiles.ClickAction := OpenRecentClick; 286 287 ComboBoxProducer.Clear;288 for I := 0 to Compiler.Producers.Count - 1 do289 ComboBoxProducer.AddItem(TProducer(Compiler.Producers[I]).Name, nil);290 291 ComboBoxAnalyzer.Clear;292 for I := 0 to Compiler.Analyzers.Count - 1 do293 ComboBoxAnalyzer.AddItem(TAnalyzer(Compiler.Analyzers[I]).Name, nil);294 398 end; 295 399 … … 316 420 NewProjectFile: TProjectFile; 317 421 begin 318 LoadFromRegistry ;422 LoadFromRegistry(RegistryRootKey, ApplicationInfo.RegistryKey); 319 423 DockInit; 320 424
Note:
See TracChangeset
for help on using the changeset viewer.