+ virtual void Load(FileSystemNode parent);
+ virtual void Refresh();
+
+ virtual void LaunchNotifyItemSelect(Window master, ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
+ {
+ view.NotifyItemSelect(master, view, item, selectedItems);
+ }
+
+ virtual bool Window::NotifyItemSelect(ExplorerView view, ExplorerFileItem item, ExplorerFileItemArray selectedItems);
+ virtual bool Window::NotifyItemOpen(ExplorerView view, ExplorerFileItem item);
+
+ ListBox list
+ {
+ master = master, parent = this;
+ //this, master;
+ borderStyle = none;
+ hasHorzScroll = true;
+ hasVertScroll = true;
+ resizable = true;
+ sortable = true;
+ fullRowSelect = false;
+ multiSelect = true;
+
+ anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
+
+ bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
+ {
+ ExplorerView view = (ExplorerView)listBox.parent;
+ if(listBox.currentRow)
+ {
+ DataRow listRow;
+ ExplorerFileItemArray selectedItems { growingFactor = 16 };
+ for(listRow = listBox.firstRow; listRow; listRow = listRow.next)
+ if(listRow.selected)
+ selectedItems.Add((ExplorerFileItem)listRow.tag);
+ //view.NotifyItemSelect(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
+ view.LaunchNotifyItemSelect(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag, selectedItems);
+ }
+ return true;
+ }
+
+ bool NotifyDoubleClick(ListBox listBox, int x, int y, Modifiers mods)
+ {
+ ExplorerView view = (ExplorerView)listBox.parent;
+ view.NotifyItemOpen(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
+ return false;
+ }
+
+ bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
+ {
+ if((SmartKey)key == enter)
+ {
+ ExplorerView view = (ExplorerView)listBox.parent;
+ view.NotifyItemOpen(listBox.parent.master, view, (ExplorerFileItem)listBox.currentRow.tag);
+ }
+ return true;
+ }
+ };
+
+ ExplorerView()
+ {
+ }
+}
+#endif
+
+#if 0
+class ExplorerViewList : ExplorerView
+{
+
+ FileSystemNode location;
+
+public:
+
+ DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
+
+ ExplorerViewDetails()
+ {
+ list.AddField(nameField);
+ }
+
+ void Refresh()
+ {
+ Load(location);
+ }
+
+ void Load(FileSystemNode location)
+ {
+ char path[MAX_LOCATION];
+ this.location = location;
+ location.GetPath(path);
+ {
+ FileListing listing { path };
+
+ ExplorerFileItem item;
+ DataRow row;
+
+ list.Clear();
+
+ while(listing.Find())
+ {
+ item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
+
+ row = list.AddRow();
+ row.tag = (int)item;
+ row.SetData(nameField, item);
+ }
+ list.Sort(nameField, 1);
+ }
+ }
+}
+#endif
+
+#if 0
+class ExplorerViewDetails : ExplorerView
+{
+ list.hasHeader = true;
+ list.moveFields = true;
+ list.resizable = true;
+ list.sortable = true;
+
+ FileSystemNode location;
+
+public:
+
+ DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
+ DataField typeField { header = "Type", dataType = /-*"String"*-/ "char *", width = 40 };
+ DataField sizeField { header = "Size", dataType = "FileSize", width = 96, alignment = right };
+
+ ExplorerViewDetails()
+ {
+ list.AddField(nameField);
+ list.AddField(typeField);
+ list.AddField(sizeField);
+ }
+
+ void Refresh()
+ {
+ Load(location);
+ }
+
+ void Load(FileSystemNode location)
+ {
+ char path[MAX_LOCATION];
+ this.location = location;
+ location.GetPath(path);
+ {
+ FileListing listing { path };
+
+ ExplorerFileItem item;
+ DataRow row;
+
+ list.Clear();
+
+ while(listing.Find())
+ {
+ item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
+
+ row = list.AddRow();
+ row.tag = (int)item;
+ row.SetData(nameField, item);
+ row.SetData(typeField, CopyString(item.extension));
+ row.SetData(sizeField, (uint)listing.stats.size);
+ }
+ list.Sort(nameField, 1);
+ }
+ }
+}
+#endif
+
+#if 0
+class ExplorerViewIcons : ExplorerView
+{
+
+ FileSystemNode location;
+
+public:
+
+ DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
+
+ ExplorerViewDetails()
+ {
+ list.AddField(nameField);
+ }
+
+ void Refresh()
+ {
+ Load(location);
+ }
+
+ void Load(FileSystemNode location)
+ {
+ char path[MAX_LOCATION];
+ this.location = location;
+ location.GetPath(path);
+ {
+ FileListing listing { path };
+
+ ExplorerFileItem item;
+ DataRow row;
+
+ list.Clear();
+
+ while(listing.Find())
+ {
+ item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
+
+ row = list.AddRow();
+ row.tag = (int)item;
+ row.SetData(nameField, item);
+ }
+ list.Sort(nameField, 1);
+ }
+ }
+}
+#endif
+
+#if 0
+class ExplorerViewCards : ExplorerView
+{
+
+ FileSystemNode location;
+
+public:
+
+ DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 304, editable = true, userData = this };
+
+ ExplorerViewDetails()
+ {
+ list.AddField(nameField);
+ }
+
+ void Refresh()
+ {
+ Load(location);
+ }
+
+ void Load(FileSystemNode location)
+ {
+ char path[MAX_LOCATION];
+ this.location = location;
+ location.GetPath(path);
+ {
+ FileListing listing { path };
+
+ ExplorerFileItem item;
+ DataRow row;
+
+ list.Clear();
+
+ while(listing.Find())
+ {
+ item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
+
+ row = list.AddRow();
+ row.tag = (int)item;
+ row.SetData(nameField, item);
+ }
+ list.Sort(nameField, 1);
+ }
+ }
+}
+#endif
+
+#if 0
+public class BitmapArray : RedjArray
+{
+ type = class(Bitmap);
+public:
+ Bitmap * const _;
+ Bitmap * Add(Bitmap bitmap)
+ {
+ uint pos = _count;
+ Append(1);
+ _[pos] = bitmap;
+ return &_[pos];
+ }
+ Bitmap * AddBefore(uint position, Bitmap bitmap)
+ {
+ Insert(position, 1);
+ _[position] = bitmap;
+ return &_[position];
+ }
+ void Clear()
+ {
+ int c;
+ for(c = 0; c < _count; c++)
+ {
+ _[c].Free();
+ delete _[c];
+ }
+ count = 0;
+ size = 0;
+ }
+}
+#endif
+
+#if 0
+class ExplorerViewShowcase : ExplorerView
+{
+ list.anchor = Anchor { left = 0, top = 0, bottom = 0 };
+ list.size = Size { w = 200 };
+
+ FileSystemNode location;
+
+public:
+
+ DataField nameField { header = "Name", dataType = "ExplorerFileItem", width = 180, editable = true, userData = this };
+
+ Bitmap bitmap;
+ BitmapArray bitmaps { growingFactor = 16 };
+
+ Window show
+ {
+ this;
+ borderStyle = none;
+ anchor = Anchor { top = 0, right = 0, bottom = 0 };
+
+ void OnRedraw(Surface surface)
+ {
+ ExplorerViewShowcase view = (ExplorerViewShowcase)parent;
+ if(view.bitmap)
+ {
+ int wBmp = view.bitmap.width;
+ int hBmp = view.bitmap.height;
+ int wWnd = clientSize.w;
+ int hWnd = clientSize.h;
+
+ int wList = view.list.size.w + view.split.size.w;
+
+ float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
+
+ int wDraw = (int)(wBmp * scale);
+ int hDraw = (int)(hBmp * scale);
+
+ #ifndef __linux__
+ surface.Filter(view.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
+ #else
+ // Until Filter / Stretch works with X
+ surface.Blit(view.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw);
+ #endif
+ }
+ else
+ {
+ surface.SetForeground(white);
+ surface.Area(0, 0, view.clientSize.w - 1, view.clientSize.h - 1);
+ }
+ }
+ }
+
+ SplitWindow split
+ {
+ this;
+ leftPane = list;
+ rightPane = show;
+ split = 200;
+ tabCycle = true;
+ };
+
+ ExplorerViewDetails()
+ {
+ list.AddField(nameField);
+ }
+
+ void LaunchNotifyItemSelect(Window master, ExplorerViewShowcase view, ExplorerFileItem item, ExplorerFileItemArray selectedItems)
+ {
+ int pos;
+ ExplorerFileItem selItem;
+ if(view.bitmap)
+ view.bitmap.Free();
+ delete view.bitmap;
+ if(item && item.type == pictureFile)
+ {
+ view.bitmap = Bitmap { };
+ view.bitmap.Load(item.path, null, displaySystem);
+ }
+
+ view.bitmaps.Clear();
+ view.bitmaps = BitmapArray { };
+ for(pos = 0; pos < selectedItems.count; pos++)
+ {
+ Bitmap bitmap { };
+ selItem = (ExplorerFileItem)selectedItems._[pos];
+ bitmap.Load(selItem.path, null, displaySystem);
+ //view.bitmaps.Add(bitmap);
+ }
+ if(item && item.type == pictureFile)
+ {
+ view.bitmap = Bitmap { };
+ view.bitmap.Load(item.path, null, displaySystem);
+ }
+
+ view.show.Update(null);
+ view.NotifyItemSelect(master, view, item, selectedItems);
+ }
+
+ void Refresh()
+ {
+ Load(location);
+ }
+
+ void Load(FileSystemNode location)
+ {
+ char path[MAX_LOCATION];
+ this.location = location;
+ location.GetPath(path);
+ {
+ FileListing listing { path };
+
+ ExplorerFileItem item;
+ DataRow row;
+
+ list.Clear();
+
+ while(listing.Find())
+ {
+ item = MakeFileItem(listing.stats.attribs, listing.name, listing.path, previewPictures, displaySystem);
+
+ row = list.AddRow();
+ row.tag = (int)item;
+ row.SetData(nameField, item);
+ }
+ list.Sort(nameField, 1);
+ }
+ }
+}
+#endif
+
+#if 0
+class ExplorerTree : FileSystemBox
+{
+ hasHorzScroll = false;
+ hasVertScroll = false;
+
+ menu = Menu { };
+
+public:
+
+ DataField nameField { dataType = "FileSystemNode", width = 240, userData = this };
+
+ FileSystemNode root;
+ FileSystemNode selection;
+
+ virtual bool Window::NotifyNodeSelect(ExplorerTree tree, FileSystemNode node);
+
+ property FileSystemNode node
+ {
+ get
+ {
+ if(!tree)
+ return null;
+ if(!tree.currentRow)
+ return null;
+ if(!tree.currentRow.tag)
+ return null;
+ return (FileSystemNode)tree.currentRow.tag;
+ }
+ }
+
+ void Select(FileSystemNode node)
+ {
+ if(node.row)
+ {
+ node.EnsureVisible(false);
+ tree.SelectRow(node.row);
+ }
+ }
+
+ FileSystemNode Find(const char * name, FileSystemNode parent)
+ {
+ FileSystemNode node;
+ FileSystemNode start = parent ? parent : root;
+ if(!start.loaded || !start.childrenLoaded)
+ LoadTreeNode(start, tree);
+ for(node = start.children.first; node; node = node.next)
+ if(node.name && !strcmpi(node.name, name))
+ return node;
+ return null;
+ }
+
+ ListBox tree
+ {
+ master = master, parent = this;
+ //this, master;
+ borderStyle = none;
+ hasHorzScroll = true;
+ hasVertScroll = true;
+ fullRowSelect = false;
+ treeNodees = true;
+ collapseControl = true;
+ rootCollapseButton = true;
+
+ anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
+
+ // WHY is this not working ?
+ /-*void OnResize(int width, int height)
+ {
+ if(vertScroll.visible)
+ nameField.width = width - vertScroll.size.w;
+ else
+ nameField.width = width;
+ }*-/
+
+ bool NotifyCollapse(ListBox listBox, DataRow row, bool collapsed)
+ {
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ FileSystemNode child;
+ if(collapsed)
+ {
+ /-*
+ for(child = node.children.last; child; child = node.children.last)
+ {
+ listBox.DeleteRow(child.row);
+ child.Free();
+ delete child;
+ }
+ node.childrenLoaded = false;
+ *-/
+ }
+ else
+ {
+ if(!node.loaded || !node.childrenLoaded)
+ LoadTreeNode(node, tree);
+ for(child = node.children.first; child && child.next; child = child.next);
+ if(child)
+ child.EnsureVisible(false);
+ }
+ }
+ return true;
+ }
+
+ bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
+ {
+ DataRow row = listBox.currentRow;
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ if(node)
+ {
+ PopupMenu popup;
+ Menu menu { };
+
+ MenuItem { menu, "Cut\tCtrl+X", t, NotifySelect = null, disabled = false };
+ MenuItem { menu, "Copy\tCtrl+C", c, NotifySelect = null, disabled = false };
+ MenuItem { menu, "Paste\tCtrl+V", p, NotifySelect = null, disabled = false /-*!clipboard*-/ };
+ MenuItem { menu, "Delete\tDel", d, NotifySelect = null, disabled = false };
+ //MenuDivider { menu };
+
+ popup = PopupMenu
+ {
+ master = this, menu = menu,
+ position = {
+ x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
+ y + clientStart.y + absPosition.y - guiApp.desktop.position.y }
+ };
+ popup.Create();
+ }
+ }
+ return true;
+ }
+
+ bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
+ {
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ NotifyNodeSelect(listBox.parent.master, this, node);
+ selection = node;
+ }
+ return true;
+ }
+
+ bool NotifyEditing(ListBox listBox, DataRow row)
+ {
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ }
+ return true;
+ }
+
+ bool NotifyEdited(ListBox listBox, DataRow row)
+ {
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ }
+ return true;
+ }
+
+ bool NotifyEditDone(ListBox listBox, DataRow row)
+ {
+ if(row)
+ {
+ FileSystemNode node = (FileSystemNode)row.tag;
+ }
+ return true;
+ }
+ };
+
+ // Edit Menu
+ Menu editMenu { menu, "Edit", e };
+ MenuItem itemEditCut
+ {
+ editMenu, "Cut\tCtrl+X", t, disabled = true;
+
+ bool NotifySelect(MenuItem selection, Modifiers mods)
+ {
+ //EditCut();
+ return true;
+ }
+ };
+ MenuItem itemEditCopy
+ {
+ editMenu, "Copy\tCtrl+C", c, disabled = true;
+
+ bool NotifySelect(MenuItem selection, Modifiers mods)
+ {
+ //EditCopy();
+ return true;
+ }
+ };
+ MenuItem itemEditPaste
+ {
+ editMenu, "Paste\tCtrl+V", p;
+
+ bool NotifySelect(MenuItem selection, Modifiers mods)
+ {
+ //EditPaste();
+ return true;
+ }
+ };
+ MenuItem itemEditDelete
+ {
+ editMenu, "Delete\tDel", d, disabled = true;
+
+ bool NotifySelect(MenuItem selection, Modifiers mods)
+ {
+ //EditDelete();
+ return true;
+ }
+ };
+
+ // WHY is this crashing ?
+ /-*void OnResize(int width, int height)
+ {
+ if(this && nameField)
+ nameField.width = width - 80;
+ }*-/
+
+ ExplorerTree()
+ {
+ tree.AddField(nameField);
+ }
+
+ void Load()
+ {
+ FileSystemNode parent;
+ FileSystemNode node;
+ FileListing listing { "/" };
+
+ tree.Clear();
+
+ root = FileSystemNode { type = computer, loaded = true, childrenLoaded = true };
+ #ifdef __WIN32__
+ root.name = rootName;
+ #else
+ root.name = "/";
+ #endif
+ AddTreeNode(root, true, false, null, tree);
+
+ // How can this make sense for linux?
+ #ifdef __WIN32__
+ while(listing.Find())
+ {
+ int len = strlen(listing.name);
+ char info[MAX_LOCATION];
+ char name[MAX_LOCATION];
+ if(listing.stats.attribs.isDrive &&
+ len > 3 && !strncmp(&listing.name[1], ": [", 3))
+ {
+ strncpy(name, listing.name, 2);
+ name[2] = 0;
+ strncpy(info, &listing.name[4], len - 5);
+ info[len - 5] = 0;
+ }
+ else
+ {
+ strcpy(name, listing.name);
+ info[0] = 0;
+ }
+
+ parent = MakeFileSystemNode(listing.stats, name);
+ if(info[0])
+ parent.info = CopyString(info);
+ parent.loaded = true;
+ AddTreeNode(parent, !listing.stats.attribs.isDirectory, listing.stats.attribs.isDirectory, root, tree);
+ if(!listing.stats.attribs.isDirectory)
+ parent.childrenLoaded = true;
+ }
+ #endif
+ node = FileSystemNode { name = msNetwork, type = network };
+ AddTreeNode(node, false, true, null, tree);
+ node.row.collapsed = true;
+ tree.Sort(nameField, 1);
+ tree.SelectRow(root.row);
+ }
+}
+
+#if 0
+public class ClipBoardFiles
+{
+
+public: