--- /dev/null
+public import "ecere"
+
+public class CreateNewFileDialog : Window
+{
+ background = activeBorder;
+ minClientSize = Size { 240, 100 };
+ tabCycle = true;
+ hasClose = true;
+ text = "Create New File";
+
+public:
+
+ property char * currentDirectory
+ {
+ set
+ {
+ GetWorkingDir(currentDirectory, MAX_DIRECTORY); // is this necessary?
+ PathCat(currentDirectory, value);
+ FileFixCase(currentDirectory);
+ }
+ get { return (char *)currentDirectory; }
+ };
+
+private:
+
+ char currentDirectory[MAX_DIRECTORY];
+
+ CreateNewFileDialog()
+ {
+ FileNameType c;
+
+ GetWorkingDir(currentDirectory, MAX_DIRECTORY);
+ FileFixCase(currentDirectory);
+ }
+
+ ~CreateNewFileDialog()
+ {
+ }
+
+ bool OnPostCreate()
+ {
+ newNewFileName.SelectAll();
+ return true;
+ }
+
+ Button ok
+ {
+ parent = this, isDefault = true, position = { 70, 60 }, size = { 60 }, text = "OK";
+ bool NotifyClicked(Button button, int x, int y, Modifiers mods)
+ {
+ if(newNewFileName.contents && newNewFileName.contents[0])
+ {
+ char newFilePath[MAX_DIRECTORY];
+ strcpy(newFilePath, currentDirectory);
+ PathCat(newFilePath, newNewFileName.contents);
+ if(!FileExists(newFilePath).isFile)
+ {
+ File f = FileOpen(newFilePath, write);
+ if(f)
+ {
+ f.Flush();
+ }
+ delete f;
+ Destroy(DialogResult::ok);
+ }
+ else
+ MessageBox { master = this, parent = parent, type = ok, text = "Create NewFile Error", contents = "NewFile already exists." }.Modal();
+ }
+ else
+ MessageBox { master = this, parent = parent, type = ok, text = "Create NewFile Error", contents = "Please enter a name." }.Modal();
+ return true;
+ }
+ };
+
+ Button cancel
+ {
+ parent = this, position = { 140, 60 }, size = { 60 }, hotKey = escape, text = "Cancel";
+ NotifyClicked = ButtonCloseDialog;
+ };
+
+ EditBox newNewFileName
+ {
+ this, textHorzScroll = true, anchor = { left = 10, right = 10, top = 30 }, size = { 250 };
+ hotKey = altN, text = "Name";
+ contents = "New NewFile";
+ };
+ Label { this, position = { 10, 10 }, labeledWindow = newNewFileName };
+
+}