]>
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 | |
af1337b0 | 5 | // Copyright: (c) Robert O'Connor and Vaclav Slavik |
64d452a8 | 6 | // Licence: wxWindows licence |
af1337b0 | 7 | //----------------------------------------------------------------------------- |
64d452a8 | 8 | |
af1337b0 | 9 | //----------------------------------------------------------------------------- |
be5a51fb | 10 | // Standard wxWidgets headers |
af1337b0 JS |
11 | //----------------------------------------------------------------------------- |
12 | ||
64d452a8 VS |
13 | // For compilers that support precompilation, includes "wx/wx.h". |
14 | #include "wx/wxprec.h" | |
15 | ||
16 | #ifdef __BORLANDC__ | |
17 | #pragma hdrstop | |
18 | #endif | |
19 | ||
af1337b0 | 20 | // For all others, include the necessary headers (this file is usually all you |
be5a51fb | 21 | // need because it includes almost all "standard" wxWidgets headers) |
64d452a8 VS |
22 | #ifndef WX_PRECOMP |
23 | #include "wx/wx.h" | |
64d452a8 VS |
24 | #endif |
25 | ||
af1337b0 JS |
26 | //----------------------------------------------------------------------------- |
27 | // Header of this .cpp file | |
28 | //----------------------------------------------------------------------------- | |
64d452a8 | 29 | |
af1337b0 | 30 | #include "xrcdemo.h" |
64d452a8 | 31 | |
af1337b0 | 32 | //----------------------------------------------------------------------------- |
23bc3597 | 33 | // Remaining headers: Needed wx headers, then wx/contrib headers, then app one |
af1337b0 | 34 | //----------------------------------------------------------------------------- |
64d452a8 | 35 | |
af1337b0 JS |
36 | #include "wx/image.h" // wxImage |
37 | ||
23bc3597 | 38 | #include "wx/xrc/xmlres.h" // XRC XML resources |
af1337b0 | 39 | |
74a59798 VZ |
40 | #if wxUSE_RIBBON |
41 | #include "wx/xrc/xh_ribbon.h" | |
42 | #endif // wxUSE_RIBBON | |
43 | ||
23bc3597 | 44 | #include "wx/cshelp.h" // wxSimpleHelpProvider for helptext |
af1337b0 JS |
45 | |
46 | #include "myframe.h" | |
47 | ||
48 | //----------------------------------------------------------------------------- | |
be5a51fb | 49 | // wxWidgets macro: Declare the application. |
af1337b0 | 50 | //----------------------------------------------------------------------------- |
64d452a8 | 51 | |
be5a51fb | 52 | // Create a new application object: this macro will allow wxWidgets to create |
64d452a8 VS |
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 | |
af1337b0 JS |
55 | // wxGetApp() which will return the reference of the right type (i.e. the_app and |
56 | // not wxApp). | |
64d452a8 VS |
57 | IMPLEMENT_APP(MyApp) |
58 | ||
af1337b0 JS |
59 | //----------------------------------------------------------------------------- |
60 | // Public methods | |
61 | //----------------------------------------------------------------------------- | |
64d452a8 VS |
62 | |
63 | // 'Main program' equivalent: the program execution "starts" here | |
64 | bool MyApp::OnInit() | |
65 | { | |
45e6e6f8 VZ |
66 | if ( !wxApp::OnInit() ) |
67 | return false; | |
68 | ||
af1337b0 | 69 | // If there is any of a certain format of image in the xrcs, then first |
0526c8cc VZ |
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() | |
af1337b0 JS |
72 | // documentation for the types of image handlers available. |
73 | wxImage::AddHandler(new wxXPMHandler); | |
0526c8cc | 74 | wxImage::AddHandler(new wxGIFHandler); |
f80ea77b | 75 | |
af1337b0 JS |
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. | |
f80ea77b WS |
82 | wxXmlResource::Get()->InitAllHandlers(); |
83 | ||
74a59798 VZ |
84 | #if wxUSE_RIBBON |
85 | wxXmlResource::Get()->AddHandler(new wxRibbonXmlHandler); | |
86 | #endif | |
87 | ||
af1337b0 | 88 | // Load all of the XRC files that will be used. You can put everything |
f80ea77b WS |
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. | |
2bb9a404 | 91 | if ( !wxXmlResource::Get()->LoadAllFiles("rc") ) |
885a9fe9 VZ |
92 | return false; |
93 | ||
23bc3597 VZ |
94 | #if wxUSE_HELP |
95 | // Use the simple help provider to show the context-sensitive help | |
96 | wxHelpProvider::Set( new wxSimpleHelpProvider ); | |
97 | #endif // wxUSE_HELP | |
98 | ||
f80ea77b | 99 | // Make an instance of your derived frame. Passing NULL (the default value |
2148dc99 VZ |
100 | // of MyFrame's constructor is NULL) as the frame doesn't have a parent |
101 | // since it is the main application window. | |
af1337b0 | 102 | MyFrame *frame = new MyFrame(); |
f80ea77b | 103 | |
2148dc99 | 104 | // Show the frame as it's created initially hidden. |
f80ea77b WS |
105 | frame->Show(true); |
106 | ||
107 | // Return true to tell program to continue (false would terminate). | |
108 | return true; | |
64d452a8 VS |
109 | } |
110 |