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