]>
git.saurik.com Git - wxWidgets.git/blob - contrib/samples/xrc/xrcdemo.cpp
1 //-----------------------------------------------------------------------------
3 // Purpose: XML resources sample: Main application file
4 // Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
6 // Copyright: (c) Robert O'Connor and Vaclav Slavik
7 // Licence: wxWindows licence
8 //-----------------------------------------------------------------------------
10 //-----------------------------------------------------------------------------
12 //-----------------------------------------------------------------------------
15 #pragma implementation "xrcdemo.h"
18 //-----------------------------------------------------------------------------
19 // Standard wxWindows headers
20 //-----------------------------------------------------------------------------
22 // For compilers that support precompilation, includes "wx/wx.h".
23 #include "wx/wxprec.h"
29 // For all others, include the necessary headers (this file is usually all you
30 // need because it includes almost all "standard" wxWindows headers)
35 //-----------------------------------------------------------------------------
36 // Header of this .cpp file
37 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 // Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
43 //-----------------------------------------------------------------------------
45 #include "wx/image.h" // wxImage
47 //-----------------------------------------------------------------------------
49 #include "wx/xrc/xmlres.h" // XRC XML resouces
51 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 // wxWindows macro: Declare the application.
57 //-----------------------------------------------------------------------------
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
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 // 'Main program' equivalent: the program execution "starts" here
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
);
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();
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.
91 wxXmlResource::Get()->Load("rc/menu.xrc");
93 wxXmlResource::Get()->Load("rc/toolbar.xrc");
94 // Non-derived dialog example
95 wxXmlResource::Get()->Load("rc/basicdlg.xrc");
96 // Derived dialog example
97 wxXmlResource::Get()->Load("rc/derivdlg.xrc");
98 // Controls property example
99 wxXmlResource::Get()->Load("rc/controls.xrc");
101 wxXmlResource::Get()->Load("rc/frame.xrc");
102 // Uncentered example
103 wxXmlResource::Get()->Load("rc/uncenter.xrc");
104 // Custom class example
105 wxXmlResource::Get()->Load("rc/custclas.xrc");
106 // wxArtProvider example
107 wxXmlResource::Get()->Load("rc/artprov.xrc");
108 // Platform property example
109 wxXmlResource::Get()->Load("rc/platform.xrc");
110 // Variable expansion example
111 wxXmlResource::Get()->Load("rc/variable.xrc");
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();
121 // Return TRUE to tell program to continue (FALSE would terminate).