]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msgout.h
cleaning up problems after string changes
[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 wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0;
40 WX_DEFINE_VARARG_FUNC_VOID(Printf, DoPrintf)
41
42 protected:
43 void DoPrintf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
44 virtual void Output(const wxString& str) = 0;
45 };
46
47 #ifdef __VISUALC__
48 // "non dll-interface class 'wxStringPrintfMixin' used as base interface
49 // for dll-interface class 'wxString'" -- this is OK in our case
50 #pragma warning (disable:4275)
51 #endif
52
53 class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase
54 {
55 public:
56 virtual ~wxMessageOutput() { }
57
58 // gets the current wxMessageOutput object (may be NULL during
59 // initialization or shutdown)
60 static wxMessageOutput* Get();
61
62 // sets the global wxMessageOutput instance; returns the previous one
63 static wxMessageOutput* Set(wxMessageOutput* msgout);
64
65 private:
66 static wxMessageOutput* ms_msgOut;
67 };
68
69 #ifdef __VISUALC__
70 #pragma warning (default:4275)
71 #endif
72
73 // ----------------------------------------------------------------------------
74 // implementation showing the message to the user in "best" possible way: uses
75 // native message box if available (currently only under Windows) and stderr
76 // otherwise; unlike wxMessageOutputMessageBox this class is always safe to use
77 // ----------------------------------------------------------------------------
78
79 class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
80 {
81 public:
82 wxMessageOutputBest() { }
83
84 protected:
85 virtual void Output(const wxString& str);
86 };
87
88 // ----------------------------------------------------------------------------
89 // implementation which sends output to stderr
90 // ----------------------------------------------------------------------------
91
92 class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
93 {
94 public:
95 wxMessageOutputStderr() { }
96
97 protected:
98 virtual void Output(const wxString& str);
99 };
100
101 // ----------------------------------------------------------------------------
102 // implementation which shows output in a message box
103 // ----------------------------------------------------------------------------
104
105 #if wxUSE_GUI
106
107 class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
108 {
109 public:
110 wxMessageOutputMessageBox() { }
111
112 protected:
113 virtual void Output(const wxString& str);
114 };
115
116 #endif // wxUSE_GUI
117
118 // ----------------------------------------------------------------------------
119 // implementation using the native way of outputting debug messages
120 // ----------------------------------------------------------------------------
121
122 class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
123 {
124 public:
125 wxMessageOutputDebug() { }
126
127 protected:
128 virtual void Output(const wxString& str);
129 };
130
131 // ----------------------------------------------------------------------------
132 // implementation using wxLog (mainly for backwards compatibility)
133 // ----------------------------------------------------------------------------
134
135 class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
136 {
137 public:
138 wxMessageOutputLog() { }
139
140 protected:
141 virtual void Output(const wxString& str);
142 };
143
144 #endif
145 // _WX_MSGOUT_H_