]> git.saurik.com Git - wxWidgets.git/blame - include/wx/app.h
documented how to handle C++ exceptions in wxWindows
[wxWidgets.git] / include / wx / app.h
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame - include/wx/app.h


500 - Internal Server Error

Malformed UTF-8 character (fatal) at /usr/lib/x86_64-linux-gnu/perl5/5.40/HTML/Entities.pm line 485, <$fd> line 703.
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
090a6d7a 2// Name: wx/app.h
094637f6
VZ
3// Purpose: wxAppBase class and macros used for declaration of wxApp
4// derived class in the user code
c801d85f
KB
5// Author: Julian Smart
6// Modified by:
7// Created: 01/02/97
8// RCS-ID: $Id$
371a5b4e 9// Copyright: (c) Julian Smart
094637f6 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
34138703
JS
13#ifndef _WX_APP_H_BASE_
14#define _WX_APP_H_BASE_
c801d85f 15
23280650
VZ
16// ----------------------------------------------------------------------------
17// headers we have to include here
18// ----------------------------------------------------------------------------
19
20#include "wx/event.h" // for the base class
21
e90c1d2a 22#if wxUSE_GUI
bf188f1a 23 #include "wx/window.h" // for wxTopLevelWindows
e90c1d2a 24#endif // wxUSE_GUI
23280650 25
090a6d7a 26#include "wx/build.h"
0fcbaf23 27#include "wx/init.h" // we must declare wxEntry()
090a6d7a 28
e8e1149b 29class WXDLLIMPEXP_BASE wxAppConsole;
bddd7a8d
VZ
30class WXDLLIMPEXP_BASE wxAppTraits;
31class WXDLLIMPEXP_BASE wxCmdLineParser;
32class WXDLLIMPEXP_BASE wxLog;
33class WXDLLIMPEXP_BASE wxMessageOutput;
a69be60b 34
fb761cd5
VZ
35// wxUSE_EVTLOOP_IN_APP is a temporary hack needed until all ports are updated
36// to use wxEventLoop, otherwise we get linking errors on wxMac, it's going to
37// disappear a.s.a.p.
38#ifdef __WXMAC__
39 #define wxUSE_EVTLOOP_IN_APP 0
40#else
41 #define wxUSE_EVTLOOP_IN_APP 1
42 class WXDLLEXPORT wxEventLoop;
43#endif
1bf77ee5 44
53c9228e
VZ
45// ----------------------------------------------------------------------------
46// typedefs
47// ----------------------------------------------------------------------------
48
49// the type of the function used to create a wxApp object on program start up
e8e1149b 50typedef wxAppConsole* (*wxAppInitializerFunction)();
53c9228e 51
094637f6
VZ
52// ----------------------------------------------------------------------------
53// constants
54// ----------------------------------------------------------------------------
55
e2478fde
VZ
56enum
57{
58 wxPRINT_WINDOWS = 1,
59 wxPRINT_POSTSCRIPT = 2
60};
094637f6 61
1b4908de
VS
62// ----------------------------------------------------------------------------
63// support for framebuffer ports
64// ----------------------------------------------------------------------------
65
66#if wxUSE_GUI
67// VS: Fullscreen/framebuffer application needs to choose display mode prior
68// to wxWindows initialization. This class holds information about display
55176f44 69// mode. It is used by wxApp::Set/GetDisplayMode.
bddd7a8d 70class WXDLLIMPEXP_CORE wxDisplayModeInfo
1b4908de
VS
71{
72public:
73 wxDisplayModeInfo() : m_ok(FALSE) {}
a69be60b 74 wxDisplayModeInfo(unsigned width, unsigned height, unsigned depth)
07082b28 75 : m_width(width), m_height(height), m_depth(depth), m_ok(TRUE) {}
a69be60b 76
07082b28
VS
77 unsigned GetWidth() const { return m_width; }
78 unsigned GetHeight() const { return m_height; }
1b4908de
VS
79 unsigned GetDepth() const { return m_depth; }
80 bool IsOk() const { return m_ok; }
81
82private:
07082b28 83 unsigned m_width, m_height, m_depth;
1b4908de
VS
84 bool m_ok;
85};
e2478fde 86#endif // wxUSE_GUI
1b4908de 87
a8eaaeb2 88
094637f6 89// ----------------------------------------------------------------------------
e2478fde 90// wxAppConsole: wxApp for non-GUI applications
094637f6
VZ
91// ----------------------------------------------------------------------------
92
bddd7a8d 93class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
094637f6
VZ
94{
95public:
e2478fde
VZ
96 // ctor and dtor
97 wxAppConsole();
98 virtual ~wxAppConsole();
99
1e6feb95 100
094637f6
VZ
101 // the virtual functions which may/must be overridden in the derived class
102 // -----------------------------------------------------------------------
bf188f1a 103
94826170
VZ
104 // This is the very first function called for a newly created wxApp object,
105 // it is used by the library to do the global initialization. If, for some
106 // reason, you must override it (instead of just overriding OnInit(), as
107 // usual, for app-specific initializations), do not forget to call the base
108 // class version!
05e2b077 109 virtual bool Initialize(int& argc, wxChar **argv);
94826170 110
7fbc89bb
DE
111 // This gives wxCocoa a chance to call OnInit() with a memory pool in place
112 virtual bool CallOnInit() { return OnInit(); }
113
e2478fde
VZ
114 // Called before OnRun(), this is a good place to do initialization -- if
115 // anything fails, return false from here to prevent the program from
116 // continuing. The command line is normally parsed here, call the base
117 // class OnInit() to do it.
bf188f1a 118 virtual bool OnInit();
094637f6 119
94826170
VZ
120 // this is here only temproary hopefully (FIXME)
121 virtual bool OnInitGui() { return true; }
122
e2478fde
VZ
123 // This is the replacement for the normal main(): all program work should
124 // be done here. When OnRun() returns, the programs starts shutting down.
e90c1d2a 125 virtual int OnRun() = 0;
094637f6 126
e2478fde
VZ
127 // This is only called if OnInit() returned true so it's a good place to do
128 // any cleanup matching the initializations done there.
7beba2fc 129 virtual int OnExit();
094637f6 130
94826170
VZ
131 // This is the very last function called on wxApp object before it is
132 // destroyed. If you override it (instead of overriding OnExit() as usual)
133 // do not forget to call the base class version!
134 virtual void CleanUp();
135
e2478fde
VZ
136 // Called when a fatal exception occurs, this function should take care not
137 // to do anything which might provoke a nested exception! It may be
138 // overridden if you wish to react somehow in non-default way (core dump
139 // under Unix, application crash under Windows) to fatal program errors,
140 // however extreme care should be taken if you don't want this function to
141 // crash.
094637f6
VZ
142 virtual void OnFatalException() { }
143
e2478fde
VZ
144 // Called from wxExit() function, should terminate the application a.s.a.p.
145 virtual void Exit();
094637f6 146
094637f6
VZ
147
148 // application info: name, description, vendor
149 // -------------------------------------------
150
151 // NB: all these should be set by the application itself, there are no
152 // reasonable default except for the application name which is taken to
153 // be argv[0]
154
155 // set/get the application name
156 wxString GetAppName() const
157 {
e2478fde 158 return m_appName.empty() ? m_className : m_appName;
094637f6
VZ
159 }
160 void SetAppName(const wxString& name) { m_appName = name; }
161
162 // set/get the app class name
163 wxString GetClassName() const { return m_className; }
164 void SetClassName(const wxString& name) { m_className = name; }
165
166 // set/get the vendor name
167 const wxString& GetVendorName() const { return m_vendorName; }
168 void SetVendorName(const wxString& name) { m_vendorName = name; }
169
e90c1d2a 170
bf188f1a
VZ
171 // cmd line parsing stuff
172 // ----------------------
173
174 // all of these methods may be overridden in the derived class to
175 // customize the command line parsing (by default only a few standard
176 // options are handled)
177 //
178 // you also need to call wxApp::OnInit() from YourApp::OnInit() for all
179 // this to work
180
181#if wxUSE_CMDLINE_PARSER
182 // this one is called from OnInit() to add all supported options
b913d3ed
VZ
183 // to the given parser (don't forget to call the base class version if you
184 // override it!)
bf188f1a
VZ
185 virtual void OnInitCmdLine(wxCmdLineParser& parser);
186
187 // called after successfully parsing the command line, return TRUE
b913d3ed
VZ
188 // to continue and FALSE to exit (don't forget to call the base class
189 // version if you override it!)
bf188f1a
VZ
190 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
191
192 // called if "--help" option was specified, return TRUE to continue
193 // and FALSE to exit
194 virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
195
196 // called if incorrect command line options were given, return
197 // FALSE to abort and TRUE to continue
198 virtual bool OnCmdLineError(wxCmdLineParser& parser);
199#endif // wxUSE_CMDLINE_PARSER
200
e2478fde 201
094637f6
VZ
202 // miscellaneous customization functions
203 // -------------------------------------
204
e2478fde
VZ
205 // create the app traits object to which we delegate for everything which
206 // either should be configurable by the user (then he can change the
207 // default behaviour simply by overriding CreateTraits() and returning his
208 // own traits object) or which is GUI/console dependent as then wxAppTraits
209