]> git.saurik.com Git - wxWidgets.git/blob - utils/projgen/makeproj.cpp
Committing in .
[wxWidgets.git] / utils / projgen / makeproj.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: makeproj.cpp
3 // Purpose: Generate sample VC++ project files
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 10/12/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "makeproj.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #if defined(__BORLANDC__)
20 #pragma hdrstop
21 #endif
22
23 #include "wx/wx.h"
24 #include "wx/resource.h"
25
26 #if wxUSE_IOSTREAMH
27 #include <iostream.h>
28 #include <fstream.h>
29 #else
30 #include <iostream>
31 #include <fstream>
32 #endif
33
34 #include "makeproj.h"
35 #include "projgenrc.h"
36
37 // ----------------------------------------------------------------------------
38 // ressources
39 // ----------------------------------------------------------------------------
40 // the application icon
41 #if defined(__WXGTK__) || defined(__WXMOTIF__)
42 #include "mondrian.xpm"
43 #endif
44
45 // ----------------------------------------------------------------------------
46 // private classes
47 // ----------------------------------------------------------------------------
48
49 const wxStringList wxEmptyStringList;
50
51 // Define a new application type, each program should derive a class from wxApp
52 class MyApp : public wxApp
53 {
54 public:
55 // override base class virtuals
56 // ----------------------------
57
58 // this one is called on application startup and is a good place for the app
59 // initialization (doing it here and not in the ctor allows to have an error
60 // return: if OnInit() returns false, the application terminates)
61 virtual bool OnInit();
62
63 bool GenerateSample(const wxString& projectName, const wxString& targetName,
64 const wxString& path, const wxStringList& sourceFiles, const wxString& relativeRootPath = "../..",
65 const wxStringList& extraLibsDebug = wxEmptyStringList,
66 const wxStringList& extraLibsRelease = wxEmptyStringList);
67 void GenerateSamples(const wxString& dir); // Takes wxWindows directory path
68 };
69
70 // Define a new frame type: this is going to be our main frame
71 class MyFrame : public wxFrame
72 {
73 public:
74 // ctor(s)
75 MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
76
77 // event handlers (these functions should _not_ be virtual)
78 void OnQuit(wxCommandEvent& event);
79 void OnAbout(wxCommandEvent& event);
80 void OnGenerate(wxCommandEvent& event);
81
82 bool GenerateSample(const wxString& projectName, const wxString& targetName,
83 const wxString& path, const wxStringList& sourceFiles, const wxString& relativeRootPath = "../..");
84
85 private:
86 // any class wishing to process wxWindows events must use this macro
87 DECLARE_EVENT_TABLE()
88 };
89
90 // Define a dialog: this will be our main dialog
91 class MyDialog : public wxDialog
92 {
93 public:
94 // ctor(s)
95 MyDialog(const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
96
97 // event handlers (these functions should _not_ be virtual)
98 void OnQuit(wxCommandEvent& event);
99 void OnAbout(wxCommandEvent& event);
100 void OnGenerate(wxCommandEvent& event);
101 void OnGenerateSamples(wxCommandEvent& event);
102
103 private:
104 // any class wishing to process wxWindows events must use this macro
105 DECLARE_EVENT_TABLE()
106 };
107
108
109 // ----------------------------------------------------------------------------
110 // constants
111 // ----------------------------------------------------------------------------
112
113 // IDs for the controls and the menu commands
114 enum
115 {
116 // menu items
117 MakeProject_Quit = 1,
118 MakeProject_About,
119 MakeProject_Generate,
120 MakeProject_GenerateSamples,
121
122 // controls start here (the numbers are, of course, arbitrary)
123 MakeProject_Text = 1000,
124 };
125
126 // ----------------------------------------------------------------------------
127 // event tables and other macros for wxWindows
128 // ----------------------------------------------------------------------------
129
130 // the event tables connect the wxWindows events with the functions (event
131 // handlers) which process them. It can be also done at run-time, but for the
132 // simple menu events like this the static method is much simpler.
133 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
134 EVT_MENU(MakeProject_Quit, MyFrame::OnQuit)
135 EVT_MENU(MakeProject_About, MyFrame::OnAbout)
136 EVT_MENU(MakeProject_Generate, MyFrame::OnGenerate)
137 END_EVENT_TABLE()
138
139 // Create a new application object: this macro will allow wxWindows to create
140 // the application object during program execution (it's better than using a
141 // static object for many reasons) and also declares the accessor function
142 // wxGetApp() which will return the reference of the right type (i.e. MyApp and
143 // not wxApp)
144 IMPLEMENT_APP(MyApp)
145
146 // ============================================================================
147 // implementation
148 // ============================================================================
149
150 // ----------------------------------------------------------------------------
151 // the application class
152 // ----------------------------------------------------------------------------
153
154 // 'Main program' equivalent: the program execution "starts" here
155 bool MyApp::OnInit()
156 {
157 #if 0
158 // Create the main application window
159 MyFrame *frame = new MyFrame("MakeProject wxWindows App",
160 wxPoint(50, 50), wxSize(450, 340));
161
162 frame->Show(TRUE);
163 SetTopWindow(frame);
164 #endif
165 wxResourceParseFile("projgenrc.wxr");
166
167 MyDialog* dialog = new MyDialog("VC++ MakeProject");
168 dialog->ShowModal();
169
170 delete dialog;
171
172 return FALSE;
173 }
174
175 bool MyApp::GenerateSample(const wxString& projectName, const wxString& targetName,
176 const wxString& path, const wxStringList& sourceFiles, const wxString& relativeRootPath,
177 const wxStringList& extraLibsDebug, const wxStringList& extraLibsRelease)
178 {
179 wxString relativeIncludePath(relativeRootPath + wxString("/include"));
180 wxString relativeLibPath(relativeRootPath + wxString("/lib"));
181 wxString relativeIncludePathContrib(relativeRootPath + wxString("/contrib/include"));
182 wxString relativeLibPathContrib(relativeRootPath + wxString("/contrib/lib"));
183
184 wxProject project;
185
186 // For all samples
187 project.SetIncludeDirs(wxStringList((const char*) relativeIncludePath, (const char*) relativeIncludePathContrib, 0));
188 project.SetResourceIncludeDirs(wxStringList((const char*) relativeIncludePath, (const char*) relativeIncludePathContrib, 0));
189 project.SetLibDirs(wxStringList((const char*) relativeLibPath, (const char*) relativeLibPathContrib, 0));
190
191 // project.SetExtraLibsDebug(wxStringList("opengl32.lib", "glu32.lib", 0));
192 // project.SetExtraLibsRelease(wxStringList("opengl32.lib", "glu32.lib", 0));
193 project.SetExtraLibsDebug(extraLibsDebug);
194 project.SetExtraLibsRelease(extraLibsRelease);
195
196 project.SetProjectName(projectName);
197 project.SetTargetName(targetName);
198 project.SetProjectPath(path);
199 project.SetSourceFiles(sourceFiles);
200
201 if (!project.GenerateVCProject())
202 {
203 wxString msg("Could not generate ");
204 msg += projectName;
205 wxMessageBox(msg);
206 return FALSE;
207 }
208 return TRUE;
209 }
210
211
212 void MyApp::GenerateSamples(const wxString& dir)
213 {
214 // Small bug. Because we don't distinguish between Debug/DebugDLL, Release/ReleaseDLL,
215 // we can't yet make a sample that uses other wxWindows static libraries + the wxWindows DLL library.
216
217 //// Samples
218
219 GenerateSample("CalendarVC", "calendar", dir + wxString("/samples/calendar"), wxStringList("calendar.cpp", 0));
220 GenerateSample("CaretVC", "caret", dir + wxString("/samples/caret"), wxStringList("caret.cpp", 0));
221 GenerateSample("CheckLstVC", "checklst", dir + wxString("/samples/checklst"), wxStringList("checklst.cpp", 0));
222 GenerateSample("ConfigVC", "conftest", dir + wxString("/samples/config"), wxStringList("conftest.cpp", 0));
223 GenerateSample("ControlsVC", "controls", dir + wxString("/samples/controls"), wxStringList("controls.cpp", 0));
224 GenerateSample("DbVC", "dbtest", dir + wxString("/samples/db"),
225 wxStringList("dbtest.cpp", "listdb.cpp", "dbtest.h", "listdb.h", 0));
226 GenerateSample("DialogsVC", "dialogs", dir + wxString("/samples/dialogs"),
227 wxStringList("dialogs.cpp", "dialogs.h", 0));
228 GenerateSample("DndVC", "dnd", dir + wxString("/samples/dnd"), wxStringList("dnd.cpp", 0));
229 GenerateSample("DocViewVC", "docview", dir + wxString("/samples/docview"),
230 wxStringList("docview.cpp", "doc.cpp", "view.cpp", "docview.h", "doc.h", "view.h", 0));
231 GenerateSample("DocVwMDIVC", "docview", dir + wxString("/samples/docvwmdi"),
232 wxStringList("docview.cpp", "doc.cpp", "view.cpp", "docview.h", "doc.h", "view.h", 0));
233 GenerateSample("DynamicVC", "dynamic", dir + wxString("/samples/dynamic"), wxStringList("dynamic.cpp", 0));
234 GenerateSample("DrawingVC", "drawing", dir + wxString("/samples/drawing"), wxStringList("drawing.cpp", 0));
235 GenerateSample("ExecVC", "exec", dir + wxString("/samples/exec"), wxStringList("exec.cpp", 0));
236 GenerateSample("EventVC", "event", dir + wxString("/samples/event"), wxStringList("event.cpp", 0));
237 GenerateSample("GridVC", "grid", dir + wxString("/samples/grid"), wxStringList("grid.cpp", 0));
238 GenerateSample("NewGridVC", "griddemo", dir + wxString("/samples/newgrid"), wxStringList("griddemo.cpp", 0));
239 GenerateSample("HelpVC", "demo", dir + wxString("/samples/help"), wxStringList("demo.cpp", 0));
240
241 // OpenGL samples
242 GenerateSample("CubeVC", "cube", dir + wxString("/samples/opengl/cube"), wxStringList("cube.cpp", "cube.h", 0),
243 "../../..", wxStringList("opengl32.lib", "glu32.lib", 0), wxStringList("opengl32.lib", "glu32.lib", 0));
244 GenerateSample("IsosurfVC", "isosurf", dir + wxString("/samples/opengl/isosurf"), wxStringList("isosurf.cpp", "isousrf.h", 0),
245 "../../..", wxStringList("opengl32.lib", "glu32.lib", 0), wxStringList("opengl32.lib", "glu32.lib", 0));
246 GenerateSample("PenguinVC", "penguin", dir + wxString("/samples/opengl/penguin"), wxStringList("penguin.cpp", "penguin.h",
247 "lw.cpp", "lw.h", "trackball.c", "trackball.h", 0),
248 "../../..", wxStringList("opengl32.lib", "glu32.lib", 0), wxStringList("opengl32.lib", "glu32.lib", 0));
249
250 // wxHTML samples
251 GenerateSample("AboutVC", "about", dir + wxString("/samples/html/about"), wxStringList("about.cpp", 0),
252 "../../..");
253 GenerateSample("HelpVC", "help", dir + wxString("/samples/html/help"), wxStringList("help.cpp", 0),
254 "../../..");
255 GenerateSample("PrintingVC", "printing", dir + wxString("/samples/html/printing"), wxStringList("printing.cpp", 0),
256 "../../..");
257 GenerateSample("TestVC", "test", dir + wxString("/samples/html/test"), wxStringList("test.cpp", 0),
258 "../../..");
259 GenerateSample("VirtualVC", "virtual", dir + wxString("/samples/html/virtual"), wxStringList("virtual.cpp", 0),
260 "../../..");
261 GenerateSample("WidgetVC", "widget", dir + wxString("/samples/html/widget"), wxStringList("widget.cpp", 0),
262 "../../..");
263 GenerateSample("ZipVC", "zip", dir + wxString("/samples/html/zip"), wxStringList("zip.cpp", 0),
264 "../../..");
265 GenerateSample("HelpViewVC", "helpview", dir + wxString("/samples/html/helpview"), wxStringList("helpview.cpp", 0),
266 "../../..");
267
268 GenerateSample("ImageVC", "image", dir + wxString("/samples/image"), wxStringList("image.cpp", 0));
269 GenerateSample("InternatVC", "internat", dir + wxString("/samples/internat"), wxStringList("internat.cpp", 0));
270 GenerateSample("JoytestVC", "joytest", dir + wxString("/samples/joytest"), wxStringList("joytest.cpp", "joytest.h", 0));
271 GenerateSample("LayoutVC", "layout", dir + wxString("/samples/layout"), wxStringList("layout.cpp", "layout.h", 0));
272 GenerateSample("ListctrlVC", "listtest", dir + wxString("/samples/listctrl"), wxStringList("listtest.cpp", "listtest.h", 0));
273 GenerateSample("MdiVC", "mdi", dir + wxString("/samples/mdi"), wxStringList("mdi.cpp", "mdi.h", 0));
274 GenerateSample("MemcheckVC", "memcheck", dir + wxString("/samples/memcheck"), wxStringList("memcheck.cpp", 0));
275 // Don't always generate this project since it has to be tweaked by hand.
276 // GenerateSample("MfcVC", "mfctest", dir + wxString("/samples/mfc"), wxStringList("mfctest.cpp", "mfctest.h", 0));
277 GenerateSample("MiniframVC", "minifram", dir + wxString("/samples/minifram"), wxStringList("minifram.cpp", "minifram.h", 0));
278 GenerateSample("MinimalVC", "minimal", dir + wxString("/samples/minimal"), wxStringList("minimal.cpp", 0));
279 GenerateSample("NativdlgVC", "nativdlg", dir + wxString("/samples/nativdlg"), wxStringList("nativdlg.cpp", "nativdlg.h", "resource.h", 0));
280 GenerateSample("DialupVC", "nettest", dir + wxString("/samples/dialup"), wxStringList("nettest.cpp", 0));
281 GenerateSample("NotebookVC", "notebook", dir + wxString("/samples/notebook"), wxStringList("notebook.cpp", "notebook.h", 0));
282 GenerateSample("OleautoVC", "oleauto", dir + wxString("/samples/oleauto"), wxStringList("oleauto.cpp", 0));
283 GenerateSample("OwnerdrwVC", "ownerdrw", dir + wxString("/samples/ownerdrw"), wxStringList("ownerdrw.cpp", 0));
284 GenerateSample("PngVC", "pngdemo", dir + wxString("/samples/png"), wxStringList("pngdemo.cpp", "pngdemo.h", 0));
285 GenerateSample("PrintingVC", "printing", dir + wxString("/samples/printing"), wxStringList("printing.cpp", "printing.h", 0));
286 GenerateSample("ProplistVC", "proplist", dir + wxString("/samples/proplist"), wxStringList("proplist.cpp", "proplist.h", 0));
287 GenerateSample("PropsizeVC", "propsize", dir + wxString("/samples/propsize"), wxStringList("propsize.cpp", 0));
288 GenerateSample("RegtestVC", "regtest", dir + wxString("/samples/regtest"), wxStringList("regtest.cpp", 0));
289 GenerateSample("ResourceVC", "resource", dir + wxString("/samples/resource"), wxStringList("resource.cpp", "resource.h", 0));
290 GenerateSample("RichEditVC", "wxLayout", dir + wxString("/samples/richedit"), wxStringList("wxLayout.cpp",
291 "kbList.cpp", "wxllist.cpp", "wxlparser.cpp", "wxlwindow.cpp", 0));
292 GenerateSample("SashtestVC", "sashtest", dir + wxString("/samples/sashtest"), wxStringList("sashtest.cpp", "sashtest.h", 0));
293 GenerateSample("ScrollVC", "scroll", dir + wxString("/samples/scroll"), wxStringList("scroll.cpp", 0));
294 GenerateSample("ScrollsubVC", "scrollsub", dir + wxString("/samples/scrollsub"), wxStringList("scrollsub.cpp", 0));
295 GenerateSample("SplitterVC", "splitter", dir + wxString("/samples/splitter"), wxStringList("splitter.cpp", 0));
296 GenerateSample("StatbarVC", "statbar", dir + wxString("/samples/statbar"), wxStringList("statbar.cpp", 0));
297 GenerateSample("TabVC", "tab", dir + wxString("/samples/tab"), wxStringList("tab.cpp", "tab.h", 0));
298 GenerateSample("TaskbarVC", "tbtest", dir + wxString("/samples/taskbar"), wxStringList("tbtest.cpp", "tbtest.h", 0));
299 GenerateSample("TextVC", "text", dir + wxString("/samples/text"), wxStringList("text.cpp", 0));
300 GenerateSample("ThreadVC", "thread", dir + wxString("/samples/thread"), wxStringList("thread.cpp", 0));
301 GenerateSample("ToolbarVC", "toolbar", dir + wxString("/samples/toolbar"), wxStringList("toolbar.cpp", 0));
302 GenerateSample("TreectrlVC", "treectrl", dir + wxString("/samples/treectrl"), wxStringList("treectrl.cpp", "treectrl.h", 0));
303 GenerateSample("TypetestVC", "typetest", dir + wxString("/samples/typetest"), wxStringList("typetest.cpp", "typetest.h", 0));
304 GenerateSample("ValidateVC", "validate", dir + wxString("/samples/validate"), wxStringList("validate.cpp", "validate.h", 0));
305 GenerateSample("ClientVC", "client", dir + wxString("/samples/sockets"), wxStringList("client.cpp", 0));
306 GenerateSample("ServerVC", "server", dir + wxString("/samples/sockets"), wxStringList("server.cpp", 0));
307 GenerateSample("ClientVC", "client", dir + wxString("/samples/ipc"), wxStringList("client.cpp", "client.h", "ddesetup.h", 0));
308 GenerateSample("ServerVC", "server", dir + wxString("/samples/ipc"), wxStringList("server.cpp", "server.h", "ddesetup.h", 0));
309 GenerateSample("CaretVC", "caret", dir + wxString("/samples/caret"), wxStringList("caret.cpp", 0));
310 GenerateSample("DrawingVC", "drawing", dir + wxString("/samples/drawing"), wxStringList("drawing.cpp", 0));
311 GenerateSample("ScrollVC", "scroll", dir + wxString("/samples/scroll"), wxStringList("scroll.cpp", 0));
312 GenerateSample("WizardVC", "wizard", dir + wxString("/samples/wizard"), wxStringList("wizard.cpp", 0));
313 GenerateSample("RotateVC", "rotate", dir + wxString("/samples/rotate"), wxStringList("rotate.cpp", 0));
314 GenerateSample("ExecVC", "exec", dir + wxString("/samples/exec"), wxStringList("exec.cpp", 0));
315 GenerateSample("FontVC", "font", dir + wxString("/samples/font"), wxStringList("font.cpp", 0));
316 GenerateSample("MenuVC", "menu", dir + wxString("/samples/menu"), wxStringList("menu.cpp", 0));
317 GenerateSample("TreelayVC", "treelay", dir + wxString("/samples/treelay"), wxStringList("treelay.cpp", "treelay.h", 0));
318 GenerateSample("DragimagVC", "dragimag", dir + wxString("/samples/dragimag"), wxStringList("dragimag.cpp", "dragimag.h", 0));
319 GenerateSample("PlotVC", "plot", dir + wxString("/samples/plot"), wxStringList("plot.cpp", 0));
320
321 //// Demos
322
323 GenerateSample("BombsVC", "bombs", dir + wxString("/demos/bombs"),
324 wxStringList("bombs.cpp", "bombs1.cpp", "game.cpp", "bombs.h", "game.h", 0));
325
326 GenerateSample("FortyVC", "forty", dir + wxString("/demos/forty"),
327 wxStringList("forty.cpp", "canvas.cpp", "card.cpp", "game.cpp", "pile.cpp", "playerdg.cpp", "scoredg.cpp", "scorefil.cpp",
328 "canvas.h", "forty.h", "card.h", "game.h", "pile.h", "playerdg.h", "scoredg.h", "scorefil.h",
329 0));
330
331 GenerateSample("FractalVC", "fractal", dir + wxString("/demos/fractal"), wxStringList("fractal.cpp", 0));
332
333 GenerateSample("LifeVC", "life", dir + wxString("/demos/life"),
334 wxStringList("life.cpp", "game.cpp", "dialogs.cpp", "life.h", "game.h", "dialogs.h", 0));
335
336 GenerateSample("PoemVC", "wxpoem", dir + wxString("/demos/poem"), wxStringList("wxpoem.cpp", "wxpoem.h", 0));
337
338 GenerateSample("DbbrowseVC", "dbbrowse", dir + wxString("/demos/dbbrowse"),
339 wxStringList("dbbrowse.cpp", "browsedb.cpp", "dbgrid.cpp", "dbtree.cpp", "dlguser.cpp", "doc.cpp",
340 "pgmctrl.cpp", "tabpgwin.cpp",
341 "dbbrowse.h", "browsedb.h", "dbgrid.h", "dbtree.h", "dlguser.h", "doc.h", "pgmctrl.h", "std.h", "tabpgwin.h",
342 0));
343
344 //// Samples in contrib
345
346 // OGLEdit
347
348 GenerateSample("OGLEditVC", "ogledit", dir + wxString("/contrib/samples/ogl/ogledit"),
349 wxStringList("ogledit.cpp", "doc.cpp", "palette.cpp", "view.cpp",
350 "doc.h", "ogledit.h", "palette.h", "view.h", 0),
351 "../../../..",
352 wxStringList("ogld.lib", 0), wxStringList("ogl.lib", 0));
353
354 // OGL Studio
355
356 GenerateSample("StudioVC", "studio", dir + wxString("/contrib/samples/ogl/studio"),
357 wxStringList("studio.cpp", "cspalette.cpp", "dialogs.cpp", "view.cpp",
358 "doc.cpp", "mainfrm.cpp", "project.cpp", "shapes.cpp", "symbols.cpp", "csprint.cpp",
359 "studio.h", "cspalette.h", "dialogs.h", "view.h",
360 "doc.h", "mainfrm.h", "project.h", "shapes.h", "symbols.h", 0),
361 "../../../..",
362 wxStringList("ogld.lib", 0), wxStringList("ogl.lib", 0));
363
364 // MMedia mmboard
365
366 GenerateSample("MMboardVC", "mmboard", dir + wxString("/contrib/samples/mmedia"),
367 wxStringList("mmboard.cpp", "mmboard.h", "mmbman.cpp", "mmbman.h", 0),
368 "../../..",
369 wxStringList("mmediad.lib", 0), wxStringList("mmedia.lib", 0));
370
371 // STC (Scintilla widget)
372
373 GenerateSample("StcTestVC", "stctest", dir + wxString("/contrib/samples/stc"),
374 wxStringList("stctest.cpp", 0),
375 "../../..",
376 wxStringList("stcd.lib", 0), wxStringList("stc.lib", 0));
377
378 //// Utilities
379
380 // Dialog Editor
381
382 GenerateSample("DialogEdVC", "dialoged", dir + wxString("/utils/dialoged/src"),
383 wxStringList("dialoged.cpp", "dlghndlr.cpp", "edlist.cpp", "edtree.cpp",
384 "reseditr.cpp", "reswrite.cpp", "symbtabl.cpp", "winstyle.cpp", "winprop.cpp",
385 "dialoged.h", "dlghndlr.h", "edlist.h", "edtree.h", "reseditr.h", "symbtabl.h", "winprop.h",
386 "winstyle.h", 0),
387 "../../..");
388
389 // Tex2RTF
390
391 GenerateSample("Tex2RTFVC", "tex2rtf", dir + wxString("/utils/tex2rtf/src"),
392 wxStringList("tex2rtf.cpp", "htmlutil.cpp", "readshg.cpp", "rtfutils.cpp",
393 "table.cpp", "tex2any.cpp", "texutils.cpp", "xlputils.cpp",
394 "bmputils.h", "readshg.h", "rtfutils.h", "table.h", "tex2any.h", "tex2rtf.h", "wxhlpblk.h",
395 0),
396 "../../..");
397
398 // HelpGen
399
400 GenerateSample("HelpGenVC", "helpgen", dir + wxString("/utils/helpgen/src"),
401 wxStringList("helpgen.cpp", "cjparser.cpp", "docripper.cpp", "ifcontext.cpp",
402 "markup.cpp", "ripper_main.cpp", "scriptbinder.cpp", "sourcepainter.cpp",
403 "srcparser.cpp",
404 "cjparser.h", "docripper.h", "ifcontext.h", "markup.h", "scriptbinder.h", "sourcepainter.h",
405 "srcparser.h", "wxstlac.h", "wxstllst.h", "wxstlvec.h", 0),
406 "../../..");
407
408 // ProjGen
409 GenerateSample("ProjGenVC", "makeproj", dir + wxString("/utils/projgen"),
410 wxStringList("makeproj.cpp", "makeproj.h", 0),
411 "../..");
412
413 // hhp2cached
414
415 GenerateSample("hhp2cachedVC", "hhp2cached", dir + wxString("/utils/hhp2cached"),
416 wxStringList("hhp2cached.cpp", 0),
417 "../..");
418
419 }
420
421 // ----------------------------------------------------------------------------
422 // main frame
423 // ----------------------------------------------------------------------------
424
425 // frame constructor
426 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
427 : wxFrame((wxFrame *)NULL, -1, title, pos, size)
428 {
429 // set the frame icon
430 SetIcon(wxICON(mondrian));
431
432 // create a menu bar
433 wxMenu *menuFile = new wxMenu;
434
435 menuFile->Append(MakeProject_Generate, "&Generate");
436 menuFile->Append(MakeProject_About, "&About...");
437 menuFile->AppendSeparator();
438 menuFile->Append(MakeProject_Quit, "E&xit");
439
440 // now append the freshly created menu to the menu bar...
441 wxMenuBar *menuBar = new wxMenuBar;
442 menuBar->Append(menuFile, "&File");
443
444 // ... and attach this menu bar to the frame
445 SetMenuBar(menuBar);
446
447 // create a status bar just for fun (by default with 1 pane only)
448 CreateStatusBar(2);
449 SetStatusText("Welcome to wxWindows!");
450 }
451
452
453 // event handlers
454
455 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
456 {
457 // TRUE is to force the frame to close
458 Close(TRUE);
459 }
460
461 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
462 {
463 wxMessageBox("MakeProject: generates VC++ project files",
464 "About MakeProject", wxOK | wxICON_INFORMATION, this);
465 }
466
467 void MyFrame::OnGenerate(wxCommandEvent& WXUNUSED(event))
468 {
469 wxGetApp().GenerateSamples("d:/wx2/wxWindows");
470 }
471
472 bool MyFrame::GenerateSample(const wxString& projectName, const wxString& targetName,
473 const wxString& path, const wxStringList& sourceFiles, const wxString& relativeRootPath)
474 {
475 return wxGetApp().GenerateSample(projectName, targetName, path, sourceFiles, relativeRootPath);
476 }
477
478 /*
479 * wxProject
480 */
481
482 wxProject::wxProject()
483 {
484 }
485
486 wxProject::~wxProject()
487 {
488 }
489
490
491 bool wxProject::GenerateVCProject()
492 {
493 wxString fullProjectName = m_path + wxString("/") + m_projectName + ".dsp";
494
495 ofstream stream(fullProjectName);
496 if (stream.bad())
497 return FALSE;
498
499 /////////////////////// General stuff
500
501 stream << "# Microsoft Developer Studio Project File - Name=\"" << m_projectName << "\" - Package Owner=<4>\n";
502 stream << "# Microsoft Developer Studio Generated Build File, Format Version 5.00\n";
503 stream << "# (Actually, generated by MakeProject, (c) Julian Smart, 1998)\n";
504 stream << "# ** DO NOT EDIT **\n\n";
505 stream << "# TARGTYPE \"Win32 (x86) Application\" 0x0101\n\n";
506 stream << "CFG=" << m_projectName << " - Win32 Debug\n";
507 stream << "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n";
508 stream << "!MESSAGE use the Export Makefile command and run\n";
509 stream << "!MESSAGE\n";
510 stream << "!MESSAGE NMAKE /f \"" << m_projectName << ".mak\".\n";
511 stream << "!MESSAGE\n";
512 stream << "!MESSAGE You can specify a configuration when running NMAKE\n";
513 stream << "!MESSAGE by defining the macro CFG on the command line. For example:\n";
514 stream << "!MESSAGE\n";
515 stream << "!MESSAGE NMAKE /f \"" << m_projectName << ".mak\" CFG=\"" << m_projectName << " - Win32 Debug\"\n";
516 stream << "!MESSAGE\n";
517 stream << "!MESSAGE Possible choices for configuration are:\n";
518 stream << "!MESSAGE\n";
519 stream << "!MESSAGE \"" << m_projectName << " - Win32 Release\" (based on \"Win32 (x86) Application\")\n";
520 stream << "!MESSAGE \"" << m_projectName << " - Win32 Debug\" (based on \"Win32 (x86) Application\")\n";
521 stream << "!MESSAGE \"" << m_projectName << " - Win32 Debug DLL\" (based on \"Win32 (x86) Application\")\n";
522 stream << "!MESSAGE \"" << m_projectName << " - Win32 Release DLL\" (based on \"Win32 (x86) Application\")\n";
523 stream << "!MESSAGE\n";
524 stream << "\n";
525 stream << "# Begin Project\n";
526 stream << "# PROP Scc_ProjName \"\"\n";
527 stream << "# PROP Scc_LocalPath \"\"\n";
528 stream << "CPP=cl.exe\n";
529 stream << "MTL=midl.exe\n";
530 stream << "RSC=rc.exe\n";
531 stream << "\n";
532
533 /////////////////////// Win32 Release target
534
535 stream << "!IF \"$(CFG)\" == \"" << m_projectName << " - Win32 Release\"\n";
536 stream << "\n";
537 stream << "# PROP BASE Use_MFC 0\n";
538 stream << "# PROP BASE Use_Debug_Libraries 0\n";
539 stream << "# PROP BASE Output_Dir \"Release\"\n";
540 stream << "# PROP BASE Intermediate_Dir \"Release\"\n";
541 stream << "# PROP BASE Target_Dir \"\"\n";
542 stream << "# PROP Use_MFC 0\n";
543 stream << "# PROP Use_Debug_Libraries 0\n";
544 stream << "# PROP Output_Dir \"Release\"\n";
545 stream << "# PROP Intermediate_Dir \"Release\"\n";
546 stream << "# PROP Ignore_Export_Lib 0\n";
547 stream << "# PROP Target_Dir \"\"\n";
548 stream << "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /YX /FD /c\n";
549 stream << "# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2";
550
551 int n = m_includeDirs.Number();
552 int i;
553 for (i = 0; i < n; i++)
554 {
555 wxString includeDir = m_includeDirs[i];
556 stream << " /I \"" << includeDir << "\"";
557 }
558
559 stream << " /D \"NDEBUG\" /D \"WIN32\" /D \"_WINDOWS\" /D \"__WINDOWS__\" /D \"__WXMSW__\" /D \"__WIN95__\" /D \"__WIN32__\" /D WINVER=0x0400 /D \"STRICT\" /FD /c\n";
560 stream << "# SUBTRACT CPP /YX\n";
561 stream << "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o NUL /win32\n";
562 stream << "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o NUL /win32\n";
563 stream << "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\n";
564 stream << "# ADD RSC /l 0x809 /d \"NDEBUG\"\n";
565 stream << "BSC32=bscmake.exe\n";
566 stream << "# ADD BASE BSC32 /nologo\n";
567 stream << "# ADD BSC32 /nologo\n";
568 stream << "LINK32=link.exe\n";
569 stream << "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386\n";
570 stream << "# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wx.lib png.lib zlib.lib jpeg.lib tiff.lib ";
571 n = m_extraLibsRelease.Number();
572 for (i = 0; i < n; i++)
573 {
574 wxString lib = m_extraLibsRelease[i];
575 stream << lib << " ";
576 }
577
578 stream << "/nologo /subsystem:windows /machine:I386 /nodefaultlib:\"libc.lib,libci.lib,msvcrtd.lib\" /out:\"Release/" << m_targetName << ".exe\"";
579
580 n = m_releaseLibDirs.Number();
581 for (i = 0; i < n; i++)
582 {
583 wxString libDir = m_releaseLibDirs[i];
584 stream << " /libpath:\"" << libDir << "\"";
585 }
586 n = m_libDirs.Number();
587 for (i = 0; i < n; i++)
588 {
589 wxString libDir = m_libDirs[i];
590 stream << " /libpath:\"" << libDir << "\"";
591 }
592 stream << "\n";
593 stream << "\n";
594
595 /////////////////////// Win32 Debug target
596
597 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Debug\"\n";
598 stream << "\n";
599 stream << "# PROP BASE Use_MFC 0\n";
600 stream << "# PROP BASE Use_Debug_Libraries 1\n";
601 stream << "# PROP BASE Output_Dir \"Debug\"\n";
602 stream << "# PROP BASE Intermediate_Dir \"Debug\"\n";
603 stream << "# PROP BASE Target_Dir \"\"\n";
604 stream << "# PROP Use_MFC 0\n";
605 stream << "# PROP Use_Debug_Libraries 1\n";
606 stream << "# PROP Output_Dir \"Debug\"\n";
607 stream << "# PROP Intermediate_Dir \"Debug\"\n";
608 stream << "# PROP Ignore_Export_Lib 0\n";
609 stream << "# PROP Target_Dir \"\"\n";
610 stream << "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /YX /FD /c\n";
611 stream << "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
612
613 n = m_includeDirs.Number();
614 for (i = 0; i < n; i++)
615 {
616 wxString includeDir = m_includeDirs[i];
617 stream << " /I \"" << includeDir << "\"";
618 }
619
620 stream << " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"__WINDOWS__\" /D \"__WXMSW__\" /D DEBUG=1 /D \"__WXDEBUG__\" /D \"__WIN95__\" /D \"__WIN32__\" /D WINVER=0x0400 /D \"STRICT\" /Yu\"wx/wxprec.h\" /FD /c\n";
621 stream << "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /o NUL /win32\n";
622 stream << "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /o NUL /win32\n";
623 stream << "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\n";
624 stream << "# ADD RSC /l 0x809 /d \"_DEBUG\"\n";
625 stream << "BSC32=bscmake.exe\n";
626 stream << "# ADD BASE BSC32 /nologo\n";
627 stream << "# ADD BSC32 /nologo\n";
628 stream << "LINK32=link.exe\n";
629 stream << "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\n";
630 stream << "# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib ";
631 n = m_extraLibsDebug.Number();
632 for (i = 0; i < n; i++)
633 {
634 wxString lib = m_extraLibsDebug[i];
635 stream << lib << " ";
636 }
637 stream << "/nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:\"libcd.lib,libcid.lib,msvcrt.lib\" /out:\"Debug/" << m_targetName << ".exe\" /pdbtype:sept";
638
639 n = m_debugLibDirs.Number();
640 for (i = 0; i < n; i++)
641 {
642 wxString libDir = m_debugLibDirs[i];
643 stream << " /libpath:\"" << libDir << "\"";
644 }
645 n = m_libDirs.Number();
646 for (i = 0; i < n; i++)
647 {
648 wxString libDir = m_libDirs[i];
649 stream << " /libpath:\"" << libDir << "\"";
650 }
651 stream << "\n";
652 stream << "\n";
653 // stream << "!ENDIF\n";
654 // stream << "\n";
655
656 /////////////////////// Win32 Debug DLL target
657
658 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Debug DLL\"\n";
659 stream << "\n";
660 stream << "# PROP BASE Use_MFC 0\n";
661 stream << "# PROP BASE Use_Debug_Libraries 1\n";
662 stream << "# PROP BASE Output_Dir \"DebugDLL\"\n";
663 stream << "# PROP BASE Intermediate_Dir \"DebugDLL\"\n";
664 stream << "# PROP BASE Target_Dir \"\"\n";
665 stream << "# PROP Use_MFC 0\n";
666 stream << "# PROP Use_Debug_Libraries 1\n";
667 stream << "# PROP Output_Dir \"DebugDLL\"\n";
668 stream << "# PROP Intermediate_Dir \"DebugDLL\"\n";
669 stream << "# PROP Ignore_Export_Lib 0\n";
670 stream << "# PROP Target_Dir \"\"\n";
671 stream << "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /YX /FD /c\n";
672 stream << "# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od";
673
674 n = m_includeDirs.Number();
675 for (i = 0; i < n; i++)
676 {
677 wxString includeDir = m_includeDirs[i];
678 stream << " /I \"" << includeDir << "\"";
679 }
680
681 stream << " /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"__WINDOWS__\" /D \"__WXMSW__\" /D DEBUG=1 /D \"__WXDEBUG__\" /D \"__WIN95__\" /D \"__WIN32__\" /D WINVER=0x0400 /D \"STRICT\" /D WXUSINGDLL=1 /Yu\"wx/wxprec.h\" /FD /c\n";
682 stream << "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /o NUL /win32\n";
683 stream << "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /o NUL /win32\n";
684 stream << "# ADD BASE RSC /l 0x809 /d \"_DEBUG\"\n";
685 stream << "# ADD RSC /l 0x809 /d \"_DEBUG\"\n";
686 stream << "BSC32=bscmake.exe\n";
687 stream << "# ADD BASE BSC32 /nologo\n";
688 stream << "# ADD BSC32 /nologo\n";
689 stream << "LINK32=link.exe\n";
690 stream << "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\n";
691 stream << "# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxdlld.lib ";
692 n = m_extraLibsDebug.Number();
693 for (i = 0; i < n; i++)
694 {
695 wxString lib = m_extraLibsDebug[i];
696 stream << lib << " ";
697 }
698 stream << "/nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:\"libcd.lib\" /nodefaultlib:\"libcid.lib\" /out:\"DebugDLL/" << m_targetName << ".exe\" /pdbtype:sept";
699
700 n = m_debugLibDirs.Number();
701 for (i = 0; i < n; i++)
702 {
703 wxString libDir = m_debugLibDirs[i];
704 libDir += "DLL"; // Assume that we have e.g. Debug so make it DebugDLL
705 stream << " /libpath:\"" << libDir << "\"";
706 }
707 n = m_libDirs.Number();
708 for (i = 0; i < n; i++)
709 {
710 wxString libDir = m_libDirs[i];
711 stream << " /libpath:\"" << libDir << "\"";
712 }
713 stream << "\n";
714 stream << "\n";
715 // stream << "!ENDIF\n";
716 // stream << "\n";
717
718 /////////////////////// Win32 Release DLL target
719
720 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Release DLL\"\n";
721 stream << "\n";
722 stream << "# PROP BASE Use_MFC 0\n";
723 stream << "# PROP BASE Use_Debug_Libraries 0\n";
724 stream << "# PROP BASE Output_Dir \"ReleaseDLL\"\n";
725 stream << "# PROP BASE Intermediate_Dir \"ReleaseDLL\"\n";
726 stream << "# PROP BASE Target_Dir \"\"\n";
727 stream << "# PROP Use_MFC 0\n";
728 stream << "# PROP Use_Debug_Libraries 0\n";
729 stream << "# PROP Output_Dir \"ReleaseDLL\"\n";
730 stream << "# PROP Intermediate_Dir \"ReleaseDLL\"\n";
731 stream << "# PROP Ignore_Export_Lib 0\n";
732 stream << "# PROP Target_Dir \"\"\n";
733 stream << "# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /YX /FD /c\n";
734 stream << "# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2";
735
736 n = m_includeDirs.Number();
737 for (i = 0; i < n; i++)
738 {
739 wxString includeDir = m_includeDirs[i];
740 stream << " /I \"" << includeDir << "\"";
741 }
742
743 stream << " /D \"NDEBUG\" /D \"WIN32\" /D \"_WINDOWS\" /D \"__WINDOWS__\" /D \"__WXMSW__\" /D \"__WIN95__\" /D \"__WIN32__\" /D WINVER=0x0400 /D \"STRICT\" /D WXUSINGDLL=1 /FD /c\n";
744 stream << "# SUBTRACT CPP /YX\n";
745 stream << "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o NUL /win32\n";
746 stream << "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o NUL /win32\n";
747 stream << "# ADD BASE RSC /l 0x809 /d \"NDEBUG\"\n";
748 stream << "# ADD RSC /l 0x809 /d \"NDEBUG\"\n";
749 stream << "BSC32=bscmake.exe\n";
750 stream << "# ADD BASE BSC32 /nologo\n";
751 stream << "# ADD BSC32 /nologo\n";
752 stream << "LINK32=link.exe\n";
753 stream << "# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386\n";
754 stream << "# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib wxdll.lib ";
755 n = m_extraLibsRelease.Number();
756 for (i = 0; i < n; i++)
757 {
758 wxString lib = m_extraLibsRelease[i];
759 stream << lib << " ";
760 }
761 stream << "/nologo /subsystem:windows /machine:I386 /nodefaultlib:\"libc.lib\" /nodefaultlib:\"libci.lib\" /out:\"ReleaseDLL/" << m_targetName << ".exe\"";
762
763 n = m_releaseLibDirs.Number();
764 for (i = 0; i < n; i++)
765 {
766 wxString libDir = m_releaseLibDirs[i];
767 libDir += "DLL"; // Assume that we have e.g. Release so make it ReleaseDLL
768 stream << " /libpath:\"" << libDir << "\"";
769 }
770 n = m_libDirs.Number();
771 for (i = 0; i < n; i++)
772 {
773 wxString libDir = m_libDirs[i];
774 stream << " /libpath:\"" << libDir << "\"";
775 }
776 stream << "\n";
777 stream << "\n";
778 stream << "!ENDIF\n";
779 stream << "\n";
780
781 /////////////////////// Source code for targets
782
783 stream << "# Begin Target\n";
784 stream << "\n";
785 stream << "# Name \"" << m_projectName << " - Win32 Release\"\n";
786 stream << "# Name \"" << m_projectName << " - Win32 Debug\"\n";
787 stream << "# Name \"" << m_projectName << " - Win32 Debug DLL\"\n";
788 stream << "# Name \"" << m_projectName << " - Win32 Release DLL\"\n";
789
790 // C++ source files
791 n = m_sourceFiles.Number();
792 for (i = 0; i < n; i++)
793 {
794 wxString sourceFile = m_sourceFiles[i];
795
796 stream << "# Begin Source File\n";
797 stream << "\n";
798 stream << "SOURCE=.\\" << sourceFile << "\n";
799 stream << "\n";
800 stream << "!IF \"$(CFG)\" == \"" << m_projectName << " - Win32 Release\"\n";
801 stream << "\n";
802 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Debug\"\n";
803 stream << "\n";
804 stream << "# SUBTRACT CPP /YX /Yc /Yu\n";
805 stream << "\n";
806 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Debug DLL\"\n";
807 stream << "\n";
808 stream << "# SUBTRACT BASE CPP /YX /Yc /Yu\n";
809 stream << "# SUBTRACT CPP /YX /Yc /Yu\n";
810 stream << "\n";
811 stream << "!ELSEIF \"$(CFG)\" == \"" << m_projectName << " - Win32 Release DLL\"\n";
812 stream << "\n";
813 stream << "!ENDIF\n";
814 stream << "\n";
815 stream << "# End Source File\n";
816 }
817
818 // The .rc file: assume it has the target name + rc extension.
819 stream << "# Begin Source File\n";
820 stream << "\n";
821 stream << "SOURCE=.\\" << m_targetName << ".rc\n";
822 stream << "# ADD BASE RSC /l 0x809\n";
823 stream << "# ADD RSC /l 0x809";
824
825 n = m_resourceIncludeDirs.Number();
826 for (i = 0; i < n; i++)
827 {
828 wxString includeDir = m_resourceIncludeDirs[i];
829 stream << " /i \"" << includeDir << "\"";
830 }
831
832 stream << "\n";
833 stream << "# End Source File\n";
834 stream << "# End Target\n";
835 stream << "# End Project\n";
836
837 // Now generate the .dsw workspace file
838
839 wxString fullWorkSpaceName = m_path + wxString("/") + m_projectName + ".dsw";
840
841 ofstream stream2(fullWorkSpaceName);
842 if (stream2.bad())
843 return FALSE;
844
845 stream2 << "Microsoft Developer Studio Workspace File, Format Version 5.00\n";
846 stream2 << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n";
847 stream2 << "\n";
848 stream2 << "###############################################################################\n";
849 stream2 << "\n";
850 stream2 << "Project: \"" << m_projectName << "\"=.\\" << m_projectName << ".dsp - Package Owner=<4>\n";
851 stream2 << "\n";
852 stream2 << "Package=<5>\n";
853 stream2 << "{{{\n";
854 stream2 << "}}}\n";
855 stream2 << "\n";
856 stream2 << "Package=<4>\n";
857 stream2 << "{{{\n";
858 stream2 << "}}}\n";
859 stream2 << "\n";
860 stream2 << "###############################################################################\n";
861 stream2 << "\n";
862 stream2 << "Global:\n";
863 stream2 << "\n";
864 stream2 << "Package=<5>\n";
865 stream2 << "{{{\n";
866 stream2 << "}}}\n";
867 stream2 << "\n";
868 stream2 << "Package=<3>\n";
869 stream2 << "{{{\n";
870 stream2 << "}}}\n";
871 stream2 << "\n";
872 stream2 << "###############################################################################\n";
873 stream2 << "\n";
874
875 return TRUE;
876 }
877
878 BEGIN_EVENT_TABLE(MyDialog, wxDialog)
879 EVT_BUTTON(wxID_EXIT, MyDialog::OnQuit)
880 EVT_BUTTON(ID_GENERATE_PROJECT, MyDialog::OnGenerate)
881 EVT_BUTTON(ID_GENERATE_SAMPLES, MyDialog::OnGenerateSamples)
882 END_EVENT_TABLE()
883
884 // ----------------------------------------------------------------------------
885 // main frame
886 // ----------------------------------------------------------------------------
887
888 // frame constructor
889 MyDialog::MyDialog(const wxString& title, const wxPoint& pos, const wxSize& size):
890 wxDialog()
891 {
892 LoadFromResource((wxWindow*) NULL, "project_dialog");
893
894 }
895
896 void MyDialog::OnQuit(wxCommandEvent& event)
897 {
898 this->EndModal(wxID_OK);
899 }
900
901 void MyDialog::OnAbout(wxCommandEvent& event)
902 {
903 }
904
905 void MyDialog::OnGenerate(wxCommandEvent& event)
906 {
907 }
908
909 void MyDialog::OnGenerateSamples(wxCommandEvent& event)
910 {
911 char* dir = getenv("WXWIN");
912 wxString dirStr;
913 if (dir)
914 dirStr = dir;
915 wxTextEntryDialog dialog(this, "Please enter the wxWindows directory", "Text entry", dirStr, wxOK|wxCANCEL);
916 if (dialog.ShowModal() == wxID_OK)
917 {
918 if (wxDirExists(dialog.GetValue()))
919 {
920 // wxGetApp().GenerateSample("MinimalVC", "minimal", dir + wxString("/samples/minimal"),
921 // wxStringList("minimal.cpp", 0));
922
923 wxGetApp().GenerateSamples(dialog.GetValue());
924 }
925 else
926 {
927 wxMessageBox("This directory doesn't exist.");
928 }
929 }
930 }
931