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, 506 };
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 Workspace workspace = ide.workspace;
92 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
93 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
94 ideSettings.compilerConfigs.Free();
95 for(compiler : compilersTab.compilerConfigs)
97 ideSettings.compilerConfigs.Add(compiler.Copy());
100 compilerSettingsChanged = true;
103 if(projectOptionsTab.modifiedDocument)
105 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
106 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
108 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
109 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
110 projectOptionsChanged = true;
114 if(workspaceOptionsTab.modifiedDocument)
116 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
117 if(row && row.string)
119 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
121 ideSettings.defaultCompiler = row.string;
122 workspaceOptionsChanged = true;
127 settingsContainer.Save();
129 if(compilerSettingsChanged)
130 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
131 if(editorSettingsChanged)
132 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
133 if(projectOptionsChanged)
134 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
136 editorTab.modifiedDocument = false;
137 compilersTab.modifiedDocument = false;
138 projectOptionsTab.modifiedDocument = false;
139 workspaceOptionsTab.modifiedDocument = false;
142 Destroy(DialogResult::ok);
151 for(c = 0; c < DirTypes::enumSize; c++)
153 CompilerDir compilerDir;
155 for(systemDir : ideSettings.systemDirs[c])
157 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
158 dirs.Add(compilerDir);
161 row = compilersTab.dirs[c].AddRow();
162 row.SetData(null, "");
163 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
164 compilersTab.dirs[c].modifiedDocument = false;
171 CompilerConfig activateCompiler = null;
172 CompilerConfig readonlyCompiler = null;
175 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
176 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
177 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
180 if(workspaceActiveCompiler)
182 for(compiler : ideSettings.compilerConfigs)
184 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
185 activateCompiler = compiler;
186 if(!readonlyCompiler && compiler.readOnly)
187 readonlyCompiler = compiler;
188 if(activateCompiler && readonlyCompiler)
192 if(!activateCompiler && readonlyCompiler)
193 activateCompiler = readonlyCompiler;
194 if(!activateCompiler && ideSettings.compilerConfigs.count)
195 activateCompiler = ideSettings.compilerConfigs[0];
197 for(compiler : ideSettings.compilerConfigs)
198 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
199 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
202 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
203 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
210 editorTab.modifiedDocument = false;
211 compilersTab.modifiedDocument = false;
212 compilersTab.dirsTab.modifiedDocument = false;
213 compilersTab.toolchainTab.modifiedDocument = false;
214 compilersTab.optionsTab.modifiedDocument = false;
215 compilersTab.activeCompiler = null;
216 compilersTab.compilerConfigs.Free();
217 compilersTab.compilerSelector.Clear();
218 projectOptionsTab.modifiedDocument = false;
219 workspaceOptionsTab.modifiedDocument = false;
222 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
225 class EditorTab : GlobalSettingsSubTab
227 background = formColor;
232 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
233 NotifyClicked = NotifyClickedModifiedDocument;
236 Button caretFollowsScrolling
238 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
239 NotifyClicked = NotifyClickedModifiedDocument;
242 Button showLineNumbers
244 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
245 NotifyClicked = NotifyClickedModifiedDocument;
248 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
250 modifiedDocument = true;
255 static void DrawStipple(Surface surface, Size clientSize)
259 int x2 = clientSize.w - 1;
260 int y2 = clientSize.h - 1;
261 if((x2 - x1) & 1) x2--;
262 if((y2 - y1) & 1) y2--;
264 surface.LineStipple(0x5555);
265 surface.Rectangle(x1, y1, x2, y2);
266 surface.LineStipple(0);
269 class CompilersTab : GlobalSettingsSubTab
271 background = formColor;
274 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
275 PathBox compilerConfigsDir
277 this, anchor = { left = 210, top = 8, right = 8 };
278 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
281 SelectorBar compilerSelector
283 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
285 direction = horizontal, scrollable = true;
287 bool OnKeyDown(Key key, unichar ch)
291 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
296 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
299 return SelectorBar::OnKeyDown(key, ch);
302 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
304 ((CompilersTab)master).labelCompilers.Update(null);
310 CompilersTab compilers = (CompilersTab)parent;
311 SelectorBar::OnPostCreate();
312 if(compilers.selectedButton)
314 Button sb = compilers.selectedButton;
317 // Why was this being set to null? On going back to compilers the 2nd time, the selectedButton was lost and so was not made visible...
318 // compilers.selectedButton = null;
324 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
326 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
327 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
328 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
329 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
331 List<CompilerConfig> compilerConfigs { };
332 CompilerConfig activeCompiler;
336 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
338 void OnRedraw(Surface surface)
340 Label::OnRedraw(surface);
341 if(labeledWindow.active)
342 DrawStipple(surface, clientSize);
346 void FindUniqueCompilerName(char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
349 char tmp[MAX_F_STRING];
350 /*if(startWithNumber)
351 sprintf(tmp, "%s%d", baseName, num);
353 strcpy(tmp, baseName);
356 CompilerConfig matchingCompiler = null;
357 for(c : compilerConfigs)
358 { // TOFIX: Error when omitting these brackets, c not found
359 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
361 matchingCompiler = c;
368 sprintf(tmp, "%s%d", baseName, num);
376 Button createCompiler
378 parent = this, bevelOver = true, inactive = true;
380 anchor = { top = 40, right = 77 };
381 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
383 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
385 char compilerName[MAX_F_STRING];
386 CompilerConfig newCompiler;
387 FindUniqueCompilerName("New Compiler", null, compilerName);
388 newCompiler = MakeDefaultCompiler(compilerName, false);
389 AddCompiler(newCompiler, true);
390 modifiedDocument = true;
394 Button detectCompiler
396 parent = this, bevelOver = true, inactive = true;
398 anchor = { top = 40, right = 54 };
399 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
401 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
403 CompilersDetectionDialog compilersDetectionDialog
408 if(compilersDetectionDialog.Modal())
410 if(compilersDetectionDialog.selectedCompilerType)
412 char uniqueName[MAX_F_STRING];
413 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
414 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
415 newCompiler.name = uniqueName;
416 AddCompiler(newCompiler, true);
417 modifiedDocument = true;
423 Button duplicateCompiler
425 parent = this, bevelOver = true, inactive = true;
427 anchor = { top = 40, right = 31 };
428 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
430 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
432 char copyName[MAX_F_STRING];
433 CompilerConfig copyCompiler = activeCompiler.Copy();
434 FindUniqueCompilerName(copyCompiler.name, null, copyName);
435 copyCompiler.readOnly = false;
436 copyCompiler.name = copyName;
437 AddCompiler(copyCompiler, true);
438 modifiedDocument = true;
442 Button deleteCompiler
444 parent = this, bevelOver = true, inactive = true;
446 anchor = { top = 40, right = 8 };
447 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
449 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
453 CompilerConfig compilerToDelete = activeCompiler;
454 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
455 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
456 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
458 SelectorButton button = compilerSelector.FindButtonByID((int64)compilerToDelete);
460 compilerSelector.RemoveButton(button);
461 //DeleteCompiler(compilerToDelete);
463 Iterator<CompilerConfig> it { compilerConfigs };
464 if(it.Find(compilerToDelete))
465 compilerConfigs.Delete(it.pointer);
467 modifiedDocument = true;
476 void AddCompiler(CompilerConfig compiler, bool load)
478 SelectorButton selectButton;
479 if(compiler.readOnly)
481 SelectorButton button
483 compilerSelector, master = this, text = compiler.name, id = (int64)compiler;
484 NotifyClicked = CompilerClicked;
486 selectButton = button;
490 EditableSelectorButton button
492 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)compiler;
493 NotifyClicked = CompilerClicked;
495 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
497 if(*newName && (*newName)[0])
499 char compilerName[MAX_F_STRING];
500 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
501 if(strcmp(*newName, compilerName))
504 *newName = CopyString(compilerName);
506 activeCompiler.name = compilerName;
507 modifiedDocument = true;
513 selectButton = (SelectorButton)button;
515 compilerConfigs.Add(compiler);
518 LoadCompiler(compiler);
519 selectedButton = selectButton;
520 compilerSelector.Select(selectedButton);
523 SelectorButton selectedButton;
525 void LoadCompiler(CompilerConfig compiler)
527 bool modified = modifiedDocument;
528 activeCompiler = compiler;
532 environmentTab.Load();
535 // Restore original modifiedDocument
536 modifiedDocument = modified;
538 deleteCompiler.disabled = compiler.readOnly;
541 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
543 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
545 LoadCompiler((CompilerConfig)clickedButton.id);
546 selectedButton = (SelectorButton)clickedButton;
551 bool NotifyModifiedDocument(PathBox pathBox)
553 modifiedDocument = true;
558 Array<String> displayDirectoryNames
565 class CompilerDirectoriesTab : CompilersSubTab
567 background = formColor;
568 text = $"Directories";
570 Button dirTypeTglBtn[DirTypes];
571 DirectoriesBox dirs[DirTypes], currentDirs;
573 ~CompilerDirectoriesTab()
576 for(c = 0; c < DirTypes::enumSize; c++)
579 delete dirTypeTglBtn[c];
582 CompilerDirectoriesTab()
585 for(c = 0; c < DirTypes::enumSize; c++)
587 dirs[c] = DirectoriesBox
589 this;//, alwaysHighLight = true
590 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
593 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
594 settingsFileDialog.filePath = directory;
595 if(settingsFileDialog.Modal())
596 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
599 bool NotifyModified(DirectoriesBox dirsBox)
601 CompilerConfig compiler = loadedCompiler;
604 DirTypes dirType = (DirTypes)dirsBox.id;
605 if(dirType == includes)
606 compiler.includeDirs = dirsBox.strings;
607 else if(dirType == libraries)
608 compiler.libraryDirs = dirsBox.strings;
609 else if(dirType == executables)
610 compiler.executableDirs = dirsBox.strings;
612 compilersTab.modifiedDocument = true;
620 dirs[c].visible = false;
622 // (width) Should be 324 for text...
623 //field[c] = { dataType = class(char *), editable = true };
624 //dirs[c].AddField(field[c]);
627 int v = (int)c * 100 + 8;
628 dirTypeTglBtn[c] = Button
630 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
634 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
636 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
638 DirTypes dirType = (DirTypes)button.id;
639 currentDirs.visible = false;
640 dirs[dirType].visible = true;
641 currentDirs = dirs[dirType];
645 incref dirTypeTglBtn[c];
648 dirTypeTglBtn[c].hotKey = altI;
649 else if(c == libraries)
650 dirTypeTglBtn[c].hotKey = altL;
651 else if(c == executables)
652 dirTypeTglBtn[c].hotKey = altE;
655 currentDirs = dirs[includes];
656 dirTypeTglBtn[includes].checked = true;
662 CompilerConfig compiler = loadedCompiler;
665 dirs[includes].strings = compiler.includeDirs;
666 dirs[libraries].strings = compiler.libraryDirs;
667 dirs[executables].strings = compiler.executableDirs;
668 dirs[includes].list.scroll = { 0, 0 };
669 dirs[libraries].list.scroll = { 0, 0 };
670 dirs[executables].list.scroll = { 0, 0 };
675 class CompilerToolchainTab : CompilersSubTab
677 background = formColor;
683 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
686 this, anchor = { left = margin, top = 8, right = 8 };
687 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
689 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
692 this, anchor = { left = margin, top = 34, right = 8 };
693 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
695 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
698 this, anchor = { left = margin, top = 60, right = 8 };
699 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
701 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
704 this, anchor = { left = margin, top = 86, right = 8 };
705 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
707 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
710 this, anchor = { left = margin, top = 112, right = 8 };
711 text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
713 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
716 this, anchor = { left = margin, top = 138, right = 8 };
717 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
719 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
722 this, anchor = { left = margin, top = 164, right = 8 };
723 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
725 Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
728 this, anchor = { left = margin, top = 190, right = 8 };
729 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
731 Label gnuToolchainPrefixLabel { this, position = { 8, 220 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
732 PathBox gnuToolchainPrefix
734 this, anchor = { left = margin, top = 216, right = 8 };
735 text = $"GNU Toolchain Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
737 Label sysrootLabel { this, position = { 8, 246 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
740 this, anchor = { left = margin, top = 242, right = 8 };
741 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
743 Label executableLauncherLabel { this, position = { 8, 272 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
744 PathBox executableLauncher
746 this, anchor = { left = margin, top = 268, right = 8 };
747 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
750 bool NotifyModifiedDocument(PathBox pathBox)
752 CompilerConfig compiler = loadedCompiler;
756 compiler.ecpCommand = pathBox.slashPath;
757 else if(pathBox == ecc)
758 compiler.eccCommand = pathBox.slashPath;
759 else if(pathBox == ecs)
760 compiler.ecsCommand = pathBox.slashPath;
761 else if(pathBox == ear)
762 compiler.earCommand = pathBox.slashPath;
763 else if(pathBox == cpp)
764 compiler.cppCommand = pathBox.slashPath;
765 else if(pathBox == cc)
766 compiler.ccCommand = pathBox.slashPath;
767 else if(pathBox == cxx)
768 compiler.cxxCommand = pathBox.slashPath;
769 else if(pathBox == make)
770 compiler.makeCommand = pathBox.slashPath;
771 else if(pathBox == executableLauncher)
772 compiler.execPrefixCommand = pathBox.slashPath;
773 else if(pathBox == gnuToolchainPrefix)
774 compiler.gccPrefix = pathBox.slashPath;
775 else if(pathBox == sysroot)
776 compiler.sysroot = pathBox.slashPath;
777 modifiedDocument = true;
778 compilersTab.modifiedDocument = true;
785 CompilerConfig compiler = loadedCompiler;
788 bool disabled = compiler.readOnly;
789 bool isVC = compiler.type.isVC;
790 ecp.path = compiler.ecpCommand;
791 ecc.path = compiler.eccCommand;
792 ecs.path = compiler.ecsCommand;
793 ear.path = compiler.earCommand;
794 cpp.path = compiler.cppCommand;
795 cc.path = compiler.ccCommand;
796 cxx.path = compiler.cxxCommand;
797 make.path = compiler.makeCommand;
798 executableLauncher.path = compiler.executableLauncher;
799 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
800 sysroot.path = compiler.sysroot;
802 ecpLabel.disabled = ecp.disabled = disabled;
803 eccLabel.disabled = ecc.disabled = disabled;
804 ecsLabel.disabled = ecs.disabled = disabled;
805 earLabel.disabled = ear.disabled = disabled;
806 cppLabel.disabled = cpp.disabled = isVC || disabled;
807 cxxLabel.disabled = cxx.disabled = isVC || disabled;
808 ccLabel.disabled = cc.disabled = isVC || disabled;
809 makeLabel.disabled = make.disabled = disabled;
810 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
811 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
812 sysrootLabel.disabled = sysroot.disabled = disabled;
814 modifiedDocument = false;
818 class CompilerEnvironmentTab : CompilersSubTab
820 background = formColor;
821 text = $"Environment";
823 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
824 NamedStringsBox envVars
826 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
827 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
829 bool NotifyModified(NamedStringsBox stringsBox)
831 CompilerConfig compiler = loadedCompiler;
834 compiler.environmentVars = stringsBox.namedStrings;
835 modifiedDocument = true;
836 compilersTab.modifiedDocument = true;
842 CompilerEnvironmentTab()
848 CompilerConfig compiler = loadedCompiler;
851 envVars.namedStrings = compiler.environmentVars;
853 modifiedDocument = false;
858 class CompilerOptionsTab : CompilersSubTab
860 background = formColor;
863 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
864 DropBox targetPlatform
866 this, position = { 110, 8 }, size = { 160 };
867 text = $"Target Platform", hotKey = altT;
868 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
870 CompilerConfig compiler = loadedCompiler;
873 compiler.targetPlatform = (Platform)row.tag;
874 modifiedDocument = true;
875 compilersTab.modifiedDocument = true;
882 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
885 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
886 position = { 184, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
888 bool OnKeyDown(Key key, unichar ch)
890 if((SmartKey)key == enter)
892 DataBox::OnKeyDown(key, ch);
896 return DataBox::OnKeyDown(key, ch);
899 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
909 bool NotifyChanged(bool closingDropDown)
911 CompilerConfig compiler = loadedCompiler;
914 compiler.numJobs = numJobs;
915 modifiedDocument = true;
916 compilersTab.modifiedDocument = true;
924 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
927 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
929 CompilerConfig compiler = loadedCompiler;
932 compiler.ccacheEnabled = button.checked;
933 modifiedDocument = true;
934 compilersTab.modifiedDocument = true;
942 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
945 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
947 CompilerConfig compiler = loadedCompiler;
950 distccHosts.disabled = !button.checked;
951 compiler.distccEnabled = button.checked;
952 modifiedDocument = true;
953 compilersTab.modifiedDocument = true;
959 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
962 this, text = $"distcc hosts", hotKey = altH;
963 position = { 88, 92 }, size = { 300 };
965 bool NotifyModified(EditBox editBox)
967 CompilerConfig compiler = loadedCompiler;
970 compiler.distccHosts = editBox.contents;
971 modifiedDocument = true;
972 compilersTab.modifiedDocument = true;
978 Label lblPrepDefs { this, position = { 8, 124 }, labeledWindow = prepDefs };
979 StringListBox prepDefs
981 this, text = $"Preprocessor directives:", hotKey = altP;
982 position = { 148, 124 }, size = { 300 };
984 bool NotifyModified(EditBox editBox)
988 CompilerConfig compiler = loadedCompiler;
989 compiler.prepDirectives = ((StringListBox)editBox).strings;
990 modifiedDocument = true;
991 compilersTab.modifiedDocument = true;
997 Label lblCompilerFlags { this, position = { 8, 152 }, labeledWindow = compilerFlags };
998 StringListBox compilerFlags
1000 this, text = $"Additional compiler flags:", hotKey = altL;
1001 position = { 148, 152 }, size = { 300 };
1003 bool NotifyModified(EditBox editBox)
1007 CompilerConfig compiler = loadedCompiler;
1008 compiler.compilerFlags = ((StringListBox)editBox).strings;
1009 modifiedDocument = true;
1010 compilersTab.modifiedDocument = true;
1016 Label lblLinkerFlags { this, position = { 8, 180 }, labeledWindow = linkerFlags };
1017 StringListBox linkerFlags
1019 this, text = $"Additional linker flags:", hotKey = altL;
1020 position = { 148, 180 }, size = { 300 };
1022 bool NotifyModified(EditBox editBox)
1026 CompilerConfig compiler = loadedCompiler;
1027 compiler.linkerFlags = ((StringListBox)editBox).strings;
1028 modifiedDocument = true;
1029 compilersTab.modifiedDocument = true;
1035 Label lblExcludedLibraries { this, position = { 8, 208 }, labeledWindow = excludedLibraries };
1036 StringListBox excludedLibraries
1038 this, text = $"Libraries to exclude:", hotKey = altX;
1039 position = { 148, 208 }, size = { 300 };
1041 bool NotifyModified(EditBox editBox)
1045 CompilerConfig compiler = loadedCompiler;
1046 compiler.excludeLibs = ((StringListBox)editBox).strings;
1047 modifiedDocument = true;
1048 compilersTab.modifiedDocument = true;
1054 CompilerOptionsTab()
1058 for(p = (Platform)1; p < Platform::enumSize; p++)
1060 row = targetPlatform.AddRow();
1068 CompilerConfig compiler = loadedCompiler;
1071 bool disabled = compiler.readOnly;
1072 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1073 numJobs = compiler.numJobs;
1074 numJobsBox.Refresh();
1075 ccacheEnabled.checked = compiler.ccacheEnabled;
1076 distccEnabled.checked = compiler.distccEnabled;
1077 distccHosts.disabled = !compiler.distccEnabled;
1078 distccHosts.contents = compiler.distccHosts;
1079 prepDefs.strings = compiler.prepDirectives;
1080 excludedLibraries.strings = compiler.excludeLibs;
1081 compilerFlags.strings = compiler.compilerFlags;
1082 linkerFlags.strings = compiler.linkerFlags;
1084 labelTargetPlatform.disabled = disabled;
1085 targetPlatform.disabled = disabled;
1088 modifiedDocument = false;
1092 class CompilersSubTab : Tab
1094 property CompilersTab compilersTab
1098 CompilersTab tab = (CompilersTab)master;
1099 while(tab && tab._class != class(CompilersTab))
1100 tab = (CompilersTab)tab.master;
1105 property CompilerConfig loadedCompiler
1109 CompilersTab tab = compilersTab;
1110 return tab ? tab.activeCompiler : null;
1115 class ProjectOptionsTab : GlobalSettingsSubTab
1117 background = formColor;
1120 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1121 PathBox defaultTargetDir
1123 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1124 text = $"Default Target Directory", hotKey = altT;
1126 bool NotifyModified(PathBox editBox)
1128 modifiedDocument = true;
1133 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1134 PathBox defaultIntermediateObjDir
1136 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1137 text = $"Default Intermediate Objects Directory", hotKey = altI;
1139 bool NotifyModified(PathBox editBox)
1141 modifiedDocument = true;
1147 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1148 // of WorkspaceOptionsTab will *not* be called!
1149 class GlobalSettingsSubTab : Tab
1151 property GlobalSettingsDialog dialog
1155 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1156 while(dialog && dialog._class != class(GlobalSettingsDialog))
1157 dialog = (GlobalSettingsDialog)dialog.master;
1163 class WorkspaceOptionsTab : GlobalSettingsSubTab
1165 background = formColor;
1166 text = $"Workspace";
1168 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1169 DropBox defaultCompilerDropBox
1171 this, position = { 140, 8 }, size = { 220 };
1172 text = $"Default Compiler", hotKey = altA;
1174 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1176 modifiedDocument = true;
1183 GlobalSettingsDialog dialog = this.dialog;
1184 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1187 for(compiler : dialog.ideSettings.compilerConfigs)
1189 row = defaultCompilerDropBox.AddString(compiler.name);
1190 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1191 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1192 defaultCompilerDropBox.currentRow = row;
1194 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1195 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1202 // TOFIX: The selection will be lost upon changing tab...
1203 // Should either warn, or leave it modified and put in place
1204 // checks to save/find the compiler by name
1205 defaultCompilerDropBox.Clear();
1206 modifiedDocument = false;
1210 //static define app = ((GuiApplication)__thisModule);