ide: remove background image, make ToolBox and Properties Sheet invisible by default.
[sdk] / ide / src / ProjectSettings.ec
index e1d745d..8ffb1e5 100644 (file)
@@ -9,16 +9,32 @@ static Platform platform;
 static ProjectNode currentNode;
 static Project project;
 
-static String MakeString(char * s, int len)
+static String MakeString(const char * s, int len, const char * switchToKeep, int lenSwitchToKeep)
 {
    String string = new char[len+1];
-   memcpy(string, s, len);
-   string[len] = 0;
+   if(s[0] == '-' && switchToKeep && switchToKeep[0])
+   {
+      if(strstr(s+1, switchToKeep) == s+1)
+      {
+         memcpy(string, s+lenSwitchToKeep+1, len-lenSwitchToKeep-1);
+         string[len-lenSwitchToKeep-1] = '\0';
+      }
+      else
+         delete string;
+   }
+   else
+   {
+      memcpy(string, s, len);
+      string[len] = '\0';
+   }
    return string;
 }
 
 class StringListBox : EditBox
 {
+   const char * switchToKeep;
+   int lenSwitchToKeep;
+
    textHorzScroll = true;
 
    property Array<String> strings
@@ -31,15 +47,13 @@ class StringListBox : EditBox
             bool first = true;
             for(item : value)
             {
-               bool quoted = strchr(item, ' ') != null;
-               if(!first)
-                  AddS(" ");
-               if(quoted)
-                  AddS("\"");
-               AddS(item);
-               if(quoted)
-                  AddS("\"");
-               first = false;
+               if(item)
+               {
+                  if(!first)
+                     AddS(" ");
+                  AddS(item);
+                  first = false;
+               }
             }
          }
       }
@@ -47,7 +61,8 @@ class StringListBox : EditBox
       {
          Array<String> array { };
          int c, start = 0;
-         char * contents = property::contents;
+         const char * contents = property::contents;
+         char * s;
          char ch;
          bool quoted = false;
 
@@ -56,27 +71,25 @@ class StringListBox : EditBox
             if(ch == ' ' && !quoted)
             {
                if(c - start)
-                  array.Add(MakeString(contents + start, c - start));
+               {
+                  if((s = MakeString(contents + start, c - start, switchToKeep, lenSwitchToKeep)))
+                     array.Add(s);
+               }
                start = c + 1;
             }
             else if(ch == '\"')
             {
                if(quoted)
-               {
-                  if(c - start)
-                     array.Add(MakeString(contents + start, c - start));
                   quoted = false;
-                  start = c + 1;
-               }
                else
-               {
                   quoted = true;
-                  start = c + 1;
-               }
             }
          }
          if(c - start)
-            array.Add(MakeString(contents + start, c - start));
+         {
+            if((s = MakeString(contents + start, c - start, switchToKeep, lenSwitchToKeep)))
+               array.Add(s);
+         }
          return array;
       }
    }
@@ -89,10 +102,9 @@ class ProjectSettings : Window
    text = dialogTitle;
    background = formColor;
    borderStyle = sizable;
-   minClientSize = { 650, 490 };
+   minClientSize = { 650, 520 };
    hasClose = true;
    tabCycle = true;
-   size = { 650, 490 };
 
    property Project project
    {
@@ -121,10 +133,10 @@ class ProjectSettings : Window
       //char * s = PrintString("Project Settings - ", project.topNode.fileName);
       //text = s;
       char * projectName = new char[strlen(project.topNode.name) + 1];
-      char * nodeName = currentNode && currentNode != project.topNode ? currentNode.name : "";
-      char * config = buildTab.selectedConfigName;
-      char * platform = buildTab.selectedPlatformName;
-      char * label = new char[strlen(dialogTitle) + 3 + strlen(project.topNode.name) + 3 + 
+      const char * nodeName = currentNode && currentNode != project.topNode ? currentNode.name : "";
+      const char * config = buildTab.selectedConfigName;
+      const char * platform = buildTab.selectedPlatformName;
+      char * label = new char[strlen(dialogTitle) + 3 + strlen(project.topNode.name) + 3 +
                               strlen(nodeName) + 2 + strlen(config) + 1 + strlen(platform) + 1 + 1];
       strcpy(label, dialogTitle);
       strcat(label, " - ");
@@ -219,7 +231,6 @@ class ProjectSettings : Window
             project.topNode.modified = true;
             project.MarkChanges(buildTab.backupNode);
             ide.projectView.modifiedDocument = true;
-            ide.UpdateToolBarActiveConfigs(false);
             ide.projectView.Update(null);
          }
          if(prjTabControl.curTab == workspaceTab && workspaceTab.modifiedDocument)
@@ -241,11 +252,15 @@ class ProjectSettings : Window
    {
       UpdateDialogTitle();
       prjTabControl.curTab = buildTab;
+
+      ((DirectoriesBox)buildTab.compilerTab.includeDirs.editor).baseBrowsePath = project.topNode.path;
+      ((DirectoriesBox)buildTab.linkerTab.libraryDirs.editor).baseBrowsePath = project.topNode.path;
+
       return true;
    }
 }
 
