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 String workspaceActiveCompiler;
24 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 8, right = 8, bottom = 40 } };
26 EditorTab editorTab { this, tabControl = tabControl };
27 CompilersTab compilersTab { this, tabControl = tabControl };
28 ProjectOptionsTab projectOptionsTab { this, tabControl = tabControl };
29 WorkspaceOptionsTab workspaceOptionsTab { this, tabControl = tabControl };
31 property bool settingsModified
35 return editorTab.modifiedDocument || compilersTab.modifiedDocument ||
36 projectOptionsTab.modifiedDocument || workspaceOptionsTab.modifiedDocument;
40 bool OnClose(bool parentClosing)
42 if(!settingsModified || MessageBox {
43 type = okCancel, master = ide,
44 text = $"Lose Changes?",
45 contents = $"Are you sure you wish to discard changes?"
53 parent = this, hotKey = escape, text = $"Cancel", id = DialogResult::cancel;
54 position = { 290, 290 }, size = { 80 };
55 anchor = { right = 8, bottom = 8 };
56 NotifyClicked = ButtonCloseDialog;
61 parent = this, isDefault = true, text = $"OK";
62 position = { 200, 290 }, size = { 90 };
63 anchor = { right = 96, bottom = 8 };
65 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
69 bool editorSettingsChanged = false;
70 bool compilerSettingsChanged = false;
71 bool projectOptionsChanged = false;
72 AVLTree<String> cfgsToWrite = null;
73 if(editorTab.modifiedDocument)
75 if(editorTab.useFreeCaret.checked != ideSettings.useFreeCaret ||
76 editorTab.showLineNumbers.checked != ideSettings.showLineNumbers ||
77 editorTab.caretFollowsScrolling.checked != ideSettings.caretFollowsScrolling ||
78 editorTab.fontPicker.fontSize != ideSettings.codeEditorFontSize ||
79 editorTab.fontPicker.faceName.OnCompare(ideSettings.codeEditorFont) ||
80 editorTab.dbColorSchemes.currentRow.string.OnCompare(ideSettings.activeColorScheme)
83 DataRow csRow = editorTab.dbColorSchemes.currentRow;
84 ideSettings.useFreeCaret = editorTab.useFreeCaret.checked;
85 ideSettings.showLineNumbers = editorTab.showLineNumbers.checked;
86 ideSettings.caretFollowsScrolling = editorTab.caretFollowsScrolling.checked;
87 ideSettings.codeEditorFont = editorTab.fontPicker.faceName;
88 ideSettings.codeEditorFontSize = editorTab.fontPicker.fontSize;
89 if(csRow && csRow.string)
91 ideSettings.activeColorScheme = csRow.string;
92 for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, csRow.string))
95 ide.ApplyColorScheme(colorScheme);
100 ide.ApplyFont(ideSettings.codeEditorFont, ideSettings.codeEditorFontSize);
102 editorSettingsChanged = true;
106 if(compilersTab.modifiedDocument)
108 if(strcmp(compilersTab.compilerConfigsDir.path, ideSettings.compilerConfigsDir))
109 ideSettings.compilerConfigsDir = compilersTab.compilerConfigsDir.path;
110 if(compilersTab.compilerConfigs.OnCompare(ideConfig.compilers))
112 cfgsToWrite = compilersTab.compilerConfigs.getWriteRequiredList(ideConfig.compilers);
113 ideConfig.compilers.Free();
114 for(compiler : compilersTab.compilerConfigs)
116 ideConfig.compilers.Add(compiler.Copy());
118 compilerSettingsChanged = true;
122 if(projectOptionsTab.modifiedDocument)
124 if(strcmp(projectOptionsTab.defaultTargetDir.path, ideSettings.projectDefaultTargetDir)
125 || strcmp(projectOptionsTab.defaultIntermediateObjDir.path, ideSettings.projectDefaultIntermediateObjDir))
127 ideSettings.projectDefaultTargetDir = projectOptionsTab.defaultTargetDir.path;
128 ideSettings.projectDefaultIntermediateObjDir = projectOptionsTab.defaultIntermediateObjDir.path;
129 projectOptionsChanged = true;
133 if(workspaceOptionsTab.modifiedDocument)
135 DataRow row = workspaceOptionsTab.defaultCompilerDropBox.currentRow;
136 if(row && row.string)
138 if(!ideSettings.defaultCompiler || strcmp(row.string, ideSettings.defaultCompiler))
140 ideSettings.defaultCompiler = row.string;
145 if(editorSettingsChanged || projectOptionsChanged)
146 settingsContainer.Save();
148 if(compilerSettingsChanged)
150 ideConfig.compilers.write(settingsContainer, cfgsToWrite);
151 OnGlobalSettingChange(GlobalSettingsChange::compilerSettings);
155 if(editorSettingsChanged)
156 OnGlobalSettingChange(GlobalSettingsChange::editorSettings);
157 if(projectOptionsChanged)
158 OnGlobalSettingChange(GlobalSettingsChange::projectOptions);
160 editorTab.modifiedDocument = false;
161 compilersTab.modifiedDocument = false;
162 projectOptionsTab.modifiedDocument = false;
163 workspaceOptionsTab.modifiedDocument = false;
166 Destroy(DialogResult::ok);
175 for(c = 0; c < DirTypes::enumSize; c++)
177 CompilerDir compilerDir;
179 for(systemDir : ideSettings.systemDirs[c])
181 compilerDir = CompilerDir { type = c; compilerConfig = null; path = CopyString(systemDir) };
182 dirs.Add(compilerDir);
185 row = compilersTab.dirs[c].AddRow();
186 row.SetData(null, "");
187 compilersTab.dirs[c].currentRow = compilersTab.dirs[c].firstRow;
188 compilersTab.dirs[c].modifiedDocument = false;
195 CompilerConfig activateCompiler = null;
196 CompilerConfig readonlyCompiler = null;
199 editorTab.useFreeCaret.checked = ideSettings.useFreeCaret;
200 editorTab.showLineNumbers.checked = ideSettings.showLineNumbers;
201 editorTab.caretFollowsScrolling.checked = ideSettings.caretFollowsScrolling;
204 if(workspaceActiveCompiler)
206 for(compiler : ideConfig.compilers)
208 if(!activateCompiler && !strcmp(workspaceActiveCompiler, compiler.name))
209 activateCompiler = compiler;
210 if(!readonlyCompiler && compiler.readOnly)
211 readonlyCompiler = compiler;
212 if(activateCompiler && readonlyCompiler)
216 if(!activateCompiler && readonlyCompiler)
217 activateCompiler = readonlyCompiler;
218 if(!activateCompiler && ideConfig.compilers.count)
219 activateCompiler = ideConfig.compilers[0];
221 for(compiler : ideConfig.compilers)
222 compilersTab.AddCompiler(compiler.Copy(), compiler == activateCompiler);
223 compilersTab.compilerConfigsDir.path = ideSettings.compilerConfigsDir;
226 projectOptionsTab.defaultTargetDir.path = ideSettings.projectDefaultTargetDir;
227 projectOptionsTab.defaultIntermediateObjDir.path = ideSettings.projectDefaultIntermediateObjDir;
234 editorTab.modifiedDocument = false;
235 compilersTab.modifiedDocument = false;
236 compilersTab.dirsTab.modifiedDocument = false;
237 compilersTab.toolchainTab.modifiedDocument = false;
238 compilersTab.optionsTab.modifiedDocument = false;
239 compilersTab.activeCompiler = null;
240 compilersTab.compilerConfigs.Free();
241 compilersTab.compilerSelector.Clear();
242 projectOptionsTab.modifiedDocument = false;
243 workspaceOptionsTab.modifiedDocument = false;
246 virtual void OnGlobalSettingChange(GlobalSettingsChange globalSettingsChange);
251 class EditorTab : GlobalSettingsSubTab
253 background = formColor;
258 dbColorSchemes.Clear();
260 for(s : ideSettings.colorSchemes)
262 DataRow row = dbColorSchemes.AddString(s.name);
263 if(!strcmp(s.name, ideSettings.activeColorScheme))
264 dbColorSchemes.currentRow = row;
269 Label lblColorSchemes { this, anchor = { top = 92, right = 126 }, labeledWindow = dbColorSchemes };
270 DropBox dbColorSchemes
272 this, text = $"Color Scheme: ", anchor = { top = 92, right = 16 }, size = { 100, 22 };
274 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
278 IDEColorScheme colorScheme = null;
279 for(cs : ideSettings.colorSchemes; cs.name && !strcmp(cs.name, row.string))
284 fontPicker.SelectColorScheme(colorScheme);
285 modifiedDocument = true;
293 this, text = $"Move code editor caret freely past end of line", position = { 16, 58 }, isCheckbox = true;
294 NotifyClicked = NotifyClickedModifiedDocument;
297 Button caretFollowsScrolling
299 this, text = $"Keep caret visible (move along) when scrolling", position = { 16, 78 }, isCheckbox = true;
300 NotifyClicked = NotifyClickedModifiedDocument;
303 Button showLineNumbers
305 this, text = $"Show line numbers in code editor", position = { 16, 98 }, isCheckbox = true;
306 NotifyClicked = NotifyClickedModifiedDocument;
309 bool NotifyClickedModifiedDocument(Button button, int x, int y, Modifiers mods)
311 modifiedDocument = true;
315 FontPicker fontPicker
317 this, anchor = { left = 8, right = 8, top = 120, bottom = 8 };
321 modifiedDocument = true;
327 static void DrawStipple(Surface surface, Size clientSize)
331 int x2 = clientSize.w - 1;
332 int y2 = clientSize.h - 1;
333 if((x2 - x1) & 1) x2--;
334 if((y2 - y1) & 1) y2--;
336 surface.LineStipple(0x5555);
337 surface.Rectangle(x1, y1, x2, y2);
338 surface.LineStipple(0);
341 class CompilersTab : GlobalSettingsSubTab
343 background = formColor;
346 Label compilerConfigsDirLabel { this, position = { 8, 12 }, labeledWindow = compilerConfigsDir, tabCycle = false, inactive = true };
347 PathBox compilerConfigsDir
349 this, anchor = { left = 230, top = 8, right = 8 };
350 text = $"Compiler Configurations Directory", browseDialog = settingsFileDialog, NotifyModified = NotifyModifiedDocument;
353 SelectorBar compilerSelector
355 this, text = $"Compiler Configurations:", anchor = { left = 148, top = 38, right = 99 }; size = { 0, 26 };
357 direction = horizontal;
362 bool OnKeyDown(Key key, unichar ch)
366 ((CompilersTab)parent).createCompiler.NotifyClicked(parent, ((CompilersTab)parent).createCompiler, 0, 0, 0);
371 ((CompilersTab)parent).deleteCompiler.NotifyClicked(parent, ((CompilersTab)parent).deleteCompiler, 0, 0, 0);
374 return SelectorBar::OnKeyDown(key, ch);
377 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
379 ((CompilersTab)master).labelCompilers.Update(null);
385 CompilersTab compilers = (CompilersTab)parent;
386 SelectorBar::OnPostCreate();
387 if(compilers.selectedButton)
389 Button sb = compilers.selectedButton;
392 // 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...
393 // compilers.selectedButton = null;
399 TabControl tabControl { this, background = formColor, anchor = { left = 8, top = 68, right = 8, bottom = 8 } };
401 CompilerDirectoriesTab dirsTab { this, tabControl = tabControl };
402 CompilerToolchainTab toolchainTab { this, tabControl = tabControl };
403 CompilerEnvironmentTab environmentTab { this, tabControl = tabControl };
404 CompilerOptionsTab optionsTab { this, tabControl = tabControl };
406 CompilerConfigs compilerConfigs { };
407 CompilerConfig activeCompiler;
411 this, anchor = { left = 8, top = 44 }, labeledWindow = compilerSelector;
413 void OnRedraw(Surface surface)
415 Label::OnRedraw(surface);
416 if(labeledWindow.active)
417 DrawStipple(surface, clientSize);
421 void FindUniqueCompilerName(const char * baseName, CompilerConfig compiler/*, bool startWithNumber*/, char * output)
424 char tmp[MAX_F_STRING];
425 /*if(startWithNumber)
426 sprintf(tmp, "%s%d", baseName, num);
428 strcpy(tmp, baseName);
431 CompilerConfig matchingCompiler = null;
432 for(c : compilerConfigs)
433 { // TOFIX: Error when omitting these brackets, c not found
434 if((!compiler || c != compiler) && c.name && !strcmp(c.name, tmp))
436 matchingCompiler = c;
443 sprintf(tmp, "%s%d", baseName, num);
451 Button createCompiler
453 parent = this, bevelOver = true, inactive = true;
455 anchor = { top = 40, right = 77 };
456 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/docNew.png", alphaBlend = true };
458 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
460 char compilerName[MAX_F_STRING];
461 CompilerConfig newCompiler;
462 FindUniqueCompilerName("New Compiler", null, compilerName);
463 newCompiler = MakeDefaultCompiler(compilerName, false);
464 AddCompiler(newCompiler, true);
465 modifiedDocument = true;
469 Button detectCompiler
471 parent = this, bevelOver = true, inactive = true;
473 anchor = { top = 40, right = 54 };
474 hotKey = altC, bitmap = BitmapResource { fileName = ":actions/attach.png", alphaBlend = true };
476 bool NotifyClicked(Button b, int x, int y, Modifiers mods)
478 CompilersDetectionDialog compilersDetectionDialog
483 if(compilersDetectionDialog.Modal())
485 if(compilersDetectionDialog.selectedCompilerType)
487 char uniqueName[MAX_F_STRING];
488 CompilerConfig newCompiler = compilersDetectionDialog.compilerConfig;
489 FindUniqueCompilerName(newCompiler.name, null, uniqueName);
490 newCompiler.name = uniqueName;
491 AddCompiler(newCompiler, true);
492 modifiedDocument = true;
498 Button duplicateCompiler
500 parent = this, bevelOver = true, inactive = true;
502 anchor = { top = 40, right = 31 };
503 hotKey = altU, bitmap = BitmapResource { fileName = ":actions/editCopy.png", alphaBlend = true };
505 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
507 char copyName[MAX_F_STRING];
508 CompilerConfig copyCompiler = activeCompiler.Copy();
509 FindUniqueCompilerName(copyCompiler.name, null, copyName);
510 copyCompiler.readOnly = false;
511 copyCompiler.name = copyName;
512 AddCompiler(copyCompiler, true);
513 modifiedDocument = true;
517 Button deleteCompiler
519 parent = this, bevelOver = true, inactive = true;
521 anchor = { top = 40, right = 8 };
522 hotKey = altD, bitmap = BitmapResource { fileName = ":actions/delete2.png", alphaBlend = true };
524 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
528 CompilerConfig compilerToDelete = activeCompiler;
529 String title = PrintString($"Delete ", compilerToDelete.name, $" Compiler Configuration");
530 String msg = PrintString($"Are you sure you wish to delete the ", compilerToDelete.name, $" compiler configuration?");
531 if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
533 SelectorButton button = compilerSelector.FindButtonByID((int64)(intptr)compilerToDelete);
535 compilerSelector.RemoveButton(button);
536 //DeleteCompiler(compilerToDelete);
538 Iterator<CompilerConfig> it { compilerConfigs };
539 if(it.Find(compilerToDelete))
540 compilerConfigs.Delete(it.pointer);
542 modifiedDocument = true;
551 void AddCompiler(CompilerConfig compiler, bool load)
553 SelectorButton selectButton;
554 if(compiler.readOnly)
556 SelectorButton button
558 compilerSelector, master = this, text = compiler.name, id = (int64)(intptr)compiler;
559 NotifyClicked = CompilerClicked;
561 selectButton = button;
565 EditableSelectorButton button
567 compilerSelector, master = this, renameable = true, text = compiler.name, id = (int64)(intptr)compiler;
568 NotifyClicked = CompilerClicked;
570 bool OnRename(EditableSelectorButton button, char ** oldName, char ** newName)
572 if(*newName && (*newName)[0])
574 char compilerName[MAX_F_STRING];
575 FindUniqueCompilerName(*newName, activeCompiler, compilerName);
576 if(strcmp(*newName, compilerName))
579 *newName = CopyString(compilerName);
581 activeCompiler.name = compilerName;
582 modifiedDocument = true;
588 selectButton = (SelectorButton)button;
590 compilerConfigs.Add(compiler);
593 LoadCompiler(compiler);
594 selectedButton = selectButton;
595 compilerSelector.Select(selectedButton);
598 SelectorButton selectedButton;
600 void LoadCompiler(CompilerConfig compiler)
602 bool modified = modifiedDocument;
603 activeCompiler = compiler;
607 environmentTab.Load();
610 // Restore original modifiedDocument
611 modifiedDocument = modified;
613 deleteCompiler.disabled = compiler.readOnly;
616 bool CompilerClicked(Button clickedButton, int x, int y, Modifiers mods)
618 if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
620 LoadCompiler((CompilerConfig)(intptr)clickedButton.id);
621 selectedButton = (SelectorButton)clickedButton;
626 bool NotifyModifiedDocument(PathBox pathBox)
628 BasicValidatePathBoxPath(pathBox);
629 modifiedDocument = true;
634 Array<const String> displayDirectoryNames
641 class CompilerDirectoriesTab : CompilersSubTab
643 background = formColor;
644 text = $"Directories";
646 Button dirTypeTglBtn[DirTypes];
647 DirectoriesBox dirs[DirTypes], currentDirs;
649 ~CompilerDirectoriesTab()
652 for(c = 0; c < DirTypes::enumSize; c++)
655 delete dirTypeTglBtn[c];
658 CompilerDirectoriesTab()
662 for(c = 0; c < DirTypes::enumSize; c++)
664 dirs[c] = DirectoriesBox
666 this;//, alwaysHighLight = true
667 anchor = { left = 8, top = 8, right = 8, bottom = 8 };
670 /* MAKE SURE THINGS ARE DONE PROPERLY IN THE NEW DIRECTORIES BOX WHEN BROWSING FOR A DIR?
671 settingsFileDialog.filePath = directory;
672 if(settingsFileDialog.Modal())
673 row.SetData(null, (s = CopyUnixPath(settingsFileDialog.filePath)));
676 bool NotifyModified(DirectoriesBox dirsBox)
678 CompilerConfig compiler = loadedCompiler;
681 DirTypes dirType = (DirTypes)dirsBox.id;
682 if(dirType == includes)
683 compiler.includeDirs = dirsBox.strings;
684 else if(dirType == libraries)
685 compiler.libraryDirs = dirsBox.strings;
686 else if(dirType == executables)
687 compiler.executableDirs = dirsBox.strings;
689 compilersTab.modifiedDocument = true;
693 bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
695 BasicValidatePathBoxPath(pathBox);
702 dirs[c].visible = false;
704 // (width) Should be 324 for text...
705 //field[c] = { dataType = class(char *), editable = true };
706 //dirs[c].AddField(field[c]);
708 dirTypeTglBtn[c] = Button
710 this, inactive = true, text = displayDirectoryNames[c], bevelOver = true, isRadio = true, bitmap = null;
713 minClientSize = { 99, 20 };
714 anchor = { left = v, top = 8 }; // ((int)c) * 100 + 8
716 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
718 DirTypes dirType = (DirTypes)button.id;
719 currentDirs.visible = false;
720 dirs[dirType].visible = true;
721 currentDirs = dirs[dirType];
725 v += dirTypeTglBtn[c].size.w + 1;
726 incref dirTypeTglBtn[c];
729 dirTypeTglBtn[c].hotKey = altI;
730 else if(c == libraries)
731 dirTypeTglBtn[c].hotKey = altL;
732 else if(c == executables)
733 dirTypeTglBtn[c].hotKey = altE;
735 currentDirs = dirs[includes];
736 dirTypeTglBtn[includes].checked = true;
740 bool OnLoadGraphics()
744 for(c = 0; c < DirTypes::enumSize; c++)
746 dirTypeTglBtn[c].anchor.left = v;
747 v += dirTypeTglBtn[c].size.w + 1;
749 return CompilersSubTab::OnLoadGraphics();
754 CompilerConfig compiler = loadedCompiler;
757 dirs[includes].strings = compiler.includeDirs;
758 dirs[libraries].strings = compiler.libraryDirs;
759 dirs[executables].strings = compiler.executableDirs;
760 dirs[includes].list.scroll = { 0, 0 };
761 dirs[libraries].list.scroll = { 0, 0 };
762 dirs[executables].list.scroll = { 0, 0 };
767 class CompilerToolchainTab : CompilersSubTab
769 background = formColor;
775 Label ecpLabel { this, position = { 8, 12 }, labeledWindow = ecp, tabCycle = false, inactive = true };
778 this, anchor = { left = margin, top = 8, right = 8 };
779 text = $"eC Precompiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
781 Label eccLabel { this, position = { 8, 38 }, labeledWindow = ecc, tabCycle = false, inactive = true };
784 this, anchor = { left = margin, top = 34, right = 8 };
785 text = $"eC Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
787 Label ecsLabel { this, position = { 8, 64 }, labeledWindow = ecs, tabCycle = false, inactive = true };
790 this, anchor = { left = margin, top = 60, right = 8 };
791 text = $"eC Symbol Loader", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
793 Label earLabel { this, position = { 8, 90 }, labeledWindow = ear, tabCycle = false, inactive = true };
796 this, anchor = { left = margin, top = 86, right = 8 };
797 text = $"Ecere Archiver", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
799 Label cppLabel { this, position = { 8, 116 }, labeledWindow = cpp, tabCycle = false, inactive = true };
802 this, anchor = { left = margin, top = 112, right = 8 };
803 //text = $"C Preprocessor", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
804 text = $"C Preprocessor";//, NotifyModified = NotifyModifiedDocument;
805 bool NotifyModified(EditBox editBox)
807 CompilerConfig compiler = loadedCompiler;
810 compiler.cppCommand = editBox.contents;
811 modifiedDocument = true;
812 compilersTab.modifiedDocument = true;
817 Label ccLabel { this, position = { 8, 142 }, labeledWindow = cc, tabCycle = false, inactive = true };
820 this, anchor = { left = margin, top = 138, right = 8 };
821 text = $"C Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
823 Label cxxLabel { this, position = { 8, 168 }, labeledWindow = cxx, tabCycle = false, inactive = true };
826 this, anchor = { left = margin, top = 164, right = 8 };
827 text = $"C++ Compiler", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
829 Label arLabel { this, position = { 8, 194 }, labeledWindow = ar, tabCycle = false, inactive = true };
832 this, anchor = { left = margin, top = 190, right = 8 };
833 text = $"AR", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
835 Label ldLabel { this, position = { 8, 220 }, labeledWindow = ld, tabCycle = false, inactive = true };
838 this, anchor = { left = margin, top = 216, right = 8 };
839 text = $"Linker", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
841 Label makeLabel { this, position = { 8, 246 }, labeledWindow = make, tabCycle = false, inactive = true };
844 this, anchor = { left = margin, top = 242, right = 8 };
845 text = $"GNU Make", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
847 Label gnuToolchainPrefixLabel { this, position = { 8, 272 }, labeledWindow = gnuToolchainPrefix, tabCycle = false, inactive = true };
848 PathBox gnuToolchainPrefix
850 this, anchor = { left = margin, top = 268, right = 8 };
851 text = $"GNU Toolchain Prefix", typeExpected = directory, browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
853 Label sysrootLabel { this, position = { 8, 298 }, labeledWindow = sysroot, tabCycle = false, inactive = true };
856 this, anchor = { left = margin, top = 294, right = 8 };
857 text = $"SYSROOT", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
859 Label executableLauncherLabel { this, position = { 8, 324 }, labeledWindow = executableLauncher, tabCycle = false, inactive = true };
860 PathBox executableLauncher
862 this, anchor = { left = margin, top = 320, right = 8 };
863 text = $"Executable Launcher", browseDialog = toolchainFileDialog, NotifyModified = NotifyModifiedDocument;
866 bool NotifyModifiedDocument(PathBox pathBox)
868 CompilerConfig compiler = loadedCompiler;
871 BasicValidatePathBoxPath(pathBox);
873 compiler.ecpCommand = pathBox.slashPath;
874 else if(pathBox == ecc)
875 compiler.eccCommand = pathBox.slashPath;
876 else if(pathBox == ecs)
877 compiler.ecsCommand = pathBox.slashPath;
878 else if(pathBox == ear)
879 compiler.earCommand = pathBox.slashPath;
880 /*else if(pathBox == cpp)
881 compiler.cppCommand = pathBox.slashPath;*/
882 else if(pathBox == cc)
883 compiler.ccCommand = pathBox.slashPath;
884 else if(pathBox == cxx)
885 compiler.cxxCommand = pathBox.slashPath;
886 else if(pathBox == ld)
887 compiler.ldCommand = pathBox.slashPath;
888 else if(pathBox == ar)
889 compiler.arCommand = pathBox.slashPath;
890 else if(pathBox == make)
891 compiler.makeCommand = pathBox.slashPath;
892 else if(pathBox == executableLauncher)
893 compiler.executableLauncher = pathBox.slashPath;
894 else if(pathBox == gnuToolchainPrefix)
895 compiler.gccPrefix = pathBox.slashPath;
896 else if(pathBox == sysroot)
897 compiler.sysroot = pathBox.slashPath;
898 modifiedDocument = true;
899 compilersTab.modifiedDocument = true;
906 CompilerConfig compiler = loadedCompiler;
909 bool disabled = compiler.readOnly;
910 bool isVC = compiler.type.isVC;
911 ecp.path = compiler.ecpCommand;
912 ecc.path = compiler.eccCommand;
913 ecs.path = compiler.ecsCommand;
914 ear.path = compiler.earCommand;
915 //cpp.path = compiler.cppCommand;
916 cpp.contents = compiler.cppCommand;
917 cc.path = compiler.ccCommand;
918 cxx.path = compiler.cxxCommand;
919 ld.path = compiler.ldCommand;
920 ar.path = compiler.arCommand;
921 make.path = compiler.makeCommand;
922 executableLauncher.path = compiler.executableLauncher;
923 gnuToolchainPrefix.path = compiler.gnuToolchainPrefix;
924 sysroot.path = compiler.sysroot;
926 ecpLabel.disabled = ecp.disabled = disabled;
927 eccLabel.disabled = ecc.disabled = disabled;
928 ecsLabel.disabled = ecs.disabled = disabled;
929 earLabel.disabled = ear.disabled = disabled;
930 cppLabel.disabled = cpp.disabled = isVC || disabled;
931 cxxLabel.disabled = cxx.disabled = isVC || disabled;
932 ccLabel.disabled = cc.disabled = isVC || disabled;
933 ldLabel.disabled = ld.disabled = isVC || disabled;
934 arLabel.disabled = ar.disabled = isVC || disabled;
935 makeLabel.disabled = make.disabled = disabled;
936 executableLauncherLabel.disabled = executableLauncher.disabled = disabled;
937 gnuToolchainPrefixLabel.disabled = gnuToolchainPrefix.disabled = disabled;
938 sysrootLabel.disabled = sysroot.disabled = disabled;
940 modifiedDocument = false;
944 class CompilerEnvironmentTab : CompilersSubTab
946 background = formColor;
947 text = $"Environment";
949 Label labelEnvVars { envVars, labeledWindow = envVars, position = { 0, 6 }; };
950 NamedStringsBox envVars
952 this, size = { 290, 22 }, anchor = { left = 8, top = 8, right = 8, bottom = 8 };
953 text = $"Environment Variables", hotKey = altE; //, option = OPTION(postbuildCommands);
955 bool NotifyModified(NamedStringsBox stringsBox)
957 CompilerConfig compiler = loadedCompiler;
960 compiler.environmentVars = stringsBox.namedStrings;
961 modifiedDocument = true;
962 compilersTab.modifiedDocument = true;
968 CompilerEnvironmentTab()
974 CompilerConfig compiler = loadedCompiler;
977 envVars.namedStrings = compiler.environmentVars;
979 modifiedDocument = false;
984 class CompilerOptionsTab : CompilersSubTab
986 background = formColor;
989 Label labelTargetPlatform { this, position = { 8, 12 }, labeledWindow = targetPlatform }; // TOCHECK: nameless instances dissapear when selecting tabs?
990 DropBox targetPlatform
992 this, position = { 110, 8 }, size = { 160 };
993 text = $"Target Platform", hotKey = altT;
994 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
996 CompilerConfig compiler = loadedCompiler;
999 compiler.targetPlatform = (Platform)row.tag;
1000 modifiedDocument = true;
1001 compilersTab.modifiedDocument = true;
1008 Label numJobsLabel { this, position = { 8, 40 }, labeledWindow = numJobsBox };
1011 this, text = $"Number of parallel build jobs", hotKey = altJ, borderStyle = deep;
1012 position = { 244, 36 }, size = { 80, 20 }, type = class(int), data = &numJobs;
1014 bool OnKeyDown(Key key, unichar ch)
1016 if((SmartKey)key == enter)
1018 DataBox::OnKeyDown(key, ch);
1022 return DataBox::OnKeyDown(key, ch);
1025 bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
1035 bool NotifyChanged(DataBox dataBox, bool closingDropDown)
1037 CompilerConfig compiler = loadedCompiler;
1040 compiler.numJobs = numJobs;
1041 modifiedDocument = true;
1042 compilersTab.modifiedDocument = true;
1048 Button ccacheEnabled
1050 this, text = $"Use ccache", hotKey = altC, position = { 8, 68 };
1053 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1055 CompilerConfig compiler = loadedCompiler;
1058 compiler.ccacheEnabled = button.checked;
1059 modifiedDocument = true;
1060 compilersTab.modifiedDocument = true;
1066 Button distccEnabled
1068 this, text = $"Use distcc", position = { 158, 68 };
1071 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1073 CompilerConfig compiler = loadedCompiler;
1076 distccHostsLabel.disabled = distccHosts.disabled = !button.checked;
1077 compiler.distccEnabled = button.checked;
1078 modifiedDocument = true;
1079 compilersTab.modifiedDocument = true;
1085 Label distccHostsLabel { this, position = { 240, 68 }, labeledWindow = distccHosts };
1088 this, text = $"distcc hosts", hotKey = altH;
1089 position = { 320, 64 }, size = { 160, 22 };
1091 bool NotifyModified(EditBox editBox)
1093 CompilerConfig compiler = loadedCompiler;
1096 compiler.distccHosts = editBox.contents;
1097 modifiedDocument = true;
1098 compilersTab.modifiedDocument = true;
1104 Label lblPrepDefs { this, position = { 8, 96 }, labeledWindow = prepDefs };
1105 StringListBox prepDefs
1107 this, text = $"Preprocessor directives", hotKey = altP;
1108 position = { 168, 94 }, size = { 280, 22 }, anchor = { left = 168, top = 94, right = 8 };
1110 bool NotifyModified(EditBox editBox)
1114 CompilerConfig compiler = loadedCompiler;
1115 compiler.prepDirectives = ((StringListBox)editBox).strings;
1116 modifiedDocument = true;
1117 compilersTab.modifiedDocument = true;
1123 Label leCcompilerFlags { this, position = { 8, 126 }, labeledWindow = eCcompilerFlags };
1124 StringListBox eCcompilerFlags
1126 this, text = $"Additional eC compiler flags", hotKey = altG;
1127 position = { 168, 124 }, size = { 280, 22 }, anchor = { left = 168, top = 124, right = 8 };
1129 bool NotifyModified(EditBox editBox)
1133 CompilerConfig compiler = loadedCompiler;
1134 compiler.eCcompilerFlags = ((StringListBox)editBox).strings;
1135 modifiedDocument = true;
1136 compilersTab.modifiedDocument = true;
1142 Label lblCompilerFlags { this, position = { 8, 156 }, labeledWindow = compilerFlags };
1143 StringListBox compilerFlags
1145 this, text = $"Additional C compiler flags", hotKey = altR;
1146 position = { 168, 154 }, size = { 280, 22 }, anchor = { left = 168, top = 154, right = 8 };
1148 bool NotifyModified(EditBox editBox)
1152 CompilerConfig compiler = loadedCompiler;
1153 compiler.compilerFlags = ((StringListBox)editBox).strings;
1154 modifiedDocument = true;
1155 compilersTab.modifiedDocument = true;
1161 Label lblcxxFlags { this, position = { 8, 186 }, labeledWindow = cxxFlags };
1162 StringListBox cxxFlags
1164 this, text = $"Additional C++ compiler flags", hotKey = altD;
1165 position = { 168, 184 }, size = { 280, 22 }, anchor = { left = 168, top = 184, right = 8 };
1167 bool NotifyModified(EditBox editBox)
1171 CompilerConfig compiler = loadedCompiler;
1172 compiler.cxxFlags = ((StringListBox)editBox).strings;
1173 modifiedDocument = true;
1174 compilersTab.modifiedDocument = true;
1180 Label lblLinkerFlags { this, position = { 8, 216 }, labeledWindow = linkerFlags };
1181 StringListBox linkerFlags
1183 this, text = $"Additional linker flags", hotKey = altL;
1184 position = { 168, 214 }, size = { 280, 22 }, anchor = { left = 168, top = 214, right = 8 };
1186 bool NotifyModified(EditBox editBox)
1190 CompilerConfig compiler = loadedCompiler;
1191 compiler.linkerFlags = ((StringListBox)editBox).strings;
1192 modifiedDocument = true;
1193 compilersTab.modifiedDocument = true;
1199 Label lblExcludedLibraries { this, position = { 8, 246 }, labeledWindow = excludedLibraries };
1200 StringListBox excludedLibraries
1202 this, text = $"Libraries to exclude", hotKey = altX;
1203 position = { 168, 244 }, size = { 280, 22 }, anchor = { left = 168, top = 244, right = 8 };
1205 bool NotifyModified(EditBox editBox)
1209 CompilerConfig compiler = loadedCompiler;
1210 compiler.excludeLibs = ((StringListBox)editBox).strings;
1211 modifiedDocument = true;
1212 compilersTab.modifiedDocument = true;
1218 Label objectFileExtLabel { this, position = { 8, 276 }, labeledWindow = objectFileExt };
1219 EditBox objectFileExt
1221 this, text = $"Object file extension";//, hotKey = altH;
1222 position = { 168, 274 }, size = { 80, 22 };
1224 bool NotifyModified(EditBox editBox)
1226 CompilerConfig compiler = loadedCompiler;
1229 compiler.objectFileExt = editBox.contents;
1230 modifiedDocument = true;
1231 compilersTab.modifiedDocument = true;
1237 Label staticLibFileExtLabel { this, position = { 8, 306 }, labeledWindow = staticLibFileExt };
1238 EditBox staticLibFileExt
1240 this, text = $"Target extensions (a, so, exe)";//, hotKey = altH;
1241 position = { 168, 304 }, size = { 80, 22 };
1243 bool NotifyModified(EditBox editBox)
1245 CompilerConfig compiler = loadedCompiler;
1248 compiler.staticLibFileExt = editBox.contents;
1249 modifiedDocument = true;
1250 compilersTab.modifiedDocument = true;
1255 EditBox sharedLibFileExt
1258 position = { 256, 304 }, size = { 80, 22 };
1260 bool NotifyModified(EditBox editBox)
1262 CompilerConfig compiler = loadedCompiler;
1265 compiler.sharedLibFileExt = editBox.contents;
1266 modifiedDocument = true;
1267 compilersTab.modifiedDocument = true;
1272 EditBox executableFileExt
1275 position = { 344, 304 }, size = { 80, 22 };
1277 bool NotifyModified(EditBox editBox)
1279 CompilerConfig compiler = loadedCompiler;
1282 compiler.executableFileExt = editBox.contents;
1283 modifiedDocument = true;
1284 compilersTab.modifiedDocument = true;
1292 this, text = $"Strip target", hotKey = altC, position = { 168, 332 };
1295 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1297 CompilerConfig compiler = loadedCompiler;
1300 compiler.noStripTarget = !button.checked;
1301 modifiedDocument = true;
1302 compilersTab.modifiedDocument = true;
1308 Button resourcesDotEar
1310 this, text = $"Use resources.ear", position = { 308, 332 };
1313 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
1315 CompilerConfig compiler = loadedCompiler;
1318 compiler.resourcesDotEar = button.checked;
1319 modifiedDocument = true;
1320 compilersTab.modifiedDocument = true;
1326 CompilerOptionsTab()
1330 for(p = (Platform)1; p < Platform::enumSize; p++)
1332 row = targetPlatform.AddRow();
1340 CompilerConfig compiler = loadedCompiler;
1343 bool disabled = compiler.readOnly;
1344 targetPlatform.currentRow = targetPlatform.FindRow(compiler.targetPlatform);
1345 numJobs = compiler.numJobs;
1346 numJobsBox.Refresh();
1347 ccacheEnabled.checked = compiler.ccacheEnabled;
1348 distccEnabled.checked = compiler.distccEnabled;
1349 distccHostsLabel.disabled = distccHosts.disabled = !compiler.distccEnabled;
1350 distccHosts.contents = compiler.distccHosts;
1351 prepDefs.strings = compiler.prepDirectives;
1352 excludedLibraries.strings = compiler.excludeLibs;
1353 eCcompilerFlags.strings = compiler.eCcompilerFlags;
1354 compilerFlags.strings = compiler.compilerFlags;
1355 cxxFlags.strings = compiler.cxxFlags;
1356 linkerFlags.strings = compiler.linkerFlags;
1357 objectFileExt.contents = compiler.objectFileExt;
1358 staticLibFileExt.contents = compiler.staticLibFileExt;
1359 sharedLibFileExt.contents = compiler.sharedLibFileExt;
1360 executableFileExt.contents = compiler.executableFileExt;
1361 stripTarget.checked = !compiler.noStripTarget;
1362 resourcesDotEar.checked = compiler.resourcesDotEar;
1364 labelTargetPlatform.disabled = disabled;
1365 targetPlatform.disabled = disabled;
1368 modifiedDocument = false;
1372 class CompilersSubTab : Tab
1374 property CompilersTab compilersTab
1378 CompilersTab tab = (CompilersTab)master;
1379 while(tab && tab._class != class(CompilersTab))
1380 tab = (CompilersTab)tab.master;
1385 property CompilerConfig loadedCompiler
1389 CompilersTab tab = compilersTab;
1390 return tab ? tab.activeCompiler : null;
1395 class ProjectOptionsTab : GlobalSettingsSubTab
1397 background = formColor;
1400 Label defaultTargetDirLabel { this, position = { 8, 34 }, labeledWindow = defaultTargetDir };
1401 PathBox defaultTargetDir
1403 this, size = { 160, 21 }, position = { 8, 52 }, anchor = { left = 8, top = 52, right = 8 };
1404 text = $"Default Target Directory", hotKey = altT;
1406 bool NotifyModified(PathBox pathBox)
1408 BasicValidatePathBoxPath(pathBox);
1409 modifiedDocument = true;
1414 Label defaultIntermediateObjDirLabel { this, position = { 8, 78 }, labeledWindow = defaultIntermediateObjDir };
1415 PathBox defaultIntermediateObjDir
1417 this, size = { 160, 21 }, position = { 8, 96 }, anchor = { left = 8, top = 96, right = 8 };
1418 text = $"Default Intermediate Objects Directory", hotKey = altI;
1420 bool NotifyModified(PathBox pathBox)
1422 BasicValidatePathBoxPath(pathBox);
1423 modifiedDocument = true;
1429 // COMPILER TOFIX: if class GlobalSettingsSubTab is after class WorkspaceOptionsTab the OnPostCreate
1430 // of WorkspaceOptionsTab will *not* be called!
1431 class GlobalSettingsSubTab : Tab
1433 property GlobalSettingsDialog dialog
1437 GlobalSettingsDialog dialog = (GlobalSettingsDialog)master;
1438 while(dialog && dialog._class != class(GlobalSettingsDialog))
1439 dialog = (GlobalSettingsDialog)dialog.master;
1445 class WorkspaceOptionsTab : GlobalSettingsSubTab
1447 background = formColor;
1448 text = $"Workspace";
1450 Label defaultCompilerLabel { this, position = { 8, 14 }, labeledWindow = defaultCompilerDropBox };
1451 DropBox defaultCompilerDropBox
1453 this, position = { 140, 8 }, size = { 220 };
1454 text = $"Default Compiler", hotKey = altA;
1456 bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
1458 modifiedDocument = true;
1465 GlobalSettingsDialog dialog = this.dialog;
1466 if(dialog && dialog.compilersTab.compilerConfigs && ideSettings)
1469 for(compiler : ideConfig.compilers)
1471 row = defaultCompilerDropBox.AddString(compiler.name);
1472 if(ideSettings.defaultCompiler && ideSettings.defaultCompiler[0] &&
1473 !strcmp(compiler.name, ideSettings.defaultCompiler))
1474 defaultCompilerDropBox.currentRow = row;
1476 if(!defaultCompilerDropBox.currentRow && defaultCompilerDropBox)
1477 defaultCompilerDropBox.currentRow = defaultCompilerDropBox.firstRow;
1484 // TOFIX: The selection will be lost upon changing tab...
1485 // Should either warn, or leave it modified and put in place
1486 // checks to save/find the compiler by name
1487 defaultCompilerDropBox.Clear();
1488 modifiedDocument = false;
1492 //static define app = ((GuiApplication)__thisModule);