]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
Commented out wxAutoNSAutoreleasePool in CallOnInit()
[wxWidgets.git] / include / wx / apptrait.h
CommitLineData
e2478fde
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/apptrait.h
3// Purpose: declaration of wxAppTraits and derived classes
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 19.06.2003
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_APPTRAIT_H_
13#define _WX_APPTRAIT_H_
14
dcc7f39c 15class WXDLLEXPORT wxObject;
e2478fde
VZ
16class WXDLLEXPORT wxAppTraits;
17#if wxUSE_FONTMAP
18 class WXDLLEXPORT wxFontMapper;
19#endif // wxUSE_FONTMAP
20class WXDLLEXPORT wxLog;
21class WXDLLEXPORT wxMessageOutput;
df5168c4 22class WXDLLEXPORT wxString;
e2478fde
VZ
23
24// ----------------------------------------------------------------------------
25// wxAppTraits: this class defines various configurable aspects of wxApp
26// ----------------------------------------------------------------------------
27
7af1b539 28class WXDLLIMPEXP_BASE wxAppTraitsBase
e2478fde
VZ
29{
30public:
e2478fde
VZ
31 // hooks for creating the global objects, may be overridden by the user
32 // ------------------------------------------------------------------------
33
34#if wxUSE_LOG
35 // create the default log target
36 virtual wxLog *CreateLogTarget() = 0;
37#endif // wxUSE_LOG
38
39 // create the global object used for printing out messages
40 virtual wxMessageOutput *CreateMessageOutput() = 0;
41
42#if wxUSE_FONTMAP
43 // create the global font mapper object used for encodings/charset mapping
44 virtual wxFontMapper *CreateFontMapper() = 0;
45#endif // wxUSE_FONTMAP
46
47
48 // functions abstracting differences between GUI and console modes
49 // ------------------------------------------------------------------------
50
51#ifdef __WXDEBUG__
52 // show the assert dialog with the specified message in GUI or just print
53 // the string to stderr in console mode
54 //
55 // base class version has an implementation (in spite of being pure
56 // virtual) in base/appbase.cpp which can be called as last resort.
57 //
58 // return true to suppress subsequent asserts, false to continue as before
59 virtual bool ShowAssertDialog(const wxString& msg) = 0;
60#endif // __WXDEBUG__
61
62 // return true if fprintf(stderr) goes somewhere, false otherwise
63 virtual bool HasStderr() = 0;
64
65 // managing "pending delete" list: in GUI mode we can't immediately delete
66 // some objects because there may be unprocessed events for them and so we
67 // only do it during the next idle loop iteration while this is, of course,
68 // unnecessary in wxBase, so we have a few functions to abstract these
69 // operations
70
71 // add the object to the pending delete list in GUI, delete it immediately
72 // in wxBase
73 virtual void ScheduleForDestroy(wxObject *object) = 0;
74
75 // remove this object from the pending delete list in GUI, do nothing in
76 // wxBase
77 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
2739d4f0
VZ
78
79
80 // other miscellaneous helpers
81 // ---------------------------
82
83 // wxGetOsVersion() behaves differently in GUI and non-GUI builds under
84 // Unix: in the former case it returns the information about the toolkit
85 // and in the latter -- about the OS, so we need to virtualize it
86 virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
e2478fde
VZ
87};
88
89// ----------------------------------------------------------------------------
90// include the platform-specific version of the class
91// ----------------------------------------------------------------------------
92
29c99ad3
VZ
93// NB: test for __UNIX__ before __WXMAC__ as under Darwin we want to use the
94// Unix code (and otherwise __UNIX__ wouldn't be defined)
e2478fde
VZ
95#if defined(__WXMSW__)
96 #include "wx/msw/apptbase.h"
2d2d4fc7
VZ
97#elif defined(__UNIX__)
98 #include "wx/unix/apptbase.h"
29c99ad3
VZ
99#elif defined(__WXMAC__)
100 #include "wx/mac/apptbase.h"
46446cc2 101#else // no platform-specific methods to add to wxAppTraits
e2478fde 102 // wxAppTraits must be a class because it was forward declared as class
bb24c68f 103 class WXDLLIMPEXP_BASE wxAppTraits : public wxAppTraitsBase
e2478fde
VZ
104 {
105 };
106#endif // platform
107
108// ============================================================================
109// standard traits for console and GUI applications
110// ============================================================================
111
112// ----------------------------------------------------------------------------
113// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
114// ----------------------------------------------------------------------------
115
7af1b539 116class WXDLLIMPEXP_BASE wxConsoleAppTraitsBase : public wxAppTraits
e2478fde
VZ
117{
118public:
119#if wxUSE_LOG
120 virtual wxLog *CreateLogTarget();
121#endif // wxUSE_LOG
122 virtual wxMessageOutput *CreateMessageOutput();
123#if wxUSE_FONTMAP
124 virtual wxFontMapper *CreateFontMapper();
125#endif // wxUSE_FONTMAP
126
127#ifdef __WXDEBUG__
128 virtual bool ShowAssertDialog(const wxString& msg);
129#endif // __WXDEBUG__
130 virtual bool HasStderr();
131
132 virtual void ScheduleForDestroy(wxObject *object);
133 virtual void RemoveFromPendingDelete(wxObject *object);
134};
135
136// ----------------------------------------------------------------------------
137// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
138// ----------------------------------------------------------------------------
139
140#if wxUSE_GUI
141
94826170 142class WXDLLEXPORT wxGUIAppTraitsBase : public wxAppTraits
e2478fde
VZ
143{
144public:
145#if wxUSE_LOG
146 virtual wxLog *CreateLogTarget();
147#endif // wxUSE_LOG
148 virtual wxMessageOutput *CreateMessageOutput();
149#if wxUSE_FONTMAP
150 virtual wxFontMapper *CreateFontMapper();
151#endif // wxUSE_FONTMAP
152
153#ifdef __WXDEBUG__
154 virtual bool ShowAssertDialog(const wxString& msg);
155#endif // __WXDEBUG__
156 virtual bool HasStderr();
157
158 virtual void ScheduleForDestroy(wxObject *object);
159 virtual void RemoveFromPendingDelete(wxObject *object);
160};
161
162#endif // wxUSE_GUI
163
164// ----------------------------------------------------------------------------
165// include the platform-specific version of the classes above
166// ----------------------------------------------------------------------------
167
168#if defined(__WXMSW__)
169 #include "wx/msw/apptrait.h"
2d2d4fc7
VZ
170#elif defined(__UNIX__)
171 #include "wx/unix/apptrait.h"
29c99ad3
VZ
172#elif defined(__WXMAC__)
173 #include "wx/mac/apptrait.h"
e2478fde
VZ
174#else // no platform-specific methods to add to wxAppTraits
175 #if wxUSE_GUI
176 typedef wxGUIAppTraitsBase wxGUIAppTraits;
177 #endif // wxUSE_GUI
178 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
179#endif // platform
180
181#endif // _WX_APPTRAIT_H_
182