Fixed major issues
[ede] / libede / src / FileSystemBox.ec
index 82a7abd..8842cf1 100644 (file)
@@ -3,22 +3,22 @@ import "FileSystemCache"
 
 #ifdef __WIN32__
 static char * rootName = "Entire Computer";
-static char * msNetwork = "Microsoft Windows Network";
+static const char * msNetwork = "Microsoft Windows Network";
 #else
-static char * rootName = "File System";
+static const char * rootName = "File System";
 #endif
 
 private:
 define guiApp = (GuiApplication)((__thisModule).application);
 define selectionColor = guiApp.currentSkin.selectionColor; //Color { 10, 36, 106 };
 
-void MessageBoxTodo(char * message)
+void MessageBoxTodo(const char * message)
 {
    PrintLn("MessageBoxTodo(char * message) -- ", message);
    MessageBox { type = ok, text = "MessageBoxTodo(char * message)", contents = message }.Modal();
 }
 
-static char * fileIconNames[] =
+static const char * fileIconNames[] =
 {
    "<:ecere>mimeTypes/file.png",         /* none */
 
@@ -58,7 +58,7 @@ static char * fileIconNames[] =
 };
 
 define countOfCompIconNames = 6;
-static char * compIconNames[] =
+static const char * compIconNames[] =
 {
 /*
    "<:ede>a.png",
@@ -213,7 +213,7 @@ public:
    virtual bool Window::NotifyNodeMenu(FileSystemBox box, Menu menu, FileSystemBoxSelection selection);
    virtual bool Window::NotifyIteratorInit(FileSystemBox box, FileSystemIterator fileSystemIterator);
 
-   property char * path
+   property const char * path
    {
       set
       {
@@ -233,7 +233,11 @@ public:
    {
       set
       {
-         delete comparedPaths;
+         if(comparedPaths)
+         {
+            comparedPaths.Free();
+            delete comparedPaths;
+         }
          if(value && value.count)
             comparedPaths = value;
          if(locationBox)
@@ -277,6 +281,11 @@ public:
          split.leftPane = value ? list : null;
          split.visible = value;
          show.visible = value;
+         if(!value)
+         {
+            list.parent = this;
+            list.anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
+         }
       }
       get { return bits.preview; }
    };
@@ -334,7 +343,7 @@ public:
       delete map;
    }
 
-   FileSystemNode SelectLocation(char * location)
+   FileSystemNode SelectLocation(const char * location)
    {
       int c;
       char * temp;
@@ -355,7 +364,7 @@ public:
 
       for(c = steps.count - 1; c >= 0; c--)
       {
-         char * t = steps[c];
+         //char * t = steps[c];
          node = Find(steps[c], node);
          if(!node)
             break;
@@ -418,6 +427,7 @@ public:
    bool MenuOpen(MenuItem selection, Modifiers mods)
    {
       OpenNode();
+      return true;
    }
 
    bool MenuReplaceListItemByContainingDir(MenuItem selection, Modifiers mods)
@@ -482,6 +492,11 @@ private:
 
    ~FileSystemBox()
    {
+      if(comparedPaths)
+      {
+         comparedPaths.Free();
+         delete comparedPaths;
+      }
       delete extensions;
       delete path;
    }
@@ -699,7 +714,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -708,7 +723,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -717,7 +732,7 @@ private:
       {
          if(row)
          {
-            FileSystemNode node = (FileSystemNode)row.tag;
+            //FileSystemNode node = (FileSystemNode)row.tag;
          }
          return true;
       }
@@ -731,20 +746,20 @@ private:
 
       bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
       {
-         bool result;
+         //bool result = false;
          if((SmartKey)key == enter)
-            result = OpenNode();
+            /*result = */OpenNode();
          #if 0
          else if((SmartKey)key == f2)
-            result = RenameNode();
+            /*result = */RenameNode();
          #endif
          else if((SmartKey)key == f2)
          {
             FileSystemNode node = selection.node;
             node.row.Edit(nameField);
          }
-         else
-            result = true;
+         //else
+            //result = true;
          return true;
       }
    };
