searchInSubDirs, searchStart, searchStop,
hasHeader
};
-static char * iconNames[Icon::enumSize] =
+static const char * iconNames[Icon::enumSize] =
{
"<:ecere>emblems/unreadable.png", /* missing */
int treeSplit;
int searchSplit;
-
+
ExplorerToolId lastViewId;
*/
menu = Menu { };
-
+
Menu fileMenu { menu, "File", f };
Menu windowMenu { menu, "Window", w };
MenuItem itemNewWindow { windowMenu, "New Window", n, NotifySelect = NewWindow_NotifySelect };
IconToolButton goUp { toolBar, this, icon = goUp, hotKey = { up, alt = true }, toolTip = "Go to Parent Folder";
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- char * path = view.path;
+ const char * path = view.path;
char * newPath = new char[strlen(path)+1];
StripLastDirectory(path, newPath);
if(!newPath[0])
ToggleIconToolButton viewDetails { toolBar, this, icon = viewDetails, toolTip = "Toggle Listing Details";
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
- view.details = true;
+ view.details = button.checked;
view.treeBranches = false;
view.Refresh();
view.Activate();
{
//((FileSystemCacheIterator)fileSystemIterator).cache = testCache;
//((FileSystemIterator)fileSystemIterator)
+ return true;
}
bool NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection)
//PrintLn(node.name);
if(box.selection.nodes.count == 1)
- itemString = node.name;
+ itemString = CopyString(node.name);
else
itemString = PrintString(box.selection.nodes.count, " items");
text = PrintString("Open ", itemString);
if(CreateNewFileDialog { /*master = */ew/*, parent = parent*/, currentDirectory = selection ? ew.view.selection.node.path : ew.view.path }.Modal() == ok )
ew.Refresh();
}
+ return true;
}
//void NewFolder()
if(CreateDirectoryDialog { /*master = */ew/*, parent = parent*/, currentDirectory = selection ? ew.view.selection.node.path : ew.view.path }.Modal() == ok )
ew.Refresh();
}
+ return true;
}
//void GoTo(char * location/*, bool viewIsAtLocation, bool treeIsAtLocation*/)
- property char * location
+ property const char * location
{
set
{
void UpdateHistoryItem(FileSystemBoxSelection selection)
{
- HistoryItem item = history[historyIndex];
-
- if(!item.holdRecordingSelection)
+ if(history.count > historyIndex) // TODO: Review why this would happen...
{
- if(selection.node || (selection.nodes && selection.nodes.count))
+ HistoryItem item = history[historyIndex];
+
+ if(!item.holdRecordingSelection)
{
- item.selection.Free();
- if(selection.nodes.count)
+ if(selection.node || (selection.nodes && selection.nodes.count))
{
- for(node : selection.nodes)
- item.selection.Add(CopyString(node.path));
+ item.selection.Free();
+ if(selection.nodes.count)
+ {
+ for(node : selection.nodes)
+ item.selection.Add(CopyString(node.path));
+ }
+ else if(selection.node)
+ item.selection.Add(CopyString(selection.node.path));
}
- else if(selection.node)
- item.selection.Add(CopyString(selection.node.path));
}
+ else
+ item.holdRecordingSelection = false;
}
- else
- item.holdRecordingSelection = false;
}
void SearchStart()
}
return true;
}*/
-
+
/*bool ViewNotifyItemOpen(ExplorerView view, ExplorerFileItem item)
{
ExplorerFileBranch branch = tree.branch;
if(item.type.isFolderType)
{
ExplorerFileBranch child;
-
+
if(!branch.loaded || !branch.childrenLoaded)
BranchLoad(branch, tree.tree);
for(child = branch.children.first; child; child = child.next)
if(!strcmp(child.name, item.name))
break;
-
+
if(child)
{
if(branch.row.collapsed)
//userMode = true;
addressBar.path = view.path;
ReadyTree();
+ view.Refresh();
return true;
}
NotifyItemOpen = ViewNotifyItemOpen;
};
lastViewId = viewList;
-
+
tree.Load();
view.Load(tree.root);
}*/
#ifdef __WIN32__
static char * rootName = "Entire Computer";
-static char * msNetwork = "Microsoft Windows Network";
+static const char * msNetwork = "Microsoft Windows Network";
#else
-static char * rootName = "File System";
+static const char * rootName = "File System";
#endif
private:
define guiApp = (GuiApplication)((__thisModule).application);
define selectionColor = guiApp.currentSkin.selectionColor; //Color { 10, 36, 106 };
-void MessageBoxTodo(char * message)
+void MessageBoxTodo(const char * message)
{
PrintLn("MessageBoxTodo(char * message) -- ", message);
MessageBox { type = ok, text = "MessageBoxTodo(char * message)", contents = message }.Modal();
}
-static char * fileIconNames[] =
+static const char * fileIconNames[] =
{
"<:ecere>mimeTypes/file.png", /* none */
"<:ecere>mimeTypes/package.png", /* treeLoader */
"<:ecere>places/startHere.png", /* lineNumbers */
-
+
""
};
define countOfCompIconNames = 6;
-static char * compIconNames[] =
+static const char * compIconNames[] =
{
/*
"<:ede>a.png",
public enum _FileType
{
none,
-
+
normalFile, ewsFile, epjFile, ecFile, ehFile, cFile, hFile, cppFile, hppFile,
textFile, webFile, pictureFile, soundFile,
archiveFile, packageFile, opticalMediaImageFile, /* these (all previous) are sort equal */
-
+
folder, folderOpen, computer,
drive, netDrive, cdrom, removable, floppy, network, server, share, // these are sort equal
-
+
// utilities
treeLoader,
lineNumbers;
- /*property char *
+ /*property char *
{
set
{
virtual bool Window::NotifyNodeOpen(FileSystemBox box, FileSystemBoxSelection selection);
virtual bool Window::NotifyNodeMenu(FileSystemBox box, Menu menu, FileSystemBoxSelection selection);
virtual bool Window::NotifyIteratorInit(FileSystemBox box, FileSystemIterator fileSystemIterator);
-
- property char * path
+
+ property const char * path
{
set
{
{
set
{
- delete comparedPaths;
+ if(comparedPaths)
+ {
+ comparedPaths.Free();
+ delete comparedPaths;
+ }
if(value && value.count)
comparedPaths = value;
if(locationBox)
split.leftPane = value ? list : null;
split.visible = value;
show.visible = value;
+ if(!value)
+ {
+ list.parent = this;
+ list.anchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
+ }
}
get { return bits.preview; }
};
property bool columnsCompareStyle { set { bits.columnsCompareStyle = value; } get { return bits.columnsCompareStyle; } };
property bool textFileLinesStyle { set { bits.textFileLinesStyle = value; } get { return bits.textFileLinesStyle; } };
-
+
property FileSystemNode node
{
get
delete map;
}
- FileSystemNode SelectLocation(char * location)
+ FileSystemNode SelectLocation(const char * location)
{
int c;
char * temp;
for(c = steps.count - 1; c >= 0; c--)
{
- char * t = steps[c];
+ //char * t = steps[c];
node = Find(steps[c], node);
if(!node)
break;
bool MenuOpen(MenuItem selection, Modifiers mods)
{
OpenNode();
+ return true;
}
bool MenuReplaceListItemByContainingDir(MenuItem selection, Modifiers mods)
FileSystemBox()
{
- path = CopyString("");
+ char wd[MAX_LOCATION];
+ GetWorkingDir(wd, sizeof(wd));
+ property::path = wd;
+
InitFileIcons();
InitCompIcons(); // todo: these icons should not be initialize, they should be set
// or at least initalized when the comparison listing is requested
~FileSystemBox()
{
+ if(comparedPaths)
+ {
+ comparedPaths.Free();
+ delete comparedPaths;
+ }
delete extensions;
delete path;
}
}
return true;
}
-
+
bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
{
DataRow row = listBox.currentRow;
popup = PopupMenu
{
master = this, menu = menu,
- position = {
- x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
+ position = {
+ x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
y + clientStart.y + absPosition.y - guiApp.desktop.position.y }
};
popup.Create();
{
if(row)
{
- FileSystemNode node = (FileSystemNode)row.tag;
+ //FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
{
if(row)
{
- FileSystemNode node = (FileSystemNode)row.tag;
+ //FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
{
if(row)
{
- FileSystemNode node = (FileSystemNode)row.tag;
+ //FileSystemNode node = (FileSystemNode)row.tag;
}
return true;
}
bool NotifyKeyDown(ListBox listBox, DataRow row, Key key, unichar ch)
{
- bool result;
+ //bool result = false;
if((SmartKey)key == enter)
- result = OpenNode();
+ /*result = */OpenNode();
#if 0
else if((SmartKey)key == f2)
- result = RenameNode();
+ /*result = */RenameNode();
#endif
else if((SmartKey)key == f2)
{
FileSystemNode node = selection.node;
node.row.Edit(nameField);
}
- else
- result = true;
+ //else
+ //result = true;
return true;
}
};
int wWnd = fsb.show.clientSize.w;
int hWnd = fsb.show.clientSize.h;
- int wList = 0;//fsb.list.size.w + fsb.split.size.w;
+ //int wList = 0;//fsb.list.size.w + fsb.split.size.w;
- float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
+ //float scale = Min((float)(wWnd - 10) / wBmp, (float)(hWnd - 10) / hBmp);
- int wDraw = (int)(wBmp * scale);
- int hDraw = (int)(hBmp * scale);
+ //int wDraw = (int)(wBmp * scale);
+ //int hDraw = (int)(hBmp * scale);
#ifndef __linux__
surface.Filter(fsb.bitmap, (wWnd - wDraw) / 2, (hWnd - hDraw) / 2, 0, 0, wDraw, hDraw, wBmp, hBmp);
surface.Area(0, 0, fsb.clientSize.w - 1, fsb.clientSize.h - 1);
}
}
- }
+ };
bool OpenNode()
{
MenuItem itemEditPaste
{
editMenu, "Paste\tCtrl+V", p;
-
+
bool NotifySelect(MenuItem selection, Modifiers mods)
{
//EditPaste();
}
};
- // WHY is this crashing ?
+ // WHY is this crashing ?
/*void OnResize(int width, int height)
{
if(this && nameField)
{
bool isRoot = !strcmp(path, "/");
char name[MAX_LOCATION];
- FileSystemNode parent;
- FileSystemNode node;
- FileListing listing { path, extensions = extensions };
+ //FileSystemNode parent;
+ //FileSystemNode node;
+ //FileListing listing { path, extensions = extensions };
if(!isRoot)
GetLastDirectory(path, name);
else
name[0] = '\0';
-
+
/*if(!path)
GetWorkingDir(startPath, sizeof(startPath));
else
strcpy(path, startPath);*/
-
bits.mode = directory;
+ list.Clear();
+
delete root;
#ifdef __WIN32__
if(isRoot)
}
}
- bool ListIterator_OnObject(char * name, char * path, FileStats stats, bool isRootObject)
+ bool ListIterator_OnObject(const char * name, const char * path, FileStats stats, bool isRootObject)
{
ProcessListItem(name, path, stats, false);
return false;
//void ListIterator_OnLeavingDirectory(char * path) { }
- void ProcessListItem(char * name, char * path, FileStats stats, bool isListItem)
+ void ProcessListItem(const char * name, const char * path, FileStats stats, bool isListItem)
{
if((!bits.foldersOnly && !bits.filesOnly) || (bits.foldersOnly && stats.attribs.isDirectory) || (bits.filesOnly && stats.attribs.isFile))
{
FileListing listing { path, extensions = extensions };
while(listing.Find())
{
- char * test;
+ //char * test;
FileSystemNode child = null;
if((!bits.foldersOnly && !bits.filesOnly) ||
(bits.foldersOnly && listing.stats.attribs.isDirectory) ||
(bits.filesOnly && listing.stats.attribs.isFile))
child = MakeAndAddToTreeFileSystemNodeFromFileListing(listing, parent);
if(child)
+ {
added = true;
- test = child.name;
- if(!test)
- PrintLn("error");
+ /*
+ test = child.name;
+ if(!test)
+ PrintLn("error");
+ */
+ }
}
if(!added)
added = true;
void LoadComparedList()
{
- int c, cmp/*, smallest*/, icon;//, equalCount;
+ int c/*, cmp*/ /*, smallest*/, icon;//, equalCount;
int count = comparedPaths ? comparedPaths.count : 0;
//bool allDone = false;
bool not;
void AddNode(FileSystemNode node)
{
DataRow row = list.AddRow();
- row.tag = (int)node;
+ row.tag = (intptr)node;
node.row = row;
incref node;
row.SetData(nameField, node);
(bits.filesOnly && listing.stats.attribs.isFile)))*/
{
bool textFileLinesStyle = false;
- char * test = listing.name;
+ const char * test = listing.name;
if(!test)
PrintLn("error");
result = MakeFileSystemNode(listing.stats, listing.name, listing.path, false, bits.previewPictures, false, displaySystem);
node.indent = addTo.indent + 1;
addTo.children.Add(node);
}
- row.tag = (int)node;
+ row.tag = (intptr)node;
node.row = row;
row.SetData(null, node);
if(bits.pathColumn)
location.GetPath(path);
{
FileListing listing { path };
-
+
ExplorerFileItem item;
DataRow row;
location.GetPath(path);
{
FileListing listing { path };
-
+
ExplorerFileItem item;
DataRow row;
location.GetPath(path);
{
FileListing listing { path };
-
+
ExplorerFileItem item;
DataRow row;
location.GetPath(path);
{
FileListing listing { path };
-
+
ExplorerFileItem item;
DataRow row;
{
_[c].Free();
delete _[c];
- }
+ }
count = 0;
size = 0;
}
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);
for(pos = 0; pos < selectedItems.count; pos++)
{
Bitmap bitmap { };
- selItem = (ExplorerFileItem)selectedItems._[pos];
+ selItem = (ExplorerFileItem)selectedItems._[pos];
bitmap.Load(selItem.path, null, displaySystem);
//view.bitmaps.Add(bitmap);
- }
+ }
if(item && item.type == pictureFile)
{
view.bitmap = Bitmap { };
location.GetPath(path);
{
FileListing listing { path };
-
+
ExplorerFileItem item;
DataRow row;
FileSystemNode selection;
virtual bool Window::NotifyNodeSelect(ExplorerTree tree, FileSystemNode node);
-
+
property FileSystemNode node
{
get
}
return true;
}
-
+
bool NotifyRightClick(ListBox listBox, int x, int y, Modifiers mods)
{
DataRow row = listBox.currentRow;
popup = PopupMenu
{
master = this, menu = menu,
- position = {
- x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
+ position = {
+ x + clientStart.x + absPosition.x - guiApp.desktop.position.x,
y + clientStart.y + absPosition.y - guiApp.desktop.position.y }
};
popup.Create();
MenuItem itemEditPaste
{
editMenu, "Paste\tCtrl+V", p;
-
+
bool NotifySelect(MenuItem selection, Modifiers mods)
{
//EditPaste();
}
};
- // WHY is this crashing ?
+ // WHY is this crashing ?
/-*void OnResize(int width, int height)
{
if(this && nameField)
#endif
AddTreeNode(root, true, false, false, null, tree);
- // How can this make sense for linux?
+ // 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 &&
+ if(listing.stats.attribs.isDrive &&
len > 3 && !strncmp(&listing.name[1], ": [", 3))
{
strncpy(name, listing.name, 2);
ClipBoard clipBoard { };
if(clipBoard.Allocate(size+1))
{
- GetSel(clipBoard.memory, true);
+ GetSel(clipBoard.memory, true);
// Save clipboard
clipBoard.Save();
}
If hGlobal Then 'if the globalalloc worked
lpGlobal = GlobalLock(hGlobal) 'lock the hGlobal
DF.pFiles = Len(DF) 'set the size of the files
-
+
Call CopyMem(ByVal lpGlobal, DF, Len(DF)) 'copy df to the lpglobal
Call CopyMem(ByVal (lpGlobal + Len(DF)), ByVal strFiles, Len(strFiles)) 'copy strfiles to lpglobal
Call GlobalUnlock(hGlobal) 'unlock hglobal again
-
+
SetClipboardData CF_HDROP, hGlobal 'put files to the clipboard
End If
*-/
}
BSloc Remove(FileSystemNode item)
{
-
+
}
}
#endif
//float scale = Min((float)clientSize.w / (float)bitmap.width, (float)clientSize.h / (float)bitmap.height);
int w = 16; //(int)(bitmap.width * scale);
int h = 16; //(int)(bitmap.height * scale);
-
+
Bitmap icon;
icon = control.fileIcons[type].bitmap;
indentSize = 8;
}
textOffset = indent * indentSize + (icon ? (icon.width + 6) : 0);
-
+
if(info)
sprintf(label, "%s [%s]", name, info);
else
{
//_[c].Free()
delete _[c];
- }
+ }
count = 0;
size = 0;
}
char info[MAX_LOCATION];
char name[MAX_LOCATION];
char extension[MAX_EXTENSION];
-
+
ExplorerFileItem item { };
//if(stats.attribs.isFile) // -- should work now
item.type = cdrom;
if(attribs.isRemote)
item.type = netDrive;
- if(attribs.isRemovable)
+ if(attribs.isRemovable)
{
if(fileName[0] == 'A' || fileName[0] == 'B')
item.type = floppy;
GetExtension(fileName, extension);
//strupr(extension);
strlwr(extension);
-
+
item.type = _FileType::SelectByExtension(extension);
}
- if(attribs.isDrive &&
+ if(attribs.isDrive &&
len > 3 && !strncmp(&fileName[1], ": [", 3))
{
strncpy(name, fileName, 2);
}
public:
- /*//LinkElement<FileSystemNode> link;
+ /* LinkElement<FileSystemNode> link;
FileSystemNode parent;
FileSystemNodeType type;
property bool isListItem { set { bits.isListItem = value; } get { return bits.isListItem; } };
- property char * path
+ property const char * path
{
set { delete path; if(value && value[0]) path = CopyString(value); }
get { return path; } isset { return path && path[0]; }
}
- property char * name
+ property const char * name
{
set { delete name; if(value && value[0]) name = CopyString(value); }
get { return name; } isset { return name && name[0]; }
set { delete extension; if(value && value[0]) extension = CopyString(value); }
get { return extension; } isset { return extension && extension[0]; }
}
- property char * label
+ property const char * label
{
set { delete label; if(value && value[0]) label = CopyString(value); }
get { return label; } isset { return label && label[0]; }
}
- property char * info
+ property const char * info
{
set { delete info; if(value && value[0]) info = CopyString(value); }
get { return info; } isset { return info && info[0]; }
Array<int> exists; // would use (see) BoolArrayInt to pack this into an int if could be accessed as an array
void GetPath(String outputPath)
- {
+ {
if(path)
strcpy(outputPath, path);
else if(parent)
PathCat(temp, outputPath);
strcpy(outputPath, temp);
}
- /*else
- {
- /-*#ifdef __WIN32__
- strcpy(outputPath, "/");
- #else*-/
- //strcpy(outputPath, name);
- strcpy(outputPath, path);
- PathCat(outputPath, name);
- //#endif
- }*/
}
+ else
+ strcpy(outputPath, name ? name : "");
}
bool IsChildOf(FileSystemNode node)
if(children.first)
{
FileSystemNode child;
-
+
for(child = children.first; child; child = child.next)
{
FileSystemNode copy { };
}
}
}
-
+
void EnsureVisible(bool expand)
{
if(parent)
void OnDisplay(Surface surface, int x, int y, int width, FileSystemBox fsb, Alignment alignment, DataDisplayFlags displayFlags)
{
//int indentSize = (displayFlags.dropBox) ? 0 : 10;
- int indent = 16;
+ //int indent = 16;
int xStart;
int len;
int w, h;
if(!this)
return;
-
+
comp = fsb.comparedPaths && fsb.comparedPaths.count > 1;
+
icon = fsb.fileIcons[type].bitmap;
alt = bits.isListItem ? path : name;
if(comp && !fsb.bits.columnsCompareStyle && cmpIcon)
strcpy(text, label ? label : alt); //"%d-%d/%s", stats.inode, stats.nlink
//sprintf(text, "%d-%d/%s", stats.inode, stats.nlink, label ? label : alt);
len = strlen(text);
-
+
if(!icon)
{
if(type == folder || type == folderOpen)
indent = 8;
}
//textOffset = indent * indentSize + (icon ? (icon.width + 4) : 0);
-
+
surface.SetForeground(displayFlags.selected ? fsb.selectionText : fsb.foreground);
surface.TextOpacity(false);
surface.TextExtent(text, len, &w, &h);
h = Max(h, 16);
-
+
// Draw the current row stipple
if(displayFlags.selected)
//surface.Area(xStart - 1, y, xStart - 1, y + h - 1);
//surface.Area(xStart + w - 1, y, xStart + w + 1, y + h - 1);
surface.Area(xStart - 3, y, xStart + w + 1, y + h - 1);
-
//surface.WriteTextDots(alignment, x + textOffset, y + 2, width - textOffset, alt, strlen(alt));
surface.WriteTextDots(alignment, xStart, y + 2, width, text, len);
//}
#endif
- bool OnGetDataFromString(char * string)
+ bool OnGetDataFromString(const char * string)
{
#if 0
if(string && *string)
return false;
}
- char * OnGetString(char * tempString, FileSystemToolWindow fileSysToolWnd, bool * needClass)
+ const char * OnGetString(char * tempString, void * unused /*FileSystemToolWindow fileSysToolWnd*/, bool * needClass)
{
return name ? name : "";
}
if(stats.attribs.isShare) node.type = share;
if(stats.attribs.isCDROM) node.type = cdrom;
if(stats.attribs.isRemote) node.type = netDrive;
- if(stats.attribs.isRemovable)
+ if(stats.attribs.isRemovable)
{
if(name[0] == 'A' || name[0] == 'B')
node.type = floppy;
const bool pathAddName,
const bool previewPicture,
const bool isListItem,
- const DisplaySystem displaySystem)
+ /*const */DisplaySystem displaySystem)
{
int len = strlen(name);
char info[MAX_LOCATION];
char name2[MAX_LOCATION];
char extension[MAX_EXTENSION];
-
+
FileSystemNode node { stats = stats };
/*if(!pathAddName)
if(stats.attribs.isShare) node.type = share;
if(stats.attribs.isCDROM) node.type = cdrom;
if(stats.attribs.isRemote) node.type = netDrive;
- if(stats.attribs.isRemovable)
+ if(stats.attribs.isRemovable)
{
if(name[0] == 'A' || name[0] == 'B')
node.type = floppy;
{
GetExtension(name, extension);
strlwr(extension);
-
+
node.type = _FileType::SelectByExtension(extension);
}
- if(stats.attribs.isDrive &&
+ if(stats.attribs.isDrive &&
len > 3 && !strncmp(&name[1], ": [", 3))
{
strncpy(name2, name, 2);
if(pathAddName)
{
- bool isFile = stats.attribs.isFile;
- bool isFolder = stats.attribs.isDirectory;
+ //bool isFile = stats.attribs.isFile;
+ //bool isFolder = stats.attribs.isDirectory;
char full[MAX_LOCATION];
strcpy(full, path);
PathCat(full, name);
const bool previewPicture,
const int cmpIcon,
const bool cmpNot,
- const Array<int> exists,
- const DisplaySystem displaySystem)
+ /*const */Array<int> exists,
+ /*const */DisplaySystem displaySystem)
{
FileSystemNode node = MakeFileSystemNode(stats, name, path, pathAddName, previewPicture, false, displaySystem);
if(node)