extras/gui/controls: Removed obsolete DirectoriesBox/ToolBar
authorJerome St-Louis <jerome@ecere.com>
Sun, 10 Mar 2013 14:29:43 +0000 (10:29 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 10 Mar 2013 14:29:43 +0000 (10:29 -0400)
- The classes are already integrated in Ecere and conflict

extras/gui/controls/DirectoriesBox.ec [deleted file]
extras/gui/controls/ToolBar.ec [deleted file]

diff --git a/extras/gui/controls/DirectoriesBox.ec b/extras/gui/controls/DirectoriesBox.ec
deleted file mode 100644 (file)
index cfc9d6b..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-#ifdef BUILDING_ECERE_COM
-namespace gui::controls;
-import "Window"
-import "Array"
-#else
-#ifdef ECERE_STATIC
-public import static "ecere"
-#else
-public import "ecere"
-#endif
-#endif
-
-import "PathBox"
-
-FileDialog browseFileDialog { type = selectDir, text = "Select directory" };
-
-public class DirectoriesBox : CommonControl
-{
-public:
-
-   bool browsing;
-
-   opacity = 0;
-
-   virtual bool OnChangedDir(char ** directory)
-   {
-      return true;
-   }
-   virtual bool OnPrepareBrowseDir(char ** directory)
-   {
-      return true;
-   }
-   virtual bool OnBrowsedDir(char ** directory)
-   {
-      return true;
-   }
-
-   watch(foreground) { list.foreground = foreground; };
-   watch(background) { list.background = background; };
-
-   property Array<String> strings
-   {
-      set
-      {
-         list.Clear();
-         if(value)
-         {
-            for(s : value)
-            {
-               char temp[MAX_LOCATION];
-               list.AddString(GetSystemPathBuffer(temp, s));
-            }
-         }
-         list.AddString("");
-         list.currentRow = list.firstRow;
-         list.modifiedDocument = false;
-      }
-      get
-      {
-         Array<String> array { };
-         DataRow row;
-         for(row = list.firstRow; row; row = row.next)
-         {
-            String string = row.string;
-            if(string && string[0])
-               array.Add(CopyUnixPath(string));
-         }
-         return array;
-      }
-   }
-
-   virtual bool Window::NotifyModified(DirectoriesBox dirsBox);
-
-   // TOCHECK: Is this not working?! :S
-   bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-   {
-      // Browsing was not being set, fixed by introducing dependency to this class to PathBox
-      if(!active && !browsing)
-      {
-         list.StopEditing(true);
-         if(list.modifiedDocument)
-         {
-            NotifyModified(master, this);
-            list.modifiedDocument = false;
-            modifiedDocument = true;
-         }
-      }
-      return true;
-   }
-
-   Button add
-   {
-      parent = this, bevelOver = true, inactive = true;
-      position = { 265, 0 }, size = { 22, 22 };
-      anchor = { top = 0, right = 77 };
-      hotKey = plus, bitmap = BitmapResource { fileName = "<:ecere>actions/listAdd.png", alphaBlend = true };
-      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
-      {
-         list.StopEditing(true);
-         list.lastRow.Edit(null);
-         list.modifiedDocument = true;
-         return true;
-      }
-   };
-   Button remove
-   {
-      parent = this, bevelOver = true, inactive = true;
-      position = { 290, 0 }, size = { 22, 22 };
-      anchor = { top = 0, right = 54 };
-      hotKey = del, bitmap = BitmapResource { fileName = "<:ecere>actions/listRemove.png", alphaBlend = true };
-      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
-      {
-         list.StopEditing(true);
-         if(list.currentRow != list.lastRow)
-         {
-            list.DeleteRow(null);
-            list.modifiedDocument = true;
-         }
-         return true;
-      }
-   };
-   Button up
-   {
-      parent = this, bevelOver = true, inactive = true;
-      position = { 315, 0 }, size = { 22, 22 };
-      anchor = { top = 0, right = 31 };
-      hotKey = ctrlUp, bitmap = BitmapResource { fileName = "<:ecere>actions/goUp.png", alphaBlend = true };
-      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
-      {
-         if(list.currentRow != list.lastRow)
-         {
-            DataRow current = list.currentRow, row;
-            if(current)
-            {
-               row = current.previous;
-               if(row)
-               {
-                  row = row.previous;
-                  current.Move(row);
-                  list.modifiedDocument = true;
-               }
-            }
-         }
-         return true;
-      }
-   };
-   Button down
-   {
-      parent = this, bevelOver = true, inactive = true;
-      position = { 340, 0 }, size = { 22, 22 };
-      anchor = { top = 0, right = 8 };
-      hotKey = ctrlDown, bitmap = BitmapResource { fileName = "<:ecere>actions/goDown.png", alphaBlend = true };
-      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
-      {
-         DataRow current = list.currentRow, row;
-         if(current)
-         {
-            row = current.next;
-            if(row && row != list.lastRow)
-            {
-               current.Move(row);
-               list.modifiedDocument = true;
-            }
-         }
-         return true;
-      }
-   };
-   ListBox list
-   {
-      this, moveRows = true, hasVertScroll = true, dontHideScroll = true;
-      borderStyle = deep, position = { 0, 22 }, size = { 300, 60 };
-      anchor = { left = 0, top = 22, right = 0, bottom = 0 };
-
-      bool OnRightButtonDown(int x, int y, Modifiers mods)
-      {
-         return parent.OnRightButtonDown(x + position.x + parent.clientStart.x, y + position.y + parent.clientStart.y, mods);
-      }
-
-      bool NotifyChanged(ListBox listBox, DataRow row)
-      {
-         char * directory = listBox.GetData(null);
-         if(directory && directory[0])
-         {
-            char * dir = CopyString(directory);
-            if(OnChangedDir(&dir))
-            {
-               listBox.SetData(null, dir);
-               listBox.modifiedDocument = true;
-               if(listBox.currentRow == listBox.lastRow && listBox.lastRow.string)
-               {
-                  DataRow r = listBox.lastRow;
-                  char * s = r.string;
-                  listBox.currentRow = listBox.AddString("");
-               }
-            }
-            delete dir;
-         }
-         else if(listBox.currentRow != listBox.lastRow)
-         {
-            listBox.DeleteRow(null);
-            listBox.modifiedDocument = true;
-         }
-         return true;
-      }
-
-      bool NotifyEditDone(ListBox listBox, DataRow row)
-      {
-         //browseDir.Destroy(0);
-         return true;
-      }
-
-      /*
-      bool NotifyEdited(ListBox listBox, DataRow row)
-      {
-         browseDir.anchor = Anchor { right = 0, top = listBox.currentIndex * listBox.rowHeight - 2 };
-         browseDir.size = { 30, listBox.rowHeight + 3 };
-
-         browseDir.Create();
-         return true;
-      }*/
-
-      bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
-      {
-         if(key == del)
-         {
-            listBox.StopEditing(true);
-            if(listBox.currentRow != listBox.lastRow)
-               listBox.DeleteRow(null);
-            return false;
-         }
-         return true;
-      }
-
-      bool NotifyMove(ListBox listBox, DataRow row, Modifiers mods)
-      {
-         if(listBox.currentRow == listBox.lastRow)
-            return false;
-         else if(row == listBox.lastRow)
-         {
-            if(listBox.currentRow == row.previous)
-               return false;
-            listBox.currentRow.Move(row.previous);
-            return false;
-         }
-         return true;
-      }
-
-      bool NotifyReclick(ListBox listBox, DataRow row, Modifiers mods)
-      {
-         row.Edit(null);
-         return true;
-      }
-   };
-   DataField dirField { dataType = class(DirPath), editable = true, userData = browseFileDialog };
-   /*
-   Button browseDir
-   {
-      master = this, parent = list, autoCreate = false, inactive = true, hotKey = f2, text = "...";
-     
-      bool NotifyClicked(Button button, int x, int y, Modifiers mods)
-      {
-         DataRow row;
-         char * directory;
-         
-         list.StopEditing(true);
-         
-         row = list.currentRow;
-         directory = CopyString(row.string ? row.string : "");
-         if(OnPrepareBrowseDir(&directory))
-         {
-            browseFileDialog.filePath = directory;
-            StripLastDirectory(directory, directory);
-            browseFileDialog.currentDirectory = directory;
-            //browseFileDialog.master = rootWindow;
-            browsing = true;
-            if(browseFileDialog.Modal())
-            {
-               char * newDir = CopyString(browseFileDialog.filePath);
-               if(OnBrowsedDir(&newDir))
-               {
-                  row.string = newDir;
-                  if(list.lastRow.string && list.lastRow.string[0])
-                  {
-                     list.AddString("");
-                     list.currentRow = list.lastRow;
-                  }
-                  list.modifiedDocument = true;
-               }
-               delete newDir;
-            }
-            browsing = false;
-         }
-         delete directory;
-         return true;
-      }
-   };*/
-
-   DirectoriesBox()
-   {
-      list.AddField(dirField);
-      list.AddString("");
-      list.modifiedDocument = false;
-   }
-}
diff --git a/extras/gui/controls/ToolBar.ec b/extras/gui/controls/ToolBar.ec
deleted file mode 100644 (file)
index 40ea602..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-#ifdef BUILDING_ECERE_COM
-namespace gui::controls;
-import "Window"
-import "Array"
-import "Stacker"
-import "IconBag"
-#else
-#ifdef ECERE_STATIC
-// TOCHECK: these two import directives will crash the form designer when ToolBar.ec is included in ecere.epj
-//public import static "ecere"
-#else
-//public import "ecere"
-#endif
-public import "ecere"
-//public import "IconBag"
-#endif
-
-#if 0
-public class ToolBar/*<class TT>*/ : public Stacker
-{
-   direction = horizontal;
-   background = formColor;
-   opacity = 1.0f;
-   //tabCycle = true;
-   //isActiveClient = true;
-   //moveable = false;
-   gap = 0;
-   //inactive = true;
-
-   anchor = Anchor { left = 0, right = 0 };
-   clientSize = { h = 32 };
-   borderStyle = bevel;
-
-public:
-
-   IconBag/*<TT>*/ iconBag;
-
-   // Notifications
-   virtual bool Window::NotifyClicked(Button button, int x, int y, Modifiers mods);
-
-   /*Label label
-   {
-      this, anchor = { left = 8, top = 12 }, labeledWindow = this;
-
-      void OnRedraw(Surface surface)
-      {
-         Label::OnRedraw(surface);
-         if(labeledWindow.active)
-            DrawStipple(surface, clientSize);
-      }
-   };*/
-
-   void Clear()
-   {
-      Iterator<Window> it { controls };
-      while(it.Next())
-      {
-         ToolButton button = (ToolButton)it.data;
-         button.visible = false;
-         button.Destroy(0);
-         delete button;
-      }
-      OnResize(clientSize.w, clientSize.h);
-   }
-
-   void Select(ToolButton button)
-   {
-      button.checked = true;
-      button.Activate();
-      button.NotifyClicked(button.master, button, 0, 0, 0);
-      MakeControlVisible(button);
-   }
-
-   void AddButton(ToolButton button)
-   {
-      incref button;
-      if(created)
-      {
-         button.Create();
-         // Find a more elegant manner to force updating of positions?
-         OnResize(clientSize.w, clientSize.h);
-      }
-   }
-
-   void RemoveButton(ToolButton button)
-   {
-      Iterator<Window> it { controls };
-      while(it.Next())
-      {
-         if(button == (ToolButton)it.data)
-         {                     
-            if(it.Next() || (it.Prev() && it.Prev()))
-            {
-               ToolButton newSelection = (ToolButton)it.data;
-               newSelection.checked = true;
-               newSelection.NotifyClicked(newSelection.master, newSelection, 0, 0, 0);
-            }
-            break;
-         }
-      }
-      button.visible = false;
-      button.Destroy(0);
-      delete button;
-      OnResize(clientSize.w, clientSize.h);
-   }
-
-   ToolButton FindButtonByID(int id)
-   {
-      ToolButton button = null;
-      
-      Iterator<Window> it { controls };
-      while(it.Next())
-      {
-         ToolButton b = (ToolButton)it.data;
-         if(eClass_IsDerived(b._class, class(ToolButton)) && b.id == id)
-         {                     
-            button = b;
-            break;
-         }
-      }
-      
-      // This alternate technique works outside but give very weird results when used inside. :S
-      /*
-      ToolButton b;
-      for(b = (ToolButton)firstChild; b; b = (ToolButton)b.next)
-      {
-         if(eClass_IsDerived(b._class, class(ToolButton)) && b.id == id)
-         {
-            button = b;
-            break;
-         }
-      }
-      */
-      return button;
-   }
-
-   bool OnCreate()
-   {
-      OnResize(clientSize.w, clientSize.h);
-      return true;
-   }
-
-   property ToolButton selectedButton
-   {
-      get
-      {
-         ToolButton button = null;
-         Iterator<Window> it { controls };
-         while(it.Next())
-         {
-            ToolButton b = (ToolButton)it.data;
-            if(eClass_IsDerived(b._class, class(ToolButton)) && b.checked)
-            {                     
-               button = b;
-               break;
-            }
-         }
-         return button;
-      }
-   }
-
-};
-
-/*public class ToolSpace : Window
-{
-}*/
-
-public class ToolButton/*<class TT>*/ : public Button
-{
-   //text = "Unknonw", bevelOver = true, isRadio = true, bitmap = null, minClientSize = { 44, 22 }; isRemote = true;
-   bevelOver = true;
-   //isRadio = true;
-   bitmap = null;
-   size = Size { 24, 24 };
-   //isRemote = true;
-   borderStyle = none;
-   opacity = 0.0f;
-   bitmapAlignment = left;
-
-public:
-   Window focusHolder;
-
-private:
-   watch(id)
-   {
-      SetBitmap();
-   };
-
-   watch(parent)
-   {
-      if(parent && eClass_IsDerived(parent._class, class(ToolBar)))
-      {
-         ToolBar parent = (ToolBar)this.parent;
-         parent.AddButton(this);
-      }
-   };
-
-   watch(checked)
-   {
-      if(parent && eClass_IsDerived(parent._class, class(ToolBar)) && checked)
-      {
-         ToolButton b;
-         ToolBar tool = (ToolBar)parent;
-         for(b = (ToolButton)parent.firstChild; b; b = (ToolButton)b.next)
-         {
-            if(eClass_IsDerived(b._class, class(ToolButton)) && b != this)
-            {
-               b.font = null;
-               b.checked = false;
-            }
-         }
-         font = { font.faceName, font.size, bold = true }; 
-         tool.OnResize(tool.clientSize.w, tool.clientSize.h);
-         tool.MakeControlVisible(this);
-      }
-   };
-
-   watch(text)
-   {
-      if(parent && eClass_IsDerived(parent._class, class(ToolBar)))
-         parent.OnResize(parent.clientSize.w, parent.clientSize.h);
-   };
-
-   bool OnLeftButtonDown(int x, int y, Modifiers mods)
-   {
-      bool result;
-      Activate();
-      result = Button::OnLeftButtonDown(x, y, mods);
-      if(focusHolder && !checked)
-         focusHolder.Activate();
-      return result;
-   }
-
-   void SetBitmap()
-   {
-      if(id)
-      {
-         if(parent && eClass_IsDerived(parent._class, class(ToolBar)))
-         {
-            ToolBar toolBar = (ToolBar)parent;
-            if(toolBar.iconBag && toolBar.iconBag.icons && toolBar.iconBag.icons.count)
-               bitmap = id <= toolBar.iconBag.icons.count ? toolBar.iconBag.icons[id] : null;
-         }
-      }
-      else
-         bitmap = null;
-   }
-
-   void OnApplyGraphics()
-   {
-      if(!bitmap && id)
-         SetBitmap();
-   }
-
-   bool Window::NotifyClicked(ToolButton button, int x, int y, Modifiers mods)
-   {
-      ToolBar bar = (ToolBar)button.parent;
-      return bar.NotifyClicked(bar.master, button, x,y, mods);
-   }
-}
-#endif
-
-public class ToggleToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   
-   /*bool Window::NotifyClicked(ToggleToolButton button, int x, int y, Modifiers mods)
-   {
-      ToolBar bar = (ToolBar)button.parent;
-      return bar.NotifyClicked(bar.master, button, x,y, mods);
-   }*/
-}
-
-#if 0
-public class GroupToggleToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   GroupToggleToolButton * selected;
-   
-   bool Window::NotifyClicked(GroupToggleToolButton button, int x, int y, Modifiers mods)
-   {
-      bool configured = (bool)button.selected;
-      bool preselection = (configured && (*button.selected));
-      bool reclick = preselection ? (*button.selected == button) : false;
-      ToolBar bar = (ToolBar)button.parent;
-      if(configured && preselection && !reclick)
-      {
-         (*button.selected).checked = false;
-         *button.selected = button;
-      }
-      return bar.NotifyClicked(bar.master, button, x,y, mods);
-   }
-}
-
-public class OptionToolButton : ToolButton
-{
-   toggle = true;
-   size = Size { 24, 24 };
-   OptionToolButton * selected;
-
-   bool Window::NotifyClicked(OptionToolButton button, int x, int y, Modifiers mods)
-   {
-      bool configured = (bool)button.selected;
-      bool preselection = (configured && (*button.selected));
-      bool reclick = preselection ? (*button.selected == button) : false;
-      if(configured && !preselection)
-         *button.selected = button;
-      else if(configured && !reclick)
-      {
-         (*button.selected).checked = false;
-         *button.selected = button;
-      }
-      button.checked = true;
-      if(!reclick)
-      {
-         ToolBar bar = (ToolBar)button.parent;
-         return bar.NotifyClicked(bar.master, button, x,y, mods);
-      }
-      return true;
-   }
-}
-
-class EditableToolButton : ToolButton
-{
-   EditBox editBox;
-   bool renameable;
-
-   virtual bool Window::OnRename(EditableToolButton button, char ** oldName, char ** newName);
-
-   bool OnKeyDown(Key key, unichar ch)
-   {
-      if(key == f2 && !editBox)
-      {
-         if(!checked)
-         {
-            checked = true;
-            NotifyClicked(master, this, 0, 0, 0);
-         }
-         OnLeftButtonDown(0, 0, 0);
-         return false;
-      }
-      return ToolButton::OnKeyDown(key, ch);
-   }
-
-   bool OnLeftButtonDown(int x, int y, Modifiers mods)
-   {
-      Activate();
-      if(renameable && checked && !editBox)
-      {
-         editBox =
-         {
-            this, anchor = { 2, 2, 2, 2 }, /*opacity = 0, */borderStyle = 0, textHorzScroll = true;
-
-            bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
-            {
-               EditBox::OnActivate(active, previous, goOnWithActivation, direct);
-               if(!active && !destroyed)
-               {
-                  ((EditableToolButton)master).editBox = null;
-                  Destroy(0);
-                  //OnLeavingEdit();
-                  if(master && ((EditableToolButton)master).focusHolder)
-                     ((EditableToolButton)master).focusHolder.Activate();
-                  delete this;
-               }               
-               return true;
-            }
-            
-            bool NotifyModified(EditBox editBox)
-            {
-               char * oldName = CopyString(text);
-               char * newName = CopyString(editBox.contents);
-               
-               if(OnRename(master, this, &oldName, &newName))
-               {
-                  ToolBar tool = (ToolBar)parent;
-                  text = newName;
-                  if(tool)
-                  {
-                     tool.OnResize(tool.clientSize.w, tool.clientSize.h);
-                     tool.MakeControlVisible(this);
-                  }
-               }
-               
-               delete oldName;
-               delete newName;
-               
-               //OnLeavingEdit();? //master.someControl.Activate();
-               if(focusHolder)
-                  focusHolder.Activate();
-
-               return true;
-            }
-
-            bool OnKeyDown(Key key, unichar ch)
-            {
-               if((SmartKey)key == enter || key == escape)
-               {
-                  if(key == escape)
-                  {
-                     EditableToolButton button = (EditableToolButton)master;
-                     if(button.editBox)
-                        button.editBox.SetModified(false);
-                  }
-                  Deactivate();
-                  return false;
-               }
-               else
-                  return EditBox::OnKeyDown(key, ch);
-            }
-         };
-         incref editBox;
-         editBox.contents = text;         
-         editBox.Create();
-         editBox.SetModified(false);
-         editBox.SelectAll();
-      }
-      return Button::OnLeftButtonDown(x, y, mods);
-   }
-}
-#endif