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