@@ -777,12 +792,12 @@ private:
             int wWnd = fsb.show.clientSize.w;
             int hWnd = fsb.show.clientSize.h;
 
-            int wList = 0;//fsb.list.size.w + fsb.split.size.w;
+            //int wList = 0;//fsb.list.size.w + fsb.split.size.w;
 
-            float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
+            //float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
 
-            int wDraw = (int)(wBmp * scale);
-            int hDraw = (int)(hBmp * scale);
+            //int wDraw = (int)(wBmp * scale);
+            //int hDraw = (int)(hBmp * scale);
 
       #ifndef __linux__
             surface.Filter(fsb.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
@@ -797,7 +812,7 @@ private:
             surface.Area(0, 0, fsb.clientSize.w - 1, fsb.clientSize.h - 1);
          }
       }
-   }
+   };
 
    bool OpenNode()
    {
@@ -967,9 +982,9 @@ private:
    {
       bool isRoot = !strcmp(path, "/");
       char name[MAX_LOCATION];
-      FileSystemNode parent;
-      FileSystemNode node;
-      FileListing listing { path, extensions = extensions };
+      //FileSystemNode parent;
+      //FileSystemNode node;
+      //FileListing listing { path, extensions = extensions };
 
       if(!isRoot)
          GetLastDirectory(path, name);
@@ -1105,7 +1120,7 @@ private:
       }
    }
 