-#define OPTION(x) ((uint)(&((ProjectOptions)0).x))
+#define OPTION(x) ((uint)(uintptr)(&((ProjectOptions)0).x))
 
 // TOFIX: USING T INSTEAD OF Z HERE CAUSED US SOME CONFLICTS WITH T IN Array TEMPLATES
 
@@ -276,12 +291,12 @@ class OptionBox<class Z> : CommonControl
    }
 
    property bool visible { set { editor.visible = value; } get { return editor.visible; } }
-   property Window parent { set { editor.parent = value; Window::parent = value; master = value; editor.id = (int64)this; } }
+   property Window parent { set { editor.parent = value; Window::parent = value; master = value; editor.id = (int64)(intptr)this; } }
    property Point position { set { editor.position = value; } }
    property Size size { set { editor.size = value; } }
    property Anchor anchor { set { editor.anchor = value; } }
    property Key hotKey { set { editor.hotKey = value; } }
-   property char * text { set { editor.text = value; Window::text = value; } }
+   property const char * text { set { editor.caption = value; Window::caption = value; } }
 
    uint option;
 
@@ -293,7 +308,7 @@ class OptionBox<class Z> : CommonControl
 
       bool NotifySelect(MenuItem selection, Modifiers mods)
       {
-         OptionBox ob = (OptionBox)id;
+         OptionBox ob = (OptionBox)(intptr)id;
          if(eClass_IsDerived(ob._class, class(CheckBoxForEnumOptionBox)))
          {
             Window slave;
@@ -309,10 +324,10 @@ class OptionBox<class Z> : CommonControl
          return true;
       }
    };
