]>
git.saurik.com Git - wxWidgets.git/blob - 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 //-----------------------------------------------------------------------------
11 // Standard wxWidgets headers
12 //-----------------------------------------------------------------------------
14 // For compilers that support precompilation, includes "wx/wx.h".
15 #include "wx/wxprec.h"
21 // For all others, include the necessary headers (this file is usually all you
22 // need because it includes almost all "standard" wxWidgets headers)
27 //-----------------------------------------------------------------------------
28 // Header of this .cpp file
29 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 // Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
35 //-----------------------------------------------------------------------------
37 #include "wx/image.h" // wxImage
39 //-----------------------------------------------------------------------------
41 #include "wx/xrc/xmlres.h" // XRC XML resouces
43 //-----------------------------------------------------------------------------
47 //-----------------------------------------------------------------------------
48 // wxWidgets macro: Declare the application.
49 //-----------------------------------------------------------------------------
51 // Create a new application object: this macro will allow wxWidgets to create
52 // the application object during program execution (it's better than using a
53 // static object for many reasons) and also declares the accessor function
54 // wxGetApp() which will return the reference of the right type (i.e. the_app and
58 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
62 // 'Main program' equivalent: the program execution "starts" here
65 // If there is any of a certain format of image in the xrcs, then first
66 // load a handler for that image type. This example uses XPMs, but if
67 // you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
68 // documentation for the types of image handlers available.
69 wxImage::AddHandler(new wxXPMHandler
);
71 // Initialize all the XRC handlers. Always required (unless you feel like
72 // going through and initializing a handler of each control type you will
73 // be using (ie initialize the spinctrl handler, initialize the textctrl
74 // handler). However, if you are only using a few control types, it will
75 // save some space to only initialize the ones you will be using. See
76 // wxXRC docs for details.
77 wxXmlResource::Get()->InitAllHandlers();
79 // Load all of the XRC files that will be used. You can put everything
80 // into one giant XRC file if you wanted, but then they become more
81 // diffcult to manage, and harder to reuse in later projects.
83 wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
85 wxXmlResource::Get()->Load(wxT("rc/toolbar.xrc"));
86 // Non-derived dialog example
87 wxXmlResource::Get()->Load(wxT("rc/basicdlg.xrc"));
88 // Derived dialog example
89 wxXmlResource::Get()->Load(wxT("rc/derivdlg.xrc"));
90 // Controls property example
91 wxXmlResource::Get()->Load(wxT("rc/controls.xrc"));
93 wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
95 wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
96 // Custom class example
97 wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
98 // wxArtProvider example
99 wxXmlResource::Get()->Load(wxT("rc/artprov.xrc"));
100 // Platform property example
101 wxXmlResource::Get()->Load(wxT("rc/platform.xrc"));
102 // Variable expansion example
103 wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
105 // Make an instance of your derived frame. Passing NULL (the default value
106 // of MyFrame's constructor is NULL) as the frame doesn't have a parent
107 // since it is the main application window.
108 MyFrame
*frame
= new MyFrame();
110 // Show the frame as it's created initially hidden.
113 // Return true to tell program to continue (false would terminate).