]> git.saurik.com Git - wxWidgets.git/blame - include/wx/app.h
bug fix
[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 647.
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
fedec981
VZ
24
25 #include "wx/vidmode.h"
e90c1d2a 26#endif // wxUSE_GUI
23280650 27
090a6d7a 28#include "wx/build.h"
0fcbaf23 29#include "wx/init.h" // we must declare wxEntry()
090a6d7a 30
e8e1149b 31class WXDLLIMPEXP_BASE wxAppConsole;
bddd7a8d
VZ
32class WXDLLIMPEXP_BASE wxAppTraits;
33class WXDLLIMPEXP_BASE wxCmdLineParser;
34class WXDLLIMPEXP_BASE wxLog;
35class WXDLLIMPEXP_BASE wxMessageOutput;
a69be60b 36
fb761cd5
VZ
37// wxUSE_EVTLOOP_IN_APP is a temporary hack needed until all ports are updated
38// to use wxEventLoop, otherwise we get linking errors on wxMac, it's going to
39// disappear a.s.a.p.
40#ifdef __WXMAC__
41 #define wxUSE_EVTLOOP_IN_APP 0
42#else
43 #define wxUSE_EVTLOOP_IN_APP 1
44 class WXDLLEXPORT wxEventLoop;
45#endif
1bf77ee5 46
53c9228e
VZ
47// ----------------------------------------------------------------------------
48// typedefs
49// ----------------------------------------------------------------------------
50
51// the type of the function used to create a wxApp object on program start up
e8e1149b 52typedef wxAppConsole* (*wxAppInitializerFunction)();
53c9228e 53
094637f6
VZ
54// ----------------------------------------------------------------------------
55// constants
56// ----------------------------------------------------------------------------
57
e2478fde
VZ
58enum
59{
60 wxPRINT_WINDOWS = 1,
61 wxPRINT_POSTSCRIPT = 2
62};
094637f6
VZ
63
64// ----------------------------------------------------------------------------
e2478fde 65// wxAppConsole: wxApp for non-GUI applications
094637f6
VZ
66// ----------------------------------------------------------------------------
67
bddd7a8d 68class WXDLLIMPEXP_BASE wxAppConsole : public wxEvtHandler
094637f6
VZ
69{
70public:
e2478fde
VZ
71 // ctor and dtor
72 wxAppConsole();
73 virtual ~wxAppConsole();
74
1e6feb95 75
094637f6
VZ
76 // the virtual functions which may/must be overridden in the derived class
77 // -----------------------------------------------------------------------
bf188f1a 78
94826170
VZ
79 // This is the very first function called for a newly created wxApp object,
80 // it is used by the library to do the global initialization. If, for some
81 // reason, you must override it (instead of just overriding OnInit(), as
82 // usual, for app-specific initializations), do not forget to call the base
83 // class version!
05e2b077 84 virtual bool Initialize(int& argc, wxChar **argv);
94826170 85
7fbc89bb
DE
86 // This gives wxCocoa a chance to call OnInit() with a memory pool in place
87 virtual bool CallOnInit() { return OnInit(); }
88
e2478fde
VZ
89 // Called before OnRun(), this is a good place to do initialization -- if
90 // anything fails, return false from here to prevent the program from
91 // continuing. The command line is normally parsed here, call the base
92 // class OnInit() to do it.
bf188f1a 93 virtual bool OnInit();
094637f6 94
94826170
VZ
95 // this is here only temproary hopefully (FIXME)
96 virtual bool OnInitGui() { return true; }
97
e2478fde
VZ
98 // This is the replacement for the normal main(): all program work should
99 // be done here. When OnRun() returns, the programs starts shutting down.
e90c1d2a 100 virtual int OnRun() = 0;
094637f6 101
e2478fde
VZ
102 // This is only called if OnInit() returned true so it's a good place to do
103 // any cleanup matching the initializations done there.
7beba2fc 104 virtual int OnExit();
094637f6 105
94826170
VZ
106 // This is the very last function called on wxApp object before it is
107 // destroyed. If you override it (instead of overriding OnExit() as usual)
108 // do not forget to call the base class version!
109 virtual void CleanUp();
110
e2478fde
VZ
111 // Called when a fatal exception occurs, this function should take care not
112 // to do anything which might provoke a nested exception! It may be
113 // overridden if you wish to react somehow in non-default way (core dump
114 // under Unix, application crash under Windows) to fatal program errors,
115 // however extreme care should be taken if you don't want this function to
116 // crash.
094637f6
VZ
117 virtual void OnFatalException() { }
118
883117d1
VZ
119#if wxUSE_EXCEPTIONS
120 // Called when an unhandled C++ exception occurs inside OnRun(): note that
121 // the exception type is lost by now, so if you really want to handle the
122 // exception you should override OnRun() and put a try/catch around
123 // MainLoop() call there
124 virtual void OnUnhandledException() { }
125#endif // wxUSE_EXCEPTIONS
126
e2478fde
VZ
127 // Called from wxExit() function, should terminate the application a.s.a.p.
128 virtual void Exit();
094637f6 129
094637f6
VZ
130
131 // application info: name, description, vendor
132 // -------------------------------------------
133
134 // NB: all these should be set by the application itself, there are no
135 // reasonable default except for the application name which is taken to
136 // be argv[0]
137
138 // set/get the application name
139 wxString GetAppName() const
140 {
e2478fde 141 return m_appName.empty() ? m_className : m_appName;
094637f6
VZ
142 }
143 void SetAppName(const wxString& name) { m_appName = name; }
144
145 // set/get the app class name
146 wxString GetClassName() const { return m_className; }
147 void SetClassName(const wxString& name) { m_className = name; }
148
149 // set/get the vendor name
150 const wxString& GetVendorName() const { return m_vendorName; }
151 void SetVendorName(const wxString& name) { m_vendorName = name; }
152
e90c1d2a 153
bf188f1a
VZ
154 // cmd line parsing stuff
155 // ----------------------
156
157 // all of these methods may be overridden in the derived class to
158 // customize the command line parsing (by default only a few standard
159 // options are handled)
160 //
161 // you also need to call wxApp::OnInit() from YourApp::OnInit() for all
162 // this to work
163
164#if wxUSE_CMDLINE_PARSER
165 // this one is called from OnInit() to add all supported options
b913d3ed
VZ
166 // to the given parser (don't forget to call the base class version if you
167 // override it!)
bf188f1a
VZ
168 virtual void OnInitCmdLine(wxCmdLineParser& parser);
169
170 // called after successfully parsing the command line, return TRUE
b913d3ed
VZ
171 // to continue and FALSE to exit (don't forget to call the base class
172 // version if you override it!)
bf188f1a
VZ
173 virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
174
175 // called if "--help" option was specified, return TRUE to continue
176 // and FALSE to exit
177 virtual bool OnCmdLineHelp(wxCmdLineParser& parser);
178
179 // called if incorrect command line options were given, return
180 // FALSE to abort and TRUE to continue
181 virtual bool OnCmdLineError(wxCmdLineParser& parser);
182#endif // wxUSE_CMDLINE_PARSER
183
e2478fde 184
094637f6
VZ
185 // miscellaneous customization functions
186 // -------------------------------------
187
e2478fde
VZ
188 // create the app traits object to which we delegate for everything which
189 // either should be configurable by the user (then he can change the
190 // default behaviour simply by overriding CreateTraits() and returning his
191 // own traits object) or which is GUI/console dependent as then wxAppTraits
192