-   
+
    bool Window::OptionBox_OnRightButtonDown(int x, int y, Modifiers mods)
    {
-      OptionBox ob = (OptionBox)id;
+      OptionBox ob = (OptionBox)(intptr)id;
       GuiApplication app = ((GuiApplication)__thisModule.application);
       Activate();
       PopupMenu { null, this, menu = ob.clearMenu,
@@ -322,13 +337,13 @@ class OptionBox<class Z> : CommonControl
 
    bool Window::OptionBox_OnKeyDown(Key key, unichar ch)
    {
-      OptionBox ob = (OptionBox)id;
+      OptionBox ob = (OptionBox)(intptr)id;
       if(key == Key { del, ctrl = true } || key == Key { keyPadDelete, ctrl = true })
       {
          ob.Unset();
          return false;
       }
-      return (((bool(*)(Window, Key, unichar)) ob.chainKeyDown)(this, key, ch);
+      return ob.chainKeyDown ? ((bool(*)(Window, Key, unichar)) ob.chainKeyDown)(this, key, ch) : true;
    }
 
    // code: 0 = not set anywhere, 1 = overridden here, 2 = inherited
@@ -346,7 +361,7 @@ class OptionBox<class Z> : CommonControl
                break;
          }
       }
-      
+
       if(!c)
       {
          label = null;
@@ -425,10 +440,10 @@ class OptionBox<class Z> : CommonControl
          buildTab = (BuildTab)buildTab.master;
       if(buildTab) buildTab.modifiedDocument = true;
    }
-   
+
    void Unset()
    {
-      char * platformName = platform ? platform.OnGetString(0,0,0) : null;
+      const char * platformName = platform ? platform.OnGetString(0,0,0) : null;
       MarkBuildTabModified();
 
       if(config)
@@ -533,7 +548,7 @@ class OptionBox<class Z> : CommonControl
    void FigureOutInherited()
    {
       ProjectNode node;
-      char * platformName = platform ? platform.OnGetString(0,0,0) : null;
+      const char * platformName = platform ? platform.OnGetString(0,0,0) : null;
       bool skipped = false;
       for(node = currentNode; node; node = node.parent)
       {
@@ -555,7 +570,7 @@ class OptionBox<class Z> : CommonControl
                      skipped = true;
                      break;
                   }
-               }               
+               }
 
                if(skipped && c.options && OptionSet(c.options))
                {
@@ -586,7 +601,7 @@ class OptionBox<class Z> : CommonControl
 
    void Retrieve()
    {
-      char * platformName = platform ? platform.OnGetString(0,0,0) : null;
+      const char * platformName = platform ? platform.OnGetString(0,0,0) : null;
       MarkBuildTabModified();
       if(config)
       {
@@ -636,7 +651,7 @@ class OptionBox<class Z> : CommonControl
    void Load()
    {
       ProjectNode node;
-      char * platformName = platform ? platform.OnGetString(0,0,0) : null;
+      const char * platformName = platform ? platform.OnGetString(0,0,0) : null;
       bool setAttribs = false;
       for(node = currentNode; node; node = node.parent)
       {
@@ -659,7 +674,7 @@ class OptionBox<class Z> : CommonControl
                      }
                      break;
                   }
-               }               
+               }
 
                nodeConfig = c;
                break;
@@ -716,7 +731,7 @@ class StringOptionBox : OptionBox<String>
    {
       bool NotifyModified(EditBox editBox)
       {
-         ((OptionBox)editBox.id).Retrieve();
+         ((OptionBox)(intptr)editBox.id).Retrieve();
          return true;
       }
 
@@ -765,7 +780,8 @@ class PathOptionBox : OptionBox<String>
 
       bool NotifyModified(PathBox pathBox)
       {
-         ((OptionBox)pathBox.id).Retrieve();
+         FixPathOnPathBoxNotifyModified(pathBox);
+         ((OptionBox)(intptr)pathBox.id).Retrieve();
          return true;
       }
    };
@@ -822,12 +838,11 @@ class MultiStringOptionBox : OptionBox<Array<String>>
 
          if(tempStrings)
          {
-            Array<String> ts = tempStrings;
             while(it.Next())
             {
                String s = it.data;
                bool found = false;
-               for(i : tempStrings; !(caseSensitive ? strcmp : strcmpi)(i, s)) { found = true; break; }
+               for(i : tempStrings; i && s && !(caseSensitive ? strcmp : strcmpi)(i, s)) { found = true; break; }
                if(found && (!configReplaces || platform))   // ADDED || platform here...
                {
                   delete s;
@@ -853,7 +868,7 @@ class MultiStringOptionBox : OptionBox<Array<String>>
    {
       if(mergeValues)
       {
-         Array<String> strings = options ? *((Array<String>*)((byte *)options + option) : null;
+         Array<String> strings = options ? *(Array<String>*)((byte *)options + option) : null;
          if(strings)
          {
             if(!tempStrings)
@@ -861,11 +876,11 @@ class MultiStringOptionBox : OptionBox<Array<String>>
             for(s : strings)
             {
                bool found = false;
-               for(i : tempStrings; !(caseSensitive ? strcmp : strcmpi)(i, s)) { found = true; break; }
+               for(i : tempStrings; i && s && !(caseSensitive ? strcmp : strcmpi)(i, s)) { found = true; break; }
                if(!found) tempStrings.Add(s);
             }
          }
-      }         
+      }
       else
       {
          SetStrings(options ? *(Array<String>*)((byte *)options + option) : null);
@@ -911,7 +926,7 @@ class StringArrayOptionBox : MultiStringOptionBox
    {
       bool NotifyModified(EditBox editBox)
       {
-         ((OptionBox)editBox.id).Retrieve();
+         ((OptionBox)(intptr)editBox.id).Retrieve();
          return true;
       }
    };
@@ -919,21 +934,23 @@ class StringArrayOptionBox : MultiStringOptionBox
    // NO VIRTUAL PROPERTIES YET...
    Array<String> GetStrings() { return ((StringListBox)editor).strings; }
    void SetStrings(Array<String> value) { ((StringListBox)editor).strings = value; }
+
+   property const char * switchToKeep { set { ((StringListBox)editor).switchToKeep = value; ((StringListBox)editor).lenSwitchToKeep = strlen(value); } };
 }
 
 class StringsArrayOptionBox : MultiStringOptionBox
 {
    editor = StringsBox
    {
-      bool OnCreate()
+      /*bool OnCreate()
       {
          project = ::project;
          return true;
-      }
+      }*/
 
       bool NotifyModified(StringsBox stringsBox)
       {
-         ((OptionBox)stringsBox.id).Retrieve();
+         ((OptionBox)(intptr)stringsBox.id).Retrieve();
          return true;
       }
    };
@@ -942,68 +959,112 @@ class StringsArrayOptionBox : MultiStringOptionBox
    void SetStrings(Array<String> value) { ((StringsBox)editor).strings = value; }
 }
 
-class DirsArrayOptionBox : MultiStringOptionBox
+bool eString_IsPathRelatedTo(char * path, char * to)
 {
-   editor = DirectoriesBox
+   if(path[0] && to[0])
    {
-      bool NotifyModified(DirectoriesBox dirsBox)
-      {
-         ((OptionBox)dirsBox.id).Retrieve();
-         return true;
-      }
-
-      bool OnChangedDir(char * * directory)
+      char pathPart[MAX_FILENAME], pathRest[MAX_LOCATION] = "";
+      char toPart[MAX_FILENAME], toRest[MAX_LOCATION] = "";
+      SplitDirectory(path, pathPart, pathRest);
+      SplitDirectory(to, toPart, toRest);
+      if(!fstrcmp(pathPart, toPart))
       {
-         char fixedDirectory[MAX_LOCATION] = "";
-         if(PathCat(fixedDirectory, *directory))
+         if(pathRest[0] && toRest[0])
          {
-            char cwdBackup[MAX_LOCATION];
-            if(project)
-            {
-               GetWorkingDir(cwdBackup, sizeof(cwdBackup));
-               ChangeWorkingDir(project.topNode.path);
-            }
-            FileFixCase(fixedDirectory);
-            if(project)
-               ChangeWorkingDir(cwdBackup);
-            delete *directory;
-            *directory = CopyString(fixedDirectory);
-            return true;
+            SplitDirectory(pathRest, pathPart, pathRest);
+            SplitDirectory(toRest, toPart, toRest);
+            if(!fstrcmp(pathPart, toPart))
+               return true;
          }
-         return false;
       }
+   }
+   return false;
+}
+
+static void FixPathOnPathBoxNotifyModified(PathBox pathBox)
+{
+   int len;
+   char path[MAX_LOCATION];
+   ValidPathBufCopy(path, pathBox.path);
+   len = strlen(path);
+   if(len && !(path[0] == '.' && (len == 1 || (len == 2 && path[1] == DIR_SEP) || (len > 1 && path[1] == '.'))))
+   {
+      char cwdBackup[MAX_LOCATION];
+      if(project)
+      {
+         GetWorkingDir(cwdBackup, sizeof(cwdBackup));
+         ChangeWorkingDir(project.topNode.path);
+      }
+      FileFixCase(path);
+      if(project)
+         ChangeWorkingDir(cwdBackup);
+      if(eString_IsPathRelatedTo(path, project.topNode.path))
+         MakePathRelative(path, project.topNode.path, path);
+      if(!path[0])
+         strcpy(path, ".");
+      len = strlen(path);
+   }
+   if(len>1 && path[len-1] == DIR_SEP)
+      path[--len] = '\0';
+   pathBox.path = path;
+}
+
+class DirsArrayOptionBox : MultiStringOptionBox
+{
+public:
+   property const char * switchToKeep { set { switchToKeep = value; lenSwitchToKeep = strlen(value); } };
+private:
+   const char * switchToKeep;
+   int lenSwitchToKeep;
 
-      bool OnPrepareBrowseDir(char * * directory)
+   editor = DirectoriesBox
+   {
+      browseDialog = { };
+      bool NotifyModified(DirectoriesBox dirsBox)
       {
-         char dir[MAX_LOCATION];
-         if(project)
+         const char * switchToKeep = ((DirsArrayOptionBox)(intptr)dirsBox.id).switchToKeep;
+         if(switchToKeep && switchToKeep[0])
          {
-            GetSystemPathBuffer(dir, project.topNode.path);
-            if(*directory)
-               PathCat(dir, *directory);
+            bool change = false;
+            int lenSwitchToKeep = ((DirsArrayOptionBox)(intptr)dirsBox.id).lenSwitchToKeep;
+            Array<String> dirs { };
+            Array<String> previousDirs = dirsBox.strings;
+            for(d : previousDirs)
+            {
+               int c;
+               char * buffer = new char[strlen(d)+64];
+               char * tokens[1024];
+               uint count;
+               strcpy(buffer, d);
+               count = Tokenize(buffer, sizeof(tokens)/sizeof(tokens[0]), tokens, (BackSlashEscaping)false);
+               for(c=0; c<count; c++)
+               {
+                  if(tokens[c][0] == '-')
+                  {
+                     if(strstr(tokens[c]+1, switchToKeep) == tokens[c]+1)
+                        tokens[c] += lenSwitchToKeep+1;
+                     else
+                        tokens[c][0] = '\0';
+                     change = true;
+                  }
+                  dirs.Add(CopyString(tokens[c]));
+               }
+               delete buffer;
+            }
+            if(change)
+               dirsBox.strings = dirs;
+            dirs.Free();
+            delete dirs;
+            previousDirs.Free();
+            delete previousDirs;
          }
-         else if(*directory)
-            strcpy(dir, *directory);
-         else
-            dir[0] = '\0';
-         
-         delete *directory;
-         *directory = CopyString(dir);
-
-            // GCC 4.4 bug:  -----  path becomes *directory
-            //strcpy(dir, path ? path : "");
+         ((OptionBox)(intptr)dirsBox.id).Retrieve();
          return true;
       }
 
-      bool OnBrowsedDir(char * * directory)
+      bool NotifyPathBoxModified(DirectoriesBox dirsBox, PathBox pathBox)
       {
-         if(project)
-         {
-            char path[MAX_LOCATION];
-            MakePathRelative(*directory, project.topNode.path, path);
-            delete *directory;
-            *directory = CopyString(path);
-         }
+         FixPathOnPathBoxNotifyModified(pathBox);
          return true;
       }
    };
@@ -1020,7 +1081,7 @@ class BoolOptionBox : OptionBox<SetBool>
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
-         ((OptionBox)button.id).Retrieve();
+         ((OptionBox)(intptr)button.id).Retrieve();
          return true;
       }
    };
@@ -1033,7 +1094,7 @@ class BoolOptionBox : OptionBox<SetBool>
    void RetrieveOption(ProjectOptions options, bool isCfgOrPlt)
    {
       bool checked = ((Button)editor).checked;
-      *(SetBool*)((byte *)options + option) = checked ? true : 
+      *(SetBool*)((byte *)options + option) = checked ? true :
          ((currentNode.parent || isCfgOrPlt) ? false : unset);
    }
 
@@ -1051,14 +1112,14 @@ class CheckBoxForEnumOptionBox : OptionBox
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
-         ((OptionBox)button.id).Retrieve();
+         ((OptionBox)(intptr)button.id).Retrieve();
          {
             Window slave;
             for(slave = master.firstSlave; slave; slave = slave.nextSlave)
             {
                if(eClass_IsDerived(slave._class, class(CheckBoxForEnumOptionBox)) &&
-                     slave != (Window)button.id &&
-                     ((OptionBox)slave).option == ((OptionBox)button.id).option)
+                     slave != (Window)(intptr)button.id &&
+                     ((OptionBox)slave).option == ((OptionBox)(intptr)button.id).option)
                   ((OptionBox)slave).Load();
             }
          }
@@ -1089,10 +1150,10 @@ class DropOptionBox : OptionBox
    {
       bool NotifySelect(DropBox dropBox, DataRow row, Modifiers mods)
       {
-         ((OptionBox)dropBox.id).Retrieve();
+         ((OptionBox)(intptr)dropBox.id).Retrieve();
          return true;
       }
-   };   
+   };
 
    void LoadOption(ProjectOptions options)
    {
@@ -1197,7 +1258,7 @@ void DrawStipple(Surface surface, Size clientSize)
 
    surface.LineStipple(0x5555);
    surface.Rectangle(x1, y1, x2, y2);
-   surface.LineStipple(0);            
+   surface.LineStipple(0);
 }
 
 class BuildTab : Tab
@@ -1211,7 +1272,7 @@ class BuildTab : Tab
 
    ProjectNode lastSelectedNode;
 
-   property char * selectedConfigName
+   property const char * selectedConfigName
    {
       get
       {
@@ -1220,7 +1281,7 @@ class BuildTab : Tab
             SelectorButton button = (SelectorButton)configSelector.selectedButton;
             if(button && button.id)
             {
-               ProjectConfig config = (ProjectConfig)button.id;
+               ProjectConfig config = (ProjectConfig)(intptr)button.id;
                return config.name;
             }
          }
@@ -1228,7 +1289,7 @@ class BuildTab : Tab
       }
    }
 
-   property char * selectedPlatformName
+   property const char * selectedPlatformName
    {
       get
       {
@@ -1238,7 +1299,7 @@ class BuildTab : Tab
             if(button && button.id)
             {
                Platform platform = (Platform)button.id;
-               char * platformName = platform ? platform.OnGetString(0,0,0) : null; // all these platformName are leaking, no? 
+               const char * platformName = platform ? platform.OnGetString(0,0,0) : null; // all these platformName are leaking, no?
                return platformName;
             }
          }
@@ -1276,7 +1337,7 @@ class BuildTab : Tab
          }
          return SelectorBar::OnKeyDown(key, ch);
       }
-      
+
       bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
       {
          ((BuildTab)master).labelConfigurations.Update(null);
@@ -1321,11 +1382,11 @@ class BuildTab : Tab
          config.options.debug = true;
          config.options.optimization = none;
          config.options.warnings = all;
-         */         
+         */
 
          button =
          {
-            configSelector, renameable = true, master = this, text = config.name, id = (int64)config;
+            configSelector, renameable = true, master = this, text = config.name, id = (int64)(intptr)config;
             NotifyClicked = ConfigClicked, OnRename = ConfigOnRename;
          };
 
@@ -1356,7 +1417,7 @@ class BuildTab : Tab
             String msg = PrintString($"Are you sure you wish to delete the ", config.name, $" configuration?");
             if(MessageBox { type = okCancel, text = title, contents = msg }.Modal() == ok)
             {
-               Iterator<Window> it { configSelector.controls };
+               //Iterator<Window> it { configSelector.controls };
                ProjectConfig configToDelete = config;
                /*
                while(it.Next())
@@ -1377,7 +1438,7 @@ class BuildTab : Tab
                   }
                }
                */
-               SelectorButton button = configSelector.FindButtonByID((int64)configToDelete);
+               SelectorButton button = configSelector.FindButtonByID((int64)(intptr)configToDelete);
                if(button)
                   configSelector.RemoveButton(button);
 
@@ -1391,7 +1452,7 @@ class BuildTab : Tab
          return true;
       }
    };
-   
+
    Label labelPlatforms
    {
       this, anchor = { left = 8, top = 44 }, labeledWindow = platformSelector;
@@ -1429,7 +1490,7 @@ class BuildTab : Tab
       text = $"(Right click or press Ctrl-Del to revert an option to inherited value)", anchor = { top = 72, right = 16 }
    };
 
-   void FindUniqueConfigName(char * baseName, bool startWithNumber, char * output)
+   void FindUniqueConfigName(const char * baseName, bool startWithNumber, char * output)
    {
       int num = 0;
       char tmp[MAX_F_STRING];
@@ -1529,7 +1590,7 @@ class BuildTab : Tab
       }
 
       project.topNode.RenameConfig(config.name, *newName);
-      
+
       modifiedDocument = true;
       return true;
    }
