]> git.saurik.com Git - wxWidgets.git/blame - samples/xrc/xrcdemo.cpp
more wxFD_XXX renamings (patch 1488371)
[wxWidgets.git] / samples / xrc / xrcdemo.cpp
CommitLineData
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
JS
33//-----------------------------------------------------------------------------
34// Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
35//-----------------------------------------------------------------------------
64d452a8 36
af1337b0
JS
37#include "wx/image.h" // wxImage
38
39//-----------------------------------------------------------------------------
40
41#include "wx/xrc/xmlres.h" // XRC XML resouces
42
43//-----------------------------------------------------------------------------
44
45#include "myframe.h"
46
47//-----------------------------------------------------------------------------
be5a51fb 48// wxWidgets macro: Declare the application.
af1337b0 49//-----------------------------------------------------------------------------
64d452a8 50
be5a51fb 51// Create a new application object: this macro will allow wxWidgets to create
64d452a8
VS
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
af1337b0
JS
54// wxGetApp() which will return the reference of the right type (i.e. the_app and
55// not wxApp).
64d452a8
VS
56IMPLEMENT_APP(MyApp)
57
af1337b0
JS
58//-----------------------------------------------------------------------------
59// Public methods
60//-----------------------------------------------------------------------------
64d452a8
VS
61
62// 'Main program' equivalent: the program execution "starts" here
63bool MyApp::OnInit()
64{
af1337b0
JS
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);
f80ea77b 70
af1337b0
JS
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.
f80ea77b
WS
77 wxXmlResource::Get()->InitAllHandlers();
78
af1337b0 79 // Load all of the XRC files that will be used. You can put everything
f80ea77b
WS
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.
af1337b0 82 // The menubar
2b5f62a0 83 wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
af1337b0 84 // The toolbar
2b5f62a0 85 wxXmlResource::Get()->Load(wxT("rc/toolbar.xrc"));
af1337b0 86 // Non-derived dialog example
2b5f62a0 87 wxXmlResource::Get()->Load(wxT("rc/basicdlg.xrc"));
af1337b0 88 // Derived dialog example
2b5f62a0 89 wxXmlResource::Get()->Load(wxT("rc/derivdlg.xrc"));
af1337b0 90 // Controls property example
2b5f62a0 91 wxXmlResource::Get()->Load(wxT("rc/controls.xrc"));
af1337b0 92 // Frame example
2b5f62a0 93 wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
af1337b0 94 // Uncentered example
f80ea77b 95 wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
af1337b0 96 // Custom class example
2b5f62a0 97 wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
af1337b0 98 // wxArtProvider example
2b5f62a0 99 wxXmlResource::Get()->Load(wxT("rc/artprov.xrc"));
af1337b0 100 // Platform property example
2b5f62a0 101 wxXmlResource::Get()->Load(wxT("rc/platform.xrc"));
af1337b0 102 // Variable expansion example
2b5f62a0 103 wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
af1337b0 104
f80ea77b 105 // Make an instance of your derived frame. Passing NULL (the default value
2148dc99
VZ
106 // of MyFrame's constructor is NULL) as the frame doesn't have a parent
107 // since it is the main application window.
af1337b0 108 MyFrame *frame = new MyFrame();
f80ea77b 109
2148dc99 110 // Show the frame as it's created initially hidden.
f80ea77b
WS
111 frame->Show(true);
112
113 // Return true to tell program to continue (false would terminate).
114 return true;
64d452a8
VS
115}
116