]>
Commit | Line | Data |
---|---|---|
af1337b0 JS |
1 | //----------------------------------------------------------------------------- |
2 | // Name: xrcdemo.cpp | |
3 | // Purpose: XML resources sample: Main application file | |
4 | // Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik | |
64d452a8 | 5 | // RCS-ID: $Id$ |
af1337b0 | 6 | // Copyright: (c) Robert O'Connor and Vaclav Slavik |
64d452a8 | 7 | // Licence: wxWindows licence |
af1337b0 | 8 | //----------------------------------------------------------------------------- |
64d452a8 | 9 | |
af1337b0 | 10 | //----------------------------------------------------------------------------- |
be5a51fb | 11 | // Standard wxWidgets headers |
af1337b0 JS |
12 | //----------------------------------------------------------------------------- |
13 | ||
64d452a8 VS |
14 | // For compilers that support precompilation, includes "wx/wx.h". |
15 | #include "wx/wxprec.h" | |
16 | ||
17 | #ifdef __BORLANDC__ | |
18 | #pragma hdrstop | |
19 | #endif | |
20 | ||
af1337b0 | 21 | // For all others, include the necessary headers (this file is usually all you |
be5a51fb | 22 | // need because it includes almost all "standard" wxWidgets headers) |
64d452a8 VS |
23 | #ifndef WX_PRECOMP |
24 | #include "wx/wx.h" | |
64d452a8 VS |
25 | #endif |
26 | ||
af1337b0 JS |
27 | //----------------------------------------------------------------------------- |
28 | // Header of this .cpp file | |
29 | //----------------------------------------------------------------------------- | |
64d452a8 | 30 | |
af1337b0 | 31 | #include "xrcdemo.h" |
64d452a8 | 32 | |
af1337b0 | 33 | //----------------------------------------------------------------------------- |
23bc3597 | 34 | // Remaining headers: Needed wx headers, then wx/contrib headers, then app one |
af1337b0 | 35 | //----------------------------------------------------------------------------- |
64d452a8 | 36 | |
af1337b0 JS |
37 | #include "wx/image.h" // wxImage |
38 | ||
23bc3597 | 39 | #include "wx/xrc/xmlres.h" // XRC XML resources |
af1337b0 | 40 | |
74a59798 VZ |
41 | #if wxUSE_RIBBON |
42 | #include "wx/xrc/xh_ribbon.h" | |
43 | #endif // wxUSE_RIBBON | |
44 | ||
23bc3597 | 45 | #include "wx/cshelp.h" // wxSimpleHelpProvider for helptext |
af1337b0 JS |
46 | |
47 | #include "myframe.h" | |
48 | ||
49 | //----------------------------------------------------------------------------- | |
be5a51fb | 50 | // wxWidgets macro: Declare the application. |
af1337b0 | 51 | //----------------------------------------------------------------------------- |
64d452a8 | 52 | |
be5a51fb | 53 | // Create a new application object: this macro will allow wxWidgets to create |
64d452a8 VS |
54 | // the application object during program execution (it's better than using a |
55 | // static object for many reasons) and also declares the accessor function | |
af1337b0 JS |
56 | // wxGetApp() which will return the reference of the right type (i.e. the_app and |
57 | // not wxApp). | |
64d452a8 VS |
58 | IMPLEMENT_APP(MyApp) |
59 | ||
af1337b0 JS |
60 | //----------------------------------------------------------------------------- |
61 | // Public methods | |
62 | //----------------------------------------------------------------------------- | |
64d452a8 VS |
63 | |
64 | // 'Main program' equivalent: the program execution "starts" here | |
65 | bool MyApp::OnInit() | |
66 | { | |
45e6e6f8 VZ |
67 | if ( !wxApp::OnInit() ) |
68 | return false; | |
69 | ||
af1337b0 | 70 | // If there is any of a certain format of image in the xrcs, then first |
0526c8cc VZ |
71 | // load a handler for that image type. This example uses XPMs & a gif, but |
72 | // if you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler() | |
af1337b0 JS |
73 | // documentation for the types of image handlers available. |
74 | wxImage::AddHandler(new wxXPMHandler); | |
0526c8cc | 75 | wxImage::AddHandler(new wxGIFHandler); |
f80ea77b | 76 | |
af1337b0 JS |
77 | // Initialize all the XRC handlers. Always required (unless you feel like |
78 | // going through and initializing a handler of each control type you will | |
79 | // be using (ie initialize the spinctrl handler, initialize the textctrl | |
80 | // handler). However, if you are only using a few control types, it will | |
81 | // save some space to only initialize the ones you will be using. See | |
82 | // wxXRC docs for details. | |
f80ea77b WS |
83 | wxXmlResource::Get()->InitAllHandlers(); |
84 | ||
74a59798 VZ |
85 | #if wxUSE_RIBBON |
86 | wxXmlResource::Get()->AddHandler(new wxRibbonXmlHandler); | |
87 | #endif | |
88 | ||
af1337b0 | 89 | // Load all of the XRC files that will be used. You can put everything |
f80ea77b WS |
90 | // into one giant XRC file if you wanted, but then they become more |
91 | // diffcult to manage, and harder to reuse in later projects. | |
2bb9a404 | 92 | if ( !wxXmlResource::Get()->LoadAllFiles("rc") ) |
885a9fe9 VZ |
93 | return false; |
94 | ||
23bc3597 VZ |
95 | #if wxUSE_HELP |
96 | // Use the simple help provider to show the context-sensitive help | |
97 | wxHelpProvider::Set( new wxSimpleHelpProvider ); | |
98 | #endif // wxUSE_HELP | |
99 | ||
f80ea77b | 100 | // Make an instance of your derived frame. Passing NULL (the default value |
2148dc99 VZ |
101 | // of MyFrame's constructor is NULL) as the frame doesn't have a parent |
102 | // since it is the main application window. | |
af1337b0 | 103 | MyFrame *frame = new MyFrame(); |
f80ea77b | 104 | |
2148dc99 | 105 | // Show the frame as it's created initially hidden. |
f80ea77b WS |
106 | frame->Show(true); |
107 | ||
108 | // Return true to tell program to continue (false would terminate). | |
109 | return true; | |
64d452a8 VS |
110 | } |
111 |