]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/xrc/xrcdemo.cpp
added rule for building wx plugins
[wxWidgets.git] / contrib / samples / xrc / xrcdemo.cpp
1 //-----------------------------------------------------------------------------
2 // Name: xrcdemo.cpp
3 // Purpose: XML resources sample: Main application file
4 // Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) Robert O'Connor and Vaclav Slavik
7 // Licence: wxWindows licence
8 //-----------------------------------------------------------------------------
9
10 //-----------------------------------------------------------------------------
11 // GCC implementation
12 //-----------------------------------------------------------------------------
13
14 #ifdef __GNUG__
15 #pragma implementation "xrcdemo.h"
16 #endif
17
18 //-----------------------------------------------------------------------------
19 // Standard wxWindows headers
20 //-----------------------------------------------------------------------------
21
22 // For compilers that support precompilation, includes "wx/wx.h".
23 #include "wx/wxprec.h"
24
25 #ifdef __BORLANDC__
26 #pragma hdrstop
27 #endif
28
29 // For all others, include the necessary headers (this file is usually all you
30 // need because it includes almost all "standard" wxWindows headers)
31 #ifndef WX_PRECOMP
32 #include "wx/wx.h"
33 #endif
34
35 //-----------------------------------------------------------------------------
36 // Header of this .cpp file
37 //-----------------------------------------------------------------------------
38
39 #include "xrcdemo.h"
40
41 //-----------------------------------------------------------------------------
42 // Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
43 //-----------------------------------------------------------------------------
44
45 #include "wx/image.h" // wxImage
46
47 //-----------------------------------------------------------------------------
48
49 #include "wx/xrc/xmlres.h" // XRC XML resouces
50
51 //-----------------------------------------------------------------------------
52
53 #include "myframe.h"
54
55 //-----------------------------------------------------------------------------
56 // wxWindows macro: Declare the application.
57 //-----------------------------------------------------------------------------
58
59 // Create a new application object: this macro will allow wxWindows to create
60 // the application object during program execution (it's better than using a
61 // static object for many reasons) and also declares the accessor function
62 // wxGetApp() which will return the reference of the right type (i.e. the_app and
63 // not wxApp).
64 IMPLEMENT_APP(MyApp)
65
66 //-----------------------------------------------------------------------------
67 // Public methods
68 //-----------------------------------------------------------------------------
69
70 // 'Main program' equivalent: the program execution "starts" here
71 bool MyApp::OnInit()
72 {
73 // If there is any of a certain format of image in the xrcs, then first
74 // load a handler for that image type. This example uses XPMs, but if
75 // you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
76 // documentation for the types of image handlers available.
77 wxImage::AddHandler(new wxXPMHandler);
78
79 // Initialize all the XRC handlers. Always required (unless you feel like
80 // going through and initializing a handler of each control type you will
81 // be using (ie initialize the spinctrl handler, initialize the textctrl
82 // handler). However, if you are only using a few control types, it will
83 // save some space to only initialize the ones you will be using. See
84 // wxXRC docs for details.
85 wxXmlResource::Get()->InitAllHandlers();
86
87 // Load all of the XRC files that will be used. You can put everything
88 // into one giant XRC file if you wanted, but then they become more
89 // diffcult to manage, and harder to reuse in later projects.
90 // The menubar
91 wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
92 // The toolbar
93 wxXmlResource::Get()->Load(wxT("rc/toolbar.xrc"));
94 // Non-derived dialog example
95 wxXmlResource::Get()->Load(wxT("rc/basicdlg.xrc"));
96 // Derived dialog example
97 wxXmlResource::Get()->Load(wxT("rc/derivdlg.xrc"));
98 // Controls property example
99 wxXmlResource::Get()->Load(wxT("rc/controls.xrc"));
100 // Frame example
101 wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
102 // Uncentered example
103 wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
104 // Custom class example
105 wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
106 // wxArtProvider example
107 wxXmlResource::Get()->Load(wxT("rc/artprov.xrc"));
108 // Platform property example
109 wxXmlResource::Get()->Load(wxT("rc/platform.xrc"));
110 // Variable expansion example
111 wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
112
113 // Make an instance of your derived frame. Passing NULL (the default value
114 // of MyFrame's constructor is NULL) as the frame doesn't have a frame
115 // since it is the first window.
116 MyFrame *frame = new MyFrame();
117
118 // Show the frame.
119 frame->Show(TRUE);
120
121 // Return TRUE to tell program to continue (FALSE would terminate).
122 return TRUE;
123 }
124