@@ -1538,7 +1599,7 @@ class BuildTab : Tab
    {
       if(!eClass_IsDerived(clickedButton._class, class(EditableSelectorButton)) || !((EditableSelectorButton)clickedButton).editBox)
       {
-         config = (ProjectConfig)clickedButton.id;
+         config = (ProjectConfig)(intptr)clickedButton.id;
 
          // Load Settings Into Dialog
          compilerTab.LoadSettings();
@@ -1569,7 +1630,7 @@ class BuildTab : Tab
          if(!node) node = project.topNode;
 
          newNodeRes = node.isInResources;
-         
+
          currentNode = node;
          if(!ignoreAsLastSelection)
             lastSelectedNode = node;
@@ -1581,13 +1642,13 @@ class BuildTab : Tab
          }
          else
          {
-            compilerTab.rightPaneHeader.id = (int64)node;
+            compilerTab.rightPaneHeader.id = (int64)(intptr)node;
             compilerTab.rightPaneHeader.Update(null);
             compilerTab.rightPaneHeader.visible = true;
          }
 
          {
-            DataRow row = compilerTab.fileList.FindSubRow((int64)currentNode);
+            DataRow row = compilerTab.fileList.FindSubRow((int64)(intptr)currentNode);
             if(row)
             {
                compilerTab.fileList.currentRow = row;
@@ -1615,12 +1676,10 @@ class BuildTab : Tab
             compilerTab.labelOptimization.visible = !newNodeRes;
             compilerTab.optimization.visible = !newNodeRes;
             compilerTab.fastMath.visible = !newNodeRes;
-            compilerTab.m32.visible = !newNodeRes;
-            compilerTab.m64.visible = !newNodeRes;
             compilerTab.labelIncludeDirs.visible = !newNodeRes;
             compilerTab.includeDirs.visible = !newNodeRes;
          }
-         
+
          if(node == project.topNode)
          {
             compilerTab.objDir.visible = true;
@@ -1657,16 +1716,14 @@ class BuildTab : Tab
 
    void CreateConfigButtons()
    {
-      SelectorButton commonButton;
-
       // Create Config Buttons
-      commonButton = SelectorButton
+      SelectorButton
       {
-         configSelector, master = this, text = $"Common", id = (int64)null; font = { font.faceName, font.size, true };
+         configSelector, master = this, text = $"Common", id = 0; font = { font.faceName, font.size, true };
          checked = true;
          NotifyClicked = ConfigClicked;
       };
-      
+
       config = null;
 
       if(project.topNode.configurations)
@@ -1675,20 +1732,20 @@ class BuildTab : Tab
          {
             EditableSelectorButton button
             {
-               configSelector, master = this, renameable = true, text = c.name, id = (int64)c;
+               configSelector, master = this, renameable = true, text = c.name, id = (int64)(intptr)c;
                NotifyClicked = ConfigClicked, OnRename = ConfigOnRename;
             };
          }
       }
    }
-   
+
    void Init()
    {
       Platform p;
       SelectorButton button;
 
       activeConfigName = project.config ? CopyString(project.config.name) : null;
-      
+
       compilerTab.AddNode(project.topNode, null);
 
       CreateConfigButtons();
@@ -1705,7 +1762,7 @@ class BuildTab : Tab
       {
          SelectorButton button
          {
-            platformSelector, master = this, text = p.OnGetString(0,0,0), id = (int64)p; 
+            platformSelector, master = this, text = p.OnGetString(0,0,0), id = (int64)p;
             NotifyClicked = PlatformClicked;
          };
       }
@@ -1724,12 +1781,12 @@ class BuildTab : Tab
          while(it.Next())
          {
             SelectorButton configButton = (SelectorButton)it.data;
-            ProjectConfig buttonConfig = (ProjectConfig)configButton.id;
+            ProjectConfig buttonConfig = (ProjectConfig)(intptr)configButton.id;
             if(buttonConfig == project.config)
             {
                configButton.Activate();
                configButton.checked = true;
-               ConfigClicked(configButton, 0, 0, (Modifiers)null);
+               ConfigClicked(configButton, 0, 0, 0);
                break;
             }
          }
@@ -1767,6 +1824,14 @@ class BuildTab : Tab
             }
          }
       }
