3 public class CreateNewFileDialog : Window
5 background = activeBorder;
6 minClientSize = Size { 240, 100 };
9 text = "Create New File";
13 property char * currentDirectory
17 GetWorkingDir(currentDirectory, MAX_DIRECTORY); // is this necessary?
18 PathCat(currentDirectory, value);
19 FileFixCase(currentDirectory);
21 get { return (char *)currentDirectory; }
26 char currentDirectory[MAX_DIRECTORY];
32 GetWorkingDir(currentDirectory, MAX_DIRECTORY);
33 FileFixCase(currentDirectory);
36 ~CreateNewFileDialog()
42 newNewFileName.SelectAll();
48 parent = this, isDefault = true, position = { 70, 60 }, size = { 60 }, text = "OK";
49 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
51 if(newNewFileName.contents && newNewFileName.contents[0])
53 char newFilePath[MAX_DIRECTORY];
54 strcpy(newFilePath, currentDirectory);
55 PathCat(newFilePath, newNewFileName.contents);
56 if(!FileExists(newFilePath).isFile)
58 File f = FileOpen(newFilePath, write);
64 Destroy(DialogResult::ok);
67 MessageBox { master = this, parent = parent, type = ok, text = "Create NewFile Error", contents = "NewFile already exists." }.Modal();
70 MessageBox { master = this, parent = parent, type = ok, text = "Create NewFile Error", contents = "Please enter a name." }.Modal();
77 parent = this, position = { 140, 60 }, size = { 60 }, hotKey = escape, text = "Cancel";
78 NotifyClicked = ButtonCloseDialog;
81 EditBox newNewFileName
83 this, textHorzScroll = true, anchor = { left = 10, right = 10, top = 30 }, size = { 250 };
84 hotKey = altN, text = "Name";
85 contents = "New NewFile";
87 Label { this, position = { 10, 10 }, labeledWindow = newNewFileName };