import "Array"
default extern int __ecereVMethodID_class_OnGetDataFromString;
-default static void _workAround()
+default __attribute__((unused)) static void _workAround()
{
int a;
a.OnGetDataFromString(0);
{
Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
{
- DirectoriesBox dirsBox;
PathBox pathBox
{
dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 },
typeExpected = any;
path = this;
};
- if((dirsBox = pathBoxDirsBox))
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ if(dirsBox)
pathBox.browseDialog = dirsBox.browseDialog;
// TOCHECK: compiler issues?
/*else if(userData && eClass_IsDerived(userData._class, class(FileDialog)))
bool changed = false;
if(pathBox.modifiedDocument)
{
- DirectoriesBox dirsBox;
- if((dirsBox = pathBoxDirsBox))
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ if(dirsBox)
dirsBox.NotifyPathBoxModified(dirsBox.master, dirsBox, pathBox);
String::OnFree();
changed = ((bool (*)(void *, void *, const char *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetDataFromString])(_class, &this, pathBox.systemPath);
{
Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
{
- DirectoriesBox dirsBox;
PathBox pathBox
{
dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 },
typeExpected = directory;
path = this;
};
- if((dirsBox = pathBoxDirsBox))
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ if(dirsBox)
pathBox.browseDialog = dirsBox.browseDialog;
// TOCHECK: compiler issues? (same)
/*else if(userData && eClass_IsDerived(userData._class, class(FileDialog)))
bool changed = false;
if(pathBox.modifiedDocument)
{
- DirectoriesBox dirsBox;
- if((dirsBox = pathBoxDirsBox))
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ if(dirsBox)
dirsBox.NotifyPathBoxModified(dirsBox.master, dirsBox, pathBox);
String::OnFree();
changed = ((bool (*)(void *, void *, const char *))(void *)_class._vTbl[__ecereVMethodID_class_OnGetDataFromString])(_class, &this, pathBox.systemPath);
borderStyle = deep;
clientSize = { 64, 18 };
- watch(background) { editBox.background = background; };
- watch(foreground) { editBox.foreground = foreground; };
- watch(opacity) { editBox.opacity = opacity; };
-
-#if defined(__WIN32__)
- PathBox()
- {
- path[0] = '\0';
- }
-#endif
+ watch(background) { editBox.background = background; };
+ watch(foreground) { editBox.foreground = foreground; };
+ watch(selectionColor) { editBox.selectionColor = selectionColor; };
+ watch(selectionText) { editBox.selectionText = selectionText; };
+ watch(opacity) { editBox.opacity = opacity; };
PathTypeExpected typeExpected;
FileDialog browseDialog;
-#if defined(__WIN32__)
char path[MAX_LOCATION];
-#endif
BitmapResource file { "<:ecere>mimeTypes/file.png", transparent = true, alphaBlend = true };
BitmapResource brokenFile { "<:ecere>mimeTypes/brokenFile.png", transparent = true, alphaBlend = true };
bool NotifyModified(EditBox editBox)
{
PathBox pathBox = this;
- DirectoriesBox dirsBox;
- if((dirsBox = pathBoxDirsBox))
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ if(dirsBox)
dirsBox.NotifyPathBoxModified(dirsBox.master, dirsBox, this);
return NotifyModified(master, this);
}
bool NotifyClicked(Button button, int x, int y, Modifiers mods)
{
+ if(modifiedDocument)
+ NotifyModified(master, this);
+
if(browseDialog)
{
- char * browsePath = new char[MAX_LOCATION];
- char * fileName = new char[MAX_LOCATION];
- char * baseBrowsePath = null;
+ char browsePath[MAX_LOCATION];
PathBox pathBox = this;
DataBox dataBox = pathBoxDataBox;
ListBox listBox;
- DirectoriesBox dirsBox;
- browsePath[0] = fileName [0] = '\0';
- if((dirsBox = pathBoxDirsBox) && dirsBox.baseBrowsePath && dirsBox.baseBrowsePath[0])
- {
- strncpy(browsePath, dirsBox.baseBrowsePath, MAX_LOCATION); browsePath[MAX_LOCATION-1] = '\0';
- PathCat(browsePath, editBox.contents);
- }
- else
- strncpy(browsePath, editBox.contents, MAX_LOCATION); browsePath[MAX_LOCATION-1] = '\0';
- if(browsePath[0])
- {
- GetLastDirectory(browsePath, fileName);
+ DirectoriesBox dirsBox = pathBoxDirsBox;
+ const char * ebContents = editBox.contents;
+ String backFilePath = CopyString(browseDialog.filePath);
+ char * baseBrowsePath = dirsBox ? dirsBox.baseBrowsePath : null;
+
+ browsePath[0] = '\0';
+ strncpy(browsePath, browseDialog.filePath, MAX_LOCATION); browsePath[MAX_LOCATION-1] = '\0';
+ if(baseBrowsePath && baseBrowsePath[0] && ((ebContents && ebContents[0]) || !backFilePath || !backFilePath[0]))
+ PathCat(browsePath, baseBrowsePath);
+ PathCat(browsePath, ebContents);
+ browseDialog.filePath = (ebContents && ebContents[0]) ? browsePath : "";
+ if(pathBox.typeExpected == directory && browsePath[0] && FileExists(browsePath).isDirectory && backFilePath && backFilePath[0])
StripLastDirectory(browsePath, browsePath);
- }
- else
+ while(browsePath[0] && !FileExists(browsePath).isDirectory)
+ StripLastDirectory(browsePath, browsePath);
+ if(!browsePath[0])
{
- char * path = new char[MAX_LOCATION];
+ char path[MAX_LOCATION];
LocateModule(null, path);
StripLastDirectory(path, path);
strncpy(browsePath, path, MAX_LOCATION); browsePath[MAX_LOCATION-1] = '\0';
- delete path;
- }
- while(browsePath[0] && !FileExists(browsePath).isDirectory)
- {
- char * temp = new char[MAX_LOCATION];
- GetLastDirectory(browsePath, temp);
- PathCat(temp, fileName);
- strcpy(fileName, temp);
- StripLastDirectory(browsePath, browsePath);
- delete temp;
}
- browseDialog.filePath = fileName;
browseDialog.currentDirectory = browsePath;
browseDialog.master = rootWindow;
- delete browsePath;
- delete fileName;
incref this;
if(dirsBox) dirsBox.browsing = true;
if((listBox = pathBoxListBox))
listBox.StopEditing(true);
}
+ else
+ browseDialog.filePath = backFilePath;
+ delete backFilePath;
if(dirsBox) dirsBox.browsing = false;
delete this;
}
{
BitmapResource icon = null;
char path[MAX_LOCATION];
- FileAttribs exists;
+ FileAttribs exists { };
GetSystemPathBuffer(path, editBox.contents);
- exists = FileExists(path);
-
+ if(!(path[0] == DIR_SEP && path[1] == DIR_SEP && (!path[2] || !strchr(&path[2], DIR_SEP))))
+ exists = FileExists(path);
+
switch(typeExpected)
{
case any:
typeExpected = value;
if(browseDialog && browseDialog.type == open && typeExpected == directory)
browseDialog.type = selectDir;
- }
+ }
}
}
void SelectAll() { editBox.SelectAll(); }
void Deselect() { editBox.Deselect(); }
- property String path
+ property const String path
{
set
{
virtual bool OnPrepareBrowseDir(char ** directory);
virtual bool OnBrowsedDir(char ** directory);
- watch(foreground) { list.foreground = foreground; };
- watch(background) { list.background = background; };
+ watch(foreground) { list.foreground = foreground; };
+ watch(background) { list.background = background; };
+ //watch(selectionColor) { list.selectionColor = selectionColor; };
+ //watch(selectionText) { list.selectionText = selectionText; };
+ watch(opacity) { list.opacity = opacity; };
property Array<String> strings
{
DataRow row;
for(row = list.firstRow; row; row = row.next)
{
- String string = row.string;
+ const String string = row.string;
if(string && string[0])
array.Add(CopyUnixPath(string));
}
listBox.SetData(null, dir);
listBox.modifiedDocument = true;
if(listBox.currentRow == listBox.lastRow && listBox.lastRow.string)
- {
- DataRow r = listBox.lastRow;
- char * s = r.string;
listBox.currentRow = listBox.AddString("");
- }
}
delete dir;
}