+      if(!project.config)
+      {
+         List<ProjectConfig> configs = project.topNode.configurations;
+         if(configs && configs.count)
+            project.config = configs[0];
+      }
+
+      ide.UpdateToolBarActiveConfigs(false);
    }
 
    void RevertChanges()
@@ -1786,7 +1851,7 @@ class BuildTab : Tab
          while(it.Next())
          {
             Button button = (Button)it.data;
-            ProjectConfig c = (ProjectConfig)button.id;
+            ProjectConfig c = (ProjectConfig)(intptr)button.id;
             if(c && !strcmp(c.name, configName))
             {
                config = c;
@@ -1853,7 +1918,7 @@ class CompilerTab : Tab
       bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
       {
          BuildTab buildTab = (BuildTab)master;
-         ProjectNode node = (ProjectNode)row.tag;
+         ProjectNode node = (ProjectNode)(intptr)row.tag;
          buildTab.SelectNode(node, false);
          return true;
       }
@@ -1889,7 +1954,7 @@ class CompilerTab : Tab
       }
    };
 
-   Window rightPane 
+   Window rightPane
    {
       this, anchor = { left = 196, top = 0, right = 0, bottom = 0 }, background = formColor, tabCycle = true;
    };
@@ -1903,9 +1968,11 @@ class CompilerTab : Tab
       {
          if(id)
          {
+            void (* onDisplay)(void *, void *, void *, int, int, int, void *, uint, uint) = (void *)class(ProjectNode)._vTbl[__ecereVMethodID_class_OnDisplay];
+
             ide.projectView.drawingInProjectSettingsDialogHeader = true;
-            ((void (*)(void *, void *, void *, int, int, int, void *, uint, uint))(void *)class(ProjectNode)._vTbl[__ecereVMethodID_class_OnDisplay])(class(ProjectNode),
-               (void *)id, surface, 8, 2, clientSize.w, ide.projectView, Alignment::left, DataDisplayFlags { selected = true });
+            if(onDisplay)
+               onDisplay(class(ProjectNode), (void *)(intptr)id, surface, 8, 2, clientSize.w, ide.projectView, Alignment::left, DataDisplayFlags { selected = true });
             ide.projectView.drawingInProjectSettingsDialogHeader = false;
          }
       }
