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());
96 compilerSettingsChanged = true;
99 if(projectOptionsTab.modifiedDocument)
101 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
102 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
104 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
105 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
106 projectOptionsChanged = true;
110 if(workspaceOptionsTab.modifiedDocument)
112 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
113 if(row && row.string)
115 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
117 ideSettings.defaultCompiler = row.string;
122 settingsContainer.Save();
124 if(compilerSettingsChanged)
125 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
126 if(editorSettingsChanged)
127 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
128 if(projectOptionsChanged)
129 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
131 editorTab.modifiedDocument = false;
132 compilersTab.modifiedDocument = false;
133 projectOptionsTab.modifiedDocument = false;
134 workspaceOptionsTab.modifiedDocument = false;
137 Destroy(DialogResult::ok);
146 for(c = 0; c < DirTypes::enumSize; c++)
148 CompilerDir compilerDir;
150 for(systemDir : ideSettings.systemDirs[c])
152 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
153 dirs.Add(compilerDir);
156 row = compilersTab.dirs[c].AddRow();
157 row.SetData(null, "");
158 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
159 compilersTab.dirs[c].modifiedDocument = false;
166 CompilerConfig activateCompiler = null;
167 CompilerConfig readonlyCompiler = null;
170 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
171 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
172 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
175 if(workspaceActiveCompiler)
177 for(compiler : ideSettings.compilerConfigs)
179 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
180 activateCompiler = compiler;
181 if(!readonlyCompiler && compiler.readOnly)
182 readonlyCompiler = compiler;
183 if(activateCompiler && readonlyCompiler)
187 if(!activateCompiler && readonlyCompiler)
188 activateCompiler = readonlyCompiler;
189 if(!activateCompiler && ideSettings.compilerConfigs.count)
190 activateCompiler = ideSettings.compilerConfigs[0];
192 for(compiler : ideSettings.compilerConfigs)
193 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
194 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
197 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
198 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
205 editorTab.modifiedDocument = false;
206 compilersTab.modifiedDocument = false;
207 compilersTab.dirsTab.modifiedDocument = false;
208 compilersTab.toolchainTab.modifiedDocument = false;
209 compilersTab.optionsTab.modifiedDocument = false;
210 compilersTab.activeCompiler = null;
211 compilersTab.compilerConfigs.Free();
212 compilersTab.compilerSelector.Clear();
213 projectOptionsTab.modifiedDocument = false;
214 workspaceOptionsTab.modifiedDocument = false;
217 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
220 class EditorTab : GlobalSettingsSubTab
222 background = formColor;
227 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
228 NotifyClicked = NotifyClickedModifiedDocument;
231 Button caretFollowsScrolling
233 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
234 NotifyClicked = NotifyClickedModifiedDocument;
237 Button showLineNumbers
239 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
240 NotifyClicked = NotifyClickedModifiedDocument;
243 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
245 modifiedDocument = true;
250 static void DrawStipple(Surface surface, Size clientSize)
254 int x2 = clientSize.w - 1;
255 int y2 = clientSize.h - 1;
256 if((x2 - x1) & 1) x2--;
257 if((y2 - y1) & 1) y2--;
259 surface.LineStipple(0x5555);
260 surface.Rectangle(x1, y1, x2, y2);
261 surface.LineStipple(0);
264 class CompilersTab : GlobalSettingsSubTab
266 background = formColor;
269 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
270 PathBox compilerConfigsDir
272 this, anchor = { left = 230, top = 8, right = 8 };
273 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
276 SelectorBar compilerSelector
278 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
280 direction = horizontal;
285 bool OnKeyDown(Key key, unichar ch)
289 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
294 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
297 return SelectorBar::OnKeyDown(key, ch);
300 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
302 ((CompilersTab)master).labelCompilers.Update(null);
308 CompilersTab compilers = (CompilersTab)parent;
309 SelectorBar::OnPostCreate();
310 if(compilers.selectedButton)
312 Button sb = compilers.selectedButton;
315 // 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...
316 // compilers.selectedButton = null;
322 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
324 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
325 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
326 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
327 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
329 List<CompilerConfig> compilerConfigs { };
330 CompilerConfig activeCompiler;
334 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
336 void OnRedraw(Surface surface)
338 Label::OnRedraw(surface);
339 if(labeledWindow.active)
340 DrawStipple(surface, clientSize);
344 void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
347 char tmp[MAX_F_STRING];
348 /*if(startWithNumber)
349 sprintf(tmp, "%s%d", baseName, num);
351 strcpy(tmp, baseName);
354 CompilerConfig matchingCompiler = null;
355 for(c : compilerConfigs)
356 { // TOFIX: Error when omitting these brackets, c not found
357 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
359 matchingCompiler = c;
366 sprintf(tmp, "%s%d", baseName, num);
374 Button createCompiler
376 parent = this, bevelOver = true, inactive = true;
378 anchor = { top = 40, right = 77 };
379 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
381 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
383 char compilerName[MAX_F_STRING];
384 CompilerConfig newCompiler;
385 FindUniqueCompilerName("New Compiler", null, compilerName);
386 newCompiler = MakeDefaultCompiler(compilerName, false);
387 AddCompiler(newCompiler, true);
388 modifiedDocument = true;
392 Button detectCompiler
394 parent = this, bevelOver = true, inactive = true;
396 anchor = { top = 40, right = 54 };
397 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
399 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
401 CompilersDetectionDialog compilersDetectionDialog
406 if(compilersDetectionDialog.Modal())
408 if(compilersDetectionDialog.selectedCompilerType)
410 char uniqueName[MAX_F_STRING];
411 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
412 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
413 newCompiler.name = uniqueName;
414 AddCompiler(newCompiler, true);
415 modifiedDocument = true;
421 Button duplicateCompiler
423 parent = this, bevelOver = true, inactive = true;
425 anchor = { top = 40, right = 31 };
426 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
428 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
430 char copyName[MAX_F_STRING];
431 CompilerConfig copyCompiler = activeCompiler.Copy();
432 FindUniqueCompilerName(copyCompiler.name, null, copyName);
433 copyCompiler.readOnly = false;
434 copyCompiler.name = copyName;
435 AddCompiler(copyCompiler, true);
436 modifiedDocument = true;
440 Button deleteCompiler
442 parent = this, bevelOver = true, inactive = true;
444 anchor = { top = 40, right = 8 };
445 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
447 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
451 CompilerConfig compilerToDelete = activeCompiler;
452 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
453 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
454 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
456 SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
458 compilerSelector.RemoveButton(button);
459 //DeleteCompiler(compilerToDelete);
461 Iterator<CompilerConfig> it { compilerConfigs };
462 if(it.Find(compilerToDelete))
463 compilerConfigs.Delete(it.pointer);
465 modifiedDocument = true;
474 void AddCompiler(CompilerConfig compiler, bool load)
476 SelectorButton selectButton;
477 if(compiler.readOnly)
479 SelectorButton button
481 compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
482 NotifyClicked = CompilerClicked;
484 selectButton = button;
488 EditableSelectorButton button
490 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
491 NotifyClicked = CompilerClicked;
493 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
495 if(*newName && (*newName)[0])
497 char compilerName[MAX_F_STRING];
498 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
499 if(strcmp(*newName, compilerName))
502 *newName = CopyString(compilerName);
504 activeCompiler.name = compilerName;
505 modifiedDocument = true;
511 selectButton = (SelectorButton)button;
513 compilerConfigs.Add(compiler);
516 LoadCompiler(compiler);
517 selectedButton = selectButton;
518 compilerSelector.Select(selectedButton);
521 SelectorButton selectedButton;
523 void LoadCompiler(CompilerConfig compiler)
525 bool modified = modifiedDocument;
526 activeCompiler = compiler;
530 environmentTab.Load();
533 // Restore original modifiedDocument
534 modifiedDocument = modified;
536 deleteCompiler.disabled = compiler.readOnly;
539 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
541 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
543 LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
544 selectedButton = (SelectorButton)clickedButton;
549 bool NotifyModifiedDocument(PathBox pathBox)
551 BasicValidatePathBoxPath(pathBox);
552 modifiedDocument = true;
557 Array<const String> displayDirectoryNames
564 class CompilerDirectoriesTab : CompilersSubTab
566 background = formColor;
567 text = $"Directories";
569 Button dirTypeTglBtn[DirTypes];
570 DirectoriesBox dirs[DirTypes], currentDirs;
572 ~CompilerDirectoriesTab()
575 for(c = 0; c < DirTypes::enumSize; c++)
578 delete dirTypeTglBtn[c];
581 CompilerDirectoriesTab()
585 for(c = 0; c < DirTypes::enumSize; c++)
587 dirs[c] = DirectoriesBox
589 this;//, alwaysHighLight = true
590 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
593 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
594 settingsFileDialog.filePath = directory;
595 if(settingsFileDialog.Modal())
596 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
599 bool NotifyModified(DirectoriesBox dirsBox)
601 CompilerConfig compiler = loadedCompiler;
604 DirTypes dirType = (DirTypes)dirsBox.id;
605 if(dirType == includes)
606 compiler.includeDirs = dirsBox.strings;
607 else if(dirType == libraries)
608 compiler.libraryDirs = dirsBox.strings;
609 else if(dirType == executables)
610 compiler.executableDirs = dirsBox.strings;
612 compilersTab.modifiedDocument = true;
616 bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
618 BasicValidatePathBoxPath(pathBox);
625 dirs[c].visible = false;
627 // (width) Should be 324 for text...
628 //field[c] = { dataType = class(char *), editable = true };
629 //dirs[c].AddField(field[c]);
631 dirTypeTglBtn[c] = Button
633 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
636 minClientSize = { 99, 20 };
637 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
639 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
641 DirTypes dirType = (DirTypes)button.id;
642 currentDirs.visible = false;
643 dirs[dirType].visible = true;
644 currentDirs = dirs[dirType];
648 v += dirTypeTglBtn[c].size.w + 1;
649 incref dirTypeTglBtn[c];
652 dirTypeTglBtn[c].hotKey = altI;
653 else if(c == libraries)
654 dirTypeTglBtn[c].hotKey = altL;
655 else if(c == executables)
656 dirTypeTglBtn[c].hotKey = altE;
658 currentDirs = dirs[includes];
659 dirTypeTglBtn[includes].checked = true;
663 bool OnLoadGraphics()
667 for(c = 0; c < DirTypes::enumSize; c++)
669 dirTypeTglBtn[c].anchor.left = v;
670 v += dirTypeTglBtn[c].size.w + 1;
672 return CompilersSubTab::OnLoadGraphics();
677 CompilerConfig compiler = loadedCompiler;
680 dirs[includes].strings = compiler.includeDirs;
681 dirs[libraries].strings = compiler.libraryDirs;
682 dirs[executables].strings = compiler.executableDirs;
683 dirs[includes].list.scroll = { 0, 0 };
684 dirs[libraries].list.scroll = { 0, 0 };
685 dirs[executables].list.scroll = { 0, 0 };
690 class CompilerToolchainTab : CompilersSubTab
692 background = formColor;
698 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
701 this, anchor = { left = margin, top = 8, right = 8 };
702 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
704 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
707 this, anchor = { left = margin, top = 34, right = 8 };
708 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
710 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
713 this, anchor = { left = margin, top = 60, right = 8 };
714 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
716 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
719 this, anchor = { left = margin, top = 86, right = 8 };
720 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
722 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
725 this, anchor = { left = margin, top = 112, right = 8 };
726 //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
727 text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
728 bool NotifyModified(EditBox editBox)
730 CompilerConfig compiler = loadedCompiler;
733 compiler.cppCommand = editBox.contents;
734 modifiedDocument = true;
735 compilersTab.modifiedDocument = true;
740 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
743 this, anchor = { left = margin, top = 138, right = 8 };
744 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
746 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
749 this, anchor = { left = margin, top = 164, right = 8 };
750 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
752 Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
755 this, anchor = { left = margin, top = 190, right = 8 };
756 text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
758 Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
761 this, anchor = { left = margin, top = 216, right = 8 };
762 text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
764 Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
767 this, anchor = { left = margin, top = 242, right = 8 };
768 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
770 Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
771 PathBox gnuToolchainPrefix
773 this, anchor = { left = margin, top = 268, right = 8 };
774 text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
776 Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
779 this, anchor = { left = margin, top = 294, right = 8 };
780 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
782 Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
783 PathBox executableLauncher
785 this, anchor = { left = margin, top = 320, right = 8 };
786 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
789 bool NotifyModifiedDocument(PathBox pathBox)
791 CompilerConfig compiler = loadedCompiler;
794 BasicValidatePathBoxPath(pathBox);
796 compiler.ecpCommand = pathBox.slashPath;
797 else if(pathBox == ecc)
798 compiler.eccCommand = pathBox.slashPath;
799 else if(pathBox == ecs)
800 compiler.ecsCommand = pathBox.slashPath;
801 else if(pathBox == ear)
802 compiler.earCommand = pathBox.slashPath;
803 /*else if(pathBox == cpp)
804 compiler.cppCommand = pathBox.slashPath;*/
805 else if(pathBox == cc)
806 compiler.ccCommand = pathBox.slashPath;
807 else if(pathBox == cxx)
808 compiler.cxxCommand = pathBox.slashPath;
809 else if(pathBox == ld)
810 compiler.ldCommand = pathBox.slashPath;
811 else if(pathBox == ar)
812 compiler.arCommand = pathBox.slashPath;
813 else if(pathBox == make)
814 compiler.makeCommand = pathBox.slashPath;
815 else if(pathBox == executableLauncher)
816 compiler.executableLauncher = pathBox.slashPath;
817 else if(pathBox == gnuToolchainPrefix)
818 compiler.gccPrefix = pathBox.slashPath;
819 else if(pathBox == sysroot)
820 compiler.sysroot = pathBox.slashPath;
821 modifiedDocument = true;
822 compilersTab.modifiedDocument = true;
829 CompilerConfig compiler = loadedCompiler;
832 bool disabled = compiler.readOnly;
833 bool isVC = compiler.type.isVC;
834 ecp.path = compiler.ecpCommand;
835 ecc.path = compiler.eccCommand;
836 ecs.path = compiler.ecsCommand;
837 ear.path = compiler.earCommand;
838 //cpp.path = compiler.cppCommand;
839 cpp.contents = compiler.cppCommand;
840 cc.path = compiler.ccCommand;
841 cxx.path = compiler.cxxCommand;
842 ld.path = compiler.ldCommand;
843 ar.path = compiler.arCommand;
844 make.path = compiler.makeCommand;
845 executableLauncher.path = compiler.executableLauncher;
846 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
847 sysroot.path = compiler.sysroot;
849 ecpLabel.disabled = ecp.disabled = disabled;
850 eccLabel.disabled = ecc.disabled = disabled;
851 ecsLabel.disabled = ecs.disabled = disabled;
852 earLabel.disabled = ear.disabled = disabled;
853 cppLabel.disabled = cpp.disabled = isVC || disabled;
854 cxxLabel.disabled = cxx.disabled = isVC || disabled;
855 ccLabel.disabled = cc.disabled = isVC || disabled;
856 ldLabel.disabled = cxx.disabled = isVC || disabled;
857 makeLabel.disabled = make.disabled = disabled;
858 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
859 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
860 sysrootLabel.disabled = sysroot.disabled = disabled;
862 modifiedDocument = false;
866 class CompilerEnvironmentTab : CompilersSubTab
868 background = formColor;
869 text = $"Environment";
871 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
872 NamedStringsBox envVars
874 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
875 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
877 bool NotifyModified(NamedStringsBox stringsBox)
879 CompilerConfig compiler = loadedCompiler;
882 compiler.environmentVars = stringsBox.namedStrings;
883 modifiedDocument = true;
884 compilersTab.modifiedDocument = true;
890 CompilerEnvironmentTab()
896 CompilerConfig compiler = loadedCompiler;
899 envVars.namedStrings = compiler.environmentVars;
901 modifiedDocument = false;
906 class CompilerOptionsTab : CompilersSubTab
908 background = formColor;
911 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
912 DropBox targetPlatform
914 this, position = { 110, 8 }, size = { 160 };
915 text = $"Target Platform", hotKey = altT;
916 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
918 CompilerConfig compiler = loadedCompiler;
921 compiler.targetPlatform = (Platform)row.tag;
922 modifiedDocument = true;
923 compilersTab.modifiedDocument = true;
930 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
933 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
934 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
936 bool OnKeyDown(Key key, unichar ch)
938 if((SmartKey)key == enter)
940 DataBox::OnKeyDown(key, ch);
944 return DataBox::OnKeyDown(key, ch);
947 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
957 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
959 CompilerConfig compiler = loadedCompiler;
962 compiler.numJobs = numJobs;
963 modifiedDocument = true;
964 compilersTab.modifiedDocument = true;
972 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
975 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
977 CompilerConfig compiler = loadedCompiler;
980 compiler.ccacheEnabled = button.checked;
981 modifiedDocument = true;
982 compilersTab.modifiedDocument = true;
990 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
993 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
995 CompilerConfig compiler = loadedCompiler;
998 distccHosts.disabled = !button.checked;
999 compiler.distccEnabled = button.checked;
1000 modifiedDocument = true;
1001 compilersTab.modifiedDocument = true;
1007 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
1010 this, text = $"distcc hosts", hotKey = altH;
1011 position = { 88, 92 }, size = { 300, 22 };
1013 bool NotifyModified(EditBox editBox)
1015 CompilerConfig compiler = loadedCompiler;
1018 compiler.distccHosts = editBox.contents;
1019 modifiedDocument = true;
1020 compilersTab.modifiedDocument = true;
1026 Label lblPrepDefs { this, position = { 8, 126 }, labeledWindow = prepDefs };
1027 StringListBox prepDefs
1029 this, text = $"Preprocessor directives", hotKey = altP;
1030 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1032 bool NotifyModified(EditBox editBox)
1036 CompilerConfig compiler = loadedCompiler;
1037 compiler.prepDirectives = ((StringListBox)editBox).strings;
1038 modifiedDocument = true;
1039 compilersTab.modifiedDocument = true;
1045 Label leCcompilerFlags { this, position = { 8, 156 }, labeledWindow = eCcompilerFlags };
1046 StringListBox eCcompilerFlags
1048 this, text = $"Additional eC compiler flags", hotKey = altG;
1049 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1051 bool NotifyModified(EditBox editBox)
1055 CompilerConfig compiler = loadedCompiler;
1056 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1057 modifiedDocument = true;
1058 compilersTab.modifiedDocument = true;
1064 Label lblCompilerFlags { this, position = { 8, 186 }, labeledWindow = compilerFlags };
1065 StringListBox compilerFlags
1067 this, text = $"Additional compiler flags", hotKey = altR;
1068 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1070 bool NotifyModified(EditBox editBox)
1074 CompilerConfig compiler = loadedCompiler;
1075 compiler.compilerFlags = ((StringListBox)editBox).strings;
1076 modifiedDocument = true;
1077 compilersTab.modifiedDocument = true;
1083 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1084 StringListBox linkerFlags
1086 this, text = $"Additional linker flags", hotKey = altL;
1087 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1089 bool NotifyModified(EditBox editBox)
1093 CompilerConfig compiler = loadedCompiler;
1094 compiler.linkerFlags = ((StringListBox)editBox).strings;
1095 modifiedDocument = true;
1096 compilersTab.modifiedDocument = true;
1102 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1103 StringListBox excludedLibraries
1105 this, text = $"Libraries to exclude", hotKey = altX;
1106 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1108 bool NotifyModified(EditBox editBox)
1112 CompilerConfig compiler = loadedCompiler;
1113 compiler.excludeLibs = ((StringListBox)editBox).strings;
1114 modifiedDocument = true;
1115 compilersTab.modifiedDocument = true;
1121 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1122 EditBox objectFileExt
1124 this, text = $"Object file extension";//, hotKey = altH;
1125 position = { 168, 274 }, size = { 80, 22 };
1127 bool NotifyModified(EditBox editBox)
1129 CompilerConfig compiler = loadedCompiler;
1132 compiler.objectFileExt = editBox.contents;
1133 modifiedDocument = true;
1134 compilersTab.modifiedDocument = true;
1140 Label outputFileExtLabel { this, position = { 8, 306 }, labeledWindow = outputFileExt };
1141 EditBox outputFileExt
1143 this, text = $"Output file extension";//, hotKey = altH;
1144 position = { 168, 304 }, size = { 80, 22 };
1146 bool NotifyModified(EditBox editBox)
1148 CompilerConfig compiler = loadedCompiler;
1151 compiler.outputFileExt = editBox.contents;
1152 modifiedDocument = true;
1153 compilersTab.modifiedDocument = true;
1159 Button resourcesDotEar
1161 this, text = $"Use resources.ear", position = { 300, 308 };
1164 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1166 CompilerConfig compiler = loadedCompiler;
1169 compiler.resourcesDotEar = button.checked;
1170 modifiedDocument = true;
1171 compilersTab.modifiedDocument = true;
1177 CompilerOptionsTab()
1181 for(p = (Platform)1; p < Platform::enumSize; p++)
1183 row = targetPlatform.AddRow();
1191 CompilerConfig compiler = loadedCompiler;
1194 bool disabled = compiler.readOnly;
1195 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1196 numJobs = compiler.numJobs;
1197 numJobsBox.Refresh();
1198 ccacheEnabled.checked = compiler.ccacheEnabled;
1199 distccEnabled.checked = compiler.distccEnabled;
1200 distccHosts.disabled = !compiler.distccEnabled;
1201 distccHosts.contents = compiler.distccHosts;
1202 prepDefs.strings = compiler.prepDirectives;
1203 excludedLibraries.strings = compiler.excludeLibs;
1204 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1205 compilerFlags.strings = compiler.compilerFlags;
1206 linkerFlags.strings = compiler.linkerFlags;
1207 objectFileExt.contents = compiler.objectFileExt;
1208 outputFileExt.contents = compiler.outputFileExt;
1209 resourcesDotEar.checked = compiler.resourcesDotEar;
1211 labelTargetPlatform.disabled = disabled;
1212 targetPlatform.disabled = disabled;
1215 modifiedDocument = false;
1219 class CompilersSubTab : Tab
1221 property CompilersTab compilersTab
1225 CompilersTab tab = (CompilersTab)master;
1226 while(tab && tab._class != class(CompilersTab))
1227 tab = (CompilersTab)tab.master;
1232 property CompilerConfig loadedCompiler
1236 CompilersTab tab = compilersTab;
1237 return tab ? tab.activeCompiler : null;
1242 class ProjectOptionsTab : GlobalSettingsSubTab
1244 background = formColor;
1247 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1248 PathBox defaultTargetDir
1250 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1251 text = $"Default Target Directory", hotKey = altT;
1253 bool NotifyModified(PathBox pathBox)
1255 BasicValidatePathBoxPath(pathBox);
1256 modifiedDocument = true;
1261 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1262 PathBox defaultIntermediateObjDir
1264 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1265 text = $"Default Intermediate Objects Directory", hotKey = altI;
1267 bool NotifyModified(PathBox pathBox)
1269 BasicValidatePathBoxPath(pathBox);
1270 modifiedDocument = true;
1276 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1277 // of WorkspaceOptionsTab will *not* be called!
1278 class GlobalSettingsSubTab : Tab
1280 property GlobalSettingsDialog dialog
1284 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1285 while(dialog && dialog._class != class(GlobalSettingsDialog))
1286 dialog = (GlobalSettingsDialog)dialog.master;
1292 class WorkspaceOptionsTab : GlobalSettingsSubTab
1294 background = formColor;
1295 text = $"Workspace";
1297 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1298 DropBox defaultCompilerDropBox
1300 this, position = { 140, 8 }, size = { 220 };
1301 text = $"Default Compiler", hotKey = altA;
1303 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1305 modifiedDocument = true;
1312 GlobalSettingsDialog dialog = this.dialog;
1313 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1316 for(compiler : dialog.ideSettings.compilerConfigs)
1318 row = defaultCompilerDropBox.AddString(compiler.name);
1319 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1320 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1321 defaultCompilerDropBox.currentRow = row;
1323 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1324 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1331 // TOFIX: The selection will be lost upon changing tab...
1332 // Should either warn, or leave it modified and put in place
1333 // checks to save/find the compiler by name
1334 defaultCompilerDropBox.Clear();
1335 modifiedDocument = false;
1339 //static define app = ((GuiApplication)__thisModule);