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, 542 };
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 AVLTree<String> cfgsToWrite = null;
75 if(editorTab.modifiedDocument)
77 if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
78 editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
79 editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
81 ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
82 ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
83 ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
84 editorSettingsChanged = true;
88 if(compilersTab.modifiedDocument)
90 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
91 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
92 if(compilersTab.compilerConfigs.OnCompare(ideConfig.compilers))
94 cfgsToWrite = compilersTab.compilerConfigs.getWriteRequiredList(ideConfig.compilers);
95 ideConfig.compilers.Free();
96 for(compiler : compilersTab.compilerConfigs)
98 ideConfig.compilers.Add(compiler.Copy());
100 compilerSettingsChanged = true;
104 if(projectOptionsTab.modifiedDocument)
106 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
107 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
109 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
110 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
111 projectOptionsChanged = true;
115 if(workspaceOptionsTab.modifiedDocument)
117 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
118 if(row && row.string)
120 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
122 ideSettings.defaultCompiler = row.string;
127 if(editorSettingsChanged || projectOptionsChanged)
128 settingsContainer.Save();
130 if(compilerSettingsChanged)
132 ideConfig.compilers.write(cfgsToWrite);
133 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
137 if(editorSettingsChanged)
138 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
139 if(projectOptionsChanged)
140 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
142 editorTab.modifiedDocument = false;
143 compilersTab.modifiedDocument = false;
144 projectOptionsTab.modifiedDocument = false;
145 workspaceOptionsTab.modifiedDocument = false;
148 Destroy(DialogResult::ok);
157 for(c = 0; c < DirTypes::enumSize; c++)
159 CompilerDir compilerDir;
161 for(systemDir : ideSettings.systemDirs[c])
163 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
164 dirs.Add(compilerDir);
167 row = compilersTab.dirs[c].AddRow();
168 row.SetData(null, "");
169 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
170 compilersTab.dirs[c].modifiedDocument = false;
177 CompilerConfig activateCompiler = null;
178 CompilerConfig readonlyCompiler = null;
181 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
182 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
183 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
186 if(workspaceActiveCompiler)
188 for(compiler : ideConfig.compilers)
190 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
191 activateCompiler = compiler;
192 if(!readonlyCompiler && compiler.readOnly)
193 readonlyCompiler = compiler;
194 if(activateCompiler && readonlyCompiler)
198 if(!activateCompiler && readonlyCompiler)
199 activateCompiler = readonlyCompiler;
200 if(!activateCompiler && ideConfig.compilers.count)
201 activateCompiler = ideConfig.compilers[0];
203 for(compiler : ideConfig.compilers)
204 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
205 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
208 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
209 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
216 editorTab.modifiedDocument = false;
217 compilersTab.modifiedDocument = false;
218 compilersTab.dirsTab.modifiedDocument = false;
219 compilersTab.toolchainTab.modifiedDocument = false;
220 compilersTab.optionsTab.modifiedDocument = false;
221 compilersTab.activeCompiler = null;
222 compilersTab.compilerConfigs.Free();
223 compilersTab.compilerSelector.Clear();
224 projectOptionsTab.modifiedDocument = false;
225 workspaceOptionsTab.modifiedDocument = false;
228 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
231 class EditorTab : GlobalSettingsSubTab
233 background = formColor;
238 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
239 NotifyClicked = NotifyClickedModifiedDocument;
242 Button caretFollowsScrolling
244 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
245 NotifyClicked = NotifyClickedModifiedDocument;
248 Button showLineNumbers
250 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
251 NotifyClicked = NotifyClickedModifiedDocument;
254 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
256 modifiedDocument = true;
261 static void DrawStipple(Surface surface, Size clientSize)
265 int x2 = clientSize.w - 1;
266 int y2 = clientSize.h - 1;
267 if((x2 - x1) & 1) x2--;
268 if((y2 - y1) & 1) y2--;
270 surface.LineStipple(0x5555);
271 surface.Rectangle(x1, y1, x2, y2);
272 surface.LineStipple(0);
275 class CompilersTab : GlobalSettingsSubTab
277 background = formColor;
280 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
281 PathBox compilerConfigsDir
283 this, anchor = { left = 230, top = 8, right = 8 };
284 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
287 SelectorBar compilerSelector
289 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
291 direction = horizontal;
296 bool OnKeyDown(Key key, unichar ch)
300 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
305 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
308 return SelectorBar::OnKeyDown(key, ch);
311 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
313 ((CompilersTab)master).labelCompilers.Update(null);
319 CompilersTab compilers = (CompilersTab)parent;
320 SelectorBar::OnPostCreate();
321 if(compilers.selectedButton)
323 Button sb = compilers.selectedButton;
326 // 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...
327 // compilers.selectedButton = null;
333 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
335 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
336 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
337 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
338 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
340 CompilerConfigs compilerConfigs { };
341 CompilerConfig activeCompiler;
345 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
347 void OnRedraw(Surface surface)
349 Label::OnRedraw(surface);
350 if(labeledWindow.active)
351 DrawStipple(surface, clientSize);
355 void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
358 char tmp[MAX_F_STRING];
359 /*if(startWithNumber)
360 sprintf(tmp, "%s%d", baseName, num);
362 strcpy(tmp, baseName);
365 CompilerConfig matchingCompiler = null;
366 for(c : compilerConfigs)
367 { // TOFIX: Error when omitting these brackets, c not found
368 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
370 matchingCompiler = c;
377 sprintf(tmp, "%s%d", baseName, num);
385 Button createCompiler
387 parent = this, bevelOver = true, inactive = true;
389 anchor = { top = 40, right = 77 };
390 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
392 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
394 char compilerName[MAX_F_STRING];
395 CompilerConfig newCompiler;
396 FindUniqueCompilerName("New Compiler", null, compilerName);
397 newCompiler = MakeDefaultCompiler(compilerName, false);
398 AddCompiler(newCompiler, true);
399 modifiedDocument = true;
403 Button detectCompiler
405 parent = this, bevelOver = true, inactive = true;
407 anchor = { top = 40, right = 54 };
408 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
410 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
412 CompilersDetectionDialog compilersDetectionDialog
417 if(compilersDetectionDialog.Modal())
419 if(compilersDetectionDialog.selectedCompilerType)
421 char uniqueName[MAX_F_STRING];
422 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
423 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
424 newCompiler.name = uniqueName;
425 AddCompiler(newCompiler, true);
426 modifiedDocument = true;
432 Button duplicateCompiler
434 parent = this, bevelOver = true, inactive = true;
436 anchor = { top = 40, right = 31 };
437 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
439 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
441 char copyName[MAX_F_STRING];
442 CompilerConfig copyCompiler = activeCompiler.Copy();
443 FindUniqueCompilerName(copyCompiler.name, null, copyName);
444 copyCompiler.readOnly = false;
445 copyCompiler.name = copyName;
446 AddCompiler(copyCompiler, true);
447 modifiedDocument = true;
451 Button deleteCompiler
453 parent = this, bevelOver = true, inactive = true;
455 anchor = { top = 40, right = 8 };
456 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
458 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
462 CompilerConfig compilerToDelete = activeCompiler;
463 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
464 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
465 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
467 SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
469 compilerSelector.RemoveButton(button);
470 //DeleteCompiler(compilerToDelete);
472 Iterator<CompilerConfig> it { compilerConfigs };
473 if(it.Find(compilerToDelete))
474 compilerConfigs.Delete(it.pointer);
476 modifiedDocument = true;
485 void AddCompiler(CompilerConfig compiler, bool load)
487 SelectorButton selectButton;
488 if(compiler.readOnly)
490 SelectorButton button
492 compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
493 NotifyClicked = CompilerClicked;
495 selectButton = button;
499 EditableSelectorButton button
501 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
502 NotifyClicked = CompilerClicked;
504 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
506 if(*newName && (*newName)[0])
508 char compilerName[MAX_F_STRING];
509 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
510 if(strcmp(*newName, compilerName))
513 *newName = CopyString(compilerName);
515 activeCompiler.name = compilerName;
516 modifiedDocument = true;
522 selectButton = (SelectorButton)button;
524 compilerConfigs.Add(compiler);
527 LoadCompiler(compiler);
528 selectedButton = selectButton;
529 compilerSelector.Select(selectedButton);
532 SelectorButton selectedButton;
534 void LoadCompiler(CompilerConfig compiler)
536 bool modified = modifiedDocument;
537 activeCompiler = compiler;
541 environmentTab.Load();
544 // Restore original modifiedDocument
545 modifiedDocument = modified;
547 deleteCompiler.disabled = compiler.readOnly;
550 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
552 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
554 LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
555 selectedButton = (SelectorButton)clickedButton;
560 bool NotifyModifiedDocument(PathBox pathBox)
562 BasicValidatePathBoxPath(pathBox);
563 modifiedDocument = true;
568 Array<const String> displayDirectoryNames
575 class CompilerDirectoriesTab : CompilersSubTab
577 background = formColor;
578 text = $"Directories";
580 Button dirTypeTglBtn[DirTypes];
581 DirectoriesBox dirs[DirTypes], currentDirs;
583 ~CompilerDirectoriesTab()
586 for(c = 0; c < DirTypes::enumSize; c++)
589 delete dirTypeTglBtn[c];
592 CompilerDirectoriesTab()
596 for(c = 0; c < DirTypes::enumSize; c++)
598 dirs[c] = DirectoriesBox
600 this;//, alwaysHighLight = true
601 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
604 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
605 settingsFileDialog.filePath = directory;
606 if(settingsFileDialog.Modal())
607 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
610 bool NotifyModified(DirectoriesBox dirsBox)
612 CompilerConfig compiler = loadedCompiler;
615 DirTypes dirType = (DirTypes)dirsBox.id;
616 if(dirType == includes)
617 compiler.includeDirs = dirsBox.strings;
618 else if(dirType == libraries)
619 compiler.libraryDirs = dirsBox.strings;
620 else if(dirType == executables)
621 compiler.executableDirs = dirsBox.strings;
623 compilersTab.modifiedDocument = true;
627 bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
629 BasicValidatePathBoxPath(pathBox);
636 dirs[c].visible = false;
638 // (width) Should be 324 for text...
639 //field[c] = { dataType = class(char *), editable = true };
640 //dirs[c].AddField(field[c]);
642 dirTypeTglBtn[c] = Button
644 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
647 minClientSize = { 99, 20 };
648 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
650 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
652 DirTypes dirType = (DirTypes)button.id;
653 currentDirs.visible = false;
654 dirs[dirType].visible = true;
655 currentDirs = dirs[dirType];
659 v += dirTypeTglBtn[c].size.w + 1;
660 incref dirTypeTglBtn[c];
663 dirTypeTglBtn[c].hotKey = altI;
664 else if(c == libraries)
665 dirTypeTglBtn[c].hotKey = altL;
666 else if(c == executables)
667 dirTypeTglBtn[c].hotKey = altE;
669 currentDirs = dirs[includes];
670 dirTypeTglBtn[includes].checked = true;
674 bool OnLoadGraphics()
678 for(c = 0; c < DirTypes::enumSize; c++)
680 dirTypeTglBtn[c].anchor.left = v;
681 v += dirTypeTglBtn[c].size.w + 1;
683 return CompilersSubTab::OnLoadGraphics();
688 CompilerConfig compiler = loadedCompiler;
691 dirs[includes].strings = compiler.includeDirs;
692 dirs[libraries].strings = compiler.libraryDirs;
693 dirs[executables].strings = compiler.executableDirs;
694 dirs[includes].list.scroll = { 0, 0 };
695 dirs[libraries].list.scroll = { 0, 0 };
696 dirs[executables].list.scroll = { 0, 0 };
701 class CompilerToolchainTab : CompilersSubTab
703 background = formColor;
709 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
712 this, anchor = { left = margin, top = 8, right = 8 };
713 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
715 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
718 this, anchor = { left = margin, top = 34, right = 8 };
719 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
721 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
724 this, anchor = { left = margin, top = 60, right = 8 };
725 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
727 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
730 this, anchor = { left = margin, top = 86, right = 8 };
731 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
733 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
736 this, anchor = { left = margin, top = 112, right = 8 };
737 //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
738 text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
739 bool NotifyModified(EditBox editBox)
741 CompilerConfig compiler = loadedCompiler;
744 compiler.cppCommand = editBox.contents;
745 modifiedDocument = true;
746 compilersTab.modifiedDocument = true;
751 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
754 this, anchor = { left = margin, top = 138, right = 8 };
755 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
757 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
760 this, anchor = { left = margin, top = 164, right = 8 };
761 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
763 Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
766 this, anchor = { left = margin, top = 190, right = 8 };
767 text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
769 Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
772 this, anchor = { left = margin, top = 216, right = 8 };
773 text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
775 Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
778 this, anchor = { left = margin, top = 242, right = 8 };
779 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
781 Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
782 PathBox gnuToolchainPrefix
784 this, anchor = { left = margin, top = 268, right = 8 };
785 text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
787 Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
790 this, anchor = { left = margin, top = 294, right = 8 };
791 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
793 Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
794 PathBox executableLauncher
796 this, anchor = { left = margin, top = 320, right = 8 };
797 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
800 bool NotifyModifiedDocument(PathBox pathBox)
802 CompilerConfig compiler = loadedCompiler;
805 BasicValidatePathBoxPath(pathBox);
807 compiler.ecpCommand = pathBox.slashPath;
808 else if(pathBox == ecc)
809 compiler.eccCommand = pathBox.slashPath;
810 else if(pathBox == ecs)
811 compiler.ecsCommand = pathBox.slashPath;
812 else if(pathBox == ear)
813 compiler.earCommand = pathBox.slashPath;
814 /*else if(pathBox == cpp)
815 compiler.cppCommand = pathBox.slashPath;*/
816 else if(pathBox == cc)
817 compiler.ccCommand = pathBox.slashPath;
818 else if(pathBox == cxx)
819 compiler.cxxCommand = pathBox.slashPath;
820 else if(pathBox == ld)
821 compiler.ldCommand = pathBox.slashPath;
822 else if(pathBox == ar)
823 compiler.arCommand = pathBox.slashPath;
824 else if(pathBox == make)
825 compiler.makeCommand = pathBox.slashPath;
826 else if(pathBox == executableLauncher)
827 compiler.executableLauncher = pathBox.slashPath;
828 else if(pathBox == gnuToolchainPrefix)
829 compiler.gccPrefix = pathBox.slashPath;
830 else if(pathBox == sysroot)
831 compiler.sysroot = pathBox.slashPath;
832 modifiedDocument = true;
833 compilersTab.modifiedDocument = true;
840 CompilerConfig compiler = loadedCompiler;
843 bool disabled = compiler.readOnly;
844 bool isVC = compiler.type.isVC;
845 ecp.path = compiler.ecpCommand;
846 ecc.path = compiler.eccCommand;
847 ecs.path = compiler.ecsCommand;
848 ear.path = compiler.earCommand;
849 //cpp.path = compiler.cppCommand;
850 cpp.contents = compiler.cppCommand;
851 cc.path = compiler.ccCommand;
852 cxx.path = compiler.cxxCommand;
853 ld.path = compiler.ldCommand;
854 ar.path = compiler.arCommand;
855 make.path = compiler.makeCommand;
856 executableLauncher.path = compiler.executableLauncher;
857 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
858 sysroot.path = compiler.sysroot;
860 ecpLabel.disabled = ecp.disabled = disabled;
861 eccLabel.disabled = ecc.disabled = disabled;
862 ecsLabel.disabled = ecs.disabled = disabled;
863 earLabel.disabled = ear.disabled = disabled;
864 cppLabel.disabled = cpp.disabled = isVC || disabled;
865 cxxLabel.disabled = cxx.disabled = isVC || disabled;
866 ccLabel.disabled = cc.disabled = isVC || disabled;
867 ldLabel.disabled = ld.disabled = isVC || disabled;
868 arLabel.disabled = ar.disabled = isVC || disabled;
869 makeLabel.disabled = make.disabled = disabled;
870 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
871 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
872 sysrootLabel.disabled = sysroot.disabled = disabled;
874 modifiedDocument = false;
878 class CompilerEnvironmentTab : CompilersSubTab
880 background = formColor;
881 text = $"Environment";
883 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
884 NamedStringsBox envVars
886 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
887 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
889 bool NotifyModified(NamedStringsBox stringsBox)
891 CompilerConfig compiler = loadedCompiler;
894 compiler.environmentVars = stringsBox.namedStrings;
895 modifiedDocument = true;
896 compilersTab.modifiedDocument = true;
902 CompilerEnvironmentTab()
908 CompilerConfig compiler = loadedCompiler;
911 envVars.namedStrings = compiler.environmentVars;
913 modifiedDocument = false;
918 class CompilerOptionsTab : CompilersSubTab
920 background = formColor;
923 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
924 DropBox targetPlatform
926 this, position = { 110, 8 }, size = { 160 };
927 text = $"Target Platform", hotKey = altT;
928 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
930 CompilerConfig compiler = loadedCompiler;
933 compiler.targetPlatform = (Platform)row.tag;
934 modifiedDocument = true;
935 compilersTab.modifiedDocument = true;
942 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
945 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
946 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
948 bool OnKeyDown(Key key, unichar ch)
950 if((SmartKey)key == enter)
952 DataBox::OnKeyDown(key, ch);
956 return DataBox::OnKeyDown(key, ch);
959 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
969 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
971 CompilerConfig compiler = loadedCompiler;
974 compiler.numJobs = numJobs;
975 modifiedDocument = true;
976 compilersTab.modifiedDocument = true;
984 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
987 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
989 CompilerConfig compiler = loadedCompiler;
992 compiler.ccacheEnabled = button.checked;
993 modifiedDocument = true;
994 compilersTab.modifiedDocument = true;
1000 Button distccEnabled
1002 this, text = $"Use distcc", position = { 158, 68 };
1005 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1007 CompilerConfig compiler = loadedCompiler;
1010 distccHostsLabel.disabled = distccHosts.disabled = !button.checked;
1011 compiler.distccEnabled = button.checked;
1012 modifiedDocument = true;
1013 compilersTab.modifiedDocument = true;
1019 Label distccHostsLabel { this, position = { 240, 68 }, labeledWindow = distccHosts };
1022 this, text = $"distcc hosts", hotKey = altH;
1023 position = { 320, 64 }, size = { 160, 22 };
1025 bool NotifyModified(EditBox editBox)
1027 CompilerConfig compiler = loadedCompiler;
1030 compiler.distccHosts = editBox.contents;
1031 modifiedDocument = true;
1032 compilersTab.modifiedDocument = true;
1038 Label lblPrepDefs { this, position = { 8, 96 }, labeledWindow = prepDefs };
1039 StringListBox prepDefs
1041 this, text = $"Preprocessor directives", hotKey = altP;
1042 position = { 168, 94 }, size = { 280, 22 }, anchor = { left = 168, top = 94, right = 8 };
1044 bool NotifyModified(EditBox editBox)
1048 CompilerConfig compiler = loadedCompiler;
1049 compiler.prepDirectives = ((StringListBox)editBox).strings;
1050 modifiedDocument = true;
1051 compilersTab.modifiedDocument = true;
1057 Label leCcompilerFlags { this, position = { 8, 126 }, labeledWindow = eCcompilerFlags };
1058 StringListBox eCcompilerFlags
1060 this, text = $"Additional eC compiler flags", hotKey = altG;
1061 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1063 bool NotifyModified(EditBox editBox)
1067 CompilerConfig compiler = loadedCompiler;
1068 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1069 modifiedDocument = true;
1070 compilersTab.modifiedDocument = true;
1076 Label lblCompilerFlags { this, position = { 8, 156 }, labeledWindow = compilerFlags };
1077 StringListBox compilerFlags
1079 this, text = $"Additional C compiler flags", hotKey = altR;
1080 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1082 bool NotifyModified(EditBox editBox)
1086 CompilerConfig compiler = loadedCompiler;
1087 compiler.compilerFlags = ((StringListBox)editBox).strings;
1088 modifiedDocument = true;
1089 compilersTab.modifiedDocument = true;
1095 Label lblcxxFlags { this, position = { 8, 186 }, labeledWindow = cxxFlags };
1096 StringListBox cxxFlags
1098 this, text = $"Additional C++ compiler flags", hotKey = altD;
1099 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1101 bool NotifyModified(EditBox editBox)
1105 CompilerConfig compiler = loadedCompiler;
1106 compiler.cxxFlags = ((StringListBox)editBox).strings;
1107 modifiedDocument = true;
1108 compilersTab.modifiedDocument = true;
1114 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1115 StringListBox linkerFlags
1117 this, text = $"Additional linker flags", hotKey = altL;
1118 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1120 bool NotifyModified(EditBox editBox)
1124 CompilerConfig compiler = loadedCompiler;
1125 compiler.linkerFlags = ((StringListBox)editBox).strings;
1126 modifiedDocument = true;
1127 compilersTab.modifiedDocument = true;
1133 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1134 StringListBox excludedLibraries
1136 this, text = $"Libraries to exclude", hotKey = altX;
1137 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1139 bool NotifyModified(EditBox editBox)
1143 CompilerConfig compiler = loadedCompiler;
1144 compiler.excludeLibs = ((StringListBox)editBox).strings;
1145 modifiedDocument = true;
1146 compilersTab.modifiedDocument = true;
1152 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1153 EditBox objectFileExt
1155 this, text = $"Object file extension";//, hotKey = altH;
1156 position = { 168, 274 }, size = { 80, 22 };
1158 bool NotifyModified(EditBox editBox)
1160 CompilerConfig compiler = loadedCompiler;
1163 compiler.objectFileExt = editBox.contents;
1164 modifiedDocument = true;
1165 compilersTab.modifiedDocument = true;
1171 Label staticLibFileExtLabel { this, position = { 8, 306 }, labeledWindow = staticLibFileExt };
1172 EditBox staticLibFileExt
1174 this, text = $"Output (a, so, exe) file extension";//, hotKey = altH;
1175 position = { 168, 304 }, size = { 80, 22 };
1177 bool NotifyModified(EditBox editBox)
1179 CompilerConfig compiler = loadedCompiler;
1182 compiler.staticLibFileExt = editBox.contents;
1183 modifiedDocument = true;
1184 compilersTab.modifiedDocument = true;
1189 EditBox sharedLibFileExt
1192 position = { 256, 304 }, size = { 80, 22 };
1194 bool NotifyModified(EditBox editBox)
1196 CompilerConfig compiler = loadedCompiler;
1199 compiler.sharedLibFileExt = editBox.contents;
1200 modifiedDocument = true;
1201 compilersTab.modifiedDocument = true;
1206 EditBox executableFileExt
1209 position = { 344, 304 }, size = { 80, 22 };
1211 bool NotifyModified(EditBox editBox)
1213 CompilerConfig compiler = loadedCompiler;
1216 compiler.executableFileExt = editBox.contents;
1217 modifiedDocument = true;
1218 compilersTab.modifiedDocument = true;
1226 this, text = $"Strip target", hotKey = altC, position = { 168, 332 };
1229 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1231 CompilerConfig compiler = loadedCompiler;
1234 compiler.noStripTarget = !button.checked;
1235 modifiedDocument = true;
1236 compilersTab.modifiedDocument = true;
1242 Button resourcesDotEar
1244 this, text = $"Use resources.ear", position = { 308, 332 };
1247 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1249 CompilerConfig compiler = loadedCompiler;
1252 compiler.resourcesDotEar = button.checked;
1253 modifiedDocument = true;
1254 compilersTab.modifiedDocument = true;
1260 CompilerOptionsTab()
1264 for(p = (Platform)1; p < Platform::enumSize; p++)
1266 row = targetPlatform.AddRow();
1274 CompilerConfig compiler = loadedCompiler;
1277 bool disabled = compiler.readOnly;
1278 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1279 numJobs = compiler.numJobs;
1280 numJobsBox.Refresh();
1281 ccacheEnabled.checked = compiler.ccacheEnabled;
1282 distccEnabled.checked = compiler.distccEnabled;
1283 distccHostsLabel.disabled = distccHosts.disabled = !compiler.distccEnabled;
1284 distccHosts.contents = compiler.distccHosts;
1285 prepDefs.strings = compiler.prepDirectives;
1286 excludedLibraries.strings = compiler.excludeLibs;
1287 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1288 compilerFlags.strings = compiler.compilerFlags;
1289 cxxFlags.strings = compiler.cxxFlags;
1290 linkerFlags.strings = compiler.linkerFlags;
1291 objectFileExt.contents = compiler.objectFileExt;
1292 staticLibFileExt.contents = compiler.staticLibFileExt;
1293 sharedLibFileExt.contents = compiler.sharedLibFileExt;
1294 executableFileExt.contents = compiler.executableFileExt;
1295 stripTarget.checked = !compiler.noStripTarget;
1296 resourcesDotEar.checked = compiler.resourcesDotEar;
1298 labelTargetPlatform.disabled = disabled;
1299 targetPlatform.disabled = disabled;
1302 modifiedDocument = false;
1306 class CompilersSubTab : Tab
1308 property CompilersTab compilersTab
1312 CompilersTab tab = (CompilersTab)master;
1313 while(tab && tab._class != class(CompilersTab))
1314 tab = (CompilersTab)tab.master;
1319 property CompilerConfig loadedCompiler
1323 CompilersTab tab = compilersTab;
1324 return tab ? tab.activeCompiler : null;
1329 class ProjectOptionsTab : GlobalSettingsSubTab
1331 background = formColor;
1334 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1335 PathBox defaultTargetDir
1337 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1338 text = $"Default Target Directory", hotKey = altT;
1340 bool NotifyModified(PathBox pathBox)
1342 BasicValidatePathBoxPath(pathBox);
1343 modifiedDocument = true;
1348 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1349 PathBox defaultIntermediateObjDir
1351 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1352 text = $"Default Intermediate Objects Directory", hotKey = altI;
1354 bool NotifyModified(PathBox pathBox)
1356 BasicValidatePathBoxPath(pathBox);
1357 modifiedDocument = true;
1363 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1364 // of WorkspaceOptionsTab will *not* be called!
1365 class GlobalSettingsSubTab : Tab
1367 property GlobalSettingsDialog dialog
1371 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1372 while(dialog && dialog._class != class(GlobalSettingsDialog))
1373 dialog = (GlobalSettingsDialog)dialog.master;
1379 class WorkspaceOptionsTab : GlobalSettingsSubTab
1381 background = formColor;
1382 text = $"Workspace";
1384 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1385 DropBox defaultCompilerDropBox
1387 this, position = { 140, 8 }, size = { 220 };
1388 text = $"Default Compiler", hotKey = altA;
1390 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1392 modifiedDocument = true;
1399 GlobalSettingsDialog dialog = this.dialog;
1400 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1403 for(compiler : ideConfig.compilers)
1405 row = defaultCompilerDropBox.AddString(compiler.name);
1406 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1407 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1408 defaultCompilerDropBox.currentRow = row;
1410 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1411 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1418 // TOFIX: The selection will be lost upon changing tab...
1419 // Should either warn, or leave it modified and put in place
1420 // checks to save/find the compiler by name
1421 defaultCompilerDropBox.Clear();
1422 modifiedDocument = false;
1426 //static define app = ((GuiApplication)__thisModule);