public import "ecere"
-import "SplitWindow"
-import "ArrayFactoredGrowth"
-
-//import "ArrayFactoredGrowth"
-//import "ArrayBinarySorted"
#ifdef __WIN32__
static char * rootName = "Entire Computer";
}
}
+#if 0
class ExplorerView : ExplorerControl
{
borderStyle = none;
hasHorzScroll = false;
hasVertScroll = false;
- virtual void Load(ExplorerFileBranch parent);
+ virtual void Load(FileSystemNode parent);
virtual void Refresh();
virtual void LaunchNotifyItemSelect(Window master, ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
{
}
}
+#endif
+#if 0
class ExplorerViewList : ExplorerView
{
- ExplorerFileBranch location;
+ FileSystemNode location;
public:
Load(location);
}
- void Load(ExplorerFileBranch location)
+ void Load(FileSystemNode location)
{
char path[MAX_LOCATION];
this.location = location;
}
}
}
+#endif
+#if 0
class ExplorerViewDetails : ExplorerView
{
list.hasHeader = true;
list.resizable = true;
list.sortable = true;
- ExplorerFileBranch location;
+ FileSystemNode location;
public:
Load(location);
}
- void Load(ExplorerFileBranch location)
+ void Load(FileSystemNode location)
{
char path[MAX_LOCATION];
this.location = location;
}
}
}
+#endif
+#if 0
class ExplorerViewIcons : ExplorerView
{
- ExplorerFileBranch location;
+ FileSystemNode location;
public:
Load(location);
}
- void Load(ExplorerFileBranch location)
+ void Load(FileSystemNode location)
{
char path[MAX_LOCATION];
this.location = location;
}
}
}
+#endif
+#if 0
class ExplorerViewCards : ExplorerView
{
- ExplorerFileBranch location;
+ FileSystemNode location;
public:
Load(location);
}
- void Load(ExplorerFileBranch location)
+ void Load(FileSystemNode location)
{
char path[MAX_LOCATION];
this.location = location;
}
}
}
+#endif
+#if 0
public class BitmapArray : RedjArray
{
type = class(Bitmap);
size = 0;
}
}
+#endif
+#if 0
class ExplorerViewShowcase : ExplorerView
{
list.anchor = Anchor { left = 0, top = 0, bottom = 0 };
list.size = Size { w = 200 };
- ExplorerFileBranch location;
+ FileSystemNode location;
public:
Load(location);
}
- void Load(ExplorerFileBranch location)
+ void Load(FileSystemNode location)
{
char path[MAX_LOCATION];
this.location = location;
}
}
}
+#endif
+#if 0
class ExplorerTree : ExplorerControl
{
hasHorzScroll = false;
public:
- DataField nameField { dataType = "ExplorerFileBranch", width = 240, userData = this };
+ DataField nameField { dataType = "FileSystemNode", width = 240, userData = this };
- ExplorerFileBranch root;
- ExplorerFileBranch selection;
+ FileSystemNode root;
+ FileSystemNode selection;
- virtual bool Window::NotifyBranchSelect(ExplorerTree tree, ExplorerFileBranch branch);
+ virtual bool Window::NotifyNodeSelect(ExplorerTree tree, FileSystemNode node);
- property ExplorerFileBranch branch
+ property FileSystemNode node
{
get
{
return null;
if(!tree.currentRow.tag)
return null;
- return (ExplorerFileBranch)tree.currentRow.tag;
+ return (FileSystemNode)tree.currentRow.tag;
}
}
- void Select(ExplorerFileBranch branch)
+ void Select(FileSystemNode node)
{
- if(branch.row)
+ if(node.row)
{
- branch.EnsureVisible(false);
- tree.SelectRow(branch.row);
+ node.EnsureVisible(false);
+ tree.SelectRow(node.row);
}
}
- ExplorerFileBranch Find(const char * name, ExplorerFileBranch parent)
+ FileSystemNode Find(const char * name, FileSystemNode parent)
{
- ExplorerFileBranch branch;
- ExplorerFileBranch start = parent ? parent : root;
+ FileSystemNode node;
+ FileSystemNode start = parent ? parent : root;
if(!start.loaded || !start.childrenLoaded)
- BranchLoad(start, tree);
- for(branch = start.children.first; branch; branch = branch.next)
- if(branch.name && !strcmpi(branch.name, name))
- return branch;
+ NodeLoad(start, tree);
+ for(node = start.children.first; node; node = node.next)
+ if(node.name && !strcmpi(node.name, name))
+ return node;
return null;
}
hasHorzScroll = true;
hasVertScroll = true;
fullRowSelect = false;
- treeBranches = true;
+ treeNodees = true;
collapseControl = true;
rootCollapseButton = true;
{
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
- ExplorerFileBranch child;
+ FileSystemNode node = (FileSystemNode)row.tag;
+ FileSystemNode child;
if(collapsed)
{
/*
- for(child = branch.children.last; child; child = branch.children.last)
+ for(child = node.children.last; child; child = node.children.last)
{
listBox.DeleteRow(child.row);
child.Free();
delete child;
}
- branch.childrenLoaded = false;
+ node.childrenLoaded = false;
*/
}
else
{
- if(!branch.loaded || !branch.childrenLoaded)
- BranchLoad(branch, tree);
- for(child = branch.children.first; child && child.next; child = child.next);
+ if(!node.loaded || !node.childrenLoaded)
+ NodeLoad(node, tree);
+ for(child = node.children.first; child && child.next; child = child.next);
if(child)
child.EnsureVisible(false);
}
DataRow row = listBox.currentRow;
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
- if(branch)
+ FileSystemNode node = (FileSystemNode)row.tag;
+ if(node)
{
PopupMenu popup;
Menu menu { };
{
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
- NotifyBranchSelect(listBox.parent.master, this, branch);
- selection = branch;
+ FileSystemNode node = (FileSystemNode)row.tag;
+ NotifyNodeSelect(listBox.parent.master, this, node);
+ selection = node;
}
return true;
}
{
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+ FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
{
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+ FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
{
if(row)
{
- ExplorerFileBranch branch = (ExplorerFileBranch)row.tag;
+ FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
void Load()
{
- ExplorerFileBranch parent;
- ExplorerFileBranch branch;
+ FileSystemNode parent;
+ FileSystemNode node;
FileListing listing { "/" };
tree.Clear();
- root = ExplorerFileBranch { type = computer, loaded = true, childrenLoaded = true };
+ root = FileSystemNode { type = computer, loaded = true, childrenLoaded = true };
#ifdef __WIN32__
root.name = rootName;
#else
root.name = "/";
#endif
- AddBranch(root, true, false, null, tree);
+ AddNode(root, true, false, null, tree);
// How can this make sense for linux?
#ifdef __WIN32__
info[0] = 0;
}
- parent = MakeFileBranch(listing.stats, name);
+ parent = MakeFileNode(listing.stats, name);
if(info[0])
parent.info = CopyString(info);
parent.loaded = true;
- AddBranch(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
+ AddNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
if(!listing.stats.attribs.isDirectory)
parent.childrenLoaded = true;
}
- branch = ExplorerFileBranch { name = msNetwork, type = network };
- AddBranch(branch, false, true, null, tree);
- branch.row.collapsed = true;
+ node = FileSystemNode { name = msNetwork, type = network };
+ AddNode(node, false, true, null, tree);
+ node.row.collapsed = true;
tree.Sort(nameField, 1);
tree.SelectRow(root.row);
#endif
*/
}
+#endif
-/*public class FileTreeBranchBSArray : ArrayBinarySorted
+#if 0
+public class FileTreeNodeBSArray : ArrayBinarySorted
{
- type = class(ExplorerFileBranch);
+ type = class(FileSystemNode);
public:
- ExplorerFileBranch * const _;
- BSloc Add(ExplorerFileBranch item)
+ FileSystemNode * const _;
+ BSloc Add(FileSystemNode item)
{
BSloc result = Find(item);
if(!result.valid)
}
return result;
}
- BSloc Remove(ExplorerFileBranch item)
+ BSloc Remove(FileSystemNode item)
{
}
-}*/
+}
+#endif
-/*public class FileTreeBranchArray : RedjArray
+#if 0
+public class FileTreeNodeArray : RedjArray
{
- type = class(ExplorerFileBranch);
+ type = class(FileSystemNode);
public:
- ExplorerFileBranch * const _;
- ExplorerFileBranch * Add(ExplorerFileBranch item)
+ FileSystemNode * const _;
+ FileSystemNode * Add(FileSystemNode item)
{
uint pos = _count;
Append(1);
_[pos] = item;
return &_[pos];
}
- ExplorerFileBranch * AddBefore(uint position, ExplorerFileBranch item)
+ FileSystemNode * AddBefore(uint position, FileSystemNode item)
{
Insert(position, 1);
_[position] = item;
return &_[position];
}
-}*/
+}
+#endif
+#if 0
public class ExplorerFileItem : struct
{
char * path;
return item;
}
+#endif
-public class ExplorerFileBranch : struct
+public class FileSystemNode : struct
{
- ExplorerFileBranch prev, next;
+ FileSystemNode prev, next;
bool loaded, childrenLoaded;
int indent;
DataRow row;
OldList children;
ExplorerFileType type;
- ExplorerFileBranch parent;
+ FileSystemNode parent;
FileStats stats;
void GetPath(String outputPath)
{
- ExplorerFileBranch up;
+ FileSystemNode up;
if(parent)
{
strcpy(outputPath, name);
}
- bool IsChildOf(ExplorerFileBranch branch)
+ bool IsChildOf(FileSystemNode node)
{
- ExplorerFileBranch test;
+ FileSystemNode test;
for(test = parent; test; test = test.parent)
- if(test == branch)
+ if(test == node)
return true;
return false;
}
- void DuplicateChildren(bool recursive, bool forceExpanded, ExplorerFileBranch addTo, ListBox tree)
+ void DuplicateChildren(bool recursive, bool forceExpanded, FileSystemNode addTo, ListBox tree)
{
if(children.first)
{
- ExplorerFileBranch child;
+ FileSystemNode child;
for(child = children.first; child; child = child.next)
{
- ExplorerFileBranch copy { };
+ FileSystemNode copy { };
copy.name = CopyString(child.name);
copy.type = child.type;
- AddBranch(copy, child.loaded, false, addTo, tree);
+ AddNode(copy, child.loaded, false, addTo, tree);
if(forceExpanded)
copy.row.collapsed = false;
if(recursive)
void Free()
{
- ExplorerFileBranch child;
+ FileSystemNode child;
for(; (child = children.first); )
{
child.Free();
}
}
- int OnCompare(ExplorerFileBranch b)
+ int OnCompare(FileSystemNode b)
{
int result;
if(type == b.type || (type < folder && b.type < folder) || (type >= drive))
}
};
-ExplorerFileBranch MakeFileBranch(const FileStats stats, const char * name)
+FileSystemNode MakeFileNode(const FileStats stats, const char * name)
{
- ExplorerFileBranch fileTreeBranch { stats = stats };
- fileTreeBranch.name = CopyString(name);
- if(!fileTreeBranch.name)
- fileTreeBranch.name = null;
+ FileSystemNode fileTreeNode { stats = stats };
+ fileTreeNode.name = CopyString(name);
+ if(!fileTreeNode.name)
+ fileTreeNode.name = null;
if(stats.attribs.isDirectory)
{
- fileTreeBranch.type = (stats.attribs.isDrive) ? drive : folder;
- if(stats.attribs.isServer) fileTreeBranch.type = server;
- if(stats.attribs.isShare) fileTreeBranch.type = share;
- if(stats.attribs.isCDROM) fileTreeBranch.type = cdrom;
- if(stats.attribs.isRemote) fileTreeBranch.type = netDrive;
+ fileTreeNode.type = (stats.attribs.isDrive) ? drive : folder;
+ if(stats.attribs.isServer) fileTreeNode.type = server;
+ if(stats.attribs.isShare) fileTreeNode.type = share;
+ if(stats.attribs.isCDROM) fileTreeNode.type = cdrom;
+ if(stats.attribs.isRemote) fileTreeNode.type = netDrive;
if(stats.attribs.isRemovable)
{
if(name[0] == 'A' || name[0] == 'B')
- fileTreeBranch.type = floppy;
+ fileTreeNode.type = floppy;
else
- fileTreeBranch.type = removable;
+ fileTreeNode.type = removable;
}
}
else
{
char extension[MAX_EXTENSION];
- GetExtension(fileTreeBranch.name, extension);
- fileTreeBranch.type = ExplorerFileType::SelectByExtension(extension);
+ GetExtension(fileTreeNode.name, extension);
+ fileTreeNode.type = ExplorerFileType::SelectByExtension(extension);
}
- return fileTreeBranch;
+ return fileTreeNode;
}
-void AddBranch(ExplorerFileBranch branch, bool loaded, bool addLoader, ExplorerFileBranch addTo, ListBox tree)
+void AddNode(FileSystemNode node, bool loaded, bool addLoader, FileSystemNode addTo, ListBox tree)
{
DataRow row = (addTo && addTo.row) ? addTo.row.AddRow() : tree.AddRow();
if(addTo)
{
- branch.parent = addTo;
- branch.indent = addTo.indent + 1;
- addTo.children.Add(branch);
+ node.parent = addTo;
+ node.indent = addTo.indent + 1;
+ addTo.children.Add(node);
}
- row.tag = (int)branch;
- branch.row = row;
- row.SetData(null, branch);
+ row.tag = (int)node;
+ node.row = row;
+ row.SetData(null, node);
- branch.loaded = loaded;
+ node.loaded = loaded;
if(addLoader)
- //AddBranch(ExplorerFileBranch { }, false, false, branch, tree); // why would this create a compile error?
- AddBranch(ExplorerFileBranch { type = none }, false, false, branch, tree);
+ //AddNode(FileSystemNode { }, false, false, node, tree); // why would this create a compile error?
+ AddNode(FileSystemNode { type = none }, false, false, node, tree);
- if(branch.indent > 0)
+ if(node.indent > 0)
row.collapsed = true;
- else if(branch.type == folder)
- branch.type = folderOpen;
+ else if(node.type == folder)
+ node.type = folderOpen;
}
-void BranchLoad(ExplorerFileBranch branch, ListBox tree)
+void NodeLoad(FileSystemNode node, ListBox tree)
{
- if(!branch.loaded)
+ if(!node.loaded)
{
char path[MAX_LOCATION];
- branch.GetPath(path);
+ node.GetPath(path);
{
FileListing listing { path };
- if(branch.children.count == 1)
- DeleteBranch(branch.children.first, tree);
+ if(node.children.count == 1)
+ DeleteNode(node.children.first, tree);
while(listing.Find())
{
if(listing.stats.attribs.isDirectory)
{
- ExplorerFileBranch child = MakeFileBranch(listing.stats, listing.name);
- AddBranch(child, true, false, branch, tree);
- BranchChildLoad(child, branch, tree);
+ FileSystemNode child = MakeFileNode(listing.stats, listing.name);
+ AddNode(child, true, false, node, tree);
+ NodeChildLoad(child, node, tree);
}
}
}
- branch.childrenLoaded = true;
- branch.loaded = true;
- branch.row.SortSubRows(false);
+ node.childrenLoaded = true;
+ node.loaded = true;
+ node.row.SortSubRows(false);
}
- else if(!branch.childrenLoaded)
+ else if(!node.childrenLoaded)
{
- ExplorerFileBranch child;
- if(branch.children.first)
+ FileSystemNode child;
+ if(node.children.first)
{
- for(child = branch.children.first; child; child = child.next)
+ for(child = node.children.first; child; child = child.next)
{
if(!child.loaded)
- BranchLoad(child, tree);
+ NodeLoad(child, tree);
else if(!child.childrenLoaded)
- BranchChildLoad(child, branch, tree);
+ NodeChildLoad(child, node, tree);
}
- branch.childrenLoaded = true;
- branch.row.SortSubRows(false);
+ node.childrenLoaded = true;
+ node.row.SortSubRows(false);
}
}
}
-static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch, ListBox tree)
+static void NodeChildLoad(FileSystemNode parent, FileSystemNode node, ListBox tree)
{
char path[MAX_LOCATION];
parent.GetPath(path);
{
if(listing.stats.attribs.isDirectory)
{
- ExplorerFileBranch child = MakeFileBranch(listing.stats, listing.name);
- AddBranch(child, true, false, parent, tree);
+ FileSystemNode child = MakeFileNode(listing.stats, listing.name);
+ AddNode(child, true, false, parent, tree);
added = true;
}
}
//parent.childrenLoaded = true;
}
-void DeleteBranch(ExplorerFileBranch branch, ListBox tree)
+void DeleteNode(FileSystemNode node, ListBox tree)
{
- ExplorerFileBranch child;
- for(; (child = branch.children.first); )
- DeleteBranch(child, tree);
- tree.DeleteRow(branch.row);
- branch.Delete();
+ FileSystemNode child;
+ for(; (child = node.children.first); )
+ DeleteNode(child, tree);
+ tree.DeleteRow(node.row);
+ node.Delete();
}
-