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