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