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 cxxLabel.disabled = cxx.disabled = isVC || disabled;
853 ccLabel.disabled = cc.disabled = isVC || disabled;
854 ldLabel.disabled = cxx.disabled = isVC || disabled;
855 makeLabel.disabled = make.disabled = disabled;
856 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
857 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
858 sysrootLabel.disabled = sysroot.disabled = disabled;
860 modifiedDocument = false;
864 class CompilerEnvironmentTab : CompilersSubTab
866 background = formColor;
867 text = $"Environment";
869 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
870 NamedStringsBox envVars
872 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
873 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
875 bool NotifyModified(NamedStringsBox stringsBox)
877 CompilerConfig compiler = loadedCompiler;
880 compiler.environmentVars = stringsBox.namedStrings;
881 modifiedDocument = true;
882 compilersTab.modifiedDocument = true;
888 CompilerEnvironmentTab()
894 CompilerConfig compiler = loadedCompiler;
897 envVars.namedStrings = compiler.environmentVars;
899 modifiedDocument = false;
904 class CompilerOptionsTab : CompilersSubTab
906 background = formColor;
909 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
910 DropBox targetPlatform
912 this, position = { 110, 8 }, size = { 160 };
913 text = $"Target Platform", hotKey = altT;
914 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
916 CompilerConfig compiler = loadedCompiler;
919 compiler.targetPlatform = (Platform)row.tag;
920 modifiedDocument = true;
921 compilersTab.modifiedDocument = true;
928 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
931 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
932 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
934 bool OnKeyDown(Key key, unichar ch)
936 if((SmartKey)key == enter)
938 DataBox::OnKeyDown(key, ch);
942 return DataBox::OnKeyDown(key, ch);
945 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
955 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
957 CompilerConfig compiler = loadedCompiler;
960 compiler.numJobs = numJobs;
961 modifiedDocument = true;
962 compilersTab.modifiedDocument = true;
970 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
973 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
975 CompilerConfig compiler = loadedCompiler;
978 compiler.ccacheEnabled = button.checked;
979 modifiedDocument = true;
980 compilersTab.modifiedDocument = true;
988 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
991 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
993 CompilerConfig compiler = loadedCompiler;
996 distccHosts.disabled = !button.checked;
997 compiler.distccEnabled = button.checked;
998 modifiedDocument = true;
999 compilersTab.modifiedDocument = true;
1005 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
1008 this, text = $"distcc hosts", hotKey = altH;
1009 position = { 88, 92 }, size = { 300, 22 };
1011 bool NotifyModified(EditBox editBox)
1013 CompilerConfig compiler = loadedCompiler;
1016 compiler.distccHosts = editBox.contents;
1017 modifiedDocument = true;
1018 compilersTab.modifiedDocument = true;
1024 Label lblPrepDefs { this, position = { 8, 126 }, labeledWindow = prepDefs };
1025 StringListBox prepDefs
1027 this, text = $"Preprocessor directives", hotKey = altP;
1028 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1030 bool NotifyModified(EditBox editBox)
1034 CompilerConfig compiler = loadedCompiler;
1035 compiler.prepDirectives = ((StringListBox)editBox).strings;
1036 modifiedDocument = true;
1037 compilersTab.modifiedDocument = true;
1043 Label leCcompilerFlags { this, position = { 8, 156 }, labeledWindow = eCcompilerFlags };
1044 StringListBox eCcompilerFlags
1046 this, text = $"Additional eC compiler flags", hotKey = altG;
1047 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1049 bool NotifyModified(EditBox editBox)
1053 CompilerConfig compiler = loadedCompiler;
1054 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1055 modifiedDocument = true;
1056 compilersTab.modifiedDocument = true;
1062 Label lblCompilerFlags { this, position = { 8, 186 }, labeledWindow = compilerFlags };
1063 StringListBox compilerFlags
1065 this, text = $"Additional compiler flags", hotKey = altR;
1066 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1068 bool NotifyModified(EditBox editBox)
1072 CompilerConfig compiler = loadedCompiler;
1073 compiler.compilerFlags = ((StringListBox)editBox).strings;
1074 modifiedDocument = true;
1075 compilersTab.modifiedDocument = true;
1081 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1082 StringListBox linkerFlags
1084 this, text = $"Additional linker flags", hotKey = altL;
1085 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1087 bool NotifyModified(EditBox editBox)
1091 CompilerConfig compiler = loadedCompiler;
1092 compiler.linkerFlags = ((StringListBox)editBox).strings;
1093 modifiedDocument = true;
1094 compilersTab.modifiedDocument = true;
1100 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1101 StringListBox excludedLibraries
1103 this, text = $"Libraries to exclude", hotKey = altX;
1104 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1106 bool NotifyModified(EditBox editBox)
1110 CompilerConfig compiler = loadedCompiler;
1111 compiler.excludeLibs = ((StringListBox)editBox).strings;
1112 modifiedDocument = true;
1113 compilersTab.modifiedDocument = true;
1119 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1120 EditBox objectFileExt
1122 this, text = $"Object file extension";//, hotKey = altH;
1123 position = { 168, 274 }, size = { 80, 22 };
1125 bool NotifyModified(EditBox editBox)
1127 CompilerConfig compiler = loadedCompiler;
1130 compiler.objectFileExt = editBox.contents;
1131 modifiedDocument = true;
1132 compilersTab.modifiedDocument = true;
1138 Label outputFileExtLabel { this, position = { 8, 306 }, labeledWindow = outputFileExt };
1139 EditBox outputFileExt
1141 this, text = $"Output file extension";//, hotKey = altH;
1142 position = { 168, 304 }, size = { 80, 22 };
1144 bool NotifyModified(EditBox editBox)
1146 CompilerConfig compiler = loadedCompiler;
1149 compiler.outputFileExt = editBox.contents;
1150 modifiedDocument = true;
1151 compilersTab.modifiedDocument = true;
1157 Button resourcesDotEar
1159 this, text = $"Use resources.ear", position = { 300, 308 };
1162 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1164 CompilerConfig compiler = loadedCompiler;
1167 compiler.resourcesDotEar = button.checked;
1168 modifiedDocument = true;
1169 compilersTab.modifiedDocument = true;
1175 CompilerOptionsTab()
1179 for(p = (Platform)1; p < Platform::enumSize; p++)
1181 row = targetPlatform.AddRow();
1189 CompilerConfig compiler = loadedCompiler;
1192 bool disabled = compiler.readOnly;
1193 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1194 numJobs = compiler.numJobs;
1195 numJobsBox.Refresh();
1196 ccacheEnabled.checked = compiler.ccacheEnabled;
1197 distccEnabled.checked = compiler.distccEnabled;
1198 distccHosts.disabled = !compiler.distccEnabled;
1199 distccHosts.contents = compiler.distccHosts;
1200 prepDefs.strings = compiler.prepDirectives;
1201 excludedLibraries.strings = compiler.excludeLibs;
1202 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1203 compilerFlags.strings = compiler.compilerFlags;
1204 linkerFlags.strings = compiler.linkerFlags;
1205 objectFileExt.contents = compiler.objectFileExt;
1206 outputFileExt.contents = compiler.outputFileExt;
1207 resourcesDotEar.checked = compiler.resourcesDotEar;
1209 labelTargetPlatform.disabled = disabled;
1210 targetPlatform.disabled = disabled;
1213 modifiedDocument = false;
1217 class CompilersSubTab : Tab
1219 property CompilersTab compilersTab
1223 CompilersTab tab = (CompilersTab)master;
1224 while(tab && tab._class != class(CompilersTab))
1225 tab = (CompilersTab)tab.master;
1230 property CompilerConfig loadedCompiler
1234 CompilersTab tab = compilersTab;
1235 return tab ? tab.activeCompiler : null;
1240 class ProjectOptionsTab : GlobalSettingsSubTab
1242 background = formColor;
1245 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1246 PathBox defaultTargetDir
1248 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1249 text = $"Default Target Directory", hotKey = altT;
1251 bool NotifyModified(PathBox pathBox)
1253 BasicValidatePathBoxPath(pathBox);
1254 modifiedDocument = true;
1259 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1260 PathBox defaultIntermediateObjDir
1262 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1263 text = $"Default Intermediate Objects Directory", hotKey = altI;
1265 bool NotifyModified(PathBox pathBox)
1267 BasicValidatePathBoxPath(pathBox);
1268 modifiedDocument = true;
1274 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1275 // of WorkspaceOptionsTab will *not* be called!
1276 class GlobalSettingsSubTab : Tab
1278 property GlobalSettingsDialog dialog
1282 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1283 while(dialog && dialog._class != class(GlobalSettingsDialog))
1284 dialog = (GlobalSettingsDialog)dialog.master;
1290 class WorkspaceOptionsTab : GlobalSettingsSubTab
1292 background = formColor;
1293 text = $"Workspace";
1295 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1296 DropBox defaultCompilerDropBox
1298 this, position = { 140, 8 }, size = { 220 };
1299 text = $"Default Compiler", hotKey = altA;
1301 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1303 modifiedDocument = true;
1310 GlobalSettingsDialog dialog = this.dialog;
1311 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1314 for(compiler : dialog.ideSettings.compilerConfigs)
1316 row = defaultCompilerDropBox.AddString(compiler.name);
1317 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1318 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1319 defaultCompilerDropBox.currentRow = row;
1321 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1322 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1329 // TOFIX: The selection will be lost upon changing tab...
1330 // Should either warn, or leave it modified and put in place
1331 // checks to save/find the compiler by name
1332 defaultCompilerDropBox.Clear();
1333 modifiedDocument = false;
1337 //static define app = ((GuiApplication)__thisModule);