@@ -1974,12 +2041,6 @@ class CompilerTab : Tab
       text = $"Optimization", hotKey = altO, option = OPTION(optimization);
    };
 
-   BuildBitDepthOptionBox m32
-   {
-      rightPane, this, position = { 348, 154 };
-      text = $"32bit", hotKey = alt3, option = OPTION(buildBitDepth), enumValue = bits32;
-   };
-
    BoolOptionBox debug
    {
       rightPane, this, position = { 8, 188 };
@@ -1998,17 +2059,19 @@ class CompilerTab : Tab
       text = $"No Line Numbers", hotKey = altN, option = OPTION(noLineNumbers);
    };
 
-   BuildBitDepthOptionBox m64
+   Label labelCompilerOptions { rightPane, this, position = { 8, 208 }, labeledWindow = compilerOptions };
+   StringArrayOptionBox compilerOptions
    {
-      rightPane, this, position = { 348, 188 };
-      text = $"64bit", hotKey = alt6, option = OPTION(buildBitDepth), enumValue = bits64;
+      rightPane, this, size = { 290, 22 }, anchor = { left = 8, top = 224, right = 8 };
+      text = $"Compiler Options", hotKey = altO, option = OPTION(compilerOptions);
+      configReplaces = true;
    };
 
    Label labelIncludeDirs { includeDirs.editor, labeledWindow = includeDirs, position = { 0, 6 }; };
    DirsArrayOptionBox includeDirs
    {
-      rightPane, this, size = { 290, 22 }, anchor = { left = 8, top = 208, right = 8, bottom = 8 };
-      text = $"Additional Include Directories", hotKey = altI, option = OPTION(includeDirs);
+      rightPane, this, size = { 290, 22 }, anchor = { left = 8, top = 250, right = 8, bottom = 8 };
+      text = $"Additional Include Directories", hotKey = altI, option = OPTION(includeDirs), switchToKeep = "I";
    };
 
    CompilerTab()
