3 // import "SelectorBar"
4 import "CompilersDetectionDialog"
7 FileDialog settingsFileDialog { type = selectDir, text = $"Select directory" };
9 FileDialog toolchainFileDialog { type = open, text = $"Open"; mayNotExist = true; };
11 class GlobalSettingsDialog : Window
15 background = formColor;
17 borderStyle = sizable;
18 text = $"Global Settings";
19 minClientSize = { 560, 446 };
20 nativeDecorations = true;
22 IDESettings ideSettings;
23 IDESettingsContainer settingsContainer;
24 String workspaceActiveCompiler;
26 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 8, right = 8, bottom = 40 } };
28 EditorTab editorTab { this, tabControl = tabControl };
29 CompilersTab compilersTab { this, tabControl = tabControl };
30 ProjectOptionsTab projectOptionsTab { this, tabControl = tabControl };
31 WorkspaceOptionsTab workspaceOptionsTab { this, tabControl = tabControl };
33 property bool settingsModified
37 return editorTab.modifiedDocument || compilersTab.modifiedDocument ||
38 projectOptionsTab.modifiedDocument || workspaceOptionsTab.modifiedDocument;
42 bool OnClose(bool parentClosing)
44 if(!settingsModified || MessageBox {
45 type = okCancel, master = ide,
46 text = $"Lose Changes?",
47 contents = $"Are you sure you wish to discard changes?"
55 parent = this, hotKey = escape, text = $"Cancel", id = DialogResult::cancel;
56 position = { 290, 290 }, size = { 80 };
57 anchor = { right = 8, bottom = 8 };
58 NotifyClicked = ButtonCloseDialog;
63 parent = this, isDefault = true, text = $"OK";
64 position = { 200, 290 }, size = { 90 };
65 anchor = { right = 96, bottom = 8 };
67 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
71 bool editorSettingsChanged = false;
72 bool compilerSettingsChanged = false;
73 bool projectOptionsChanged = false;
74 bool workspaceOptionsChanged = false;
76 if(editorTab.modifiedDocument)
78 if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
79 editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
80 editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
82 ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
83 ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
84 ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
85 editorSettingsChanged = true;
89 if(compilersTab.modifiedDocument)
91 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
92 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
93 ideSettings.compilerConfigs.Free();
94 for(compiler : compilersTab.compilerConfigs)
95 ideSettings.compilerConfigs.Add(compiler.Copy());
96 compilerSettingsChanged = true;
99 if(projectOptionsTab.modifiedDocument)
101 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
102 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
104 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
105 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
106 projectOptionsChanged = true;
110 if(workspaceOptionsTab.modifiedDocument)
112 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
113 if(row && row.string)
115 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
117 ideSettings.defaultCompiler = row.string;
118 workspaceOptionsChanged = true;
123 settingsContainer.Save();
125 if(compilerSettingsChanged)
126 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
127 if(editorSettingsChanged)
128 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
129 if(projectOptionsChanged)
130 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
133 Destroy(DialogResult::ok);
142 for(c = 0; c < DirTypes::enumSize; c++)
144 CompilerDir compilerDir;
146 for(systemDir : ideSettings.systemDirs[c])
148 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
149 dirs.Add(compilerDir);
152 row = compilersTab.dirs[c].AddRow();
153 row.SetData(null, "");
154 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
155 compilersTab.dirs[c].modifiedDocument = false;
162 CompilerConfig activateCompiler = null;
163 CompilerConfig readonlyCompiler = null;
166 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
167 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
168 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
171 if(workspaceActiveCompiler)
173 for(compiler : ideSettings.compilerConfigs)
175 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
176 activateCompiler = compiler;
177 if(!readonlyCompiler && compiler.readOnly)
178 readonlyCompiler = compiler;
179 if(activateCompiler && readonlyCompiler)
183 if(!activateCompiler && readonlyCompiler)
184 activateCompiler = readonlyCompiler;
185 if(!activateCompiler && ideSettings.compilerConfigs.count)
186 activateCompiler = ideSettings.compilerConfigs[0];
188 for(compiler : ideSettings.compilerConfigs)
189 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
190 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
193 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
194 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
201 editorTab.modifiedDocument = false;
202 compilersTab.modifiedDocument = false;
203 compilersTab.dirsTab.modifiedDocument = false;
204 compilersTab.toolchainTab.modifiedDocument = false;
205 compilersTab.optionsTab.modifiedDocument = false;
206 compilersTab.activeCompiler = null;
207 compilersTab.compilerConfigs.Free();
208 compilersTab.compilerSelector.Clear();
209 projectOptionsTab.modifiedDocument = false;
210 workspaceOptionsTab.modifiedDocument = false;
213 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
216 class EditorTab : GlobalSettingsSubTab
218 background = formColor;
223 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
224 NotifyClicked = NotifyClickedModifiedDocument;
227 Button caretFollowsScrolling
229 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
230 NotifyClicked = NotifyClickedModifiedDocument;
233 Button showLineNumbers
235 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
236 NotifyClicked = NotifyClickedModifiedDocument;
239 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
241 modifiedDocument = true;
246 static void DrawStipple(Surface surface, Size clientSize)
250 int x2 = clientSize.w - 1;
251 int y2 = clientSize.h - 1;
252 if((x2 - x1) & 1) x2--;
253 if((y2 - y1) & 1) y2--;
255 surface.LineStipple(0x5555);
256 surface.Rectangle(x1, y1, x2, y2);
257 surface.LineStipple(0);
260 class CompilersTab : GlobalSettingsSubTab
262 background = formColor;
265 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
266 PathBox compilerConfigsDir
268 this, anchor = { left = 210, top = 8, right = 8 };
269 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
272 SelectorBar compilerSelector
274 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
276 direction = horizontal, scrollable = true;
278 bool OnKeyDown(Key key, unichar ch)
282 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
287 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
290 return SelectorBar::OnKeyDown(key, ch);
293 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
295 ((CompilersTab)master).labelCompilers.Update(null);
301 SelectorBar::OnPostCreate();
302 if(((CompilersTab)parent).selectedButton)
304 ((CompilersTab)parent).selectedButton.Activate();
305 ((CompilersTab)parent).selectedButton.checked = true;
306 ((CompilersTab)parent).selectedButton = null;
312 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
314 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
315 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
316 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
317 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
319 List<CompilerConfig> compilerConfigs { };
320 CompilerConfig activeCompiler;
324 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
326 void OnRedraw(Surface surface)
328 Label::OnRedraw(surface);
329 if(labeledWindow.active)
330 DrawStipple(surface, clientSize);
334 void FindUniqueCompilerName(char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
337 char tmp[MAX_F_STRING];
338 /*if(startWithNumber)
339 sprintf(tmp, "%s%d", baseName, num);
341 strcpy(tmp, baseName);
344 CompilerConfig matchingCompiler = null;
345 for(c : compilerConfigs)
346 { // TOFIX: Error when omitting these brackets, c not found
347 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
349 matchingCompiler = c;
356 sprintf(tmp, "%s%d", baseName, num);
364 Button createCompiler
366 parent = this, bevelOver = true, inactive = true;
368 anchor = { top = 40, right = 77 };
369 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
371 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
373 char compilerName[MAX_F_STRING];
374 CompilerConfig newCompiler;
375 FindUniqueCompilerName("New Compiler", null, compilerName);
376 newCompiler = MakeDefaultCompiler(compilerName, false);
377 AddCompiler(newCompiler, true);
378 modifiedDocument = true;
382 Button detectCompiler
384 parent = this, bevelOver = true, inactive = true;
386 anchor = { top = 40, right = 54 };
387 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
389 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
391 CompilersDetectionDialog compilersDetectionDialog
396 if(compilersDetectionDialog.Modal())
398 if(compilersDetectionDialog.selectedCompilerType)
400 char uniqueName[MAX_F_STRING];
401 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
402 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
403 newCompiler.name = uniqueName;
404 AddCompiler(newCompiler, true);
405 modifiedDocument = true;
411 Button duplicateCompiler
413 parent = this, bevelOver = true, inactive = true;
415 anchor = { top = 40, right = 31 };
416 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
418 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
420 char copyName[MAX_F_STRING];
421 CompilerConfig copyCompiler = activeCompiler.Copy();
422 FindUniqueCompilerName(copyCompiler.name, null, copyName);
423 copyCompiler.readOnly = false;
424 copyCompiler.name = copyName;
425 AddCompiler(copyCompiler, true);
426 modifiedDocument = true;
430 Button deleteCompiler
432 parent = this, bevelOver = true, inactive = true;
434 anchor = { top = 40, right = 8 };
435 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
437 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
441 CompilerConfig compilerToDelete = activeCompiler;
442 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
443 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
444 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
446 SelectorButton button = compilerSelector.FindButtonByID((int)compilerToDelete);
448 compilerSelector.RemoveButton(button);
449 //DeleteCompiler(compilerToDelete);
451 Iterator<CompilerConfig> it { compilerConfigs };
452 if(it.Find(compilerToDelete))
453 compilerConfigs.Delete(it.pointer);
455 modifiedDocument = true;
464 void AddCompiler(CompilerConfig compiler, bool load)
466 SelectorButton selectButton;
467 if(compiler.readOnly)
469 SelectorButton button
471 compilerSelector, master = this, text = compiler.name, id = (int)compiler;
472 NotifyClicked = CompilerClicked;
474 selectButton = button;
478 EditableSelectorButton button
480 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int)compiler;
481 NotifyClicked = CompilerClicked;
483 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
485 if(*newName && (*newName)[0])
487 char compilerName[MAX_F_STRING];
488 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
489 if(strcmp(*newName, compilerName))
492 *newName = CopyString(compilerName);
494 activeCompiler.name = compilerName;
495 modifiedDocument = true;
501 selectButton = (SelectorButton)button;
503 compilerConfigs.Add(compiler);
506 LoadCompiler(compiler);
507 selectedButton = selectButton;
508 compilerSelector.Select(selectedButton);
511 SelectorButton selectedButton;
513 void LoadCompiler(CompilerConfig compiler)
515 bool modified = modifiedDocument;
516 activeCompiler = compiler;
520 environmentTab.Load();
523 // Restore original modifiedDocument
524 modifiedDocument = modified;
526 deleteCompiler.disabled = compiler.readOnly;
529 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
531 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
532 LoadCompiler((CompilerConfig)clickedButton.id);
536 bool NotifyModifiedDocument(PathBox pathBox)
538 modifiedDocument = true;
543 Array<String> displayDirectoryNames
550 class CompilerDirectoriesTab : CompilersSubTab
552 background = formColor;
553 text = $"Directories";
555 Button dirTypeTglBtn[DirTypes];
556 DirectoriesBox dirs[DirTypes], currentDirs;
558 ~CompilerDirectoriesTab()
561 for(c = 0; c < DirTypes::enumSize; c++)
564 delete dirTypeTglBtn[c];
567 CompilerDirectoriesTab()
570 for(c = 0; c < DirTypes::enumSize; c++)
572 dirs[c] = DirectoriesBox
574 this;//, alwaysHighLight = true
575 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
578 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
579 settingsFileDialog.filePath = directory;
580 if(settingsFileDialog.Modal())
581 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
584 bool NotifyModified(DirectoriesBox dirsBox)
586 CompilerConfig compiler = loadedCompiler;
589 DirTypes dirType = (DirTypes)dirsBox.id;
590 if(dirType == includes)
591 compiler.includeDirs = dirsBox.strings;
592 else if(dirType == libraries)
593 compiler.libraryDirs = dirsBox.strings;
594 else if(dirType == executables)
595 compiler.executableDirs = dirsBox.strings;
597 compilersTab.modifiedDocument = true;
605 dirs[c].visible = false;
607 // (width) Should be 324 for text...
608 //field[c] = { dataType = class(char *), editable = true };
609 //dirs[c].AddField(field[c]);
612 int v = (int)c * 100 + 8;
613 dirTypeTglBtn[c] = Button
615 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
619 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
621 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
623 DirTypes dirType = (DirTypes)button.id;
624 currentDirs.visible = false;
625 dirs[dirType].visible = true;
626 currentDirs = dirs[dirType];
630 incref dirTypeTglBtn[c];
633 dirTypeTglBtn[c].hotKey = altI;
634 else if(c == libraries)
635 dirTypeTglBtn[c].hotKey = altL;
636 else if(c == executables)
637 dirTypeTglBtn[c].hotKey = altE;
640 currentDirs = dirs[includes];
641 dirTypeTglBtn[includes].checked = true;
649 CompilerConfig compiler = loadedCompiler;
650 dirs[includes].strings = compiler.includeDirs;
651 dirs[libraries].strings = compiler.libraryDirs;
652 dirs[executables].strings = compiler.executableDirs;
653 dirs[includes].list.scroll = { 0, 0 };
654 dirs[libraries].list.scroll = { 0, 0 };
655 dirs[executables].list.scroll = { 0, 0 };
660 class CompilerToolchainTab : CompilersSubTab
662 background = formColor;
665 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
668 this, anchor = { left = 120, top = 8, right = 8 };
669 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
671 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
674 this, anchor = { left = 120, top = 34, right = 8 };
675 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
677 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
680 this, anchor = { left = 120, top = 60, right = 8 };
681 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
683 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
686 this, anchor = { left = 120, top = 86, right = 8 };
687 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
689 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
692 this, anchor = { left = 120, top = 112, right = 8 };
693 text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
695 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
698 this, anchor = { left = 120, top = 138, right = 8 };
699 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
701 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
704 this, anchor = { left = 120, top = 164, right = 8 };
705 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
707 Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
710 this, anchor = { left = 120, top = 190, right = 8 };
711 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
713 Label execPrefixLabel { this, position = { 8, 220 }, labeledWindow = execPrefix, tabCycle = false, inactive = true };
716 this, anchor = { left = 120, top = 216, right = 8 };
717 text = $"Execution Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
720 bool NotifyModifiedDocument(PathBox pathBox)
724 CompilerConfig compiler = loadedCompiler;
726 compiler.ecpCommand = pathBox.slashPath;
727 else if(pathBox == ecc)
728 compiler.eccCommand = pathBox.slashPath;
729 else if(pathBox == ecs)
730 compiler.ecsCommand = pathBox.slashPath;
731 else if(pathBox == ear)
732 compiler.earCommand = pathBox.slashPath;
733 else if(pathBox == cpp)
734 compiler.cppCommand = pathBox.slashPath;
735 else if(pathBox == cc)
736 compiler.ccCommand = pathBox.slashPath;
737 else if(pathBox == cxx)
738 compiler.cxxCommand = pathBox.slashPath;
739 else if(pathBox == make)
740 compiler.makeCommand = pathBox.slashPath;
741 else if(pathBox == execPrefix)
742 compiler.execPrefixCommand = pathBox.slashPath;
743 modifiedDocument = true;
744 compilersTab.modifiedDocument = true;
753 CompilerConfig compiler = loadedCompiler;
754 bool disabled = compiler.readOnly;
755 bool isVC = compiler.type.isVC;
756 ecp.path = compiler.ecpCommand;
757 ecc.path = compiler.eccCommand;
758 ecs.path = compiler.ecsCommand;
759 ear.path = compiler.earCommand;
760 cpp.path = compiler.cppCommand;
761 cc.path = compiler.ccCommand;
762 cxx.path = compiler.cxxCommand;
763 make.path = compiler.makeCommand;
764 execPrefix.path = compiler.execPrefixCommand;
766 ecpLabel.disabled = ecp.disabled = disabled;
767 eccLabel.disabled = ecc.disabled = disabled;
768 ecsLabel.disabled = ecs.disabled = disabled;
769 earLabel.disabled = ear.disabled = disabled;
770 cppLabel.disabled = cpp.disabled = isVC || disabled;
771 ccLabel.disabled = cc.disabled = isVC || disabled;
772 makeLabel.disabled = make.disabled = disabled;
773 execPrefixLabel.disabled = execPrefix.disabled = disabled;
775 modifiedDocument = false;
779 class CompilerEnvironmentTab : CompilersSubTab
781 background = formColor;
782 text = $"Environment";
784 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
785 NamedStringsBox envVars
787 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
788 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
790 bool NotifyModified(NamedStringsBox stringsBox)
792 loadedCompiler.environmentVars = stringsBox.namedStrings;
793 modifiedDocument = true;
794 compilersTab.modifiedDocument = true;
799 CompilerEnvironmentTab()
807 CompilerConfig compiler = loadedCompiler;
808 envVars.namedStrings = compiler.environmentVars;
810 modifiedDocument = false;
815 class CompilerOptionsTab : CompilersSubTab
817 background = formColor;
820 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
821 DropBox targetPlatform
823 this, position = { 110, 8 }, size = { 160 };
824 text = $"Target Platform", hotKey = altT;
825 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
827 CompilerConfig compiler = loadedCompiler;
830 compiler.targetPlatform = (Platform)row.tag;
831 modifiedDocument = true;
832 compilersTab.modifiedDocument = true;
839 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
842 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
843 position = { 184, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
845 bool OnKeyDown(Key key, unichar ch)
847 if((SmartKey)key == enter)
849 DataBox::OnKeyDown(key, ch);
853 return DataBox::OnKeyDown(key, ch);
856 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
866 bool NotifyChanged(bool closingDropDown)
868 CompilerConfig compiler = loadedCompiler;
871 compiler.numJobs = numJobs;
872 modifiedDocument = true;
873 compilersTab.modifiedDocument = true;
881 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
884 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
886 CompilerConfig compiler = loadedCompiler;
889 compiler.ccacheEnabled = button.checked;
890 modifiedDocument = true;
891 compilersTab.modifiedDocument = true;
899 this, text = $"Use distcc", hotKey = altD, position = { 8, 96 };
902 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
904 CompilerConfig compiler = loadedCompiler;
907 distccHosts.disabled = !button.checked;
908 compiler.distccEnabled = button.checked;
909 modifiedDocument = true;
910 compilersTab.modifiedDocument = true;
916 Label distccHostsLabel { this, position = { 8, 124 }, labeledWindow = distccHosts };
919 this, text = $"distcc hosts", hotKey = altH;
920 position = { 88, 120 }, size = { 300 };
922 bool NotifyModified(EditBox editBox)
926 CompilerConfig compiler = loadedCompiler;
927 compiler.distccHosts = editBox.contents;
928 modifiedDocument = true;
929 compilersTab.modifiedDocument = true;
939 for(p = (Platform)1; p < Platform::enumSize; p++)
941 row = targetPlatform.AddRow();
951 CompilerConfig compiler = loadedCompiler;
952 bool disabled = compiler.readOnly;
953 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
954 numJobs = compiler.numJobs;
955 numJobsBox.Refresh();
956 ccacheEnabled.checked = compiler.ccacheEnabled;
957 distccEnabled.checked = compiler.distccEnabled;
958 distccHosts.disabled = !compiler.distccEnabled;
959 distccHosts.contents = compiler.distccHosts;
961 labelTargetPlatform.disabled = disabled;
962 targetPlatform.disabled = disabled;
965 modifiedDocument = false;
969 class CompilersSubTab : Tab
971 property CompilersTab compilersTab
975 CompilersTab tab = (CompilersTab)master;
976 while(tab && tab._class != class(CompilersTab))
977 tab = (CompilersTab)tab.master;
982 property CompilerConfig loadedCompiler
986 CompilersTab tab = compilersTab;
987 return tab ? tab.activeCompiler : null;
992 class ProjectOptionsTab : GlobalSettingsSubTab
994 background = formColor;
997 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
998 PathBox defaultTargetDir
1000 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1001 text = $"Default Target Directory", hotKey = altT;
1003 bool NotifyModified(PathBox editBox)
1005 modifiedDocument = true;
1010 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1011 PathBox defaultIntermediateObjDir
1013 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1014 text = $"Default Intermediate Objects Directory", hotKey = altI;
1016 bool NotifyModified(PathBox editBox)
1018 modifiedDocument = true;
1024 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1025 // of WorkspaceOptionsTab will *not* be called!
1026 class GlobalSettingsSubTab : Tab
1028 property GlobalSettingsDialog dialog
1032 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1033 while(dialog && dialog._class != class(GlobalSettingsDialog))
1034 dialog = (GlobalSettingsDialog)dialog.master;
1040 class WorkspaceOptionsTab : GlobalSettingsSubTab
1042 background = formColor;
1043 text = $"Workspace";
1045 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1046 DropBox defaultCompilerDropBox
1048 this, position = { 140, 8 }, size = { 220 };
1049 text = $"Default Compiler", hotKey = altA;
1051 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1053 modifiedDocument = true;
1060 GlobalSettingsDialog dialog = this.dialog;
1061 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1064 for(compiler : dialog.ideSettings.compilerConfigs)
1066 row = defaultCompilerDropBox.AddString(compiler.name);
1067 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1068 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1069 defaultCompilerDropBox.currentRow = row;
1071 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1072 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1079 // TOFIX: The selection will be lost upon changing tab...
1080 // Should either warn, or leave it modified and put in place
1081 // checks to save/find the compiler by name
1082 defaultCompilerDropBox.Clear();
1083 modifiedDocument = false;
1087 //static define app = ((GuiApplication)__thisModule);