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