4 static char * rootName = "Entire Computer";
5 static char * msNetwork = "Microsoft Windows Network";
7 static char * rootName = "File System";
11 define guiApp = (GuiApplication)((__thisModule).application);
12 define selectionColor = guiApp.currentSkin.selectionColor; //Color { 10, 36, 106 };
14 static char * fileIconNames[] =
16 "<:ecere>mimeTypes/file.png", /* none */
18 "<:ecere>mimeTypes/file.png", /* normalFile */
19 "<:ecere>mimeTypes/textEcereWorkspace.png", /* ewsFile */
20 "<:ecere>mimeTypes/textEcereProject.png", /* epjFile */
21 "<:ecere>mimeTypes/textEcereSource.png", /* ecFile */
22 "<:ecere>mimeTypes/textEcereHeader.png", /* ehFile */
23 "<:ecere>mimeTypes/textCSource.png", /* cFile */
24 "<:ecere>mimeTypes/textCHeader.png", /* hFile */
25 "<:ecere>mimeTypes/textC++Source.png", /* cppFile */
26 "<:ecere>mimeTypes/textC++Header.png", /* hppFile */
27 "<:ecere>mimeTypes/text.png", /* textFile */
28 "<:ecere>mimeTypes/textHyperTextMarkup.png", /* webFile */
29 "<:ecere>mimeTypes/image.png", /* pictureFile */
30 "<:ecere>status/audioVolumeHigh.png", /* soundFile */
31 "<:ecere>mimeTypes/package.png", /* archiveFile */
32 "<:ecere>mimeTypes/packageSoftware.png", /* packageFile */
33 "<:ecere>mimeTypes/packageOpticalDisc.png", /* opticalMediaImageFile */
35 "<:ecere>places/folder.png", /* folder */
36 "<:ecere>status/folderOpen.png", /* folderOpen */
37 "<:ecere>devices/computer.png", /* computer */
38 "<:ecere>devices/driveHardDisk.png", /* drive */
39 "<:ecere>places/driveRemote.png", /* netDrive */
40 "<:ecere>devices/mediaOptical.png", /* cdrom */
41 "<:ecere>devices/driveRemovableMedia.png", /* removable */
42 "<:ecere>devices/mediaFloppy.png", /* floppy */
43 "<:ecere>places/networkWorkgroup.png", /* network */
44 "<:ecere>places/networkServer.png", /* server */
45 "<:ecere>places/folderRemote.png", /* share */
47 "<:ecere>mimeTypes/package.png", /* treeLoader */
48 "<:ecere>places/startHere.png", /* lineNumbers */
57 normalFile, ewsFile, epjFile, ecFile, ehFile, cFile, hFile, cppFile, hppFile,
58 textFile, webFile, pictureFile, soundFile,
59 archiveFile, packageFile, opticalMediaImageFile, /* these (all previous) are sort equal */
61 folder, folderOpen, computer,
62 drive, netDrive, cdrom, removable, floppy, network, server, share, // these are sort equal
72 this = SelectByExtension(value);
76 public property bool isFolder
78 get { return this >= folder && this <= share; }
81 public property bool isFile
83 get { return this >= normalFile && this <= opticalMediaImageFile; }
86 _FileType ::SelectByExtension(char * extension)
88 if(!strcmpi(extension, "ews"))
90 else if(!strcmpi(extension, "epj"))
92 else if(!strcmpi(extension, "ec"))
94 else if(!strcmpi(extension, "eh"))
96 else if(!strcmpi(extension, "cpp") ||
97 !strcmpi(extension, "cc") || !strcmpi(extension, "cxx"))
99 else if(!strcmpi(extension, "hpp") ||
100 !strcmpi(extension, "hh") || !strcmpi(extension, "hxx"))
102 else if(!strcmpi(extension, "c"))
104 else if(!strcmpi(extension, "h"))
106 else if(!strcmpi(extension, "txt") || !strcmpi(extension, "text") ||
107 !strcmpi(extension, "nfo") || !strcmpi(extension, "info"))
109 else if(!strcmpi(extension, "htm") || !strcmpi(extension, "html") ||
110 !strcmpi(extension, "css") || !strcmpi(extension, "php") ||
111 !strcmpi(extension, "js"))
113 else if(!strcmpi(extension, "bmp") || !strcmpi(extension, "pcx") ||
114 !strcmpi(extension, "jpg") || !strcmpi(extension, "jpeg") ||
115 !strcmpi(extension, "gif") || !strcmpi(extension, "png") ||
116 !strcmpi(extension, "ico"))
118 else if(!strcmpi(extension, "wav") || !strcmpi(extension, "mp3") ||
119 !strcmpi(extension, "ogg") || !strcmpi(extension, "snd"))
121 else if(!strcmpi(extension, "ear") || !strcmpi(extension, "7z") ||
122 !strcmpi(extension, "rar") || !strcmpi(extension, "zip") ||
123 !strcmpi(extension, "gz") || !strcmpi(extension, "bz2") ||
124 !strcmpi(extension, "tar") || !strcmpi(extension, "arj") ||
125 !strcmpi(extension, "lza") || !strcmpi(extension, "lzh") ||
126 !strcmpi(extension, "cpio") || !strcmpi(extension, "z"))
128 else if(!strcmpi(extension, "cab") || !strcmpi(extension, "deb") ||
129 !strcmpi(extension, "rpm"))
131 else if(!strcmpi(extension, "iso") || !strcmpi(extension, "mds") ||
132 !strcmpi(extension, "cue") || !strcmpi(extension, "bin") ||
133 !strcmpi(extension, "ccd") || !strcmpi(extension, "bwt") ||
134 !strcmpi(extension, "cdi") || !strcmpi(extension, "nrg"))
135 return opticalMediaImageFile;
140 class FileSystemBoxBits
142 bool foldersOnly:1, filesOnly:1, details:1, pathColumn:1, treeBranches:1, previewPictures:1, navigateFolders:1, autoLoad:1;
144 //bool header:1, freeSelect:1, fullRowSelect:1, multiSelect:1, autoScroll:1, alwaysHL : 1, moveRows:1, resizable:1;
145 //bool moveFields:1, clearHeader:1, alwaysEdit:1, collapse:1, treeBranch:1, rootCollapse:1, heightSet:1;
146 //bool sortable:1, noDragging:1, fillLastField:1, expandOnAdd:1;
149 public class FileSystemBox : Window // should we not derive from ListBox instead?
150 // I say we should, but we can't right now...
151 // because ListBox (inside ecere library) is
152 // not exposing enough internal machinery...
153 // could we not have a different private and
154 // public mechanism when deriving a class than
155 // we do when simply instanciating a class?
157 this stuff from the listbox would be nicely exposed...
158 fullRowSelect = false;
160 collapseControl = true;
161 rootCollapseButton = true;
166 hasHorzScroll = false;
167 hasVertScroll = false;
173 FileSystemBoxSelection selection { };
175 virtual bool Window::NotifyNodeSelect(FileSystemBox box, FileSystemBoxSelection selection);
176 //virtual bool Window::NotifyNodeNavigate(FileSystemBox box, FileSystemNode node);
177 virtual bool Window::NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection);
184 if(value && value[0])
185 path = CopyString(value);
187 locationBox.path = value;
193 //isset { return path && path[0]; }
196 property bool foldersOnly { set { bits.foldersOnly = value; bits.filesOnly = !value; } get { return bits.foldersOnly; } };
197 property bool filesOnly { set { bits.filesOnly = value; bits.foldersOnly = !value; } get { return bits.filesOnly; } };
198 property bool previewPictures { set { bits.previewPictures = value; } get { return bits.previewPictures; } };
199 property char * extensions { set { delete extensions; if(value && value[0]) extensions = CopyString(value); } get { return extensions; } }
200 property bool details { set { bits.details = value; ChangeViewType(); } get { return bits.details; } };
201 property bool pathColumn { set { bits.pathColumn = value; ChangeViewType(); } get { return bits.pathColumn; } };
202 property bool treeBranches
206 bits.treeBranches = value;
207 list.treeBranches = value;
208 list.collapseControl = value;
209 list.rootCollapseButton = value;
211 get { return bits.treeBranches; }
213 property Color selectionColor { set { list.selectionColor = value; } get { return list.selectionColor; }/* isset { return selectionColor ? true : false; }*/ };
214 property Color selectionText { set { list.selectionText = value; } get { return list.selectionText; }/* isset { return selectionText ? true : false; }*/ };
215 property bool navigateFolders { set { bits.navigateFolders = value; bits.filesOnly = !value; } get { return bits.navigateFolders; } };
216 property bool multiSelect { set { list.multiSelect = value; } get { return list.multiSelect; } };
217 property bool autoLoad { set { bits.autoLoad = value; } get { return bits.autoLoad; } };
218 property bool hasHeader { set { list.hasHeader = value; } get { return list.hasHeader; } };
219 property bool preview
223 bits.preview = value;
224 split.leftPane = value ? list : null;
225 split.visible = value;
226 show.visible = value;
228 get { return bits.preview; }
231 property FileSystemNode node
239 if(!list.currentRow.tag)
241 return (FileSystemNode)list.currentRow.tag;
247 void Select(FileSystemNode node)
251 node.EnsureVisible(false);
252 list.SelectRow(node.row);
256 void SelectMultipleByPath(Array<String> paths)
259 bool firstRow = false;
260 Map<String, bool> map { };
263 for(row = list.firstRow; row; row = row.next)
265 FileSystemNode node = (FileSystemNode)row.tag;
277 row.selected = false;
282 FileSystemNode SelectLocation(char * location)
286 char step[MAX_LOCATION];
288 //StringArray steps { growingFactor = 4 };
289 Array<String> steps { };
290 FileSystemNode result = null;
291 FileSystemNode node = null;
293 temp = CopyString(location);
296 GetLastDirectory(temp, step);
297 StripLastDirectory(temp, temp);
298 steps.Add(CopyString(step));
301 for(c = steps.count - 1; c >= 0; c--)
304 node = Find(steps[c], node);
322 FileSystemNode Find(const char * name, FileSystemNode parent)
324 FileSystemNode node = null;
325 FileSystemNode result = null;
326 if(!parent/* && !strcmp(name, "/")*/)
329 for(row = list.firstRow; row; row = row.next)
331 node = (FileSystemNode)row.tag;
332 if(node.name && !fstrcmp(node.name, name))
341 FileSystemNode start = parent ? parent : root;
342 if(!start.bits.loaded || !start.bits.childrenLoaded)
344 for(node = start.children.first; node; node = node.next)
345 if(node.name && !fstrcmp(node.name, name))
364 FileSystemBoxBits bits;
369 BitmapResource fileIcons[_FileType];
372 //BitmapArray bitmaps { growingFactor = 16 };
376 char wd[MAX_LOCATION];
377 GetWorkingDir(wd, sizeof(wd));
381 list.AddField(nameField);
382 bits.autoLoad = true;
393 list.background = background;
399 for(c = 0; c < _FileType::enumSize; c++)
401 fileIcons[c] = BitmapResource { fileIconNames[c], alphaBlend = true };
402 AddResource(fileIcons[c]);
406 DataField nameField { header = "Name", dataType = "FileSystemNode", width = 240, userData = this, freeData = false };
407 DataField pathField { header = "Location", dataType = /*"String"*/ "char *", width = 300, freeData = false };
408 DataField typeField { header = "Type", dataType = /*"String"*/ "char *", width = 40, freeData = false };
409 DataField sizeField { header = "Size", dataType = "FileSize", width = 96, alignment = right, freeData = false };
410 DataField modifiedField { header = "Modified", dataType = "SecSince1970", width = 96, alignment = right, freeData = false };
424 hasHorzScroll = true;
425 hasVertScroll = true;
426 fullRowSelect = false;
428 alwaysHighLight = true;
430 anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
432 // WHY is this not working ?
433 /*void OnResize(int width, int height)
435 if(vertScroll.visible)
436 nameField.width = width - vertScroll.size.w;
438 nameField.width = width;
441 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
445 FileSystemNode node = (FileSystemNode)row.tag;
446 FileSystemNode child;
450 for(child = node.children.last; child; child = node.children.last)
452 listBox.DeleteRow(child.row);
456 node.childrenLoaded = false;
461 if(!node.bits.loaded || !node.bits.childrenLoaded)
464 //list.Sort(nameField, 1);
467 for(child = node.children.first; child && child.next; child = child.next);
469 child.EnsureVisible(false);
475 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
477 DataRow row = listBox.currentRow;
480 FileSystemNode node = (FileSystemNode)row.tag;
488 text = PrintString("Open ", node.path);
490 MenuItem { menu, text, o, NotifySelect = MenuOpen, disabled = false };
491 MenuItem { menu, "Cut\tCtrl+X", t, NotifySelect = null, disabled = false };
492 MenuItem { menu, "Copy\tCtrl+C", c, NotifySelect = null, disabled = false };
493 MenuItem { menu, "Paste\tCtrl+V", p, NotifySelect = null, disabled = false /*!clipboard*/ };
494 MenuItem { menu, "Delete\tDel", d, NotifySelect = null, disabled = false };
495 //MenuDivider { menu };
499 master = this, menu = menu,
501 x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
502 y + clientStart.y + absPosition.y - guiApp.desktop.position.y }
510 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
515 selection.nodes.Free();
516 list.GetMultiSelection(rows);
517 for(item = rows.first; item; item = item.next)
519 DataRow row = item.data;
520 FileSystemNode node = (FileSystemNode)row.tag;
521 selection.nodes.Add(node);
526 selection.node = (FileSystemNode)row.tag;
528 selection.node = null;
530 if(selection.node && bits.preview)
533 FileSystemNode node = selection.node;
537 if(node && node.type == pictureFile)
540 bitmap.Load(node.path, null, displaySystem);
544 bitmaps = BitmapArray { };
545 for(pos = 0; pos < selectedItems.count; pos++)
548 selItem = (ExplorerFileItem)selectedItems._[pos];
549 bitmap.Load(selItem.path, null, displaySystem);
550 //bitmaps.Add(bitmap);
552 if(node && node.type == pictureFile)
555 bitmap.Load(node.path, null, displaySystem);
559 //NotifyItemSelect(master, view, item, selectedItems);
562 NotifyNodeSelect(listBox.parent.master, this, selection);
566 bool NotifyEditing(ListBox listBox, DataRow row)
570 FileSystemNode node = (FileSystemNode)row.tag;
575 bool NotifyEdited(ListBox listBox, DataRow row)
579 FileSystemNode node = (FileSystemNode)row.tag;
584 bool NotifyEditDone(ListBox listBox, DataRow row)
588 FileSystemNode node = (FileSystemNode)row.tag;
593 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
595 bool result = !(selection.node && selection.node.type.isFolder && bits.navigateFolders);
600 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
603 if((SmartKey)key == enter)
627 anchor = Anchor { top = 0, right = 0, bottom = 0 };
629 void OnRedraw(Surface surface)
631 FileSystemBox fsb = (FileSystemBox)parent;
634 int wBmp = fsb.bitmap.width;
635 int hBmp = fsb.bitmap.height;
636 int wWnd = fsb.show.clientSize.w;
637 int hWnd = fsb.show.clientSize.h;
639 int wList = 0;//fsb.list.size.w + fsb.split.size.w;
641 float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
643 int wDraw = (int)(wBmp * scale);
644 int hDraw = (int)(hBmp * scale);
647 surface.Filter(fsb.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
649 // Until Filter / Stretch works with X
650 surface.Blit(fsb.bitmap, (wWnd - wBmp) / 2, (hWnd - hBmp) / 2, 0, 0, wBmp, hBmp);
655 surface.SetForeground(white);
656 surface.Area(0, 0, fsb.clientSize.w - 1, fsb.clientSize.h - 1);
661 bool MenuOpen(MenuItem selection, Modifiers mods)
669 FileSystemBoxSelection selection = this.selection.Copy();
670 FileSystemNode node = selection.node;
671 if(node && node.type.isFolder && bits.navigateFolders)
672 property::path = node.path;
673 result = NotifyNodeOpen(this.master, this, selection);
678 Menu editMenu { menu, "Edit", e };
681 editMenu, "Cut\tCtrl+X", t, disabled = true;
683 bool NotifySelect(MenuItem selection, Modifiers mods)
689 MenuItem itemEditCopy
691 editMenu, "Copy\tCtrl+C", c, disabled = true;
693 bool NotifySelect(MenuItem selection, Modifiers mods)
699 MenuItem itemEditPaste
701 editMenu, "Paste\tCtrl+V", p;
703 bool NotifySelect(MenuItem selection, Modifiers mods)
709 MenuItem itemEditDelete
711 editMenu, "Delete\tDel", d, disabled = true;
713 bool NotifySelect(MenuItem selection, Modifiers mods)
720 // WHY is this crashing ?
721 /*void OnResize(int width, int height)
723 if(this && nameField)
724 nameField.width = width - 80;
727 void ChangeViewType()
731 list.resizable = bits.details || bits.pathColumn;
732 list.moveFields = bits.details || bits.pathColumn;
733 list.hasHeader = bits.details || bits.pathColumn;
734 list.AddField(nameField);
736 list.AddField(pathField);
739 list.AddField(typeField);
740 list.AddField(sizeField);
741 list.AddField(modifiedField);
748 // this is crashing in for designer when details = true // can't save the file, always yields a crash
749 /*if(list && created)
752 list.AddField(nameField);
755 list.AddField(typeField);
756 list.AddField(sizeField);
759 if(bits.treeBranches)
767 FileListing listing { path, extensions = extensions };
770 while(listing.Find())
772 if((!bits.foldersOnly && !bits.filesOnly) ||
773 (bits.foldersOnly && listing.stats.attribs.isDirectory) ||
774 (bits.filesOnly && listing.stats.attribs.isFile))
776 FileSystemNode node = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem);
780 list.Sort(nameField, 1);
785 bool isRoot = !strcmp(path, "/");
786 char name[MAX_LOCATION];
787 FileSystemNode parent;
789 FileListing listing { path, extensions = extensions };
792 GetLastDirectory(path, name);
797 GetWorkingDir(startPath, sizeof(startPath));
799 strcpy(path, startPath);*/
807 root = FileSystemNode { bits.loaded = true, bits.childrenLoaded = true };
808 AddTreeNode(root, true, false, null);
809 while(listing.Find())
811 int len = strlen(listing.name);
812 char info[MAX_LOCATION];
813 char name[MAX_LOCATION];
814 if(listing.stats.attribs.isDrive &&
815 len > 3 && !strncmp(&listing.name[1], ": [", 3))
817 strncpy(name, listing.name, 2);
819 strncpy(info, &listing.name[4], len - 5);
824 strcpy(name, listing.name);
828 parent = MakeFileSystemNode(listing.stats, name, listing.path, false, bits.previewPictures, displaySystem);
830 parent.info = info; //CopyString(info);
831 parent.bits.loaded = true;
832 AddTreeNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root);
833 if(!listing.stats.attribs.isDirectory)
834 parent.bits.childrenLoaded = true;
837 node = FileSystemNode { name = msNetwork, type = network };
838 AddTreeNode(node, false, true, null);
839 node.row.collapsed = true;
844 root = MakeFileSystemNode(FileStats { attribs = FileExists(path)}, name, path, false, bits.previewPictures, displaySystem);
845 AddTreeNode(root, false, true, null);
851 root.type = computer;
852 root.label = rootName;
855 list.Sort(nameField, 1);
856 list.SelectRow(root.row);
859 void LoadTreeNode(FileSystemNode node)
861 if(!node.bits.loaded)
863 char path[MAX_LOCATION];
866 FileListing listing { path, extensions = extensions };
867 if(node.children.count == 1)
868 DeleteNode(node.children.first);
870 while(listing.Find())
872 if(!listing.stats.attribs.isRemovable && ((!bits.foldersOnly && !bits.filesOnly) ||
873 (bits.foldersOnly && listing.stats.attribs.isDirectory) ||
874 (bits.filesOnly && listing.stats.attribs.isFile)))
876 FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem);
877 AddTreeNode(child, true, false, node);
878 NodeChildLoad(child, node);
882 node.bits.childrenLoaded = true;
883 node.bits.loaded = true;
884 node.row.SortSubRows(false);
886 else if(!node.bits.childrenLoaded)
888 FileSystemNode child;
889 if(node.children.first)
891 for(child = node.children.first; child; child = child.next)
893 if(!child.bits.loaded)
895 else if(!child.bits.childrenLoaded)
896 NodeChildLoad(child, node);
898 node.bits.childrenLoaded = true;
899 node.row.SortSubRows(false);
904 void NodeChildLoad(FileSystemNode parent, FileSystemNode node)
906 char path[MAX_LOCATION];
907 parent.GetPath(path);
910 FileListing listing { path, extensions = extensions };
911 while(listing.Find())
913 if((!bits.foldersOnly && !bits.filesOnly) ||
914 (bits.foldersOnly && listing.stats.attribs.isDirectory) ||
915 (bits.filesOnly && listing.stats.attribs.isFile))
917 FileSystemNode child = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, displaySystem);
918 AddTreeNode(child, listing.stats.attribs.isFile, !listing.stats.attribs.isFile, parent);
925 parent.bits.childrenLoaded = true;
928 void AddNode(FileSystemNode node)
930 DataRow row = list.AddRow();
934 row.SetData(nameField, node);
936 row.SetData(pathField, node.path);
941 row.SetData(typeField, node.extension);
942 row.SetData(sizeField, /*(void *)*/node.stats.size);
944 row.SetData(modifiedField, node.stats.modified);
948 void AddTreeNode(FileSystemNode node, bool loaded, bool addLoader, FileSystemNode addTo)
950 DataRow row = (addTo && addTo.row) ? addTo.row.AddRow() : list.AddRow();
954 node.indent = addTo.indent + 1;
955 addTo.children.Add(node);
959 row.SetData(null, node);
961 row.SetData(pathField, node.path);
966 row.SetData(typeField, node.extension);
967 row.SetData(sizeField, /*(void *)*/node.stats.size);
969 row.SetData(modifiedField, node.stats.modified);
972 node.bits.loaded = loaded;
974 //AddTreeNode(FileSystemNode { }, false, false, node); // why would this create a compile error?
975 AddTreeNode(FileSystemNode { type = none }, false, false, node);
978 row.collapsed = true;
979 else if(node.type == folder)
980 node.type = folderOpen;
983 void DeleteNode(FileSystemNode node)
985 FileSystemNode child;
988 for(; (child = node.children.first); )
991 list.DeleteRow(node.row);
1000 class ExplorerView : FileSystemBox
1003 hasHorzScroll = false;
1004 hasVertScroll = false;
1006 virtual void Load(FileSystemNode parent);
1007 virtual void Refresh();
1009 virtual void LaunchNotifyItemSelect(Window master, ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
1011 view.NotifyItemSelect(master, view, item, selectedItems);
1014 virtual bool Window::NotifyItemSelect(ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems);
1015 virtual bool Window::NotifyItemOpen(ExplorerView view, ExplorerFileItem item);
1019 master = master, parent = this;
1022 hasHorzScroll = true;
1023 hasVertScroll = true;
1026 fullRowSelect = false;
1029 anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
1031 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
1033 ExplorerView view = (ExplorerView)listBox.parent;
1034 if(listBox.currentRow)
1037 ExplorerFileItemArray selectedItems { growingFactor = 16 };
1038 for(listRow = listBox.firstRow; listRow; listRow = listRow.next)
1039 if(listRow.selected)
1040 selectedItems.Add((ExplorerFileItem)listRow.tag);
1041 //view.NotifyItemSelect(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
1042 view.LaunchNotifyItemSelect(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag, selectedItems);
1047 bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
1049 ExplorerView view = (ExplorerView)listBox.parent;
1050 view.NotifyItemOpen(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
1054 bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
1056 if((SmartKey)key == enter)
1058 ExplorerView view = (ExplorerView)listBox.parent;
1059 view.NotifyItemOpen(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
1072 class ExplorerViewList : ExplorerView
1075 FileSystemNode location;
1079 DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
1081 ExplorerViewDetails()
1083 list.AddField(nameField);
1091 void Load(FileSystemNode location)
1093 char path[MAX_LOCATION];
1094 this.location = location;
1095 location.GetPath(path);
1097 FileListing listing { path };
1099 ExplorerFileItem item;
1104 while(listing.Find())
1106 item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
1108 row = list.AddRow();
1109 row.tag = (int)item;
1110 row.SetData(nameField, item);
1112 list.Sort(nameField, 1);
1119 class ExplorerViewDetails : ExplorerView
1121 list.hasHeader = true;
1122 list.moveFields = true;
1123 list.resizable = true;
1124 list.sortable = true;
1126 FileSystemNode location;
1130 DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
1131 DataField typeField { header = "Type", dataType = /-*"String"*-/ "char *", width = 40 };
1132 DataField sizeField { header = "Size", dataType = "FileSize", width = 96, alignment = right };
1134 ExplorerViewDetails()
1136 list.AddField(nameField);
1137 list.AddField(typeField);
1138 list.AddField(sizeField);
1146 void Load(FileSystemNode location)
1148 char path[MAX_LOCATION];
1149 this.location = location;
1150 location.GetPath(path);
1152 FileListing listing { path };
1154 ExplorerFileItem item;
1159 while(listing.Find())
1161 item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
1163 row = list.AddRow();
1164 row.tag = (int)item;
1165 row.SetData(nameField, item);
1166 row.SetData(typeField, CopyString(item.extension));
1167 row.SetData(sizeField, (uint)listing.stats.size);
1169 list.Sort(nameField, 1);
1176 class ExplorerViewIcons : ExplorerView
1179 FileSystemNode location;
1183 DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
1185 ExplorerViewDetails()
1187 list.AddField(nameField);
1195 void Load(FileSystemNode location)
1197 char path[MAX_LOCATION];
1198 this.location = location;
1199 location.GetPath(path);
1201 FileListing listing { path };
1203 ExplorerFileItem item;
1208 while(listing.Find())
1210 item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
1212 row = list.AddRow();
1213 row.tag = (int)item;
1214 row.SetData(nameField, item);
1216 list.Sort(nameField, 1);
1223 class ExplorerViewCards : ExplorerView
1226 FileSystemNode location;
1230 DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
1232 ExplorerViewDetails()
1234 list.AddField(nameField);
1242 void Load(FileSystemNode location)
1244 char path[MAX_LOCATION];
1245 this.location = location;
1246 location.GetPath(path);
1248 FileListing listing { path };
1250 ExplorerFileItem item;
1255 while(listing.Find())
1257 item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
1259 row = list.AddRow();
1260 row.tag = (int)item;
1261 row.SetData(nameField, item);
1263 list.Sort(nameField, 1);
1270 public class BitmapArray : RedjArray
1272 type = class(Bitmap);
1275 Bitmap * Add(Bitmap bitmap)
1282 Bitmap * AddBefore(uint position, Bitmap bitmap)
1284 Insert(position, 1);
1285 _[position] = bitmap;
1286 return &_[position];
1291 for(c = 0; c < _count; c++)
1303 class ExplorerViewShowcase : ExplorerView
1305 list.anchor = Anchor { left = 0, top = 0, bottom = 0 };
1306 list.size = Size { w = 200 };
1308 FileSystemNode location;
1312 DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 180, editable = true, userData = this };
1315 BitmapArray bitmaps { growingFactor = 16 };
1321 anchor = Anchor { top = 0, right = 0, bottom = 0 };
1323 void OnRedraw(Surface surface)
1325 ExplorerViewShowcase view = (ExplorerViewShowcase)parent;
1328 int wBmp = view.bitmap.width;
1329 int hBmp = view.bitmap.height;
1330 int wWnd = clientSize.w;
1331 int hWnd = clientSize.h;
1333 int wList = view.list.size.w + view.split.size.w;
1335 float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
1337 int wDraw = (int)(wBmp * scale);
1338 int hDraw = (int)(hBmp * scale);
1341 surface.Filter(view.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
1343 // Until Filter / Stretch works with X
1344 surface.Blit(view.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw);
1349 surface.SetForeground(white);
1350 surface.Area(0, 0, view.clientSize.w - 1, view.clientSize.h - 1);
1364 ExplorerViewDetails()
1366 list.AddField(nameField);
1369 void LaunchNotifyItemSelect(Window master, ExplorerViewShowcase view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
1372 ExplorerFileItem selItem;
1376 if(item && item.type == pictureFile)
1378 view.bitmap = Bitmap { };
1379 view.bitmap.Load(item.path, null, displaySystem);
1382 view.bitmaps.Clear();
1383 view.bitmaps = BitmapArray { };
1384 for(pos = 0; pos < selectedItems.count; pos++)
1387 selItem = (ExplorerFileItem)selectedItems._[pos];
1388 bitmap.Load(selItem.path, null, displaySystem);
1389 //view.bitmaps.Add(bitmap);
1391 if(item && item.type == pictureFile)
1393 view.bitmap = Bitmap { };
1394 view.bitmap.Load(item.path, null, displaySystem);
1397 view.show.Update(null);
1398 view.NotifyItemSelect(master, view, item, selectedItems);
1406 void Load(FileSystemNode location)
1408 char path[MAX_LOCATION];
1409 this.location = location;
1410 location.GetPath(path);
1412 FileListing listing { path };
1414 ExplorerFileItem item;
1419 while(listing.Find())
1421 item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
1423 row = list.AddRow();
1424 row.tag = (int)item;
1425 row.SetData(nameField, item);
1427 list.Sort(nameField, 1);
1434 class ExplorerTree : FileSystemBox
1436 hasHorzScroll = false;
1437 hasVertScroll = false;
1443 DataField nameField { dataType = "FileSystemNode", width = 240, userData = this };
1445 FileSystemNode root;
1446 FileSystemNode selection;
1448 virtual bool Window::NotifyNodeSelect(ExplorerTree tree, FileSystemNode node);
1450 property FileSystemNode node
1456 if(!tree.currentRow)
1458 if(!tree.currentRow.tag)
1460 return (FileSystemNode)tree.currentRow.tag;
1464 void Select(FileSystemNode node)
1468 node.EnsureVisible(false);
1469 tree.SelectRow(node.row);
1473 FileSystemNode Find(const char * name, FileSystemNode parent)
1475 FileSystemNode node;
1476 FileSystemNode start = parent ? parent : root;
1477 if(!start.loaded || !start.childrenLoaded)
1478 LoadTreeNode(start, tree);
1479 for(node = start.children.first; node; node = node.next)
1480 if(node.name && !strcmpi(node.name, name))
1487 master = master, parent = this;
1490 hasHorzScroll = true;
1491 hasVertScroll = true;
1492 fullRowSelect = false;
1494 collapseControl = true;
1495 rootCollapseButton = true;
1497 anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
1499 // WHY is this not working ?
1500 /-*void OnResize(int width, int height)
1502 if(vertScroll.visible)
1503 nameField.width = width - vertScroll.size.w;
1505 nameField.width = width;
1508 bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
1512 FileSystemNode node = (FileSystemNode)row.tag;
1513 FileSystemNode child;
1517 for(child = node.children.last; child; child = node.children.last)
1519 listBox.DeleteRow(child.row);
1523 node.childrenLoaded = false;
1528 if(!node.loaded || !node.childrenLoaded)
1529 LoadTreeNode(node, tree);
1530 for(child = node.children.first; child && child.next; child = child.next);
1532 child.EnsureVisible(false);
1538 bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
1540 DataRow row = listBox.currentRow;
1543 FileSystemNode node = (FileSystemNode)row.tag;
1549 MenuItem { menu, "Cut\tCtrl+X", t, NotifySelect = null, disabled = false };
1550 MenuItem { menu, "Copy\tCtrl+C", c, NotifySelect = null, disabled = false };
1551 MenuItem { menu, "Paste\tCtrl+V", p, NotifySelect = null, disabled = false /-*!clipboard*-/ };
1552 MenuItem { menu, "Delete\tDel", d, NotifySelect = null, disabled = false };
1553 //MenuDivider { menu };
1557 master = this, menu = menu,
1559 x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
1560 y + clientStart.y + absPosition.y - guiApp.desktop.position.y }
1568 bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
1572 FileSystemNode node = (FileSystemNode)row.tag;
1573 NotifyNodeSelect(listBox.parent.master, this, node);
1579 bool NotifyEditing(ListBox listBox, DataRow row)
1583 FileSystemNode node = (FileSystemNode)row.tag;
1588 bool NotifyEdited(ListBox listBox, DataRow row)
1592 FileSystemNode node = (FileSystemNode)row.tag;
1597 bool NotifyEditDone(ListBox listBox, DataRow row)
1601 FileSystemNode node = (FileSystemNode)row.tag;
1608 Menu editMenu { menu, "Edit", e };
1609 MenuItem itemEditCut
1611 editMenu, "Cut\tCtrl+X", t, disabled = true;
1613 bool NotifySelect(MenuItem selection, Modifiers mods)
1619 MenuItem itemEditCopy
1621 editMenu, "Copy\tCtrl+C", c, disabled = true;
1623 bool NotifySelect(MenuItem selection, Modifiers mods)
1629 MenuItem itemEditPaste
1631 editMenu, "Paste\tCtrl+V", p;
1633 bool NotifySelect(MenuItem selection, Modifiers mods)
1639 MenuItem itemEditDelete
1641 editMenu, "Delete\tDel", d, disabled = true;
1643 bool NotifySelect(MenuItem selection, Modifiers mods)
1650 // WHY is this crashing ?
1651 /-*void OnResize(int width, int height)
1653 if(this && nameField)
1654 nameField.width = width - 80;
1659 tree.AddField(nameField);
1664 FileSystemNode parent;
1665 FileSystemNode node;
1666 FileListing listing { "/" };
1670 root = FileSystemNode { type = computer, loaded = true, childrenLoaded = true };
1672 root.name = rootName;
1676 AddTreeNode(root, true, false, null, tree);
1678 // How can this make sense for linux?
1680 while(listing.Find())
1682 int len = strlen(listing.name);
1683 char info[MAX_LOCATION];
1684 char name[MAX_LOCATION];
1685 if(listing.stats.attribs.isDrive &&
1686 len > 3 && !strncmp(&listing.name[1], ": [", 3))
1688 strncpy(name, listing.name, 2);
1690 strncpy(info, &listing.name[4], len - 5);
1695 strcpy(name, listing.name);
1699 parent = MakeFileSystemNode(listing.stats, name);
1701 parent.info = CopyString(info);
1702 parent.loaded = true;
1703 AddTreeNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
1704 if(!listing.stats.attribs.isDirectory)
1705 parent.childrenLoaded = true;
1708 node = FileSystemNode { name = msNetwork, type = network };
1709 AddTreeNode(node, false, true, null, tree);
1710 node.row.collapsed = true;
1711 tree.Sort(nameField, 1);
1712 tree.SelectRow(root.row);
1717 public class ClipBoardFiles
1731 int size = SelSize();
1734 // Try to allocate memory
1735 ClipBoard clipBoard { };
1736 if(clipBoard.Allocate(size+1))
1738 GetSel(clipBoard.memory, true);
1751 ClipBoard clipBoard { };
1752 if(clipBoard.Load())
1753 PutS(clipBoard.memory);
1764 SetViewToCursor(true);
1770 Private Type DROPFILES
1776 For iCounter = 0 To filelist.ListCount - 1
1777 If filelist.Selected(iCounter) = True Then
1778 strFiles = strFiles & FixPath(filelist.Path) & filelist.List(iCounter) & vbNullChar
1781 'all selected items are now put in strFiles
1783 hGlobal = GlobalAlloc(GHND, Len(DF) + Len(strFiles)) 'put all files to a exclusive number
1784 If hGlobal Then 'if the globalalloc worked
1785 lpGlobal = GlobalLock(hGlobal) 'lock the hGlobal
1786 DF.pFiles = Len(DF) 'set the size of the files
1788 Call CopyMem(ByVal lpGlobal, DF, Len(DF)) 'copy df to the lpglobal
1789 Call CopyMem(ByVal (lpGlobal + Len(DF)), ByVal strFiles, Len(strFiles)) 'copy strfiles to lpglobal
1790 Call GlobalUnlock(hGlobal) 'unlock hglobal again
1792 SetClipboardData CF_HDROP, hGlobal 'put files to the clipboard
1795 bool SaveFile(const char * filePath)
1801 public class FileTreeNodeBSArray : ArrayBinarySorted
1803 type = class(FileSystemNode);
1805 FileSystemNode * const _;
1806 BSloc Add(FileSystemNode item)
1808 BSloc result = Find(item);
1811 Insert(result.pos, 1);
1812 _[result.pos] = item;
1816 BSloc Remove(FileSystemNode item)
1824 public class FileTreeNodeArray : RedjArray
1826 type = class(FileSystemNode);
1828 FileSystemNode * const _;
1829 FileSystemNode * Add(FileSystemNode item)
1836 FileSystemNode * AddBefore(uint position, FileSystemNode item)
1838 Insert(position, 1);
1840 return &_[position];
1846 public class ExplorerFileItem : struct
1857 void OnDisplay(Surface surface, int x, int y, int width, FileSystemBox control, Alignment alignment, DataDisplayFlags displayFlags)
1859 int indentSize = (displayFlags.dropBox) ? 0 : 10;
1862 char label[MAX_FILENAME];
1864 //float scale = Min((float)clientSize.w / (float)bitmap.width, (float)clientSize.h / (float)bitmap.height);
1865 int w = 16; //(int)(bitmap.width * scale);
1866 int h = 16; //(int)(bitmap.height * scale);
1870 icon = control.fileIcons[type].bitmap;
1873 if(type == folder || type == folderOpen)
1874 surface.SetForeground(red); //Color { 170, 170, 0 } // REDJ What is that color?
1877 textOffset = indent * indentSize + (icon ? (icon.width + 6) : 0);
1880 sprintf(label, "%s [%s]", name, info);
1882 strcpy(label, name);
1883 len = strlen(label);
1885 surface.WriteTextDots
1886 (alignment, x + textOffset, y + 2, width - textOffset, label, len);
1887 if(type == pictureFile && control.previewPictures && bitmap)
1890 //surface.Filter(bitmap, (clientSize.w - w) / 2,(clientSize.h - h) / 2, 0,0, w, h, bitmap.width, bitmap.height);
1891 surface.Filter(bitmap, x + indent * indentSize + 2, y, 0, 0, w, h, bitmap.width, bitmap.height);
1893 // Until Filter / Stretch works with X
1894 //surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2,(clientSize.h - bitmap.height) / 2, 0,0, bitmap.width, bitmap.height);
1895 surface.blend = true;
1896 surface.Blit(bitmap, x + indent * indentSize + 2, y,0,0, w, h);
1902 surface.Blit(icon, x + indent * indentSize + 2, y,0,0, icon.width, icon.height);
1905 int OnCompare(ExplorerFileItem b)
1908 if(type == b.type || (type < folder && b.type < folder) || (type >= drive))
1909 result = strcmpi(name, b.name);
1912 if(type == folder && b.type < folder) result = -1;
1913 else if(type < folder && b.type == folder) result = 1;
1918 void OnCopy(ExplorerFileItem newData)
1920 type = newData.type;
1921 indent = newData.indent;
1924 int len = strlen(newData.name) + 1;
1925 name = new char[len];
1926 CopyBytes(name, newData.name, len);
1930 bool OnGetDataFromString(char * string)
1932 int len = strlen(string) + 1;
1933 name = new char[len];
1934 CopyBytes(name, string, len);
1948 char * OnGetString(char * string, void * fieldData, bool * needClass)
1954 public class ExplorerFileItemArray : RedjArray
1956 type = class(ExplorerFileItem);
1958 ExplorerFileItem * const _;
1959 ExplorerFileItem * Add(ExplorerFileItem item)
1966 ExplorerFileItem * AddBefore(uint position, ExplorerFileItem item)
1968 Insert(position, 1);
1970 return &_[position];
1975 for(c = 0; c < _count; c++)
1985 ExplorerFileItem MakeFileItem(const FileAttribs attribs, const char * fileName, const char * filePath, const bool previewPicture, const DisplaySystem displaySystem)
1987 int len = strlen(fileName);
1988 char info[MAX_LOCATION];
1989 char name[MAX_LOCATION];
1990 char extension[MAX_EXTENSION];
1992 ExplorerFileItem item { };
1994 //if(stats.attribs.isFile) // -- should work now
1995 if(attribs.isDirectory)
1999 item.type = (attribs.isDrive) ? drive : folder;
2000 if(attribs.isServer)
2006 if(attribs.isRemote)
2007 item.type = netDrive;
2008 if(attribs.isRemovable)
2010 if(fileName[0] == 'A' || fileName[0] == 'B')
2013 item.type = removable;
2018 GetExtension(fileName, extension);
2019 //strupr(extension);
2022 item.type = _FileType::SelectByExtension(extension);
2025 if(attribs.isDrive &&
2026 len > 3 && !strncmp(&fileName[1], ": [", 3))
2028 strncpy(name, fileName, 2);
2030 strncpy(info, &fileName[4], len - 5);
2035 strcpy(name, fileName);
2039 item.path = CopyString(filePath);
2040 item.name = CopyString(name);
2042 item.info = CopyString(info);
2043 item.extension = CopyString(extension);
2045 if(item.type == pictureFile && previewPicture)
2047 item.bitmap = Bitmap { };
2048 item.bitmap.Load(filePath, null, displaySystem);
2056 public class FileSystemBoxSelection
2059 FileSystemNode node;
2060 Array<FileSystemNode> nodes { };
2063 FileSystemBoxSelection Copy()
2065 FileSystemBoxSelection copy { node = node };
2068 copy.nodes.Add(node);
2074 ~FileSystemBoxSelection()
2080 class FileSystemNodeBits
2082 bool loaded:1, childrenLoaded:1, displayPath:1;
2085 public class FileSystemNode
2089 FileSystemNodeBits bits;
2102 /*//LinkElement<FileSystemNode> link;
2103 FileSystemNode parent;
2105 FileSystemNodeType type;
2109 FileSystemNode prev, next;
2113 property char * path
2115 set { delete path; if(value && value[0]) path = CopyString(value); }
2116 get { return path; } isset { return path && path[0]; }
2118 property char * name
2120 set { delete name; if(value && value[0]) name = CopyString(value); }
2121 get { return name; } isset { return name && name[0]; }
2123 property char * extension
2125 set { delete extension; if(value && value[0]) extension = CopyString(value); }
2126 get { return extension; } isset { return extension && extension[0]; }
2128 property char * label
2130 set { delete label; if(value && value[0]) label = CopyString(value); }
2131 get { return label; } isset { return label && label[0]; }
2133 property char * info
2135 set { delete info; if(value && value[0]) info = CopyString(value); }
2136 get { return info; } isset { return info && info[0]; }
2142 FileSystemNode parent;
2148 void GetPath(String outputPath)
2151 strcpy(outputPath, path);
2156 strcpy(outputPath, name);
2157 for(up = parent; up; up = up.parent)
2159 char temp[MAX_LOCATION];
2160 strcpy(temp, up.name);
2161 PathCat(temp, outputPath);
2162 strcpy(outputPath, temp);
2167 strcpy(outputPath, "/");
2169 //strcpy(outputPath, name);
2170 strcpy(outputPath, path);
2171 PathCat(outputPath, name);
2177 bool IsChildOf(FileSystemNode node)
2179 FileSystemNode test;
2180 for(test = parent; test; test = test.parent)
2186 void DuplicateChildren(bool recursive, bool forceExpanded, FileSystemNode addTo, FileSystemBox fsb)
2190 FileSystemNode child;
2192 for(child = children.first; child; child = child.next)
2194 FileSystemNode copy { };
2195 copy.name = child.name; //CopyString(child.name);
2196 copy.type = child.type;
2197 fsb.AddTreeNode(copy, child.bits.loaded, false, addTo);
2199 copy.row.collapsed = false;
2201 child.DuplicateChildren(recursive, forceExpanded, copy, fsb);
2206 void EnsureVisible(bool expand)
2209 parent.EnsureVisible(true);
2211 row.collapsed = false;
2212 // TODO: row.EnsureVisible(); // making the row visible by scrolling
2222 FileSystemNode child;
2223 for(; (child = children.first); )
2226 children.Delete(child);
2240 parent.children.Delete(this);
2243 void OnDisplay(Surface surface, int x, int y, int width, FileSystemBox fsb, Alignment alignment, DataDisplayFlags displayFlags)
2245 //int indentSize = (displayFlags.dropBox) ? 0 : 10;
2251 char string[MAX_FILENAME];
2258 icon = fsb.fileIcons[type].bitmap;
2259 //xStart = indent * indent + x + (icon ? (icon.width + 5) : 0);
2260 xStart = x + (icon ? (icon.width + 5) : 0);
2266 sprintf(string, "%s [%s]", label ? label : name, info);
2268 strcpy(string, label ? label : name);
2269 len = strlen(string);
2273 if(type == folder || type == folderOpen)
2274 surface.SetForeground(yellow);
2278 //textOffset = indent * indentSize + (icon ? (icon.width + 4) : 0);
2280 surface.SetForeground(displayFlags.selected ? fsb.selectionText : fsb.foreground);
2281 surface.TextOpacity(false);
2282 surface.TextExtent(string, len, &w, &h);
2285 // Draw the current row stipple
2286 if(displayFlags.selected)
2287 //surface.Area(xStart - 1, y, xStart - 1, y + h - 1);
2288 //surface.Area(xStart + w - 1, y, xStart + w + 1, y + h - 1);
2289 surface.Area(xStart - 3, y, xStart + w + 1, y + h - 1);
2291 //surface.WriteTextDots(alignment, x + textOffset, y + 2, width - textOffset, name, strlen(name));
2292 surface.WriteTextDots(alignment, xStart, y + 2, width, string, len);
2294 if(!guiApp.textMode)
2296 if(displayFlags.current)
2298 if(displayFlags.active)
2300 surface.LineStipple(0x5555);
2301 if(displayFlags.selected)
2302 surface.SetForeground(0xFFFFFF80);
2304 surface.SetForeground(black);
2308 surface.SetForeground(selectionColor);
2310 surface.Rectangle(xStart - 3, y, xStart + w + 1, y + h - 1);
2311 surface.LineStipple(0);
2319 if(type == pictureFile && fsb.previewPictures && bitmap)
2321 surface.SetForeground(white);
2322 surface.blend = true;
2324 //surface.Filter(bitmap, (clientSize.w - w) / 2,(clientSize.h - h) / 2, 0,0, w, h, bitmap.width, bitmap.height);
2325 //surface.Filter(bitmap, x + indent/* * indentSize*/ + 2, y, 0, 0, w, h, bitmap.width, bitmap.height);
2326 surface.Filter(bitmap, x,y,0,0, w, h, bitmap.width, bitmap.height);
2328 // Until Filter / Stretch works with X
2329 //surface.Blit(bitmap, (clientSize.w - bitmap.width) / 2,(clientSize.h - bitmap.height) / 2, 0,0, bitmap.width, bitmap.height);
2330 // surface.blend = true;
2331 //surface.Blit(bitmap, x + indent/* * indentSize*/ + 2, y,0,0, w, h);
2332 //surface.Blit(bitmap, x,y,0,0, bitmap.width, bitmap.height);
2339 //surface.blend = true;
2340 //surface.alphaWrite = blend;
2341 surface.SetForeground(white);
2342 //surface.Blit(icon, x + indent * indentSize, y,0,0, icon.width, icon.height);
2343 surface.Blit(icon, x,y,0,0, icon.width, icon.height);
2348 int OnCompare(FileSystemNode b)
2351 FileSystemNode a = this;
2352 if(a.type == b.type || (a.type < folder && b.type < folder) || (a.type >= drive))
2353 result = strcmpi(a.name, b.name);
2356 if(a.type == folder && b.type < folder) result = -1;
2357 else if(a.type < folder && b.type == folder) result = 1;
2363 /*int OnCompare(FileSystemNode b)
2366 FileSystemNode a = this;
2367 if(a.parent < b.parent) result = -1;
2368 else if(a.parent > b.parent) result = 1;
2370 result = fstrcmp(a.name, b.name);
2374 char * OnGetString(char * tempString, FileSystemToolWindow fileSysToolWnd, bool * needClass)
2376 return name ? name : "";
2380 /*FileSystemNode MakeFileSystemNode(const FileStats stats, const char * name)
2382 FileSystemNode node { stats = stats };
2383 node.name = CopyString(name);
2386 if(stats.attribs.isDirectory)
2388 node.type = (stats.attribs.isDrive) ? drive : folder;
2389 if(stats.attribs.isServer) node.type = server;
2390 if(stats.attribs.isShare) node.type = share;
2391 if(stats.attribs.isCDROM) node.type = cdrom;
2392 if(stats.attribs.isRemote) node.type = netDrive;
2393 if(stats.attribs.isRemovable)
2395 if(name[0] == 'A' || name[0] == 'B')
2398 node.type = removable;
2403 char extension[MAX_EXTENSION];
2404 GetExtension(node.name, extension);
2405 node.type = _FileType::SelectByExtension(extension);
2410 FileSystemNode MakeFileSystemNode(
2411 const FileStats stats,
2414 const bool pathAddName,
2415 const bool previewPicture,
2416 const DisplaySystem displaySystem)
2418 int len = strlen(name);
2419 char info[MAX_LOCATION];
2420 char name2[MAX_LOCATION];
2421 char extension[MAX_EXTENSION];
2423 FileSystemNode node { stats = stats };
2427 char o[MAX_LOCATION];
2428 //char r[MAX_LOCATION];
2429 //StripLastDirectory(path, o);
2430 GetLastDirectory(path, o);
2431 if(fstrcmp(name, o))
2432 //if(!FileExists(path))
2435 //if(stats.attribs.isFile) // TODO fix this in ecere -- WTH -- this has been fixed :/
2436 if(stats.attribs.isDirectory)
2438 extension[0] = '\0';
2440 node.type = (stats.attribs.isDrive) ? drive : folder;
2441 if(stats.attribs.isServer) node.type = server;
2442 if(stats.attribs.isShare) node.type = share;
2443 if(stats.attribs.isCDROM) node.type = cdrom;
2444 if(stats.attribs.isRemote) node.type = netDrive;
2445 if(stats.attribs.isRemovable)
2447 if(name[0] == 'A' || name[0] == 'B')
2450 node.type = removable;
2455 GetExtension(name, extension);
2458 node.type = _FileType::SelectByExtension(extension);
2461 if(stats.attribs.isDrive &&
2462 len > 3 && !strncmp(&name[1], ": [", 3))
2464 strncpy(name2, name, 2);
2466 strncpy(info, &name[4], len - 5);
2471 strcpy(name2, name);
2477 bool isFile = stats.attribs.isFile;
2478 bool isFolder = stats.attribs.isDirectory;
2479 char full[MAX_LOCATION];
2481 PathCat(full, name);
2482 node.path = full; //CopyString(full);
2485 node.path = path; //CopyString(path);
2486 node.name = name2; //CopyString(name2);
2488 node.info = info; //CopyString(info);
2489 node.extension = extension; //CopyString(extension);
2491 if(node.type == pictureFile && previewPicture)
2493 node.bitmap = Bitmap { alphaBlend = true };
2494 node.bitmap.Load(path, null, displaySystem);