X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=ede;a=blobdiff_plain;f=libede%2Fsrc%2FFileSystemBox.ec;h=4f5d76d7a78b143d642068084ee6fecb882a83f1;hp=fae4b14bde4ad4f21cbd67d3a76985b58538ca36;hb=7634649bc4cb453b6b4144be00aae533307c47d6;hpb=8af90394632962459a06d989860896d0dc2b87d4 diff --git a/libede/src/FileSystemBox.ec b/libede/src/FileSystemBox.ec index fae4b14..4f5d76d 100644 --- a/libede/src/FileSystemBox.ec +++ b/libede/src/FileSystemBox.ec @@ -50,7 +50,7 @@ static char * fileIconNames[] = "" }; -public enum ExplorerFileType +public enum _FileType { none, @@ -84,7 +84,7 @@ public enum ExplorerFileType get { return this >= normalFile && this <= opticalMediaImageFile; } } - ExplorerFileType ::SelectByExtension(char * extension) + _FileType ::SelectByExtension(char * extension) { if(!strcmpi(extension, "ews")) return ewsFile; @@ -142,12 +142,12 @@ class ExplorerControl : Window { bool previewPictures; - BitmapResource fileIcons[ExplorerFileType]; + BitmapResource fileIcons[_FileType]; ExplorerControl() { - ExplorerFileType c; - for(c = 0; c < ExplorerFileType::enumSize; c++) + _FileType c; + for(c = 0; c < _FileType::enumSize; c++) { fileIcons[c] = BitmapResource { fileIconNames[c], alphaBlend = true }; AddResource(fileIcons[c]); @@ -155,13 +155,14 @@ class ExplorerControl : Window } } +#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) @@ -224,11 +225,13 @@ class ExplorerView : ExplorerControl { } } +#endif +#if 0 class ExplorerViewList : ExplorerView { - ExplorerFileBranch location; + FileSystemNode location; public: @@ -244,7 +247,7 @@ public: Load(location); } - void Load(ExplorerFileBranch location) + void Load(FileSystemNode location) { char path[MAX_LOCATION]; this.location = location; @@ -269,7 +272,9 @@ public: } } } +#endif +#if 0 class ExplorerViewDetails : ExplorerView { list.hasHeader = true; @@ -277,7 +282,7 @@ class ExplorerViewDetails : ExplorerView list.resizable = true; list.sortable = true; - ExplorerFileBranch location; + FileSystemNode location; public: @@ -297,7 +302,7 @@ public: Load(location); } - void Load(ExplorerFileBranch location) + void Load(FileSystemNode location) { char path[MAX_LOCATION]; this.location = location; @@ -324,11 +329,13 @@ public: } } } +#endif +#if 0 class ExplorerViewIcons : ExplorerView { - ExplorerFileBranch location; + FileSystemNode location; public: @@ -344,7 +351,7 @@ public: Load(location); } - void Load(ExplorerFileBranch location) + void Load(FileSystemNode location) { char path[MAX_LOCATION]; this.location = location; @@ -369,11 +376,13 @@ public: } } } +#endif +#if 0 class ExplorerViewCards : ExplorerView { - ExplorerFileBranch location; + FileSystemNode location; public: @@ -389,7 +398,7 @@ public: Load(location); } - void Load(ExplorerFileBranch location) + void Load(FileSystemNode location) { char path[MAX_LOCATION]; this.location = location; @@ -414,7 +423,9 @@ public: } } } +#endif +#if 0 public class BitmapArray : RedjArray { type = class(Bitmap); @@ -445,13 +456,15 @@ public: 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: @@ -549,7 +562,7 @@ public: Load(location); } - void Load(ExplorerFileBranch location) + void Load(FileSystemNode location) { char path[MAX_LOCATION]; this.location = location; @@ -574,7 +587,9 @@ public: } } } +#endif +#if 0 class ExplorerTree : ExplorerControl { hasHorzScroll = false; @@ -584,14 +599,14 @@ class ExplorerTree : ExplorerControl 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 { @@ -601,28 +616,28 @@ public: 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; } @@ -634,7 +649,7 @@ public: hasHorzScroll = true; hasVertScroll = true; fullRowSelect = false; - treeBranches = true; + treeNodees = true; collapseControl = true; rootCollapseButton = true; @@ -653,25 +668,25 @@ public: { 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); } @@ -684,8 +699,8 @@ public: DataRow row = listBox.currentRow; if(row) { - ExplorerFileBranch branch = (ExplorerFileBranch)row.tag; - if(branch) + FileSystemNode node = (FileSystemNode)row.tag; + if(node) { PopupMenu popup; Menu menu { }; @@ -713,9 +728,9 @@ public: { 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; } @@ -724,7 +739,7 @@ public: { if(row) { - ExplorerFileBranch branch = (ExplorerFileBranch)row.tag; + FileSystemNode node = (FileSystemNode)row.tag; } return true; } @@ -733,7 +748,7 @@ public: { if(row) { - ExplorerFileBranch branch = (ExplorerFileBranch)row.tag; + FileSystemNode node = (FileSystemNode)row.tag; } return true; } @@ -742,7 +757,7 @@ public: { if(row) { - ExplorerFileBranch branch = (ExplorerFileBranch)row.tag; + FileSystemNode node = (FileSystemNode)row.tag; } return true; } @@ -805,19 +820,19 @@ public: 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__ @@ -840,18 +855,18 @@ public: 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 @@ -941,13 +956,15 @@ End If */ } +#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) @@ -957,39 +974,43 @@ public: } 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; char * name; char * info; char * extension; - ExplorerFileType type; + _FileType type; int indent; Bitmap bitmap; @@ -1159,7 +1180,7 @@ ExplorerFileItem MakeFileItem(const FileAttribs attribs, const char * fileName, //strupr(extension); strlwr(extension); - item.type = ExplorerFileType::SelectByExtension(extension); + item.type = _FileType::SelectByExtension(extension); } if(attribs.isDrive && @@ -1190,10 +1211,11 @@ ExplorerFileItem MakeFileItem(const FileAttribs attribs, const char * fileName, return item; } +#endif -public class ExplorerFileBranch : struct +public class FileSystemNode : struct { - ExplorerFileBranch prev, next; + FileSystemNode prev, next; bool loaded, childrenLoaded; int indent; @@ -1201,14 +1223,14 @@ public class ExplorerFileBranch : struct char * info; DataRow row; OldList children; - ExplorerFileType type; - ExplorerFileBranch parent; + _FileType type; + FileSystemNode parent; FileStats stats; void GetPath(String outputPath) { - ExplorerFileBranch up; + FileSystemNode up; if(parent) { strcpy(outputPath, name); @@ -1229,27 +1251,27 @@ public class ExplorerFileBranch : struct } - 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) @@ -1274,7 +1296,7 @@ public class ExplorerFileBranch : struct void Free() { - ExplorerFileBranch child; + FileSystemNode child; for(; (child = children.first); ) { child.Free(); @@ -1373,7 +1395,7 @@ public class ExplorerFileBranch : struct } } - int OnCompare(ExplorerFileBranch b) + int OnCompare(FileSystemNode b) { int result; if(type == b.type || (type < folder && b.type < folder) || (type >= drive)) @@ -1392,104 +1414,104 @@ public class ExplorerFileBranch : struct } }; -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 = _FileType::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); @@ -1500,8 +1522,8 @@ static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch { 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; } } @@ -1511,12 +1533,11 @@ static void BranchChildLoad(ExplorerFileBranch parent, ExplorerFileBranch branch //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(); } -