]> git.saurik.com Git - wxWidgets.git/blame - include/wx/apptrait.h
TryParent()/ProcessEvent() were included in both base and GUI
[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
15class WXDLLEXPORT wxAppTraits;
16#if wxUSE_FONTMAP
17 class WXDLLEXPORT wxFontMapper;
18#endif // wxUSE_FONTMAP
19class WXDLLEXPORT wxLog;
20class WXDLLEXPORT wxMessageOutput;
21
22// ----------------------------------------------------------------------------
23// wxAppTraits: this class defines various configurable aspects of wxApp
24// ----------------------------------------------------------------------------
25
26class WXDLLEXPORT wxAppTraitsBase
27{
28public:
29 // wxAppTraits is an ABC, but we also provide 2 standard implementations of
30 // it, one for the console apps and the other for the GUI ones
31 static wxAppTraits *CreateConsole();
32#if wxUSE_GUI
33 static wxAppTraits *CreateGUI();
34#endif // wxUSE_GUI
35
36
37 // hooks for creating the global objects, may be overridden by the user
38 // ------------------------------------------------------------------------
39
40#if wxUSE_LOG
41 // create the default log target
42 virtual wxLog *CreateLogTarget() = 0;
43#endif // wxUSE_LOG
44
45 // create the global object used for printing out messages
46 virtual wxMessageOutput *CreateMessageOutput() = 0;
47
48#if wxUSE_FONTMAP
49 // create the global font mapper object used for encodings/charset mapping
50 virtual wxFontMapper *CreateFontMapper() = 0;
51#endif // wxUSE_FONTMAP
52
53
54 // functions abstracting differences between GUI and console modes
55 // ------------------------------------------------------------------------
56
57#ifdef __WXDEBUG__
58 // show the assert dialog with the specified message in GUI or just print
59 // the string to stderr in console mode
60 //
61 // base class version has an implementation (in spite of being pure
62 // virtual) in base/appbase.cpp which can be called as last resort.
63 //
64 // return true to suppress subsequent asserts, false to continue as before
65 virtual bool ShowAssertDialog(const wxString& msg) = 0;
66#endif // __WXDEBUG__
67
68 // return true if fprintf(stderr) goes somewhere, false otherwise
69 virtual bool HasStderr() = 0;
70
71 // managing "pending delete" list: in GUI mode we can't immediately delete
72 // some objects because there may be unprocessed events for them and so we
73 // only do it during the next idle loop iteration while this is, of course,
74 // unnecessary in wxBase, so we have a few functions to abstract these
75 // operations
76
77 // add the object to the pending delete list in GUI, delete it immediately
78 // in wxBase
79 virtual void ScheduleForDestroy(wxObject *object) = 0;
80
81 // remove this object from the pending delete list in GUI, do nothing in
82 // wxBase
83 virtual void RemoveFromPendingDelete(wxObject *object) = 0;
84};
85
86// ----------------------------------------------------------------------------
87// include the platform-specific version of the class
88// ----------------------------------------------------------------------------
89
90#if defined(__WXMSW__)
91 #include "wx/msw/apptbase.h"
46446cc2
VZ
92#elif defined(__UNIX__)
93 #include "wx/unix/apptbase.h"
94#else // no platform-specific methods to add to wxAppTraits
e2478fde
VZ
95 typedef
96 // wxAppTraits must be a class because it was forward declared as class
97 class WXDLLEXPORT wxAppTraits : public wxAppTraitsBase
98 {
99 };
100#endif // platform
101
102// ============================================================================
103// standard traits for console and GUI applications
104// ============================================================================
105
106// ----------------------------------------------------------------------------
107// wxConsoleAppTraitsBase: wxAppTraits implementation for the console apps
108// ----------------------------------------------------------------------------
109
110class wxConsoleAppTraitsBase : public wxAppTraits
111{
112public:
113#if wxUSE_LOG
114 virtual wxLog *CreateLogTarget();
115#endif // wxUSE_LOG
116 virtual wxMessageOutput *CreateMessageOutput();
117#if wxUSE_FONTMAP
118 virtual wxFontMapper *CreateFontMapper();
119#endif // wxUSE_FONTMAP
120
121#ifdef __WXDEBUG__
122 virtual bool ShowAssertDialog(const wxString& msg);
123#endif // __WXDEBUG__
124 virtual bool HasStderr();
125
126 virtual void ScheduleForDestroy(wxObject *object);
127 virtual void RemoveFromPendingDelete(wxObject *object);
128};
129
130// ----------------------------------------------------------------------------
131// wxGUIAppTraitsBase: wxAppTraits implementation for the GUI apps
132// ----------------------------------------------------------------------------
133
134#if wxUSE_GUI
135
136class wxGUIAppTraitsBase : public wxAppTraits
137{
138public:
139#if wxUSE_LOG
140 virtual wxLog *CreateLogTarget();
141#endif // wxUSE_LOG
142 virtual wxMessageOutput *CreateMessageOutput();
143#if wxUSE_FONTMAP
144 virtual wxFontMapper *CreateFontMapper();
145#endif // wxUSE_FONTMAP
146
147#ifdef __WXDEBUG__
148 virtual bool ShowAssertDialog(const wxString& msg);
149#endif // __WXDEBUG__
150 virtual bool HasStderr();
151
152 virtual void ScheduleForDestroy(wxObject *object);
153 virtual void RemoveFromPendingDelete(wxObject *object);
154};
155
156#endif // wxUSE_GUI
157
158// ----------------------------------------------------------------------------
159// include the platform-specific version of the classes above
160// ----------------------------------------------------------------------------
161
162#if defined(__WXMSW__)
163 #include "wx/msw/apptrait.h"
164#elif defined(__UNIX__)
165 #include "wx/unix/apptrait.h"
166#else // no platform-specific methods to add to wxAppTraits
167 #if wxUSE_GUI
168 typedef wxGUIAppTraitsBase wxGUIAppTraits;
169 #endif // wxUSE_GUI
170 typedef wxConsoleAppTraitsBase wxConsoleAppTraits;
171#endif // platform
172
173#endif // _WX_APPTRAIT_H_
174