]>
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
5 // Copyright: (c) Robert O'Connor and Vaclav Slavik
6 // Licence: wxWindows licence
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
10 // Standard wxWidgets headers
11 //-----------------------------------------------------------------------------
13 // For compilers that support precompilation, includes "wx/wx.h".
14 #include "wx/wxprec.h"
20 // For all others, include the necessary headers (this file is usually all you
21 // need because it includes almost all "standard" wxWidgets headers)
26 //-----------------------------------------------------------------------------
27 // Header of this .cpp file
28 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 // Remaining headers: Needed wx headers, then wx/contrib headers, then app one
34 //-----------------------------------------------------------------------------
36 #include "wx/image.h" // wxImage
38 #include "wx/xrc/xmlres.h" // XRC XML resources
41 #include "wx/xrc/xh_ribbon.h"
42 #endif // wxUSE_RIBBON
44 #include "wx/cshelp.h" // wxSimpleHelpProvider for helptext
48 //-----------------------------------------------------------------------------
49 // wxWidgets macro: Declare the application.
50 //-----------------------------------------------------------------------------
52 // Create a new application object: this macro will allow wxWidgets to create
53 // the application object during program execution (it's better than using a
54 // static object for many reasons) and also declares the accessor function
55 // wxGetApp() which will return the reference of the right type (i.e. the_app and
59 //-----------------------------------------------------------------------------
61 //-----------------------------------------------------------------------------
63 // 'Main program' equivalent: the program execution "starts" here
66 if ( !wxApp::OnInit() )
69 // If there is any of a certain format of image in the xrcs, then first
70 // load a handler for that image type. This example uses XPMs & a gif, but
71 // if you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
72 // documentation for the types of image handlers available.
73 wxImage::AddHandler(new wxXPMHandler
);
74 wxImage::AddHandler(new wxGIFHandler
);
76 // Initialize all the XRC handlers. Always required (unless you feel like
77 // going through and initializing a handler of each control type you will
78 // be using (ie initialize the spinctrl handler, initialize the textctrl
79 // handler). However, if you are only using a few control types, it will
80 // save some space to only initialize the ones you will be using. See
81 // wxXRC docs for details.
82 wxXmlResource::Get()->InitAllHandlers();
85 wxXmlResource::Get()->AddHandler(new wxRibbonXmlHandler
);
88 // Load all of the XRC files that will be used. You can put everything
89 // into one giant XRC file if you wanted, but then they become more
90 // diffcult to manage, and harder to reuse in later projects.
91 if ( !wxXmlResource::Get()->LoadAllFiles("rc") )
95 // Use the simple help provider to show the context-sensitive help
96 wxHelpProvider::Set( new wxSimpleHelpProvider
);
99 // Make an instance of your derived frame. Passing NULL (the default value
100 // of MyFrame's constructor is NULL) as the frame doesn't have a parent
101 // since it is the main application window.
102 MyFrame
*frame
= new MyFrame();
104 // Show the frame as it's created initially hidden.
107 // Return true to tell program to continue (false would terminate).