]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msgout.h
Patch from Hartwig (use new GetChildren() API)
[wxWidgets.git] / include / wx / msgout.h
CommitLineData
74698d3a
MB
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$
99d80019 8// Copyright: (c) Mattia Barbon
65571936 9// Licence: wxWindows licence
74698d3a
MB
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSGOUT_H_
13#define _WX_MSGOUT_H_
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
74698d3a 19#include "wx/defs.h"
e3f6cbd9 20#include "wx/chartype.h"
c9f78968 21#include "wx/strvararg.h"
74698d3a 22
98020767
VZ
23// ----------------------------------------------------------------------------
24// wxMessageOutput is a class abstracting formatted output target, i.e.
25// something you can printf() to
26// ----------------------------------------------------------------------------
27
c9f78968
VS
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).
33class wxMessageOutputBase
74698d3a
MB
34{
35public:
c9f78968 36 virtual ~wxMessageOutputBase() { }
74698d3a
MB
37
38 // show a message to the user
2523e9b7 39 // void Printf(const wxString& format, ...) = 0;
1528e0b8 40 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&),
d1f6e2cf 41 DoPrintfWchar, DoPrintfUtf8)
2523e9b7
VS
42#ifdef __WATCOMC__
43 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
59a14f69
VS
44 WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&),
45 (wxFormatString(f1)));
46 WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxCStrData&),
47 (wxFormatString(f1)));
48 WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*),
49 (wxFormatString(f1)));
50 WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wchar_t*),
51 (wxFormatString(f1)));
2523e9b7 52#endif
c9f78968
VS
53
54protected:
b5536269
VS
55 // NB: this is pure virtual so that it can be implemented in dllexported
56 // wxMessagOutput class
d1f6e2cf
VS
57#if !wxUSE_UTF8_LOCALE_ONLY
58 virtual void DoPrintfWchar(const wxChar *format, ...) = 0;
59#endif
60#if wxUSE_UNICODE_UTF8
61 virtual void DoPrintfUtf8(const char *format, ...) = 0;
62#endif
b5536269
VS
63
64 // called by DoPrintf() to output formatted string
5b077ec7 65 virtual void Output(const wxString& str) = 0;
c9f78968
VS
66};
67
68#ifdef __VISUALC__
69 // "non dll-interface class 'wxStringPrintfMixin' used as base interface
70 // for dll-interface class 'wxString'" -- this is OK in our case
71 #pragma warning (disable:4275)
72#endif
73
74class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase
75{
76public:
77 virtual ~wxMessageOutput() { }
98020767 78
e12a951e
VZ
79 // gets the current wxMessageOutput object (may be NULL during
80 // initialization or shutdown)
74698d3a 81 static wxMessageOutput* Get();
98020767 82
74698d3a
MB
83 // sets the global wxMessageOutput instance; returns the previous one
84 static wxMessageOutput* Set(wxMessageOutput* msgout);
98020767 85
b5536269 86protected:
d1f6e2cf
VS
87#if !wxUSE_UTF8_LOCALE_ONLY
88 virtual void DoPrintfWchar(const wxChar *format, ...);
89#endif
90#if wxUSE_UNICODE_UTF8
91 virtual void DoPrintfUtf8(const char *format, ...);
92#endif
b5536269
VS
93 virtual void Output(const wxString& str) = 0;
94
74698d3a
MB
95private:
96 static wxMessageOutput* ms_msgOut;
97};
98
c9f78968
VS
99#ifdef __VISUALC__
100 #pragma warning (default:4275)
101#endif
102
e12a951e
VZ
103// ----------------------------------------------------------------------------
104// implementation showing the message to the user in "best" possible way: uses
105// native message box if available (currently only under Windows) and stderr
106// otherwise; unlike wxMessageOutputMessageBox this class is always safe to use
107// ----------------------------------------------------------------------------
108
109class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
110{
111public:
112 wxMessageOutputBest() { }
113
c9f78968 114protected:
5b077ec7 115 virtual void Output(const wxString& str);
e12a951e
VZ
116};
117
98020767
VZ
118// ----------------------------------------------------------------------------
119// implementation which sends output to stderr
120// ----------------------------------------------------------------------------
121
bddd7a8d 122class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
74698d3a
MB
123{
124public:
98020767 125 wxMessageOutputStderr() { }
74698d3a 126
c9f78968 127protected:
5b077ec7 128 virtual void Output(const wxString& str);
74698d3a
MB
129};
130
98020767
VZ
131// ----------------------------------------------------------------------------
132// implementation which shows output in a message box
133// ----------------------------------------------------------------------------
134
fae86641 135#if wxUSE_GUI && wxUSE_MSGDLG
74698d3a 136
bddd7a8d 137class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
74698d3a
MB
138{
139public:
98020767 140 wxMessageOutputMessageBox() { }
74698d3a 141
c9f78968 142protected:
5b077ec7 143 virtual void Output(const wxString& str);
74698d3a
MB
144};
145
fae86641 146#endif // wxUSE_GUI && wxUSE_MSGDLG
74698d3a 147
e2478fde
VZ
148// ----------------------------------------------------------------------------
149// implementation using the native way of outputting debug messages
150// ----------------------------------------------------------------------------
151
bddd7a8d 152class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
e2478fde
VZ
153{
154public:
155 wxMessageOutputDebug() { }
156
c9f78968 157protected:
5b077ec7 158 virtual void Output(const wxString& str);
e2478fde
VZ
159};
160
98020767
VZ
161// ----------------------------------------------------------------------------
162// implementation using wxLog (mainly for backwards compatibility)
163// ----------------------------------------------------------------------------
164
bddd7a8d 165class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
74698d3a
MB
166{
167public:
98020767 168 wxMessageOutputLog() { }
74698d3a 169
c9f78968 170protected:
5b077ec7 171 virtual void Output(const wxString& str);
74698d3a
MB
172};
173
74698d3a
MB
174#endif
175 // _WX_MSGOUT_H_