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, 506 };
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)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)compiler;
480 NotifyClicked = CompilerClicked;
482 selectButton = button;
486 EditableSelectorButton button
488 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)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)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;
726 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
729 this, anchor = { left = margin, top = 138, right = 8 };
730 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
732 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
735 this, anchor = { left = margin, top = 164, right = 8 };
736 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
738 Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
741 this, anchor = { left = margin, top = 190, right = 8 };
742 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
744 Label gnuToolchainPrefixLabel { this, position = { 8, 220 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
745 PathBox gnuToolchainPrefix
747 this, anchor = { left = margin, top = 216, right = 8 };
748 text = $"GNU Toolchain Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
750 Label sysrootLabel { this, position = { 8, 246 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
753 this, anchor = { left = margin, top = 242, right = 8 };
754 text = $"SYSROOT", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
756 Label executableLauncherLabel { this, position = { 8, 272 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
757 PathBox executableLauncher
759 this, anchor = { left = margin, top = 268, right = 8 };
760 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
763 bool NotifyModifiedDocument(PathBox pathBox)
765 CompilerConfig compiler = loadedCompiler;
768 BasicValidatePathBoxPath(pathBox);
770 compiler.ecpCommand = pathBox.slashPath;
771 else if(pathBox == ecc)
772 compiler.eccCommand = pathBox.slashPath;
773 else if(pathBox == ecs)
774 compiler.ecsCommand = pathBox.slashPath;
775 else if(pathBox == ear)
776 compiler.earCommand = pathBox.slashPath;
777 else if(pathBox == cpp)
778 compiler.cppCommand = pathBox.slashPath;
779 else if(pathBox == cc)
780 compiler.ccCommand = pathBox.slashPath;
781 else if(pathBox == cxx)
782 compiler.cxxCommand = pathBox.slashPath;
783 else if(pathBox == make)
784 compiler.makeCommand = pathBox.slashPath;
785 else if(pathBox == executableLauncher)
786 compiler.execPrefixCommand = pathBox.slashPath;
787 else if(pathBox == gnuToolchainPrefix)
788 compiler.gccPrefix = pathBox.slashPath;
789 else if(pathBox == sysroot)
790 compiler.sysroot = pathBox.slashPath;
791 modifiedDocument = true;
792 compilersTab.modifiedDocument = true;
799 CompilerConfig compiler = loadedCompiler;
802 bool disabled = compiler.readOnly;
803 bool isVC = compiler.type.isVC;
804 ecp.path = compiler.ecpCommand;
805 ecc.path = compiler.eccCommand;
806 ecs.path = compiler.ecsCommand;
807 ear.path = compiler.earCommand;
808 cpp.path = compiler.cppCommand;
809 cc.path = compiler.ccCommand;
810 cxx.path = compiler.cxxCommand;
811 make.path = compiler.makeCommand;
812 executableLauncher.path = compiler.executableLauncher;
813 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
814 sysroot.path = compiler.sysroot;
816 ecpLabel.disabled = ecp.disabled = disabled;
817 eccLabel.disabled = ecc.disabled = disabled;
818 ecsLabel.disabled = ecs.disabled = disabled;
819 earLabel.disabled = ear.disabled = disabled;
820 cppLabel.disabled = cpp.disabled = isVC || disabled;
821 cxxLabel.disabled = cxx.disabled = isVC || disabled;
822 ccLabel.disabled = cc.disabled = isVC || disabled;
823 makeLabel.disabled = make.disabled = disabled;
824 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
825 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
826 sysrootLabel.disabled = sysroot.disabled = disabled;
828 modifiedDocument = false;
832 class CompilerEnvironmentTab : CompilersSubTab
834 background = formColor;
835 text = $"Environment";
837 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
838 NamedStringsBox envVars
840 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
841 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
843 bool NotifyModified(NamedStringsBox stringsBox)
845 CompilerConfig compiler = loadedCompiler;
848 compiler.environmentVars = stringsBox.namedStrings;
849 modifiedDocument = true;
850 compilersTab.modifiedDocument = true;
856 CompilerEnvironmentTab()
862 CompilerConfig compiler = loadedCompiler;
865 envVars.namedStrings = compiler.environmentVars;
867 modifiedDocument = false;
872 class CompilerOptionsTab : CompilersSubTab
874 background = formColor;
877 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
878 DropBox targetPlatform
880 this, position = { 110, 8 }, size = { 160 };
881 text = $"Target Platform", hotKey = altT;
882 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
884 CompilerConfig compiler = loadedCompiler;
887 compiler.targetPlatform = (Platform)row.tag;
888 modifiedDocument = true;
889 compilersTab.modifiedDocument = true;
896 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
899 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
900 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
902 bool OnKeyDown(Key key, unichar ch)
904 if((SmartKey)key == enter)
906 DataBox::OnKeyDown(key, ch);
910 return DataBox::OnKeyDown(key, ch);
913 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
923 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
925 CompilerConfig compiler = loadedCompiler;
928 compiler.numJobs = numJobs;
929 modifiedDocument = true;
930 compilersTab.modifiedDocument = true;
938 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
941 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
943 CompilerConfig compiler = loadedCompiler;
946 compiler.ccacheEnabled = button.checked;
947 modifiedDocument = true;
948 compilersTab.modifiedDocument = true;
956 this, text = $"Use distcc", hotKey = altD, position = { 158, 68 };
959 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
961 CompilerConfig compiler = loadedCompiler;
964 distccHosts.disabled = !button.checked;
965 compiler.distccEnabled = button.checked;
966 modifiedDocument = true;
967 compilersTab.modifiedDocument = true;
973 Label distccHostsLabel { this, position = { 8, 96 }, labeledWindow = distccHosts };
976 this, text = $"distcc hosts", hotKey = altH;
977 position = { 88, 92 }, size = { 300, 22 };
979 bool NotifyModified(EditBox editBox)
981 CompilerConfig compiler = loadedCompiler;
984 compiler.distccHosts = editBox.contents;
985 modifiedDocument = true;
986 compilersTab.modifiedDocument = true;
992 Label lblPrepDefs { this, position = { 8, 126 }, labeledWindow = prepDefs };
993 StringListBox prepDefs
995 this, text = $"Preprocessor directives", hotKey = altP;
996 position = { 148, 124 }, size = { 300, 22 }, anchor = { left = 148, top = 124, right = 8 };
998 bool NotifyModified(EditBox editBox)
1002 CompilerConfig compiler = loadedCompiler;
1003 compiler.prepDirectives = ((StringListBox)editBox).strings;
1004 modifiedDocument = true;
1005 compilersTab.modifiedDocument = true;
1011 Label leCcompilerFlags { this, position = { 8, 156 }, labeledWindow = eCcompilerFlags };
1012 StringListBox eCcompilerFlags
1014 this, text = $"Additional eC compiler flags", hotKey = altG;
1015 position = { 148, 154 }, size = { 300, 22 }, anchor = { left = 148, top = 154, right = 8 };
1017 bool NotifyModified(EditBox editBox)
1021 CompilerConfig compiler = loadedCompiler;
1022 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1023 modifiedDocument = true;
1024 compilersTab.modifiedDocument = true;
1030 Label lblCompilerFlags { this, position = { 8, 186 }, labeledWindow = compilerFlags };
1031 StringListBox compilerFlags
1033 this, text = $"Additional compiler flags", hotKey = altR;
1034 position = { 148, 184 }, size = { 300, 22 }, anchor = { left = 148, top = 184, right = 8 };
1036 bool NotifyModified(EditBox editBox)
1040 CompilerConfig compiler = loadedCompiler;
1041 compiler.compilerFlags = ((StringListBox)editBox).strings;
1042 modifiedDocument = true;
1043 compilersTab.modifiedDocument = true;
1049 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1050 StringListBox linkerFlags
1052 this, text = $"Additional linker flags", hotKey = altL;
1053 position = { 148, 214 }, size = { 300, 22 }, anchor = { left = 148, top = 214, right = 8 };
1055 bool NotifyModified(EditBox editBox)
1059 CompilerConfig compiler = loadedCompiler;
1060 compiler.linkerFlags = ((StringListBox)editBox).strings;
1061 modifiedDocument = true;
1062 compilersTab.modifiedDocument = true;
1068 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1069 StringListBox excludedLibraries
1071 this, text = $"Libraries to exclude", hotKey = altX;
1072 position = { 148, 244 }, size = { 300, 22 }, anchor = { left = 148, top = 244, right = 8 };
1074 bool NotifyModified(EditBox editBox)
1078 CompilerConfig compiler = loadedCompiler;
1079 compiler.excludeLibs = ((StringListBox)editBox).strings;
1080 modifiedDocument = true;
1081 compilersTab.modifiedDocument = true;
1087 CompilerOptionsTab()
1091 for(p = (Platform)1; p < Platform::enumSize; p++)
1093 row = targetPlatform.AddRow();
1101 CompilerConfig compiler = loadedCompiler;
1104 bool disabled = compiler.readOnly;
1105 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1106 numJobs = compiler.numJobs;
1107 numJobsBox.Refresh();
1108 ccacheEnabled.checked = compiler.ccacheEnabled;
1109 distccEnabled.checked = compiler.distccEnabled;
1110 distccHosts.disabled = !compiler.distccEnabled;
1111 distccHosts.contents = compiler.distccHosts;
1112 prepDefs.strings = compiler.prepDirectives;
1113 excludedLibraries.strings = compiler.excludeLibs;
1114 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1115 compilerFlags.strings = compiler.compilerFlags;
1116 linkerFlags.strings = compiler.linkerFlags;
1118 labelTargetPlatform.disabled = disabled;
1119 targetPlatform.disabled = disabled;
1122 modifiedDocument = false;
1126 class CompilersSubTab : Tab
1128 property CompilersTab compilersTab
1132 CompilersTab tab = (CompilersTab)master;
1133 while(tab && tab._class != class(CompilersTab))
1134 tab = (CompilersTab)tab.master;
1139 property CompilerConfig loadedCompiler
1143 CompilersTab tab = compilersTab;
1144 return tab ? tab.activeCompiler : null;
1149 class ProjectOptionsTab : GlobalSettingsSubTab
1151 background = formColor;
1154 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1155 PathBox defaultTargetDir
1157 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1158 text = $"Default Target Directory", hotKey = altT;
1160 bool NotifyModified(PathBox pathBox)
1162 BasicValidatePathBoxPath(pathBox);
1163 modifiedDocument = true;
1168 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1169 PathBox defaultIntermediateObjDir
1171 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1172 text = $"Default Intermediate Objects Directory", hotKey = altI;
1174 bool NotifyModified(PathBox pathBox)
1176 BasicValidatePathBoxPath(pathBox);
1177 modifiedDocument = true;
1183 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1184 // of WorkspaceOptionsTab will *not* be called!
1185 class GlobalSettingsSubTab : Tab
1187 property GlobalSettingsDialog dialog
1191 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1192 while(dialog && dialog._class != class(GlobalSettingsDialog))
1193 dialog = (GlobalSettingsDialog)dialog.master;
1199 class WorkspaceOptionsTab : GlobalSettingsSubTab
1201 background = formColor;
1202 text = $"Workspace";
1204 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1205 DropBox defaultCompilerDropBox
1207 this, position = { 140, 8 }, size = { 220 };
1208 text = $"Default Compiler", hotKey = altA;
1210 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1212 modifiedDocument = true;
1219 GlobalSettingsDialog dialog = this.dialog;
1220 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1223 for(compiler : dialog.ideSettings.compilerConfigs)
1225 row = defaultCompilerDropBox.AddString(compiler.name);
1226 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1227 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1228 defaultCompilerDropBox.currentRow = row;
1230 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1231 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1238 // TOFIX: The selection will be lost upon changing tab...
1239 // Should either warn, or leave it modified and put in place
1240 // checks to save/find the compiler by name
1241 defaultCompilerDropBox.Clear();
1242 modifiedDocument = false;
1246 //static define app = ((GuiApplication)__thisModule);