3 FileDialog fileDialog { type = selectDir, text = "Select project directory" };
5 class NewProjectDialog : Window
7 background = activeBorder;
8 minClientSize = { 316, 170 };
9 maxClientSize = { 640, 170 };
10 borderStyle = sizable;
15 char path[MAX_LOCATION];
16 char name[MAX_FILENAME];
18 PathBox locationEditBox
20 this, position = { 10, 80 }, size = { 120, 22 }, anchor = { left = 10, top = 80, right = 10 };
21 hotKey = altL, text = "Location";
22 typeExpected = directory, browseDialog = fileDialog;
24 //NotifyUpdate = EditBoxUpdate;
26 bool NotifyModified(PathBox pathBox)
28 char location[MAX_LOCATION];
29 char lastPart[MAX_FILENAME];
30 char * text = pathBox.slashPath;
32 //replacing this: NotifyUpdate = EditBoxUpdate;
33 okBtn.disabled = !(text[0] && projectName.contents[0]);
35 GetWorkingDir(location, sizeof(location) - 1);
36 PathCatSlash(location, text);
38 GetLastDirectory(path, lastPart);
39 /*if(text[0] && (!name[0] || !strcmp(lastPart, name)))
41 char newName[MAX_FILENAME];
42 GetLastDirectory(location, newName);
43 if(strcmp(newName, location))
45 strcpy(name, newName);
46 projectName.contents = name;
49 strcpy(path, location);
54 Label { this, position = { 10, 60 }, labeledWindow = locationEditBox };
56 DropBox targetType { this, position = { 10, 130 }, size = { 130 }, hotKey = altT, text = "Target Type" };
58 Label { this, position = { 10, 110 }, labeledWindow = targetType };
62 parent = this, isDefault = true, disabled = true, position = { 170, 130 }, size = { 60 }, text = "OK";
63 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
65 char * location = locationEditBox.slashPath;
66 char * prjName = projectName.contents;
67 char filePath[MAX_LOCATION];
68 char fileName[MAX_LOCATION]; // Windows Friendly path
69 char extension[MAX_EXTENSION];
73 ProjectView projectWindow;
74 ProjectConfig debug, release;
76 if(!FileExists(location).isDirectory)
78 if(MessageBox { type = yesNo, master = this,
79 text = "Directory doesn't exist", contents = "Create directory?" }.Modal() == yes)
81 if(!MakeDir(location))
83 MessageBox { type = ok, master = this, text = location, contents = "Error creating directory" }.Modal();
91 strcpy(filePath, location);
92 PathCatSlash(filePath, prjName);
93 GetExtension(filePath, extension);
95 ChangeExtension(filePath, ProjectExtension, filePath);
97 GetSystemPathBuffer(fileName, filePath);
98 exists = FileExists(filePath);
102 if(MessageBox { type = yesNo, master = this,
103 text = "Project Already Exists", contents = "Replace existing project?" }.Modal() == no)
107 debug = ProjectConfig
109 name = CopyString("Debug");
114 preprocessorDefinitions = { [ CopyString("_DEBUG") ] };
116 makingModified = true;
117 compilingModified = true;
118 linkingModified = true;
121 release = ProjectConfig
123 name = CopyString("Release");
126 optimization = speed;
129 makingModified = true;
130 compilingModified = true;
131 linkingModified = true;
134 /* error: too few arguments to function ‘__ecereProp_DirExpression_Set_char__PTR_’ -- debug.objDir = "debug";*/
139 moduleName = CopyString(name);
140 topNode.type = NodeTypes::project;
143 project.topNode.options = project.options =
146 // TOFIX: Precomp problems withou the extra ( )
147 targetType = ((TargetTypes)targetType.GetTag());
148 targetFileName = CopyString(name);
150 if(project.targetType != staticLibrary)
152 project.options.libraries = { [ CopyString("ecere") ] };
156 char workspaceFile[MAX_LOCATION];
157 strcpy(workspaceFile, filePath);
158 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
159 workspace = Workspace { compiler = ideSettings.defaultCompiler, workspaceFile = workspaceFile };
161 workspace.projects.Add(project);
163 project.topNode.configurations = project.configurations = { [ debug, release ] };
164 project.resNode = project.topNode.Add(project, "Resources", null, resources, archiveFile, false);
166 if(!project.Save(filePath))
168 MessageBox { type = ok, master = this, text = filePath, contents = "Error writing project file" }.Modal();
173 projectWindow = ide.CreateProjectView(workspace, fileName);
176 char newWorkingDir[MAX_LOCATION];
177 StripLastDirectory(filePath, newWorkingDir);
179 ide.ChangeFileDialogsDirectory(newWorkingDir, false);
181 StripLastDirectory(newWorkingDir, newWorkingDir);
182 ide.ChangeProjectFileDialogDirectory(newWorkingDir);
185 if(createForm.checked)
189 CodeEditor codeEditor = projectWindow.CreateNew("Form", "form", "Window", className);
190 EditBox editBox = codeEditor.editBox;
191 strcpy(varName, className);
192 if(islower(varName[0]))
194 memmove(varName+1, varName, strlen(varName)+1);
198 varName[0] = (char)tolower(varName[0]);
201 editBox.Printf("\n%s %s {};\n", className, varName);
203 codeEditor.EnsureUpToDate();
205 project.Save(filePath);
207 projectWindow.modifiedDocument = false;
208 project.topNode.modified = false;
211 editBox.Printf("class FormApplication : GuiApplication\n");
212 editBox.Printf("{\n");
213 editBox.Printf(" %s %s {};\n", className, varName);
214 editBox.Printf("}\n");
219 if(project && projectWindow)
220 projectWindow.ProjectPrepareMakefile(project, force, true, true);
229 parent = this, position = { 240, 130 }, size = { 60 }, hotKey = escape, text = "Cancel";
230 NotifyClicked = ButtonCloseDialog;
234 parent = this, text = "Create Form", hotKey = altF, position = { 200, 30 };
235 isCheckbox = true, checked = true;
240 parent = this, textHorzScroll = true, position = { 10, 30 }, size = { 160 };
241 hotKey = altP, text = "Project Name";
242 NotifyUpdate = EditBoxUpdate;
244 bool NotifyModified(EditBox editBox)
246 char name[MAX_FILENAME];
247 char lastPart[MAX_LOCATION];
248 char * text = editBox.contents;
250 // drop leading path stuff that has no business here
251 GetLastDirectory(text, name);
253 GetLastDirectory(path, lastPart);
254 if(name[0] && (!strcmp(path, lastPart) || !path[0] || !strcmp(this.name, lastPart)))
256 if(strcmp(path, lastPart))
257 StripLastDirectory(path, path);
258 PathCatSlash(path, name);
259 locationEditBox.path = path;
261 else if(!name[0] && !strcmp(this.name, lastPart))
263 if(strcmp(path, lastPart))
264 StripLastDirectory(path, path);
265 locationEditBox.path = path;
267 else if(strcmp(name, lastPart))
269 PathCatSlash(path, name);
270 locationEditBox.path = path;
272 strcpy(this.name, name);
273 editBox.contents = name;
277 Label { this, position = { 10, 10 }, labeledWindow = projectName };
279 void EditBoxUpdate(EditBox editBox)
281 okBtn.disabled = !(locationEditBox.path[0] && projectName.contents[0]);
286 char location[MAX_LOCATION];
288 if(ideSettings.ideProjectFileDialogLocation)
289 strcpy(location, ideSettings.ideProjectFileDialogLocation);
291 GetWorkingDir(location, sizeof(location) - 1);
293 locationEditBox.path = location;
294 strcpy(path, location);
299 //targetType.AddField("String", null, 0);
301 row = targetType.AddRow();
302 row.tag = TargetTypes::executable;
303 row.SetData(null, "Executable");
305 row = targetType.AddRow();
306 row.tag = TargetTypes::sharedLibrary;
307 row.SetData(null, "Shared Library");
309 row = targetType.AddRow();
310 row.tag = TargetTypes::staticLibrary;
311 row.SetData(null, "Static Library");
313 targetType.currentRow = targetType.FindRow(TargetTypes::executable);
318 class QuickProjectDialog : Window
320 background = activeBorder;
321 minClientSize = { 316, 110 };
322 maxClientSize = { 640, 110 };
323 borderStyle = sizable;
326 text = "Quick Project";
328 char path[MAX_LOCATION];
329 char name[MAX_FILENAME];
331 Label message { this, position = { 10, 10 }, size = { 200 }, text = "Do you want to quickly create a temporary project?" };
333 DropBox targetType { this, position = { 10, 70 }, size = { 130 }, hotKey = altT, text = "Target Type" };
334 Label { this, position = { 10, 50 }, labeledWindow = targetType };
338 parent = this, isDefault = true, position = { 170, 70 }, size = { 60 }, text = "OK";
339 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
341 char tempDir[MAX_LOCATION] = "";
342 char filePath[MAX_LOCATION];
343 char prjName[MAX_LOCATION] = "quick_project";
346 ProjectView projectWindow;
347 ProjectConfig debug, release;
349 /*if(!*/CreateTemporaryDir(tempDir, "ecereide");/*)
351 MessageBox { type = ok, master = this, text = tempDir, contents = "Error creating temporary directory." }.Modal();
355 GetLastDirectory(tempDir, prjName);
358 if((dot = strstr(prjName, ".")))
362 if(!FileExists(tempDir).isDirectory)
364 MessageBox { type = ok, master = this, text = tempDir, contents = "Temporary directory does not exist." }.Modal();
368 ide.tmpPrjDir = tempDir;
370 strcpy(filePath, tempDir);
371 PathCatSlash(filePath, prjName);
372 //GetExtension(filePath, extension);
374 ChangeExtension(filePath, ProjectExtension, filePath);
375 GetSystemPathBuffer(filePath, filePath);
377 debug = ProjectConfig
379 name = CopyString("Debug");
384 preprocessorDefinitions = { [ CopyString("_DEBUG") ] };
386 makingModified = true;
387 compilingModified = true;
388 linkingModified = true;
391 release = ProjectConfig
393 name = CopyString("Release");
396 optimization = speed;
399 makingModified = true;
400 compilingModified = true;
401 linkingModified = true;
407 moduleName = CopyString(prjName);
408 topNode.type = NodeTypes::project;
411 project.topNode.options = project.options =
414 // TOFIX: Precomp problems withou the extra ( )
415 targetType = ((TargetTypes)targetType.GetTag());
416 targetFileName = CopyString(prjName);
419 if(project.targetType != staticLibrary)
421 project.options.libraries = { [ CopyString("ecere") ] };
425 char workspaceFile[MAX_LOCATION];
426 strcpy(workspaceFile, filePath);
427 ChangeExtension(workspaceFile, WorkspaceExtension, workspaceFile);
428 workspace = Workspace { compiler = ideSettings.defaultCompiler, workspaceFile = workspaceFile };
431 workspace.projects.Add(project);
433 project.topNode.configurations = project.configurations = { [ debug, release ] };
434 project.resNode = project.topNode.Add(project, "Resources", null, resources, archiveFile, false);
436 if(!project.Save(filePath))
438 MessageBox { type = ok, master = this, text = filePath, contents = "Error writing project file" }.Modal();
441 ide.DestroyTemporaryProjectDir();
445 projectWindow = ide.CreateProjectView(workspace, filePath);
448 char extension[MAX_EXTENSION];
449 Window document = null;
450 for(document = ide.firstChild; document; document = document.next)
452 char * fileName = document.fileName;
453 if(document.isDocument && document._class == class(CodeEditor) && document.created && fileName)
455 CodeEditor codeEditor = (CodeEditor)document;
456 ide.projectView.AddFile(project.topNode, fileName, false);
457 codeEditor.DebugMenusDisabled();
462 if(project.topNode.modified)
464 project.Save(filePath);
465 projectWindow.modifiedDocument = false;
466 project.topNode.modified = false;
472 CodeEditor codeEditor = projectWindow.CreateNew("Form", "form", "Window", className);
473 EditBox editBox = codeEditor.editBox;
474 strcpy(varName, className);
475 if(islower(varName[0]))
477 memmove(varName+1, varName, strlen(varName)+1);
481 varName[0] = (char)tolower(varName[0]);
484 editBox.Printf("\n%s %s {};\n", className, varName);
486 codeEditor.EnsureUpToDate();
488 // TODO: how to save that new file?
490 project.Save(filePath);
491 projectWindow.modifiedDocument = false;
492 project.topNode.modified = false;
497 if(project && projectWindow)
498 projectWindow.ProjectPrepareMakefile(project, force, true, true);
500 ide.projectView.ProjectBuild(null, Modifiers { });
509 parent = this, position = { 240, 70 }, size = { 60 }, hotKey = escape, text = "Cancel";
510 NotifyClicked = ButtonCloseDialog;
517 row = targetType.AddRow();
518 row.tag = TargetTypes::executable;
519 row.SetData(null, "Executable");
521 row = targetType.AddRow();
522 row.tag = TargetTypes::sharedLibrary;
523 row.SetData(null, "Shared Library");
525 row = targetType.AddRow();
526 row.tag = TargetTypes::staticLibrary;
527 row.SetData(null, "Static Library");
529 targetType.currentRow = targetType.FindRow(TargetTypes::executable);