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, 446 };
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 bool workspaceOptionsChanged = false;
76 if(editorTab.modifiedDocument)
78 if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
79 editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
80 editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling)
82 ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
83 ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
84 ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
85 editorSettingsChanged = true;
89 if(compilersTab.modifiedDocument)
91 bool foundActive = false;
92 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
93 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
94 ideSettings.compilerConfigs.Free();
95 for(compiler : compilersTab.compilerConfigs)
97 ideSettings.compilerConfigs.Add(compiler.Copy());
98 if(!foundActive && ide.workspace.compiler && !strcmp(ide.workspace.compiler, compiler.name))
102 ide.workspace.compiler = defaultCompilerName;
104 compilerSettingsChanged = true;
107 if(projectOptionsTab.modifiedDocument)
109 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
110 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
112 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
113 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
114 projectOptionsChanged = true;
118 if(workspaceOptionsTab.modifiedDocument)
120 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
121 if(row && row.string)
123 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
125 ideSettings.defaultCompiler = row.string;
126 workspaceOptionsChanged = true;
131 settingsContainer.Save();
133 if(compilerSettingsChanged)
134 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
135 if(editorSettingsChanged)
136 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
137 if(projectOptionsChanged)
138 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
140 editorTab.modifiedDocument = false;
141 compilersTab.modifiedDocument = false;
142 projectOptionsTab.modifiedDocument = false;
143 workspaceOptionsTab.modifiedDocument = false;
146 Destroy(DialogResult::ok);
155 for(c = 0; c < DirTypes::enumSize; c++)
157 CompilerDir compilerDir;
159 for(systemDir : ideSettings.systemDirs[c])
161 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
162 dirs.Add(compilerDir);
165 row = compilersTab.dirs[c].AddRow();
166 row.SetData(null, "");
167 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
168 compilersTab.dirs[c].modifiedDocument = false;
175 CompilerConfig activateCompiler = null;
176 CompilerConfig readonlyCompiler = null;
179 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
180 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
181 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
184 if(workspaceActiveCompiler)
186 for(compiler : ideSettings.compilerConfigs)
188 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
189 activateCompiler = compiler;
190 if(!readonlyCompiler && compiler.readOnly)
191 readonlyCompiler = compiler;
192 if(activateCompiler && readonlyCompiler)
196 if(!activateCompiler && readonlyCompiler)
197 activateCompiler = readonlyCompiler;
198 if(!activateCompiler && ideSettings.compilerConfigs.count)
199 activateCompiler = ideSettings.compilerConfigs[0];
201 for(compiler : ideSettings.compilerConfigs)
202 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
203 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
206 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
207 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
214 editorTab.modifiedDocument = false;
215 compilersTab.modifiedDocument = false;
216 compilersTab.dirsTab.modifiedDocument = false;
217 compilersTab.toolchainTab.modifiedDocument = false;
218 compilersTab.optionsTab.modifiedDocument = false;
219 compilersTab.activeCompiler = null;
220 compilersTab.compilerConfigs.Free();
221 compilersTab.compilerSelector.Clear();
222 projectOptionsTab.modifiedDocument = false;
223 workspaceOptionsTab.modifiedDocument = false;
226 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
229 class EditorTab : GlobalSettingsSubTab
231 background = formColor;
236 this, text = $"Move code editor caret freely past end of line", position = { 16, 68 }, isCheckbox = true;
237 NotifyClicked = NotifyClickedModifiedDocument;
240 Button caretFollowsScrolling
242 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 88 }, isCheckbox = true;
243 NotifyClicked = NotifyClickedModifiedDocument;
246 Button showLineNumbers
248 this, text = $"Show line numbers in code editor", position = { 16, 108 }, isCheckbox = true;
249 NotifyClicked = NotifyClickedModifiedDocument;
252 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
254 modifiedDocument = true;
259 static void DrawStipple(Surface surface, Size clientSize)
263 int x2 = clientSize.w - 1;
264 int y2 = clientSize.h - 1;
265 if((x2 - x1) & 1) x2--;
266 if((y2 - y1) & 1) y2--;
268 surface.LineStipple(0x5555);
269 surface.Rectangle(x1, y1, x2, y2);
270 surface.LineStipple(0);
273 class CompilersTab : GlobalSettingsSubTab
275 background = formColor;
278 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
279 PathBox compilerConfigsDir
281 this, anchor = { left = 210, top = 8, right = 8 };
282 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
285 SelectorBar compilerSelector
287 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
289 direction = horizontal, scrollable = true;
291 bool OnKeyDown(Key key, unichar ch)
295 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
300 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
303 return SelectorBar::OnKeyDown(key, ch);
306 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
308 ((CompilersTab)master).labelCompilers.Update(null);
314 CompilersTab compilers = (CompilersTab)parent;
315 SelectorBar::OnPostCreate();
316 if(compilers.selectedButton)
318 Button sb = compilers.selectedButton;
321 // 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...
322 // compilers.selectedButton = null;
328 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
330 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
331 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
332 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
333 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
335 List<CompilerConfig> compilerConfigs { };
336 CompilerConfig activeCompiler;
340 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
342 void OnRedraw(Surface surface)
344 Label::OnRedraw(surface);
345 if(labeledWindow.active)
346 DrawStipple(surface, clientSize);
350 void FindUniqueCompilerName(char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
353 char tmp[MAX_F_STRING];
354 /*if(startWithNumber)
355 sprintf(tmp, "%s%d", baseName, num);
357 strcpy(tmp, baseName);
360 CompilerConfig matchingCompiler = null;
361 for(c : compilerConfigs)
362 { // TOFIX: Error when omitting these brackets, c not found
363 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
365 matchingCompiler = c;
372 sprintf(tmp, "%s%d", baseName, num);
380 Button createCompiler
382 parent = this, bevelOver = true, inactive = true;
384 anchor = { top = 40, right = 77 };
385 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
387 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
389 char compilerName[MAX_F_STRING];
390 CompilerConfig newCompiler;
391 FindUniqueCompilerName("New Compiler", null, compilerName);
392 newCompiler = MakeDefaultCompiler(compilerName, false);
393 AddCompiler(newCompiler, true);
394 modifiedDocument = true;
398 Button detectCompiler
400 parent = this, bevelOver = true, inactive = true;
402 anchor = { top = 40, right = 54 };
403 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
405 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
407 CompilersDetectionDialog compilersDetectionDialog
412 if(compilersDetectionDialog.Modal())
414 if(compilersDetectionDialog.selectedCompilerType)
416 char uniqueName[MAX_F_STRING];
417 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
418 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
419 newCompiler.name = uniqueName;
420 AddCompiler(newCompiler, true);
421 modifiedDocument = true;
427 Button duplicateCompiler
429 parent = this, bevelOver = true, inactive = true;
431 anchor = { top = 40, right = 31 };
432 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
434 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
436 char copyName[MAX_F_STRING];
437 CompilerConfig copyCompiler = activeCompiler.Copy();
438 FindUniqueCompilerName(copyCompiler.name, null, copyName);
439 copyCompiler.readOnly = false;
440 copyCompiler.name = copyName;
441 AddCompiler(copyCompiler, true);
442 modifiedDocument = true;
446 Button deleteCompiler
448 parent = this, bevelOver = true, inactive = true;
450 anchor = { top = 40, right = 8 };
451 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
453 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
457 CompilerConfig compilerToDelete = activeCompiler;
458 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
459 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
460 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
462 SelectorButton button = compilerSelector.FindButtonByID((int)compilerToDelete);
464 compilerSelector.RemoveButton(button);
465 //DeleteCompiler(compilerToDelete);
467 Iterator<CompilerConfig> it { compilerConfigs };
468 if(it.Find(compilerToDelete))
469 compilerConfigs.Delete(it.pointer);
471 modifiedDocument = true;
480 void AddCompiler(CompilerConfig compiler, bool load)
482 SelectorButton selectButton;
483 if(compiler.readOnly)
485 SelectorButton button
487 compilerSelector, master = this, text = compiler.name, id = (int)compiler;
488 NotifyClicked = CompilerClicked;
490 selectButton = button;
494 EditableSelectorButton button
496 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int)compiler;
497 NotifyClicked = CompilerClicked;
499 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
501 if(*newName && (*newName)[0])
503 char compilerName[MAX_F_STRING];
504 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
505 if(strcmp(*newName, compilerName))
508 *newName = CopyString(compilerName);
510 activeCompiler.name = compilerName;
511 modifiedDocument = true;
517 selectButton = (SelectorButton)button;
519 compilerConfigs.Add(compiler);
522 LoadCompiler(compiler);
523 selectedButton = selectButton;
524 compilerSelector.Select(selectedButton);
527 SelectorButton selectedButton;
529 void LoadCompiler(CompilerConfig compiler)
531 bool modified = modifiedDocument;
532 activeCompiler = compiler;
536 environmentTab.Load();
539 // Restore original modifiedDocument
540 modifiedDocument = modified;
542 deleteCompiler.disabled = compiler.readOnly;
545 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
547 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
549 LoadCompiler((CompilerConfig)clickedButton.id);
550 selectedButton = (SelectorButton)clickedButton;
555 bool NotifyModifiedDocument(PathBox pathBox)
557 modifiedDocument = true;
562 Array<String> displayDirectoryNames
569 class CompilerDirectoriesTab : CompilersSubTab
571 background = formColor;
572 text = $"Directories";
574 Button dirTypeTglBtn[DirTypes];
575 DirectoriesBox dirs[DirTypes], currentDirs;
577 ~CompilerDirectoriesTab()
580 for(c = 0; c < DirTypes::enumSize; c++)
583 delete dirTypeTglBtn[c];
586 CompilerDirectoriesTab()
589 for(c = 0; c < DirTypes::enumSize; c++)
591 dirs[c] = DirectoriesBox
593 this;//, alwaysHighLight = true
594 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
597 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
598 settingsFileDialog.filePath = directory;
599 if(settingsFileDialog.Modal())
600 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
603 bool NotifyModified(DirectoriesBox dirsBox)
605 CompilerConfig compiler = loadedCompiler;
608 DirTypes dirType = (DirTypes)dirsBox.id;
609 if(dirType == includes)
610 compiler.includeDirs = dirsBox.strings;
611 else if(dirType == libraries)
612 compiler.libraryDirs = dirsBox.strings;
613 else if(dirType == executables)
614 compiler.executableDirs = dirsBox.strings;
616 compilersTab.modifiedDocument = true;
624 dirs[c].visible = false;
626 // (width) Should be 324 for text...
627 //field[c] = { dataType = class(char *), editable = true };
628 //dirs[c].AddField(field[c]);
631 int v = (int)c * 100 + 8;
632 dirTypeTglBtn[c] = Button
634 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
638 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
640 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
642 DirTypes dirType = (DirTypes)button.id;
643 currentDirs.visible = false;
644 dirs[dirType].visible = true;
645 currentDirs = dirs[dirType];
649 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;
659 currentDirs = dirs[includes];
660 dirTypeTglBtn[includes].checked = true;
668 CompilerConfig compiler = loadedCompiler;
669 dirs[includes].strings = compiler.includeDirs;
670 dirs[libraries].strings = compiler.libraryDirs;
671 dirs[executables].strings = compiler.executableDirs;
672 dirs[includes].list.scroll = { 0, 0 };
673 dirs[libraries].list.scroll = { 0, 0 };
674 dirs[executables].list.scroll = { 0, 0 };
679 class CompilerToolchainTab : CompilersSubTab
681 background = formColor;
684 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
687 this, anchor = { left = 120, top = 8, right = 8 };
688 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
690 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
693 this, anchor = { left = 120, top = 34, right = 8 };
694 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
696 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
699 this, anchor = { left = 120, top = 60, right = 8 };
700 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
702 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
705 this, anchor = { left = 120, top = 86, right = 8 };
706 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
708 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
711 this, anchor = { left = 120, top = 112, right = 8 };
712 text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
714 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
717 this, anchor = { left = 120, top = 138, right = 8 };
718 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
720 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
723 this, anchor = { left = 120, top = 164, right = 8 };
724 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
726 Label makeLabel { this, position = { 8, 194 }, labeledWindow = make, tabCycle = false, inactive = true };
729 this, anchor = { left = 120, top = 190, right = 8 };
730 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
732 Label execPrefixLabel { this, position = { 8, 220 }, labeledWindow = execPrefix, tabCycle = false, inactive = true };
735 this, anchor = { left = 120, top = 216, right = 8 };
736 text = $"Execution Prefix", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
739 bool NotifyModifiedDocument(PathBox pathBox)
743 CompilerConfig compiler = loadedCompiler;
745 compiler.ecpCommand = pathBox.slashPath;
746 else if(pathBox == ecc)
747 compiler.eccCommand = pathBox.slashPath;
748 else if(pathBox == ecs)
749 compiler.ecsCommand = pathBox.slashPath;
750 else if(pathBox == ear)
751 compiler.earCommand = pathBox.slashPath;
752 else if(pathBox == cpp)
753 compiler.cppCommand = pathBox.slashPath;
754 else if(pathBox == cc)
755 compiler.ccCommand = pathBox.slashPath;
756 else if(pathBox == cxx)
757 compiler.cxxCommand = pathBox.slashPath;
758 else if(pathBox == make)
759 compiler.makeCommand = pathBox.slashPath;
760 else if(pathBox == execPrefix)
761 compiler.execPrefixCommand = pathBox.slashPath;
762 modifiedDocument = true;
763 compilersTab.modifiedDocument = true;
772 CompilerConfig compiler = loadedCompiler;
773 bool disabled = compiler.readOnly;
774 bool isVC = compiler.type.isVC;
775 ecp.path = compiler.ecpCommand;
776 ecc.path = compiler.eccCommand;
777 ecs.path = compiler.ecsCommand;
778 ear.path = compiler.earCommand;
779 cpp.path = compiler.cppCommand;
780 cc.path = compiler.ccCommand;
781 cxx.path = compiler.cxxCommand;
782 make.path = compiler.makeCommand;
783 execPrefix.path = compiler.execPrefixCommand;
785 ecpLabel.disabled = ecp.disabled = disabled;
786 eccLabel.disabled = ecc.disabled = disabled;
787 ecsLabel.disabled = ecs.disabled = disabled;
788 earLabel.disabled = ear.disabled = disabled;
789 cppLabel.disabled = cpp.disabled = isVC || disabled;
790 ccLabel.disabled = cc.disabled = isVC || disabled;
791 makeLabel.disabled = make.disabled = disabled;
792 execPrefixLabel.disabled = execPrefix.disabled = disabled;
794 modifiedDocument = false;
798 class CompilerEnvironmentTab : CompilersSubTab
800 background = formColor;
801 text = $"Environment";
803 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
804 NamedStringsBox envVars
806 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
807 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
809 bool NotifyModified(NamedStringsBox stringsBox)
811 loadedCompiler.environmentVars = stringsBox.namedStrings;
812 modifiedDocument = true;
813 compilersTab.modifiedDocument = true;
818 CompilerEnvironmentTab()
826 CompilerConfig compiler = loadedCompiler;
827 envVars.namedStrings = compiler.environmentVars;
829 modifiedDocument = false;
834 class CompilerOptionsTab : CompilersSubTab
836 background = formColor;
839 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
840 DropBox targetPlatform
842 this, position = { 110, 8 }, size = { 160 };
843 text = $"Target Platform", hotKey = altT;
844 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
846 CompilerConfig compiler = loadedCompiler;
849 compiler.targetPlatform = (Platform)row.tag;
850 modifiedDocument = true;
851 compilersTab.modifiedDocument = true;
858 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
861 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
862 position = { 184, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
864 bool OnKeyDown(Key key, unichar ch)
866 if((SmartKey)key == enter)
868 DataBox::OnKeyDown(key, ch);
872 return DataBox::OnKeyDown(key, ch);
875 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
885 bool NotifyChanged(bool closingDropDown)
887 CompilerConfig compiler = loadedCompiler;
890 compiler.numJobs = numJobs;
891 modifiedDocument = true;
892 compilersTab.modifiedDocument = true;
900 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
903 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
905 CompilerConfig compiler = loadedCompiler;
908 compiler.ccacheEnabled = button.checked;
909 modifiedDocument = true;
910 compilersTab.modifiedDocument = true;
918 this, text = $"Use distcc", hotKey = altD, position = { 8, 96 };
921 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
923 CompilerConfig compiler = loadedCompiler;
926 distccHosts.disabled = !button.checked;
927 compiler.distccEnabled = button.checked;
928 modifiedDocument = true;
929 compilersTab.modifiedDocument = true;
935 Label distccHostsLabel { this, position = { 8, 124 }, labeledWindow = distccHosts };
938 this, text = $"distcc hosts", hotKey = altH;
939 position = { 88, 120 }, size = { 300 };
941 bool NotifyModified(EditBox editBox)
945 CompilerConfig compiler = loadedCompiler;
946 compiler.distccHosts = editBox.contents;
947 modifiedDocument = true;
948 compilersTab.modifiedDocument = true;
954 Label lblExcludedLibraries { this, position = { 8, 152 }, labeledWindow = excludedLibraries };
955 StringListBox excludedLibraries
957 this, text = $"Libraries to exclude:", hotKey = altX;
958 position = { 148, 152 }, size = { 300 };
960 bool NotifyModified(EditBox editBox)
964 CompilerConfig compiler = loadedCompiler;
965 compiler.excludeLibs = ((StringListBox)editBox).strings;
966 modifiedDocument = true;
967 compilersTab.modifiedDocument = true;
973 Label lblPrepDefs { this, position = { 8, 180 }, labeledWindow = prepDefs };
974 StringListBox prepDefs
976 this, text = $"Preprocessor directives:", hotKey = altP;
977 position = { 148, 180 }, size = { 300 };
979 bool NotifyModified(EditBox editBox)
983 CompilerConfig compiler = loadedCompiler;
984 compiler.prepDirectives = ((StringListBox)editBox).strings;
985 modifiedDocument = true;
986 compilersTab.modifiedDocument = true;
996 for(p = (Platform)1; p < Platform::enumSize; p++)
998 row = targetPlatform.AddRow();
1008 CompilerConfig compiler = loadedCompiler;
1009 bool disabled = compiler.readOnly;
1010 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1011 numJobs = compiler.numJobs;
1012 numJobsBox.Refresh();
1013 ccacheEnabled.checked = compiler.ccacheEnabled;
1014 distccEnabled.checked = compiler.distccEnabled;
1015 distccHosts.disabled = !compiler.distccEnabled;
1016 distccHosts.contents = compiler.distccHosts;
1017 prepDefs.strings = compiler.prepDirectives;
1018 excludedLibraries.strings = compiler.excludeLibs;
1020 labelTargetPlatform.disabled = disabled;
1021 targetPlatform.disabled = disabled;
1024 modifiedDocument = false;
1028 class CompilersSubTab : Tab
1030 property CompilersTab compilersTab
1034 CompilersTab tab = (CompilersTab)master;
1035 while(tab && tab._class != class(CompilersTab))
1036 tab = (CompilersTab)tab.master;
1041 property CompilerConfig loadedCompiler
1045 CompilersTab tab = compilersTab;
1046 return tab ? tab.activeCompiler : null;
1051 class ProjectOptionsTab : GlobalSettingsSubTab
1053 background = formColor;
1056 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1057 PathBox defaultTargetDir
1059 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1060 text = $"Default Target Directory", hotKey = altT;
1062 bool NotifyModified(PathBox editBox)
1064 modifiedDocument = true;
1069 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1070 PathBox defaultIntermediateObjDir
1072 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1073 text = $"Default Intermediate Objects Directory", hotKey = altI;
1075 bool NotifyModified(PathBox editBox)
1077 modifiedDocument = true;
1083 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1084 // of WorkspaceOptionsTab will *not* be called!
1085 class GlobalSettingsSubTab : Tab
1087 property GlobalSettingsDialog dialog
1091 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1092 while(dialog && dialog._class != class(GlobalSettingsDialog))
1093 dialog = (GlobalSettingsDialog)dialog.master;
1099 class WorkspaceOptionsTab : GlobalSettingsSubTab
1101 background = formColor;
1102 text = $"Workspace";
1104 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1105 DropBox defaultCompilerDropBox
1107 this, position = { 140, 8 }, size = { 220 };
1108 text = $"Default Compiler", hotKey = altA;
1110 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1112 modifiedDocument = true;
1119 GlobalSettingsDialog dialog = this.dialog;
1120 if(dialog && dialog.compilersTab.compilerConfigs && dialog.ideSettings)
1123 for(compiler : dialog.ideSettings.compilerConfigs)
1125 row = defaultCompilerDropBox.AddString(compiler.name);
1126 if(dialog.ideSettings.defaultCompiler && dialog.ideSettings.defaultCompiler[0] &&
1127 !strcmp(compiler.name, dialog.ideSettings.defaultCompiler))
1128 defaultCompilerDropBox.currentRow = row;
1130 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1131 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1138 // TOFIX: The selection will be lost upon changing tab...
1139 // Should either warn, or leave it modified and put in place
1140 // checks to save/find the compiler by name
1141 defaultCompilerDropBox.Clear();
1142 modifiedDocument = false;
1146 //static define app = ((GuiApplication)__thisModule);