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, scrollable = true;
283 bool OnKeyDown(Key key, unichar ch)
287 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
292 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
295 return SelectorBar::OnKeyDown(key, ch);
298 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
300 ((CompilersTab)master).labelCompilers.Update(null);
306 CompilersTab compilers = (CompilersTab)parent;
307 SelectorBar::OnPostCreate();
308 if(compilers.selectedButton)
310 Button sb = compilers.selectedButton;
313 // 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...
314 // compilers.selectedButton = null;
320 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
322 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
323 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
324 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
325 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
327 List<CompilerConfig> compilerConfigs { };
328 CompilerConfig activeCompiler;
332 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
334 void OnRedraw(Surface surface)
336 Label::OnRedraw(surface);
337 if(labeledWindow.active)
338 DrawStipple(surface, clientSize);
342 void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
345 char tmp[MAX_F_STRING];
346 /*if(startWithNumber)
347 sprintf(tmp, "%s%d", baseName, num);
349 strcpy(tmp, baseName);
352 CompilerConfig matchingCompiler = null;
353 for(c : compilerConfigs)
354 { // TOFIX: Error when omitting these brackets, c not found
355 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
357 matchingCompiler = c;
364 sprintf(tmp, "%s%d", baseName, num);
372 Button createCompiler
374 parent = this, bevelOver = true, inactive = true;
376 anchor = { top = 40, right = 77 };
377 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
379 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
381 char compilerName[MAX_F_STRING];
382 CompilerConfig newCompiler;
383 FindUniqueCompilerName("New Compiler", null, compilerName);
384 newCompiler = MakeDefaultCompiler(compilerName, false);
385 AddCompiler(newCompiler, true);
386 modifiedDocument = true;
390 Button detectCompiler
392 parent = this, bevelOver = true, inactive = true;
394 anchor = { top = 40, right = 54 };
395 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
397 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
399 CompilersDetectionDialog compilersDetectionDialog
404 if(compilersDetectionDialog.Modal())
406 if(compilersDetectionDialog.selectedCompilerType)
408 char uniqueName[MAX_F_STRING];
409 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
410 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
411 newCompiler.name = uniqueName;
412 AddCompiler(newCompiler, true);
413 modifiedDocument = true;
419 Button duplicateCompiler
421 parent = this, bevelOver = true, inactive = true;
423 anchor = { top = 40, right = 31 };
424 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
426 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
428 char copyName[MAX_F_STRING];
429 CompilerConfig copyCompiler = activeCompiler.Copy();
430 FindUniqueCompilerName(copyCompiler.name, null, copyName);
431 copyCompiler.readOnly = false;
432 copyCompiler.name = copyName;
433 AddCompiler(copyCompiler, true);
434 modifiedDocument = true;
438 Button deleteCompiler
440 parent = this, bevelOver = true, inactive = true;
442 anchor = { top = 40, right = 8 };
443 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
445 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
449 CompilerConfig compilerToDelete = activeCompiler;
450 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
451 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
452 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
454 SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
456 compilerSelector.RemoveButton(button);
457 //DeleteCompiler(compilerToDelete);
459 Iterator<CompilerConfig> it { compilerConfigs };
460 if(it.Find(compilerToDelete))
461 compilerConfigs.Delete(it.pointer);
463 modifiedDocument = true;
472 void AddCompiler(CompilerConfig compiler, bool load)
474 SelectorButton selectButton;
475 if(compiler.readOnly)
477 SelectorButton button
479 compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
480 NotifyClicked = CompilerClicked;
482 selectButton = button;
486 EditableSelectorButton button
488 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
489 NotifyClicked = CompilerClicked;
491 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
493 if(*newName && (*newName)[0])
495 char compilerName[MAX_F_STRING];
496 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
497 if(strcmp(*newName, compilerName))
500 *newName = CopyString(compilerName);
502 activeCompiler.name = compilerName;
503 modifiedDocument = true;
509 selectButton = (SelectorButton)button;
511 compilerConfigs.Add(compiler);
514 LoadCompiler(compiler);
515 selectedButton = selectButton;
516 compilerSelector.Select(selectedButton);
519 SelectorButton selectedButton;
521 void LoadCompiler(CompilerConfig compiler)
523 bool modified = modifiedDocument;
524 activeCompiler = compiler;
528 environmentTab.Load();
531 // Restore original modifiedDocument
532 modifiedDocument = modified;
534 deleteCompiler.disabled = compiler.readOnly;
537 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
539 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
541 LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
542 selectedButton = (SelectorButton)clickedButton;
547 bool NotifyModifiedDocument(PathBox pathBox)
549 BasicValidatePathBoxPath(pathBox);
550 modifiedDocument = true;
555 Array<const String> displayDirectoryNames
562 class CompilerDirectoriesTab : CompilersSubTab
564 background = formColor;
565 text = $"Directories";
567 Button dirTypeTglBtn[DirTypes];
568 DirectoriesBox dirs[DirTypes], currentDirs;
570 ~CompilerDirectoriesTab()
573 for(c = 0; c < DirTypes::enumSize; c++)
576 delete dirTypeTglBtn[c];
579 CompilerDirectoriesTab()
583 for(c = 0; c < DirTypes::enumSize; c++)
585 dirs[c] = DirectoriesBox
587 this;//, alwaysHighLight = true
588 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
591 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
592 settingsFileDialog.filePath = directory;
593 if(settingsFileDialog.Modal())
594 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
597 bool NotifyModified(DirectoriesBox dirsBox)
599 CompilerConfig compiler = loadedCompiler;
602 DirTypes dirType = (DirTypes)dirsBox.id;
603 if(dirType == includes)
604 compiler.includeDirs = dirsBox.strings;
605 else if(dirType == libraries)
606 compiler.libraryDirs = dirsBox.strings;
607 else if(dirType == executables)
608 compiler.executableDirs = dirsBox.strings;
610 compilersTab.modifiedDocument = true;
614 bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
616 BasicValidatePathBoxPath(pathBox);
623 dirs[c].visible = false;
625 // (width) Should be 324 for text...
626 //field[c] = { dataType = class(char *), editable = true };
627 //dirs[c].AddField(field[c]);
629 dirTypeTglBtn[c] = Button
631 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
634 minClientSize = { 99, 20 };
635 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
637 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
639 DirTypes dirType = (DirTypes)button.id;
640 currentDirs.visible = false;
641 dirs[dirType].visible = true;
642 currentDirs = dirs[dirType];
646 v += dirTypeTglBtn[c].size.w + 1;
647 incref dirTypeTglBtn[c];
650 dirTypeTglBtn[c].hotKey = altI;
651 else if(c == libraries)
652 dirTypeTglBtn[c].hotKey = altL;
653 else if(c == executables)
654 dirTypeTglBtn[c].hotKey = altE;
656 currentDirs = dirs[includes];
657 dirTypeTglBtn[includes].checked = true;
661 bool OnLoadGraphics()
665 for(c = 0; c < DirTypes::enumSize; c++)
667 dirTypeTglBtn[c].anchor.left = v;
668 v += dirTypeTglBtn[c].size.w + 1;
670 return CompilersSubTab::OnLoadGraphics();
675 CompilerConfig compiler = loadedCompiler;
678 dirs[includes].strings = compiler.includeDirs;
679 dirs[libraries].strings = compiler.libraryDirs;
680 dirs[executables].strings = compiler.executableDirs;
681 dirs[includes].list.scroll = { 0, 0 };
682 dirs[libraries].list.scroll = { 0, 0 };
683 dirs[executables].list.scroll = { 0, 0 };
688 class CompilerToolchainTab : CompilersSubTab
690 background = formColor;
696 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
699 this, anchor = { left = margin, top = 8, right = 8 };
700 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
702 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
705 this, anchor = { left = margin, top = 34, right = 8 };
706 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
708 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
711 this, anchor = { left = margin, top = 60, right = 8 };
712 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
714 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
717 this, anchor = { left = margin, top = 86, right = 8 };
718 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
720 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
723 this, anchor = { left = margin, top = 112, right = 8 };
724 //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
725 text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
726 bool NotifyModified(EditBox editBox)
728 CompilerConfig compiler = loadedCompiler;
731 compiler.cppCommand = editBox.contents;
732 modifiedDocument = true;
733 compilersTab.modifiedDocument = true;
738 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
741 this, anchor = { left = margin, top = 138, right = 8 };
742 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
744 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
747 this, anchor = { left = margin, top = 164, right = 8 };
748 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
750 Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
753 this, anchor = { left = margin, top = 190, right = 8 };
754 text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
756 Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
759 this, anchor = { left = margin, top = 216, right = 8 };
760 text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
762 Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
765 this, anchor = { left = margin, top = 242, right = 8 };
766 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
768 Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
769 PathBox gnuToolchainPrefix
771 this, anchor = { left = margin, top = 268, right = 8 };
772 text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
774 Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
777 this, anchor = { left = margin, top = 294, right = 8 };
778 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
780 Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
781 PathBox executableLauncher
783 this, anchor = { left = margin, top = 320, right = 8 };
784 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
787 bool NotifyModifiedDocument(PathBox pathBox)
789 CompilerConfig compiler = loadedCompiler;
792 BasicValidatePathBoxPath(pathBox);
794 compiler.ecpCommand = pathBox.slashPath;
795 else if(pathBox == ecc)
796 compiler.eccCommand = pathBox.slashPath;
797 else if(pathBox == ecs)
798 compiler.ecsCommand = pathBox.slashPath;
799 else if(pathBox == ear)
800 compiler.earCommand = pathBox.slashPath;
801 /*else if(pathBox == cpp)
802 compiler.cppCommand = pathBox.slashPath;*/
803 else if(pathBox == cc)
804 compiler.ccCommand = pathBox.slashPath;
805 else if(pathBox == cxx)
806 compiler.cxxCommand = pathBox.slashPath;
807 else if(pathBox == ld)
808 compiler.ldCommand = pathBox.slashPath;
809 else if(pathBox == ar)
810 compiler.arCommand = pathBox.slashPath;
811 else if(pathBox == make)
812 compiler.makeCommand = pathBox.slashPath;
813 else if(pathBox == executableLauncher)
814 compiler.executableLauncher = pathBox.slashPath;
815 else if(pathBox == gnuToolchainPrefix)
816 compiler.gccPrefix = pathBox.slashPath;
817 else if(pathBox == sysroot)
818 compiler.sysroot = pathBox.slashPath;
819 modifiedDocument = true;
820 compilersTab.modifiedDocument = true;
827 CompilerConfig compiler = loadedCompiler;
830 bool disabled = compiler.readOnly;
831 bool isVC = compiler.type.isVC;
832 ecp.path = compiler.ecpCommand;
833 ecc.path = compiler.eccCommand;
834 ecs.path = compiler.ecsCommand;
835 ear.path = compiler.earCommand;
836 //cpp.path = compiler.cppCommand;
837 cpp.contents = compiler.cppCommand;
838 cc.path = compiler.ccCommand;
839 cxx.path = compiler.cxxCommand;
840 ld.path = compiler.ldCommand;
841 ar.path = compiler.arCommand;
842 make.path = compiler.makeCommand;
843 executableLauncher.path = compiler.executableLauncher;
844 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
845 sysroot.path = compiler.sysroot;
847 ecpLabel.disabled = ecp.disabled = disabled;
848 eccLabel.disabled = ecc.disabled = disabled;
849 ecsLabel.disabled = ecs.disabled = disabled;
850 earLabel.disabled = ear.disabled = disabled;
851 cppLabel.disabled = cpp.disabled = isVC || disabled;
852 ccLabel.disabled = cc.disabled = isVC || disabled;
853 cxxLabel.disabled = cxx.disabled = isVC || disabled;
854 ldLabel.disabled = ld.disabled = isVC || disabled;
855 arLabel.disabled = ar.disabled = isVC || disabled;
856 makeLabel.disabled = make.disabled = disabled;
857 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
858 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
859 sysrootLabel.disabled = sysroot.disabled = disabled;
861 modifiedDocument = false;
865 class CompilerEnvironmentTab : CompilersSubTab
867 background = formColor;
868 text = $"Environment";
870 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
871 NamedStringsBox envVars
873 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
874 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
876 bool NotifyModified(NamedStringsBox stringsBox)
878 CompilerConfig compiler = loadedCompiler;
881 compiler.environmentVars = stringsBox.namedStrings;
882 modifiedDocument = true;
883 compilersTab.modifiedDocument = true;
889 CompilerEnvironmentTab()
895 CompilerConfig compiler = loadedCompiler;
898 envVars.namedStrings = compiler.environmentVars;
900 modifiedDocument = false;
905 class CompilerOptionsTab : CompilersSubTab
907 background = formColor;
910 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
911 DropBox targetPlatform
913 this, position = { 110, 8 }, size = { 160 };
914 text = $"Target Platform", hotKey = altT;
915 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
917 CompilerConfig compiler = loadedCompiler;
920 compiler.targetPlatform = (Platform)row.tag;
921 modifiedDocument = true;
922 compilersTab.modifiedDocument = true;
929 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
932 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
933 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
935 bool OnKeyDown(Key key, unichar ch)
937 if((SmartKey)key == enter)
939 DataBox::OnKeyDown(key, ch);
943 return DataBox::OnKeyDown(key, ch);
946 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
956 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
958 CompilerConfig compiler = loadedCompiler;
961 compiler.numJobs = numJobs;
962 modifiedDocument = true;
963 compilersTab.modifiedDocument = true;
971 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
974 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
976 CompilerConfig compiler = loadedCompiler;
979 compiler.ccacheEnabled = button.checked;
980 modifiedDocument = true;
981 compilersTab.modifiedDocument = true;
989 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
992 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
994 CompilerConfig compiler = loadedCompiler;
997 distccHosts.disabled = !button.checked;
998 compiler.distccEnabled = button.checked;
999 modifiedDocument = true;
1000 compilersTab.modifiedDocument = true;
1006 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
1009 this, text = $"distcc hosts", hotKey = altH;
1010 position = { 88, 92 }, size = { 300, 22 };
1012 bool NotifyModified(EditBox editBox)
1014 CompilerConfig compiler = loadedCompiler;
1017 compiler.distccHosts = editBox.contents;
1018 modifiedDocument = true;
1019 compilersTab.modifiedDocument = true;
1025 Label lblPrepDefs { this, position = { 8, 126 }, labeledWindow = prepDefs };
1026 StringListBox prepDefs
1028 this, text = $"Preprocessor directives", hotKey = altP;
1029 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1031 bool NotifyModified(EditBox editBox)
1035 CompilerConfig compiler = loadedCompiler;
1036 compiler.prepDirectives = ((StringListBox)editBox).strings;
1037 modifiedDocument = true;
1038 compilersTab.modifiedDocument = true;
1044 Label leCcompilerFlags { this, position = { 8, 156 }, labeledWindow = eCcompilerFlags };
1045 StringListBox eCcompilerFlags
1047 this, text = $"Additional eC compiler flags", hotKey = altG;
1048 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1050 bool NotifyModified(EditBox editBox)
1054 CompilerConfig compiler = loadedCompiler;
1055 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1056 modifiedDocument = true;
1057 compilersTab.modifiedDocument = true;
1063 Label lblCompilerFlags { this, position = { 8, 186 }, labeledWindow = compilerFlags };
1064 StringListBox compilerFlags
1066 this, text = $"Additional compiler flags", hotKey = altR;
1067 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1069 bool NotifyModified(EditBox editBox)
1073 CompilerConfig compiler = loadedCompiler;
1074 compiler.compilerFlags = ((StringListBox)editBox).strings;
1075 modifiedDocument = true;
1076 compilersTab.modifiedDocument = true;
1082 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1083 StringListBox linkerFlags
1085 this, text = $"Additional linker flags", hotKey = altL;
1086 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1088 bool NotifyModified(EditBox editBox)
1092 CompilerConfig compiler = loadedCompiler;
1093 compiler.linkerFlags = ((StringListBox)editBox).strings;
1094 modifiedDocument = true;
1095 compilersTab.modifiedDocument = true;
1101 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1102 StringListBox excludedLibraries
1104 this, text = $"Libraries to exclude", hotKey = altX;
1105 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1107 bool NotifyModified(EditBox editBox)
1111 CompilerConfig compiler = loadedCompiler;
1112 compiler.excludeLibs = ((StringListBox)editBox).strings;
1113 modifiedDocument = true;
1114 compilersTab.modifiedDocument = true;
1120 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1121 EditBox objectFileExt
1123 this, text = $"Object file extension";//, hotKey = altH;
1124 position = { 168, 274 }, size = { 80, 22 };
1126 bool NotifyModified(EditBox editBox)
1128 CompilerConfig compiler = loadedCompiler;
1131 compiler.objectFileExt = editBox.contents;
1132 modifiedDocument = true;
1133 compilersTab.modifiedDocument = true;
1139 Label staticLibFileExtLabel { this, position = { 8, 306 }, labeledWindow = staticLibFileExt };
1140 EditBox staticLibFileExt
1142 this, text = $"Output (a, so, exe) file extension";//, hotKey = altH;
1143 position = { 168, 304 }, size = { 80, 22 };
1145 bool NotifyModified(EditBox editBox)
1147 CompilerConfig compiler = loadedCompiler;
1150 compiler.staticLibFileExt = editBox.contents;
1151 modifiedDocument = true;
1152 compilersTab.modifiedDocument = true;
1157 EditBox sharedLibFileExt
1160 position = { 256, 304 }, size = { 80, 22 };
1162 bool NotifyModified(EditBox editBox)
1164 CompilerConfig compiler = loadedCompiler;
1167 compiler.sharedLibFileExt = editBox.contents;
1168 modifiedDocument = true;
1169 compilersTab.modifiedDocument = true;
1174 EditBox executableFileExt
1177 position = { 344, 304 }, size = { 80, 22 };
1179 bool NotifyModified(EditBox editBox)
1181 CompilerConfig compiler = loadedCompiler;
1184 compiler.executableFileExt = editBox.contents;
1185 modifiedDocument = true;
1186 compilersTab.modifiedDocument = true;
1194 this, text = $"Strip target", hotKey = altC, position = { 8, 334 };
1197 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1199 CompilerConfig compiler = loadedCompiler;
1202 compiler.noStripTarget = !button.checked;
1203 modifiedDocument = true;
1204 compilersTab.modifiedDocument = true;
1210 CompilerOptionsTab()
1214 for(p = (Platform)1; p < Platform::enumSize; p++)
1216 row = targetPlatform.AddRow();
1224 CompilerConfig compiler = loadedCompiler;
1227 bool disabled = compiler.readOnly;
1228 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1229 numJobs = compiler.numJobs;
1230 numJobsBox.Refresh();
1231 ccacheEnabled.checked = compiler.ccacheEnabled;
1232 distccEnabled.checked = compiler.distccEnabled;
1233 distccHosts.disabled = !compiler.distccEnabled;
1234 distccHosts.contents = compiler.distccHosts;
1235 prepDefs.strings = compiler.prepDirectives;
1236 excludedLibraries.strings = compiler.excludeLibs;
1237 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1238 compilerFlags.strings = compiler.compilerFlags;
1239 linkerFlags.strings = compiler.linkerFlags;
1240 objectFileExt.contents = compiler.objectFileExt;
1241 staticLibFileExt.contents = compiler.staticLibFileExt;
1242 sharedLibFileExt.contents = compiler.sharedLibFileExt;
1243 executableFileExt.contents = compiler.executableFileExt;
1244 stripTarget.checked = !compiler.noStripTarget;
1246 labelTargetPlatform.disabled = disabled;
1247 targetPlatform.disabled = disabled;
1250 modifiedDocument = false;
1254 class CompilersSubTab : Tab
1256 property CompilersTab compilersTab
1260 CompilersTab tab = (CompilersTab)master;
1261 while(tab && tab._class != class(CompilersTab))
1262 tab = (CompilersTab)tab.master;
1267 property CompilerConfig loadedCompiler
1271 CompilersTab tab = compilersTab;
1272 return tab ? tab.activeCompiler : null;
1277 class ProjectOptionsTab : GlobalSettingsSubTab
1279 background = formColor;
1282 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1283 PathBox defaultTargetDir
1285 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1286 text = $"Default Target Directory", hotKey = altT;
1288 bool NotifyModified(PathBox pathBox)
1290 BasicValidatePathBoxPath(pathBox);
1291 modifiedDocument = true;
1296 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1297 PathBox defaultIntermediateObjDir
1299 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1300 text = $"Default Intermediate Objects Directory", hotKey = altI;
1302 bool NotifyModified(PathBox pathBox)
1304 BasicValidatePathBoxPath(pathBox);
1305 modifiedDocument = true;
1311 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1312 // of WorkspaceOptionsTab will *not* be called!
1313 class GlobalSettingsSubTab : Tab
1315 property GlobalSettingsDialog dialog
1319 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1320 while(dialog && dialog._class != class(GlobalSettingsDialog))
1321 dialog = (GlobalSettingsDialog)dialog.master;
1327 class WorkspaceOptionsTab : GlobalSettingsSubTab
1329 background = formColor;
1330 text = $"Workspace";
1332 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1333 DropBox defaultCompilerDropBox
1335 this, position = { 140, 8 }, size = { 220 };
1336 text = $"Default Compiler", hotKey = altA;
1338 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1340 modifiedDocument = true;
1347 GlobalSettingsDialog dialog = this.dialog;
1348 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1351 for(compiler : dialog.ideSettings.compilerConfigs)
1353 row = defaultCompilerDropBox.AddString(compiler.name);
1354 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1355 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1356 defaultCompilerDropBox.currentRow = row;
1358 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1359 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1366 // TOFIX: The selection will be lost upon changing tab...
1367 // Should either warn, or leave it modified and put in place
1368 // checks to save/find the compiler by name
1369 defaultCompilerDropBox.Clear();
1370 modifiedDocument = false;
1374 //static define app = ((GuiApplication)__thisModule);