@@ -2028,13 +2091,13 @@ class CompilerTab : Tab
    {
       DataRow row = addTo ? addTo.AddRow() : fileList.AddRow();
 
-      row.tag = (int64)node;
+      row.tag = (int64)(intptr)node;
 
       row.SetData(null, node);
 
-      if(node.files && node.files.first && node.parent && 
-            !(!node.parent.parent && 
-               (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") || 
+      if(node.files && node.files.first && node.parent &&
+            !(!node.parent.parent &&
+               (!strcmpi(node.name, "notes") || !strcmpi(node.name, "sources") ||
                   !strcmpi(node.name, "src") || !strcmpi(node.name, "tools"))))
          row.collapsed = true;
       else if(node.type == folder)
@@ -2057,7 +2120,7 @@ class CompilerTab : Tab
       if(activeChild && activeChild.active)
       {
          Window control = activeChild;
-         control.Deactivate();         
+         control.Deactivate();
          control.Activate();
       }
    }
@@ -2080,14 +2143,14 @@ class LinkerTab : Tab
       this, position = { 8, 24 }, size = { 200, 22 };
       text = $"Target Name", hotKey = altN, option = OPTION(targetFileName);
    };
-   
+
    Label labelTargetType { this, position = { 216, 8 }, labeledWindow = targetType };
    TargetTypeDB targetType
    {
       this, position = { 216, 24 }, size = { 120, 22 };
       text = $"Target Type", hotKey = altT, option = OPTION(targetType);
    };
-   
+
    Label labelTargetDirectory { this, position = { 344, 8 }, labeledWindow = targetDirectory };
    PathOptionBox targetDirectory
    {
@@ -2099,7 +2162,7 @@ class LinkerTab : Tab
    StringArrayOptionBox libraries
    {
       this, size = { 290, 22 }, anchor = { left = 8, top = 66, right = 8 };
-      text = $"Additional Libraries", hotKey = altL, option = OPTION(libraries);
+      text = $"Additional Libraries", hotKey = altL, option = OPTION(libraries), switchToKeep = "l";
       configReplaces = true;
    };
 
@@ -2127,7 +2190,7 @@ class LinkerTab : Tab
    DirsArrayOptionBox libraryDirs
    {
       this, size = { 290, 22 }, anchor = { left = 8, top = 182, right = 8, bottom = 8 };
-      text = $"Additional Library Directories", hotKey = altY, option = OPTION(libraryDirs);
+      text = $"Additional Library Directories", hotKey = altY, option = OPTION(libraryDirs), switchToKeep = "L";
    };
 
    bool OnCreate()
@@ -2147,7 +2210,7 @@ class LinkerTab : Tab
       if(activeChild && activeChild.active)
       {
          Window control = activeChild;
-         control.Deactivate();         
+         control.Deactivate();
          control.Activate();
       }
    }
@@ -2161,20 +2224,26 @@ class BuilderTab : Tab
    Label labelPrebuildCommands { prebuildCommands.editor, labeledWindow = prebuildCommands, position = { 0, 6 }; };
    StringsArrayOptionBox prebuildCommands
    {
-      this, size = { 290, 100 }, anchor = { left = 8, top = 8, right = 8, bottom = 0.5 };
+      this, size = { 290, 92 }, anchor = { left = 8, top = 8, right = 8, bottom = 200 };
       text = $"Pre-build Commands", hotKey = altE, option = OPTION(prebuildCommands);
    };
 
    Label labelPostbuildCommands { postbuildCommands.editor, labeledWindow = postbuildCommands, position = { 0, 6 }; };
    StringsArrayOptionBox postbuildCommands
    {
-      this, size = { 290 }, anchor = { left = 8, top = 0.5, right = 8, bottom = 8 };
+      this, size = { 290, 92 }, anchor = { left = 8, top = 100, right = 8, bottom = 100 };
       text = $"Post-build Commands", hotKey = altT, option = OPTION(postbuildCommands);
    };
 
+   Label labelInstallCommands { installCommands.editor, labeledWindow = installCommands, position = { 0, 6 }; };
+   StringsArrayOptionBox installCommands
+   {
+      this, size = { 290, 92 }, anchor = { left = 8, top = 200, right = 8, bottom = 8 };
+      text = $"Install Commands", hotKey = altT, option = OPTION(installCommands);
+   };
+
    void LoadSettings()
    {
-      bool disabled = strlen(((BuildTab)master).selectedPlatformName) > 0;
       OptionBox ob;
       for(ob = (OptionBox)firstSlave; ob; ob = (OptionBox)ob.nextSlave)
          if(eClass_IsDerived(ob._class, class(OptionBox)))
@@ -2183,8 +2252,16 @@ class BuilderTab : Tab
       if(activeChild && activeChild.active)
       {
          Window control = activeChild;
-         control.Deactivate();         
+         control.Deactivate();
          control.Activate();
       }
    }
+
+   void OnResize(int width, int height)
+   {
+      int h = (height - 8 * 4) / 3;
+      prebuildCommands.anchor = { left = 8, top = 8, right = 8, bottom = h * 2 + 8 * 3 };
+      postbuildCommands.anchor = { left = 8, top = h + 8 * 2, right = 8, bottom = h + 8 * 2 };
+      installCommands.anchor = { left = 8, top = h * 2 + 8 * 3, right = 8, bottom = 8 };
+   }
 }