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 bool foundActive = false;
92 Workspace workspace = ide.workspace;
93 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
94 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
95 ideSettings.compilerConfigs.Free();
96 for(compiler : compilersTab.compilerConfigs)
98 ideSettings.compilerConfigs.Add(compiler.Copy());
99 if(!foundActive && workspace && workspace.compiler && !strcmp(workspace.compiler, compiler.name))
102 if(workspace && !foundActive)
103 workspace.compiler = defaultCompilerName;
105 compilerSettingsChanged = true;
108 if(projectOptionsTab.modifiedDocument)
110 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
111 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
113 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
114 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
115 projectOptionsChanged = true;
119 if(workspaceOptionsTab.modifiedDocument)
121 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
122 if(row && row.string)
124 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
126 ideSettings.defaultCompiler = row.string;
127 workspaceOptionsChanged = true;
132 settingsContainer.Save();
134 if(compilerSettingsChanged)
135 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
136 if(editorSettingsChanged)
137 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
138 if(projectOptionsChanged)
139 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
141 editorTab.modifiedDocument = false;
142 compilersTab.modifiedDocument = false;
143 projectOptionsTab.modifiedDocument = false;
144 workspaceOptionsTab.modifiedDocument = false;
147 Destroy(DialogResult::ok);
156 for(c = 0; c < DirTypes::enumSize; c++)
158 CompilerDir compilerDir;
160 for(systemDir : ideSettings.systemDirs[c])
162 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
163 dirs.Add(compilerDir);
166 row = compilersTab.dirs[c].AddRow();
167 row.SetData(null, "");
168 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
169 compilersTab.dirs[c].modifiedDocument = false;
176 CompilerConfig activateCompiler = null;
177 CompilerConfig readonlyCompiler = null;
180 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
181 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
182 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
185 if(workspaceActiveCompiler)
187 for(compiler : ideSettings.compilerConfigs)
189 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
190 activateCompiler = compiler;
191 if(!readonlyCompiler && compiler.readOnly)
192 readonlyCompiler = compiler;
193 if(activateCompiler && readonlyCompiler)
197 if(!activateCompiler && readonlyCompiler)
198 activateCompiler = readonlyCompiler;
199 if(!activateCompiler && ideSettings.compilerConfigs.count)
200 activateCompiler = ideSettings.compilerConfigs[0];
202 for(compiler : ideSettings.compilerConfigs)
203 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
204 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
207 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
208 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
215 editorTab.modifiedDocument = false;
216 compilersTab.modifiedDocument = false;
217 compilersTab.dirsTab.modifiedDocument = false;
218 compilersTab.toolchainTab.modifiedDocument = false;
219 compilersTab.optionsTab.modifiedDocument = false;
220 compilersTab.activeCompiler = null;
221 compilersTab.compilerConfigs.Free();
222 compilersTab.compilerSelector.Clear();
223 projectOptionsTab.modifiedDocument = false;
224 workspaceOptionsTab.modifiedDocument = false;
227 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
230 class EditorTab : GlobalSettingsSubTab
232 background = formColor;
237 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
238 NotifyClicked = NotifyClickedModifiedDocument;
241 Button caretFollowsScrolling
243 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
244 NotifyClicked = NotifyClickedModifiedDocument;
247 Button showLineNumbers
249 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
250 NotifyClicked = NotifyClickedModifiedDocument;
253 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
255 modifiedDocument = true;
260 static void DrawStipple(Surface surface, Size clientSize)
264 int x2 = clientSize.w - 1;
265 int y2 = clientSize.h - 1;
266 if((x2 - x1) & 1) x2--;
267 if((y2 - y1) & 1) y2--;
269 surface.LineStipple(0x5555);
270 surface.Rectangle(x1, y1, x2, y2);
271 surface.LineStipple(0);
274 class CompilersTab : GlobalSettingsSubTab
276 background = formColor;
279 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
280 PathBox compilerConfigsDir
282 this, anchor = { left = 210, top = 8, right = 8 };
283 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
286 SelectorBar compilerSelector
288 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
290 direction = horizontal, scrollable = true;
292 bool OnKeyDown(Key key, unichar ch)
296 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
301 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
304 return SelectorBar::OnKeyDown(key, ch);
307 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
309 ((CompilersTab)master).labelCompilers.Update(null);
315 CompilersTab compilers = (CompilersTab)parent;
316 SelectorBar::OnPostCreate();
317 if(compilers.selectedButton)
319 Button sb = compilers.selectedButton;
322 // 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...
323 // compilers.selectedButton = null;
329 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
331 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
332 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
333 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
334 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
336 List<CompilerConfig> compilerConfigs { };
337 CompilerConfig activeCompiler;
341 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
343 void OnRedraw(Surface surface)
345 Label::OnRedraw(surface);
346 if(labeledWindow.active)
347 DrawStipple(surface, clientSize);
351 void FindUniqueCompilerName(char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
354 char tmp[MAX_F_STRING];
355 /*if(startWithNumber)
356 sprintf(tmp, "%s%d", baseName, num);
358 strcpy(tmp, baseName);
361 CompilerConfig matchingCompiler = null;
362 for(c : compilerConfigs)
363 { // TOFIX: Error when omitting these brackets, c not found
364 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
366 matchingCompiler = c;
373 sprintf(tmp, "%s%d", baseName, num);
381 Button createCompiler
383 parent = this, bevelOver = true, inactive = true;
385 anchor = { top = 40, right = 77 };
386 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
388 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
390 char compilerName[MAX_F_STRING];
391 CompilerConfig newCompiler;
392 FindUniqueCompilerName("New Compiler", null, compilerName);
393 newCompiler = MakeDefaultCompiler(compilerName, false);
394 AddCompiler(newCompiler, true);
395 modifiedDocument = true;
399 Button detectCompiler
401 parent = this, bevelOver = true, inactive = true;
403 anchor = { top = 40, right = 54 };
404 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
406 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
408 CompilersDetectionDialog compilersDetectionDialog
413 if(compilersDetectionDialog.Modal())
415 if(compilersDetectionDialog.selectedCompilerType)
417 char uniqueName[MAX_F_STRING];
418 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
419 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
420 newCompiler.name = uniqueName;
421 AddCompiler(newCompiler, true);
422 modifiedDocument = true;
428 Button duplicateCompiler
430 parent = this, bevelOver = true, inactive = true;
432 anchor = { top = 40, right = 31 };
433 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
435 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
437 char copyName[MAX_F_STRING];
438 CompilerConfig copyCompiler = activeCompiler.Copy();
439 FindUniqueCompilerName(copyCompiler.name, null, copyName);
440 copyCompiler.readOnly = false;
441 copyCompiler.name = copyName;
442 AddCompiler(copyCompiler, true);
443 modifiedDocument = true;
447 Button deleteCompiler
449 parent = this, bevelOver = true, inactive = true;
451 anchor = { top = 40, right = 8 };
452 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
454 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
458 CompilerConfig compilerToDelete = activeCompiler;
459 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
460 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
461 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
463 SelectorButton button = compilerSelector.FindButtonByID((int64)compilerToDelete);
465 compilerSelector.RemoveButton(button);
466 //DeleteCompiler(compilerToDelete);
468 Iterator<CompilerConfig> it { compilerConfigs };
469 if(it.Find(compilerToDelete))
470 compilerConfigs.Delete(it.pointer);
472 modifiedDocument = true;
481 void AddCompiler(CompilerConfig compiler, bool load)
483 SelectorButton selectButton;
484 if(compiler.readOnly)
486 SelectorButton button
488 compilerSelector, master = this, text = compiler.name, id = (int64)compiler;
489 NotifyClicked = CompilerClicked;
491 selectButton = button;
495 EditableSelectorButton button
497 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)compiler;
498 NotifyClicked = CompilerClicked;
500 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
502 if(*newName && (*newName)[0])
504 char compilerName[MAX_F_STRING];
505 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
506 if(strcmp(*newName, compilerName))
509 *newName = CopyString(compilerName);
511 activeCompiler.name = compilerName;
512 modifiedDocument = true;
518 selectButton = (SelectorButton)button;
520 compilerConfigs.Add(compiler);
523 LoadCompiler(compiler);
524 selectedButton = selectButton;
525 compilerSelector.Select(selectedButton);
528 SelectorButton selectedButton;
530 void LoadCompiler(CompilerConfig compiler)
532 bool modified = modifiedDocument;
533 activeCompiler = compiler;
537 environmentTab.Load();
540 // Restore original modifiedDocument
541 modifiedDocument = modified;
543 deleteCompiler.disabled = compiler.readOnly;
546 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
548 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
550 LoadCompiler((CompilerConfig)clickedButton.id);
551 selectedButton = (SelectorButton)clickedButton;
556 bool NotifyModifiedDocument(PathBox pathBox)
558 modifiedDocument = true;
563 Array<String> displayDirectoryNames
570 class CompilerDirectoriesTab : CompilersSubTab
572 background = formColor;
573 text = $"Directories";
575 Button dirTypeTglBtn[DirTypes];
576 DirectoriesBox dirs[DirTypes], currentDirs;
578 ~CompilerDirectoriesTab()
581 for(c = 0; c < DirTypes::enumSize; c++)
584 delete dirTypeTglBtn[c];
587 CompilerDirectoriesTab()
590 for(c = 0; c < DirTypes::enumSize; c++)
592 dirs[c] = DirectoriesBox
594 this;//, alwaysHighLight = true
595 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
598 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
599 settingsFileDialog.filePath = directory;
600 if(settingsFileDialog.Modal())
601 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
604 bool NotifyModified(DirectoriesBox dirsBox)
606 CompilerConfig compiler = loadedCompiler;
609 DirTypes dirType = (DirTypes)dirsBox.id;
610 if(dirType == includes)
611 compiler.includeDirs = dirsBox.strings;
612 else if(dirType == libraries)
613 compiler.libraryDirs = dirsBox.strings;
614 else if(dirType == executables)
615 compiler.executableDirs = dirsBox.strings;
617 compilersTab.modifiedDocument = true;
625 dirs[c].visible = false;
627 // (width) Should be 324 for text...
628 //field[c] = { dataType = class(char *), editable = true };
629 //dirs[c].AddField(field[c]);
632 int v = (int)c * 100 + 8;
633 dirTypeTglBtn[c] = Button
635 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
639 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
641 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
643 DirTypes dirType = (DirTypes)button.id;
644 currentDirs.visible = false;
645 dirs[dirType].visible = true;
646 currentDirs = dirs[dirType];
650 incref dirTypeTglBtn[c];
653 dirTypeTglBtn[c].hotKey = altI;
654 else if(c == libraries)
655 dirTypeTglBtn[c].hotKey = altL;
656 else if(c == executables)
657 dirTypeTglBtn[c].hotKey = altE;
660 currentDirs = dirs[includes];
661 dirTypeTglBtn[includes].checked = true;
667 CompilerConfig compiler = loadedCompiler;
670 dirs[includes].strings = compiler.includeDirs;
671 dirs[libraries].strings = compiler.libraryDirs;
672 dirs[executables].strings = compiler.executableDirs;
673 dirs[includes].list.scroll = { 0, 0 };
674 dirs[libraries].list.scroll = { 0, 0 };
675 dirs[executables].list.scroll = { 0, 0 };
680 class CompilerToolchainTab : CompilersSubTab
682 background = formColor;
688 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
691 this, anchor = { left = margin, top = 8, right = 8 };
692 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
694 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
697 this, anchor = { left = margin, top = 34, right = 8 };
698 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
700 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
703 this, anchor = { left = margin, top = 60, right = 8 };
704 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
706 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
709 this, anchor = { left = margin, top = 86, right = 8 };
710 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
712 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
715 this, anchor = { left = margin, top = 112, right = 8 };
716 text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
718 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
721 this, anchor = { left = margin, top = 138, right = 8 };
722 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
724 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
727 this, anchor = { left = margin, top = 164, right = 8 };
728 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
730 Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
733 this, anchor = { left = margin, top = 190, right = 8 };
734 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
736 Label gnuToolchainPrefixLabel { this, position = { 8, 220 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
737 PathBox gnuToolchainPrefix
739 this, anchor = { left = margin, top = 216, right = 8 };
740 text = $"GNU Toolchain Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
742 Label sysrootLabel { this, position = { 8, 246 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
745 this, anchor = { left = margin, top = 242, right = 8 };
746 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
748 Label executableLauncherLabel { this, position = { 8, 272 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
749 PathBox executableLauncher
751 this, anchor = { left = margin, top = 268, right = 8 };
752 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
755 bool NotifyModifiedDocument(PathBox pathBox)
757 CompilerConfig compiler = loadedCompiler;
761 compiler.ecpCommand = pathBox.slashPath;
762 else if(pathBox == ecc)
763 compiler.eccCommand = pathBox.slashPath;
764 else if(pathBox == ecs)
765 compiler.ecsCommand = pathBox.slashPath;
766 else if(pathBox == ear)
767 compiler.earCommand = pathBox.slashPath;
768 else if(pathBox == cpp)
769 compiler.cppCommand = pathBox.slashPath;
770 else if(pathBox == cc)
771 compiler.ccCommand = pathBox.slashPath;
772 else if(pathBox == cxx)
773 compiler.cxxCommand = pathBox.slashPath;
774 else if(pathBox == make)
775 compiler.makeCommand = pathBox.slashPath;
776 else if(pathBox == executableLauncher)
777 compiler.execPrefixCommand = pathBox.slashPath;
778 else if(pathBox == gnuToolchainPrefix)
779 compiler.gccPrefix = pathBox.slashPath;
780 else if(pathBox == sysroot)
781 compiler.sysroot = pathBox.slashPath;
782 modifiedDocument = true;
783 compilersTab.modifiedDocument = true;
790 CompilerConfig compiler = loadedCompiler;
793 bool disabled = compiler.readOnly;
794 bool isVC = compiler.type.isVC;
795 ecp.path = compiler.ecpCommand;
796 ecc.path = compiler.eccCommand;
797 ecs.path = compiler.ecsCommand;
798 ear.path = compiler.earCommand;
799 cpp.path = compiler.cppCommand;
800 cc.path = compiler.ccCommand;
801 cxx.path = compiler.cxxCommand;
802 make.path = compiler.makeCommand;
803 executableLauncher.path = compiler.executableLauncher;
804 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
805 sysroot.path = compiler.sysroot;
807 ecpLabel.disabled = ecp.disabled = disabled;
808 eccLabel.disabled = ecc.disabled = disabled;
809 ecsLabel.disabled = ecs.disabled = disabled;
810 earLabel.disabled = ear.disabled = disabled;
811 cppLabel.disabled = cpp.disabled = isVC || disabled;
812 cxxLabel.disabled = cxx.disabled = isVC || disabled;
813 ccLabel.disabled = cc.disabled = isVC || disabled;
814 makeLabel.disabled = make.disabled = disabled;
815 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
816 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
817 sysrootLabel.disabled = sysroot.disabled = disabled;
819 modifiedDocument = false;
823 class CompilerEnvironmentTab : CompilersSubTab
825 background = formColor;
826 text = $"Environment";
828 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
829 NamedStringsBox envVars
831 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
832 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
834 bool NotifyModified(NamedStringsBox stringsBox)
836 CompilerConfig compiler = loadedCompiler;
839 compiler.environmentVars = stringsBox.namedStrings;
840 modifiedDocument = true;
841 compilersTab.modifiedDocument = true;
847 CompilerEnvironmentTab()
853 CompilerConfig compiler = loadedCompiler;
856 envVars.namedStrings = compiler.environmentVars;
858 modifiedDocument = false;
863 class CompilerOptionsTab : CompilersSubTab
865 background = formColor;
868 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
869 DropBox targetPlatform
871 this, position = { 110, 8 }, size = { 160 };
872 text = $"Target Platform", hotKey = altT;
873 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
875 CompilerConfig compiler = loadedCompiler;
878 compiler.targetPlatform = (Platform)row.tag;
879 modifiedDocument = true;
880 compilersTab.modifiedDocument = true;
887 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
890 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
891 position = { 184, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
893 bool OnKeyDown(Key key, unichar ch)
895 if((SmartKey)key == enter)
897 DataBox::OnKeyDown(key, ch);
901 return DataBox::OnKeyDown(key, ch);
904 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
914 bool NotifyChanged(bool closingDropDown)
916 CompilerConfig compiler = loadedCompiler;
919 compiler.numJobs = numJobs;
920 modifiedDocument = true;
921 compilersTab.modifiedDocument = true;
929 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
932 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
934 CompilerConfig compiler = loadedCompiler;
937 compiler.ccacheEnabled = button.checked;
938 modifiedDocument = true;
939 compilersTab.modifiedDocument = true;
947 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
950 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
952 CompilerConfig compiler = loadedCompiler;
955 distccHosts.disabled = !button.checked;
956 compiler.distccEnabled = button.checked;
957 modifiedDocument = true;
958 compilersTab.modifiedDocument = true;
964 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
967 this, text = $"distcc hosts", hotKey = altH;
968 position = { 88, 92 }, size = { 300 };
970 bool NotifyModified(EditBox editBox)
972 CompilerConfig compiler = loadedCompiler;
975 compiler.distccHosts = editBox.contents;
976 modifiedDocument = true;
977 compilersTab.modifiedDocument = true;
983 Label lblPrepDefs { this, position = { 8, 124 }, labeledWindow = prepDefs };
984 StringListBox prepDefs
986 this, text = $"Preprocessor directives:", hotKey = altP;
987 position = { 148, 124 }, size = { 300 };
989 bool NotifyModified(EditBox editBox)
993 CompilerConfig compiler = loadedCompiler;
994 compiler.prepDirectives = ((StringListBox)editBox).strings;
995 modifiedDocument = true;
996 compilersTab.modifiedDocument = true;
1002 Label lblLinkerFlags { this, position = { 8, 152 }, labeledWindow = linkerFlags };
1003 StringListBox linkerFlags
1005 this, text = $"Additional Linker flags:", hotKey = altL;
1006 position = { 148, 152 }, size = { 300 };
1008 bool NotifyModified(EditBox editBox)
1012 CompilerConfig compiler = loadedCompiler;
1013 compiler.linkerFlags = ((StringListBox)editBox).strings;
1014 modifiedDocument = true;
1015 compilersTab.modifiedDocument = true;
1021 Label lblExcludedLibraries { this, position = { 8, 180 }, labeledWindow = excludedLibraries };
1022 StringListBox excludedLibraries
1024 this, text = $"Libraries to exclude:", hotKey = altX;
1025 position = { 148, 180 }, size = { 300 };
1027 bool NotifyModified(EditBox editBox)
1031 CompilerConfig compiler = loadedCompiler;
1032 compiler.excludeLibs = ((StringListBox)editBox).strings;
1033 modifiedDocument = true;
1034 compilersTab.modifiedDocument = true;
1040 CompilerOptionsTab()
1044 for(p = (Platform)1; p < Platform::enumSize; p++)
1046 row = targetPlatform.AddRow();
1054 CompilerConfig compiler = loadedCompiler;
1057 bool disabled = compiler.readOnly;
1058 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1059 numJobs = compiler.numJobs;
1060 numJobsBox.Refresh();
1061 ccacheEnabled.checked = compiler.ccacheEnabled;
1062 distccEnabled.checked = compiler.distccEnabled;
1063 distccHosts.disabled = !compiler.distccEnabled;
1064 distccHosts.contents = compiler.distccHosts;
1065 prepDefs.strings = compiler.prepDirectives;
1066 excludedLibraries.strings = compiler.excludeLibs;
1067 linkerFlags.strings = compiler.linkerFlags;
1069 labelTargetPlatform.disabled = disabled;
1070 targetPlatform.disabled = disabled;
1073 modifiedDocument = false;
1077 class CompilersSubTab : Tab
1079 property CompilersTab compilersTab
1083 CompilersTab tab = (CompilersTab)master;
1084 while(tab && tab._class != class(CompilersTab))
1085 tab = (CompilersTab)tab.master;
1090 property CompilerConfig loadedCompiler
1094 CompilersTab tab = compilersTab;
1095 return tab ? tab.activeCompiler : null;
1100 class ProjectOptionsTab : GlobalSettingsSubTab
1102 background = formColor;
1105 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1106 PathBox defaultTargetDir
1108 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1109 text = $"Default Target Directory", hotKey = altT;
1111 bool NotifyModified(PathBox editBox)
1113 modifiedDocument = true;
1118 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1119 PathBox defaultIntermediateObjDir
1121 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1122 text = $"Default Intermediate Objects Directory", hotKey = altI;
1124 bool NotifyModified(PathBox editBox)
1126 modifiedDocument = true;
1132 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1133 // of WorkspaceOptionsTab will *not* be called!
1134 class GlobalSettingsSubTab : Tab
1136 property GlobalSettingsDialog dialog
1140 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1141 while(dialog && dialog._class != class(GlobalSettingsDialog))
1142 dialog = (GlobalSettingsDialog)dialog.master;
1148 class WorkspaceOptionsTab : GlobalSettingsSubTab
1150 background = formColor;
1151 text = $"Workspace";
1153 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1154 DropBox defaultCompilerDropBox
1156 this, position = { 140, 8 }, size = { 220 };
1157 text = $"Default Compiler", hotKey = altA;
1159 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1161 modifiedDocument = true;
1168 GlobalSettingsDialog dialog = this.dialog;
1169 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1172 for(compiler : dialog.ideSettings.compilerConfigs)
1174 row = defaultCompilerDropBox.AddString(compiler.name);
1175 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1176 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1177 defaultCompilerDropBox.currentRow = row;
1179 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1180 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1187 // TOFIX: The selection will be lost upon changing tab...
1188 // Should either warn, or leave it modified and put in place
1189 // checks to save/find the compiler by name
1190 defaultCompilerDropBox.Clear();
1191 modifiedDocument = false;
1195 //static define app = ((GuiApplication)__thisModule);