]> git.saurik.com Git - wxWidgets.git/blame - contrib/samples/xrc/xrcdemo.cpp
corrected Info.plist.in location
[wxWidgets.git] / contrib / 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
JS
10//-----------------------------------------------------------------------------
11// GCC implementation
12//-----------------------------------------------------------------------------
64d452a8 13
64d452a8 14#ifdef __GNUG__
af1337b0 15 #pragma implementation "xrcdemo.h"
64d452a8
VS
16#endif
17
af1337b0
JS
18//-----------------------------------------------------------------------------
19// Standard wxWindows headers
20//-----------------------------------------------------------------------------
21
64d452a8
VS
22// For compilers that support precompilation, includes "wx/wx.h".
23#include "wx/wxprec.h"
24
25#ifdef __BORLANDC__
26 #pragma hdrstop
27#endif
28
af1337b0 29// For all others, include the necessary headers (this file is usually all you
64d452a8
VS
30// need because it includes almost all "standard" wxWindows headers)
31#ifndef WX_PRECOMP
32 #include "wx/wx.h"
64d452a8
VS
33#endif
34
af1337b0
JS
35//-----------------------------------------------------------------------------
36// Header of this .cpp file
37//-----------------------------------------------------------------------------
64d452a8 38
af1337b0 39#include "xrcdemo.h"
64d452a8 40
af1337b0
JS
41//-----------------------------------------------------------------------------
42// Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
43//-----------------------------------------------------------------------------
64d452a8 44
af1337b0
JS
45#include "wx/image.h" // wxImage
46
47//-----------------------------------------------------------------------------
48
49#include "wx/xrc/xmlres.h" // XRC XML resouces
50
51//-----------------------------------------------------------------------------
52
53#include "myframe.h"
54
55//-----------------------------------------------------------------------------
56// wxWindows macro: Declare the application.
57//-----------------------------------------------------------------------------
64d452a8
VS
58
59// Create a new application object: this macro will allow wxWindows to create
60// the application object during program execution (it's better than using a
61// static object for many reasons) and also declares the accessor function
af1337b0
JS
62// wxGetApp() which will return the reference of the right type (i.e. the_app and
63// not wxApp).
64d452a8
VS
64IMPLEMENT_APP(MyApp)
65
af1337b0
JS
66//-----------------------------------------------------------------------------
67// Public methods
68//-----------------------------------------------------------------------------
64d452a8
VS
69
70// 'Main program' equivalent: the program execution "starts" here
71bool MyApp::OnInit()
72{
af1337b0
JS
73 // If there is any of a certain format of image in the xrcs, then first
74 // load a handler for that image type. This example uses XPMs, but if
75 // you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
76 // documentation for the types of image handlers available.
77 wxImage::AddHandler(new wxXPMHandler);
78
79 // Initialize all the XRC handlers. Always required (unless you feel like
80 // going through and initializing a handler of each control type you will
81 // be using (ie initialize the spinctrl handler, initialize the textctrl
82 // handler). However, if you are only using a few control types, it will
83 // save some space to only initialize the ones you will be using. See
84 // wxXRC docs for details.
85 wxXmlResource::Get()->InitAllHandlers();
86
87 // Load all of the XRC files that will be used. You can put everything
88 // into one giant XRC file if you wanted, but then they become more
89 // diffcult to manage, and harder to reuse in later projects.
90 // The menubar
2b5f62a0 91 wxXmlResource::Get()->Load(wxT("rc/menu.xrc"));
af1337b0 92 // The toolbar
2b5f62a0 93 wxXmlResource::Get()->Load(wxT("rc/toolbar.xrc"));
af1337b0 94 // Non-derived dialog example
2b5f62a0 95 wxXmlResource::Get()->Load(wxT("rc/basicdlg.xrc"));
af1337b0 96 // Derived dialog example
2b5f62a0 97 wxXmlResource::Get()->Load(wxT("rc/derivdlg.xrc"));
af1337b0 98 // Controls property example
2b5f62a0 99 wxXmlResource::Get()->Load(wxT("rc/controls.xrc"));
af1337b0 100 // Frame example
2b5f62a0 101 wxXmlResource::Get()->Load(wxT("rc/frame.xrc"));
af1337b0 102 // Uncentered example
2b5f62a0 103 wxXmlResource::Get()->Load(wxT("rc/uncenter.xrc"));
af1337b0 104 // Custom class example
2b5f62a0 105 wxXmlResource::Get()->Load(wxT("rc/custclas.xrc"));
af1337b0 106 // wxArtProvider example
2b5f62a0 107 wxXmlResource::Get()->Load(wxT("rc/artprov.xrc"));
af1337b0 108 // Platform property example
2b5f62a0 109 wxXmlResource::Get()->Load(wxT("rc/platform.xrc"));
af1337b0 110 // Variable expansion example
2b5f62a0 111 wxXmlResource::Get()->Load(wxT("rc/variable.xrc"));
af1337b0
JS
112
113 // Make an instance of your derived frame. Passing NULL (the default value
114 // of MyFrame's constructor is NULL) as the frame doesn't have a frame
115 // since it is the first window.
116 MyFrame *frame = new MyFrame();
117
118 // Show the frame.
64d452a8 119 frame->Show(TRUE);
af1337b0
JS
120
121 // Return TRUE to tell program to continue (FALSE would terminate).
64d452a8
VS
122 return TRUE;
123}
124