-   bool ListIterator_OnObject(char * name, char * path, FileStats stats, bool isRootObject)
+   bool ListIterator_OnObject(const char * name, const char * path, FileStats stats, bool isRootObject)
    {
       ProcessListItem(name, path, stats, false);
       return false;
@@ -1113,7 +1128,7 @@ private:
 
    //void ListIterator_OnLeavingDirectory(char * path) { }
 
-   void ProcessListItem(char * name, char * path, FileStats stats, bool isListItem)
+   void ProcessListItem(const char * name, const char * path, FileStats stats, bool isListItem)
    {
       if((!bits.foldersOnly && !bits.filesOnly) || (bits.foldersOnly && stats.attribs.isDirectory) || (bits.filesOnly && stats.attribs.isFile))
       {
@@ -1192,17 +1207,21 @@ private:
          FileListing listing { path, extensions = extensions };
          while(listing.Find())
          {
-            char * test;
+            //char * test;
             FileSystemNode child = null;
             if((!bits.foldersOnly && !bits.filesOnly) ||
                (bits.foldersOnly && listing.stats.attribs.isDirectory) ||
                (bits.filesOnly && listing.stats.attribs.isFile))
                child = MakeAndAddToTreeFileSystemNodeFromFileListing(listing, parent);
             if(child)
+            {
                added = true;
-            test = child.name;
-            if(!test)
-               PrintLn("error");
+               /*
+               test = child.name;
+               if(!test)
+                  PrintLn("error");
+               */
+            }
          }
          if(!added)
             added = true;
@@ -1212,7 +1231,7 @@ private:
 
    void LoadComparedList()
    {
-      int c, cmp/*, smallest*/, icon;//, equalCount;
+      int c/*, cmp*/ /*, smallest*/, icon;//, equalCount;
       int count = comparedPaths ? comparedPaths.count : 0;
       //bool allDone = false;
       bool not;
@@ -1456,7 +1475,7 @@ private:
    void AddNode(FileSystemNode node)
    {
       DataRow row = list.AddRow();
-      row.tag = (int)node;
+      row.tag = (intptr)node;
       node.row = row;
       incref node;
       row.SetData(nameField, node);
@@ -1488,7 +1507,7 @@ private:
          (bits.filesOnly && listing.stats.attribs.isFile)))*/
       {
          bool textFileLinesStyle = false;
-         char * test = listing.name;
+         const char * test = listing.name;
          if(!test)
             PrintLn("error");
          result = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, false, displaySystem);
@@ -1525,7 +1544,7 @@ private:
          node.indent = addTo.indent + 1;
          addTo.children.Add(node);
       }
-      row.tag = (int)node;
+      row.tag = (intptr)node;
       node.row = row;
       row.SetData(null, node);
       if(bits.pathColumn)
@@ -2677,7 +2696,7 @@ private:
    }
 
 public:
-   /*//LinkElement<FileSystemNode> link;
+   /* LinkElement<FileSystemNode> link;
    FileSystemNode parent;
 
    FileSystemNodeType type;
@@ -2690,12 +2709,12 @@ public:
 
    property bool isListItem { set { bits.isListItem = value; } get { return bits.isListItem; } };
 
-   property char * path
+   property const char * path
    {
       set { delete path; if(value && value[0]) path = CopyString(value); }
       get { return path; } isset { return path && path[0]; }
    }
-   property char * name
+   property const char * name
    {
       set { delete name; if(value && value[0]) name = CopyString(value); }
       get { return name; } isset { return name && name[0]; }
@@ -2705,12 +2724,12 @@ public:
       set { delete extension; if(value && value[0]) extension = CopyString(value); }
       get { return extension; } isset { return extension && extension[0]; }
    }
-   property char * label
+   property const char * label
    {
       set { delete label; if(value && value[0]) label = CopyString(value); }
       get { return label; } isset { return label && label[0]; }
    }
-   property char * info
+   property const char * info
    {
       set { delete info; if(value && value[0]) info = CopyString(value); }
       get { return info; } isset { return info && info[0]; }
@@ -2819,7 +2838,7 @@ public:
    void OnDisplay(Surface surface, int x, int y, int width, FileSystemBox fsb, Alignment alignment, DataDisplayFlags displayFlags)
    {
       //int indentSize = (displayFlags.dropBox) ? 0 : 10;
-      int indent = 16;
+      //int indent = 16;
       int xStart;
       int len;
       int w, h;
@@ -3097,7 +3116,7 @@ public:
    //}
 #endif
 
-   bool OnGetDataFromString(char * string)
+   bool OnGetDataFromString(const char * string)
    {
 #if 0
       if(string && *string)
@@ -3111,7 +3130,7 @@ public:
       return false;
    }
 
-   char * OnGetString(char * tempString, FileSystemToolWindow fileSysToolWnd, bool * needClass)
+   const char * OnGetString(char * tempString, void * unused /*FileSystemToolWindow fileSysToolWnd*/, bool * needClass)
    {
       return name ? name : "";
    }
@@ -3154,7 +3173,7 @@ FileSystemNode MakeFileSystemNode(
    const bool pathAddName,
    const bool previewPicture,
    const bool isListItem,
-   const DisplaySystem displaySystem)
+   /*const */DisplaySystem displaySystem)
 {
    int len = strlen(name);
    char info[MAX_LOCATION];
@@ -3215,8 +3234,8 @@ FileSystemNode MakeFileSystemNode(
 
    if(pathAddName)
    {
-      bool isFile = stats.attribs.isFile;
-      bool isFolder = stats.attribs.isDirectory;
+      //bool isFile = stats.attribs.isFile;
+      //bool isFolder = stats.attribs.isDirectory;
       char full[MAX_LOCATION];
       strcpy(full, path);
       PathCat(full, name);
@@ -3249,8 +3268,8 @@ FileSystemNode MakeComparedFileSystemNode(
    const bool previewPicture,
    const int cmpIcon,
    const bool cmpNot,
-   const Array<int> exists,
-   const DisplaySystem displaySystem)
+   /*const */Array<int> exists,
+   /*const */DisplaySystem displaySystem)
 {
    FileSystemNode node = MakeFileSystemNode(stats, name, path, pathAddName, previewPicture, false, displaySystem);
    if(node)