]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msgout.h
Moved deprecated code to source file (didn't compile
[wxWidgets.git] / include / wx / msgout.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msgout.h
3 // Purpose: wxMessageOutput class. Shows a message to the user
4 // Author: Mattia Barbon
5 // Modified by:
6 // Created: 17.07.02
7 // RCS-ID: $Id$
8 // Copyright: (c) Mattia Barbon
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSGOUT_H_
13 #define _WX_MSGOUT_H_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20 #include "wx/chartype.h"
21 #include "wx/strvararg.h"
22
23 // ----------------------------------------------------------------------------
24 // wxMessageOutput is a class abstracting formatted output target, i.e.
25 // something you can printf() to
26 // ----------------------------------------------------------------------------
27
28 // NB: VC6 has a bug that causes linker errors if you have template methods
29 // in a class using __declspec(dllimport). The solution is to split such
30 // class into two classes, one that contains the template methods and does
31 // *not* use WXDLLIMPEXP_BASE and another class that contains the rest
32 // (with DLL linkage).
33 class wxMessageOutputBase
34 {
35 public:
36 virtual ~wxMessageOutputBase() { }
37
38 // show a message to the user
39 // void Printf(const wxString& format, ...) = 0;
40 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&),
41 DoPrintfWchar, DoPrintfUtf8)
42 #ifdef __WATCOMC__
43 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
44 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*),
45 DoPrintfWchar, DoPrintfUtf8)
46 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*),
47 DoPrintfWchar, DoPrintfUtf8)
48 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&),
49 DoPrintfWchar, DoPrintfUtf8)
50 #endif
51
52 protected:
53 // NB: this is pure virtual so that it can be implemented in dllexported
54 // wxMessagOutput class
55 #if !wxUSE_UTF8_LOCALE_ONLY
56 virtual void DoPrintfWchar(const wxChar *format, ...) = 0;
57 #endif
58 #if wxUSE_UNICODE_UTF8
59 virtual void DoPrintfUtf8(const char *format, ...) = 0;
60 #endif
61
62 // called by DoPrintf() to output formatted string
63 virtual void Output(const wxString& str) = 0;
64 };
65
66 #ifdef __VISUALC__
67 // "non dll-interface class 'wxStringPrintfMixin' used as base interface
68 // for dll-interface class 'wxString'" -- this is OK in our case
69 #pragma warning (disable:4275)
70 #endif
71
72 class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase
73 {
74 public:
75 virtual ~wxMessageOutput() { }
76
77 // gets the current wxMessageOutput object (may be NULL during
78 // initialization or shutdown)
79 static wxMessageOutput* Get();
80
81 // sets the global wxMessageOutput instance; returns the previous one
82 static wxMessageOutput* Set(wxMessageOutput* msgout);
83
84 protected:
85 #if !wxUSE_UTF8_LOCALE_ONLY
86 virtual void DoPrintfWchar(const wxChar *format, ...);
87 #endif
88 #if wxUSE_UNICODE_UTF8
89 virtual void DoPrintfUtf8(const char *format, ...);
90 #endif
91 virtual void Output(const wxString& str) = 0;
92
93 private:
94 static wxMessageOutput* ms_msgOut;
95 };
96
97 #ifdef __VISUALC__
98 #pragma warning (default:4275)
99 #endif
100
101 // ----------------------------------------------------------------------------
102 // implementation showing the message to the user in "best" possible way: uses
103 // native message box if available (currently only under Windows) and stderr
104 // otherwise; unlike wxMessageOutputMessageBox this class is always safe to use
105 // ----------------------------------------------------------------------------
106
107 class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
108 {
109 public:
110 wxMessageOutputBest() { }
111
112 protected:
113 virtual void Output(const wxString& str);
114 };
115
116 // ----------------------------------------------------------------------------
117 // implementation which sends output to stderr
118 // ----------------------------------------------------------------------------
119
120 class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
121 {
122 public:
123 wxMessageOutputStderr() { }
124
125 protected:
126 virtual void Output(const wxString& str);
127 };
128
129 // ----------------------------------------------------------------------------
130 // implementation which shows output in a message box
131 // ----------------------------------------------------------------------------
132
133 #if wxUSE_GUI
134
135 class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
136 {
137 public:
138 wxMessageOutputMessageBox() { }
139
140 protected:
141 virtual void Output(const wxString& str);
142 };
143
144 #endif // wxUSE_GUI
145
146 // ----------------------------------------------------------------------------
147 // implementation using the native way of outputting debug messages
148 // ----------------------------------------------------------------------------
149
150 class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
151 {
152 public:
153 wxMessageOutputDebug() { }
154
155 protected:
156 virtual void Output(const wxString& str);
157 };
158
159 // ----------------------------------------------------------------------------
160 // implementation using wxLog (mainly for backwards compatibility)
161 // ----------------------------------------------------------------------------
162
163 class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
164 {
165 public:
166 wxMessageOutputLog() { }
167
168 protected:
169 virtual void Output(const wxString& str);
170 };
171
172 #endif
173 // _WX_MSGOUT_H_