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 if(editorTab.modifiedDocument)
76 if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
77 editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
78 editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
80 ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
81 ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
82 ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
83 editorSettingsChanged = true;
87 if(compilersTab.modifiedDocument)
89 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
90 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
91 ideSettings.compilerConfigs.Free();
92 for(compiler : compilersTab.compilerConfigs)
94 ideSettings.compilerConfigs.Add(compiler.Copy());
97 compilerSettingsChanged = true;
100 if(projectOptionsTab.modifiedDocument)
102 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
103 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
105 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
106 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
107 projectOptionsChanged = true;
111 if(workspaceOptionsTab.modifiedDocument)
113 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
114 if(row && row.string)
116 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
118 ideSettings.defaultCompiler = row.string;
123 settingsContainer.Save();
125 if(compilerSettingsChanged)
126 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
127 if(editorSettingsChanged)
128 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
129 if(projectOptionsChanged)
130 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
132 editorTab.modifiedDocument = false;
133 compilersTab.modifiedDocument = false;
134 projectOptionsTab.modifiedDocument = false;
135 workspaceOptionsTab.modifiedDocument = false;
138 Destroy(DialogResult::ok);
147 for(c = 0; c < DirTypes::enumSize; c++)
149 CompilerDir compilerDir;
151 for(systemDir : ideSettings.systemDirs[c])
153 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
154 dirs.Add(compilerDir);
157 row = compilersTab.dirs[c].AddRow();
158 row.SetData(null, "");
159 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
160 compilersTab.dirs[c].modifiedDocument = false;
167 CompilerConfig activateCompiler = null;
168 CompilerConfig readonlyCompiler = null;
171 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
172 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
173 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
176 if(workspaceActiveCompiler)
178 for(compiler : ideSettings.compilerConfigs)
180 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
181 activateCompiler = compiler;
182 if(!readonlyCompiler && compiler.readOnly)
183 readonlyCompiler = compiler;
184 if(activateCompiler && readonlyCompiler)
188 if(!activateCompiler && readonlyCompiler)
189 activateCompiler = readonlyCompiler;
190 if(!activateCompiler && ideSettings.compilerConfigs.count)
191 activateCompiler = ideSettings.compilerConfigs[0];
193 for(compiler : ideSettings.compilerConfigs)
194 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
195 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
198 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
199 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
206 editorTab.modifiedDocument = false;
207 compilersTab.modifiedDocument = false;
208 compilersTab.dirsTab.modifiedDocument = false;
209 compilersTab.toolchainTab.modifiedDocument = false;
210 compilersTab.optionsTab.modifiedDocument = false;
211 compilersTab.activeCompiler = null;
212 compilersTab.compilerConfigs.Free();
213 compilersTab.compilerSelector.Clear();
214 projectOptionsTab.modifiedDocument = false;
215 workspaceOptionsTab.modifiedDocument = false;
218 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
221 class EditorTab : GlobalSettingsSubTab
223 background = formColor;
228 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
229 NotifyClicked = NotifyClickedModifiedDocument;
232 Button caretFollowsScrolling
234 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
235 NotifyClicked = NotifyClickedModifiedDocument;
238 Button showLineNumbers
240 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
241 NotifyClicked = NotifyClickedModifiedDocument;
244 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
246 modifiedDocument = true;
251 static void DrawStipple(Surface surface, Size clientSize)
255 int x2 = clientSize.w - 1;
256 int y2 = clientSize.h - 1;
257 if((x2 - x1) & 1) x2--;
258 if((y2 - y1) & 1) y2--;
260 surface.LineStipple(0x5555);
261 surface.Rectangle(x1, y1, x2, y2);
262 surface.LineStipple(0);
265 class CompilersTab : GlobalSettingsSubTab
267 background = formColor;
270 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
271 PathBox compilerConfigsDir
273 this, anchor = { left = 230, top = 8, right = 8 };
274 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
277 SelectorBar compilerSelector
279 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
281 direction = horizontal;
286 bool OnKeyDown(Key key, unichar ch)
290 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
295 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
298 return SelectorBar::OnKeyDown(key, ch);
301 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
303 ((CompilersTab)master).labelCompilers.Update(null);
309 CompilersTab compilers = (CompilersTab)parent;
310 SelectorBar::OnPostCreate();
311 if(compilers.selectedButton)
313 Button sb = compilers.selectedButton;
316 // 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...
317 // compilers.selectedButton = null;
323 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
325 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
326 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
327 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
328 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
330 List<CompilerConfig> compilerConfigs { };
331 CompilerConfig activeCompiler;
335 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
337 void OnRedraw(Surface surface)
339 Label::OnRedraw(surface);
340 if(labeledWindow.active)
341 DrawStipple(surface, clientSize);
345 void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
348 char tmp[MAX_F_STRING];
349 /*if(startWithNumber)
350 sprintf(tmp, "%s%d", baseName, num);
352 strcpy(tmp, baseName);
355 CompilerConfig matchingCompiler = null;
356 for(c : compilerConfigs)
357 { // TOFIX: Error when omitting these brackets, c not found
358 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
360 matchingCompiler = c;
367 sprintf(tmp, "%s%d", baseName, num);
375 Button createCompiler
377 parent = this, bevelOver = true, inactive = true;
379 anchor = { top = 40, right = 77 };
380 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
382 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
384 char compilerName[MAX_F_STRING];
385 CompilerConfig newCompiler;
386 FindUniqueCompilerName("New Compiler", null, compilerName);
387 newCompiler = MakeDefaultCompiler(compilerName, false);
388 AddCompiler(newCompiler, true);
389 modifiedDocument = true;
393 Button detectCompiler
395 parent = this, bevelOver = true, inactive = true;
397 anchor = { top = 40, right = 54 };
398 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
400 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
402 CompilersDetectionDialog compilersDetectionDialog
407 if(compilersDetectionDialog.Modal())
409 if(compilersDetectionDialog.selectedCompilerType)
411 char uniqueName[MAX_F_STRING];
412 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
413 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
414 newCompiler.name = uniqueName;
415 AddCompiler(newCompiler, true);
416 modifiedDocument = true;
422 Button duplicateCompiler
424 parent = this, bevelOver = true, inactive = true;
426 anchor = { top = 40, right = 31 };
427 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
429 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
431 char copyName[MAX_F_STRING];
432 CompilerConfig copyCompiler = activeCompiler.Copy();
433 FindUniqueCompilerName(copyCompiler.name, null, copyName);
434 copyCompiler.readOnly = false;
435 copyCompiler.name = copyName;
436 AddCompiler(copyCompiler, true);
437 modifiedDocument = true;
441 Button deleteCompiler
443 parent = this, bevelOver = true, inactive = true;
445 anchor = { top = 40, right = 8 };
446 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
448 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
452 CompilerConfig compilerToDelete = activeCompiler;
453 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
454 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
455 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
457 SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
459 compilerSelector.RemoveButton(button);
460 //DeleteCompiler(compilerToDelete);
462 Iterator<CompilerConfig> it { compilerConfigs };
463 if(it.Find(compilerToDelete))
464 compilerConfigs.Delete(it.pointer);
466 modifiedDocument = true;
475 void AddCompiler(CompilerConfig compiler, bool load)
477 SelectorButton selectButton;
478 if(compiler.readOnly)
480 SelectorButton button
482 compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
483 NotifyClicked = CompilerClicked;
485 selectButton = button;
489 EditableSelectorButton button
491 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
492 NotifyClicked = CompilerClicked;
494 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
496 if(*newName && (*newName)[0])
498 char compilerName[MAX_F_STRING];
499 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
500 if(strcmp(*newName, compilerName))
503 *newName = CopyString(compilerName);
505 activeCompiler.name = compilerName;
506 modifiedDocument = true;
512 selectButton = (SelectorButton)button;
514 compilerConfigs.Add(compiler);
517 LoadCompiler(compiler);
518 selectedButton = selectButton;
519 compilerSelector.Select(selectedButton);
522 SelectorButton selectedButton;
524 void LoadCompiler(CompilerConfig compiler)
526 bool modified = modifiedDocument;
527 activeCompiler = compiler;
531 environmentTab.Load();
534 // Restore original modifiedDocument
535 modifiedDocument = modified;
537 deleteCompiler.disabled = compiler.readOnly;
540 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
542 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
544 LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
545 selectedButton = (SelectorButton)clickedButton;
550 bool NotifyModifiedDocument(PathBox pathBox)
552 BasicValidatePathBoxPath(pathBox);
553 modifiedDocument = true;
558 Array<const 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()
586 for(c = 0; c < DirTypes::enumSize; c++)
588 dirs[c] = DirectoriesBox
590 this;//, alwaysHighLight = true
591 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
594 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
595 settingsFileDialog.filePath = directory;
596 if(settingsFileDialog.Modal())
597 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
600 bool NotifyModified(DirectoriesBox dirsBox)
602 CompilerConfig compiler = loadedCompiler;
605 DirTypes dirType = (DirTypes)dirsBox.id;
606 if(dirType == includes)
607 compiler.includeDirs = dirsBox.strings;
608 else if(dirType == libraries)
609 compiler.libraryDirs = dirsBox.strings;
610 else if(dirType == executables)
611 compiler.executableDirs = dirsBox.strings;
613 compilersTab.modifiedDocument = true;
617 bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
619 BasicValidatePathBoxPath(pathBox);
626 dirs[c].visible = false;
628 // (width) Should be 324 for text...
629 //field[c] = { dataType = class(char *), editable = true };
630 //dirs[c].AddField(field[c]);
632 dirTypeTglBtn[c] = Button
634 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
637 minClientSize = { 99, 20 };
638 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
640 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
642 DirTypes dirType = (DirTypes)button.id;
643 currentDirs.visible = false;
644 dirs[dirType].visible = true;
645 currentDirs = dirs[dirType];
649 v += dirTypeTglBtn[c].size.w + 1;
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;
659 currentDirs = dirs[includes];
660 dirTypeTglBtn[includes].checked = true;
664 bool OnLoadGraphics()
668 for(c = 0; c < DirTypes::enumSize; c++)
670 dirTypeTglBtn[c].anchor.left = v;
671 v += dirTypeTglBtn[c].size.w + 1;
673 return CompilersSubTab::OnLoadGraphics();
678 CompilerConfig compiler = loadedCompiler;
681 dirs[includes].strings = compiler.includeDirs;
682 dirs[libraries].strings = compiler.libraryDirs;
683 dirs[executables].strings = compiler.executableDirs;
684 dirs[includes].list.scroll = { 0, 0 };
685 dirs[libraries].list.scroll = { 0, 0 };
686 dirs[executables].list.scroll = { 0, 0 };
691 class CompilerToolchainTab : CompilersSubTab
693 background = formColor;
699 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
702 this, anchor = { left = margin, top = 8, right = 8 };
703 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
705 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
708 this, anchor = { left = margin, top = 34, right = 8 };
709 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
711 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
714 this, anchor = { left = margin, top = 60, right = 8 };
715 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
717 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
720 this, anchor = { left = margin, top = 86, right = 8 };
721 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
723 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
726 this, anchor = { left = margin, top = 112, right = 8 };
727 //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
728 text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
729 bool NotifyModified(EditBox editBox)
731 CompilerConfig compiler = loadedCompiler;
734 compiler.cppCommand = editBox.contents;
735 modifiedDocument = true;
736 compilersTab.modifiedDocument = true;
741 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
744 this, anchor = { left = margin, top = 138, right = 8 };
745 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
747 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
750 this, anchor = { left = margin, top = 164, right = 8 };
751 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
753 Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
756 this, anchor = { left = margin, top = 190, right = 8 };
757 text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
759 Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
762 this, anchor = { left = margin, top = 216, right = 8 };
763 text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
765 Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
768 this, anchor = { left = margin, top = 242, right = 8 };
769 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
771 Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
772 PathBox gnuToolchainPrefix
774 this, anchor = { left = margin, top = 268, right = 8 };
775 text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
777 Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
780 this, anchor = { left = margin, top = 294, right = 8 };
781 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
783 Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
784 PathBox executableLauncher
786 this, anchor = { left = margin, top = 320, right = 8 };
787 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
790 bool NotifyModifiedDocument(PathBox pathBox)
792 CompilerConfig compiler = loadedCompiler;
795 BasicValidatePathBoxPath(pathBox);
797 compiler.ecpCommand = pathBox.slashPath;
798 else if(pathBox == ecc)
799 compiler.eccCommand = pathBox.slashPath;
800 else if(pathBox == ecs)
801 compiler.ecsCommand = pathBox.slashPath;
802 else if(pathBox == ear)
803 compiler.earCommand = pathBox.slashPath;
804 /*else if(pathBox == cpp)
805 compiler.cppCommand = pathBox.slashPath;*/
806 else if(pathBox == cc)
807 compiler.ccCommand = pathBox.slashPath;
808 else if(pathBox == cxx)
809 compiler.cxxCommand = pathBox.slashPath;
810 else if(pathBox == ld)
811 compiler.ldCommand = pathBox.slashPath;
812 else if(pathBox == ar)
813 compiler.arCommand = pathBox.slashPath;
814 else if(pathBox == make)
815 compiler.makeCommand = pathBox.slashPath;
816 else if(pathBox == executableLauncher)
817 compiler.executableLauncher = pathBox.slashPath;
818 else if(pathBox == gnuToolchainPrefix)
819 compiler.gccPrefix = pathBox.slashPath;
820 else if(pathBox == sysroot)
821 compiler.sysroot = pathBox.slashPath;
822 modifiedDocument = true;
823 compilersTab.modifiedDocument = true;
830 CompilerConfig compiler = loadedCompiler;
833 bool disabled = compiler.readOnly;
834 bool isVC = compiler.type.isVC;
835 ecp.path = compiler.ecpCommand;
836 ecc.path = compiler.eccCommand;
837 ecs.path = compiler.ecsCommand;
838 ear.path = compiler.earCommand;
839 //cpp.path = compiler.cppCommand;
840 cpp.contents = compiler.cppCommand;
841 cc.path = compiler.ccCommand;
842 cxx.path = compiler.cxxCommand;
843 ld.path = compiler.ldCommand;
844 ar.path = compiler.arCommand;
845 make.path = compiler.makeCommand;
846 executableLauncher.path = compiler.executableLauncher;
847 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
848 sysroot.path = compiler.sysroot;
850 ecpLabel.disabled = ecp.disabled = disabled;
851 eccLabel.disabled = ecc.disabled = disabled;
852 ecsLabel.disabled = ecs.disabled = disabled;
853 earLabel.disabled = ear.disabled = disabled;
854 cppLabel.disabled = cpp.disabled = isVC || disabled;
855 cxxLabel.disabled = cxx.disabled = isVC || disabled;
856 ccLabel.disabled = cc.disabled = isVC || disabled;
857 ldLabel.disabled = cxx.disabled = isVC || disabled;
858 makeLabel.disabled = make.disabled = disabled;
859 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
860 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
861 sysrootLabel.disabled = sysroot.disabled = disabled;
863 modifiedDocument = false;
867 class CompilerEnvironmentTab : CompilersSubTab
869 background = formColor;
870 text = $"Environment";
872 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
873 NamedStringsBox envVars
875 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
876 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
878 bool NotifyModified(NamedStringsBox stringsBox)
880 CompilerConfig compiler = loadedCompiler;
883 compiler.environmentVars = stringsBox.namedStrings;
884 modifiedDocument = true;
885 compilersTab.modifiedDocument = true;
891 CompilerEnvironmentTab()
897 CompilerConfig compiler = loadedCompiler;
900 envVars.namedStrings = compiler.environmentVars;
902 modifiedDocument = false;
907 class CompilerOptionsTab : CompilersSubTab
909 background = formColor;
912 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
913 DropBox targetPlatform
915 this, position = { 110, 8 }, size = { 160 };
916 text = $"Target Platform", hotKey = altT;
917 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
919 CompilerConfig compiler = loadedCompiler;
922 compiler.targetPlatform = (Platform)row.tag;
923 modifiedDocument = true;
924 compilersTab.modifiedDocument = true;
931 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
934 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
935 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
937 bool OnKeyDown(Key key, unichar ch)
939 if((SmartKey)key == enter)
941 DataBox::OnKeyDown(key, ch);
945 return DataBox::OnKeyDown(key, ch);
948 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
958 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
960 CompilerConfig compiler = loadedCompiler;
963 compiler.numJobs = numJobs;
964 modifiedDocument = true;
965 compilersTab.modifiedDocument = true;
973 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
976 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
978 CompilerConfig compiler = loadedCompiler;
981 compiler.ccacheEnabled = button.checked;
982 modifiedDocument = true;
983 compilersTab.modifiedDocument = true;
991 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
994 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
996 CompilerConfig compiler = loadedCompiler;
999 distccHosts.disabled = !button.checked;
1000 compiler.distccEnabled = button.checked;
1001 modifiedDocument = true;
1002 compilersTab.modifiedDocument = true;
1008 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
1011 this, text = $"distcc hosts", hotKey = altH;
1012 position = { 88, 92 }, size = { 300, 22 };
1014 bool NotifyModified(EditBox editBox)
1016 CompilerConfig compiler = loadedCompiler;
1019 compiler.distccHosts = editBox.contents;
1020 modifiedDocument = true;
1021 compilersTab.modifiedDocument = true;
1027 Label lblPrepDefs { this, position = { 8, 126 }, labeledWindow = prepDefs };
1028 StringListBox prepDefs
1030 this, text = $"Preprocessor directives", hotKey = altP;
1031 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1033 bool NotifyModified(EditBox editBox)
1037 CompilerConfig compiler = loadedCompiler;
1038 compiler.prepDirectives = ((StringListBox)editBox).strings;
1039 modifiedDocument = true;
1040 compilersTab.modifiedDocument = true;
1046 Label leCcompilerFlags { this, position = { 8, 156 }, labeledWindow = eCcompilerFlags };
1047 StringListBox eCcompilerFlags
1049 this, text = $"Additional eC compiler flags", hotKey = altG;
1050 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1052 bool NotifyModified(EditBox editBox)
1056 CompilerConfig compiler = loadedCompiler;
1057 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1058 modifiedDocument = true;
1059 compilersTab.modifiedDocument = true;
1065 Label lblCompilerFlags { this, position = { 8, 186 }, labeledWindow = compilerFlags };
1066 StringListBox compilerFlags
1068 this, text = $"Additional compiler flags", hotKey = altR;
1069 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1071 bool NotifyModified(EditBox editBox)
1075 CompilerConfig compiler = loadedCompiler;
1076 compiler.compilerFlags = ((StringListBox)editBox).strings;
1077 modifiedDocument = true;
1078 compilersTab.modifiedDocument = true;
1084 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1085 StringListBox linkerFlags
1087 this, text = $"Additional linker flags", hotKey = altL;
1088 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1090 bool NotifyModified(EditBox editBox)
1094 CompilerConfig compiler = loadedCompiler;
1095 compiler.linkerFlags = ((StringListBox)editBox).strings;
1096 modifiedDocument = true;
1097 compilersTab.modifiedDocument = true;
1103 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1104 StringListBox excludedLibraries
1106 this, text = $"Libraries to exclude", hotKey = altX;
1107 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1109 bool NotifyModified(EditBox editBox)
1113 CompilerConfig compiler = loadedCompiler;
1114 compiler.excludeLibs = ((StringListBox)editBox).strings;
1115 modifiedDocument = true;
1116 compilersTab.modifiedDocument = true;
1122 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1123 EditBox objectFileExt
1125 this, text = $"Object file extension";//, hotKey = altH;
1126 position = { 168, 274 }, size = { 80, 22 };
1128 bool NotifyModified(EditBox editBox)
1130 CompilerConfig compiler = loadedCompiler;
1133 compiler.objectFileExt = editBox.contents;
1134 modifiedDocument = true;
1135 compilersTab.modifiedDocument = true;
1141 Label outputFileExtLabel { this, position = { 8, 306 }, labeledWindow = outputFileExt };
1142 EditBox outputFileExt
1144 this, text = $"Output file extension";//, hotKey = altH;
1145 position = { 168, 304 }, size = { 80, 22 };
1147 bool NotifyModified(EditBox editBox)
1149 CompilerConfig compiler = loadedCompiler;
1152 compiler.outputFileExt = editBox.contents;
1153 modifiedDocument = true;
1154 compilersTab.modifiedDocument = true;
1160 Button resourcesDotEar
1162 this, text = $"Use resources.ear", position = { 300, 308 };
1165 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1167 CompilerConfig compiler = loadedCompiler;
1170 compiler.resourcesDotEar = button.checked;
1171 modifiedDocument = true;
1172 compilersTab.modifiedDocument = true;
1178 CompilerOptionsTab()
1182 for(p = (Platform)1; p < Platform::enumSize; p++)
1184 row = targetPlatform.AddRow();
1192 CompilerConfig compiler = loadedCompiler;
1195 bool disabled = compiler.readOnly;
1196 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1197 numJobs = compiler.numJobs;
1198 numJobsBox.Refresh();
1199 ccacheEnabled.checked = compiler.ccacheEnabled;
1200 distccEnabled.checked = compiler.distccEnabled;
1201 distccHosts.disabled = !compiler.distccEnabled;
1202 distccHosts.contents = compiler.distccHosts;
1203 prepDefs.strings = compiler.prepDirectives;
1204 excludedLibraries.strings = compiler.excludeLibs;
1205 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1206 compilerFlags.strings = compiler.compilerFlags;
1207 linkerFlags.strings = compiler.linkerFlags;
1208 objectFileExt.contents = compiler.objectFileExt;
1209 outputFileExt.contents = compiler.outputFileExt;
1210 resourcesDotEar.checked = compiler.resourcesDotEar;
1212 labelTargetPlatform.disabled = disabled;
1213 targetPlatform.disabled = disabled;
1216 modifiedDocument = false;
1220 class CompilersSubTab : Tab
1222 property CompilersTab compilersTab
1226 CompilersTab tab = (CompilersTab)master;
1227 while(tab && tab._class != class(CompilersTab))
1228 tab = (CompilersTab)tab.master;
1233 property CompilerConfig loadedCompiler
1237 CompilersTab tab = compilersTab;
1238 return tab ? tab.activeCompiler : null;
1243 class ProjectOptionsTab : GlobalSettingsSubTab
1245 background = formColor;
1248 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1249 PathBox defaultTargetDir
1251 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1252 text = $"Default Target Directory", hotKey = altT;
1254 bool NotifyModified(PathBox pathBox)
1256 BasicValidatePathBoxPath(pathBox);
1257 modifiedDocument = true;
1262 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1263 PathBox defaultIntermediateObjDir
1265 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1266 text = $"Default Intermediate Objects Directory", hotKey = altI;
1268 bool NotifyModified(PathBox pathBox)
1270 BasicValidatePathBoxPath(pathBox);
1271 modifiedDocument = true;
1277 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1278 // of WorkspaceOptionsTab will *not* be called!
1279 class GlobalSettingsSubTab : Tab
1281 property GlobalSettingsDialog dialog
1285 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1286 while(dialog && dialog._class != class(GlobalSettingsDialog))
1287 dialog = (GlobalSettingsDialog)dialog.master;
1293 class WorkspaceOptionsTab : GlobalSettingsSubTab
1295 background = formColor;
1296 text = $"Workspace";
1298 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1299 DropBox defaultCompilerDropBox
1301 this, position = { 140, 8 }, size = { 220 };
1302 text = $"Default Compiler", hotKey = altA;
1304 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1306 modifiedDocument = true;
1313 GlobalSettingsDialog dialog = this.dialog;
1314 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1317 for(compiler : dialog.ideSettings.compilerConfigs)
1319 row = defaultCompilerDropBox.AddString(compiler.name);
1320 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1321 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1322 defaultCompilerDropBox.currentRow = row;
1324 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1325 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1332 // TOFIX: The selection will be lost upon changing tab...
1333 // Should either warn, or leave it modified and put in place
1334 // checks to save/find the compiler by name
1335 defaultCompilerDropBox.Clear();
1336 modifiedDocument = false;
1340 //static define app = ((GuiApplication)__thisModule);