]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msgout.h
Patch 1708290
[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
VS
39 // void Printf(const wxString& format, ...) = 0;
40 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxString&), DoPrintf)
41#ifdef __WATCOMC__
42 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
43 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*), DoPrintf)
44 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*), DoPrintf)
45 WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&), DoPrintf)
46#endif
c9f78968
VS
47
48protected:
b5536269
VS
49 // NB: this is pure virtual so that it can be implemented in dllexported
50 // wxMessagOutput class
2523e9b7 51 virtual void DoPrintf(const wxString& format, ...) = 0;
b5536269
VS
52
53 // called by DoPrintf() to output formatted string
5b077ec7 54 virtual void Output(const wxString& str) = 0;
c9f78968
VS
55};
56
57#ifdef __VISUALC__
58 // "non dll-interface class 'wxStringPrintfMixin' used as base interface
59 // for dll-interface class 'wxString'" -- this is OK in our case
60 #pragma warning (disable:4275)
61#endif
62
63class WXDLLIMPEXP_BASE wxMessageOutput : public wxMessageOutputBase
64{
65public:
66 virtual ~wxMessageOutput() { }
98020767 67
e12a951e
VZ
68 // gets the current wxMessageOutput object (may be NULL during
69 // initialization or shutdown)
74698d3a 70 static wxMessageOutput* Get();
98020767 71
74698d3a
MB
72 // sets the global wxMessageOutput instance; returns the previous one
73 static wxMessageOutput* Set(wxMessageOutput* msgout);
98020767 74
b5536269 75protected:
2523e9b7 76 virtual void DoPrintf(const wxString& format, ...);
b5536269
VS
77 virtual void Output(const wxString& str) = 0;
78
74698d3a
MB
79private:
80 static wxMessageOutput* ms_msgOut;
81};
82
c9f78968
VS
83#ifdef __VISUALC__
84 #pragma warning (default:4275)
85#endif
86
e12a951e
VZ
87// ----------------------------------------------------------------------------
88// implementation showing the message to the user in "best" possible way: uses
89// native message box if available (currently only under Windows) and stderr
90// otherwise; unlike wxMessageOutputMessageBox this class is always safe to use
91// ----------------------------------------------------------------------------
92
93class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
94{
95public:
96 wxMessageOutputBest() { }
97
c9f78968 98protected:
5b077ec7 99 virtual void Output(const wxString& str);
e12a951e
VZ
100};
101
98020767
VZ
102// ----------------------------------------------------------------------------
103// implementation which sends output to stderr
104// ----------------------------------------------------------------------------
105
bddd7a8d 106class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
74698d3a
MB
107{
108public:
98020767 109 wxMessageOutputStderr() { }
74698d3a 110
c9f78968 111protected:
5b077ec7 112 virtual void Output(const wxString& str);
74698d3a
MB
113};
114
98020767
VZ
115// ----------------------------------------------------------------------------
116// implementation which shows output in a message box
117// ----------------------------------------------------------------------------
118
74698d3a
MB
119#if wxUSE_GUI
120
bddd7a8d 121class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
74698d3a
MB
122{
123public:
98020767 124 wxMessageOutputMessageBox() { }
74698d3a 125
c9f78968 126protected:
5b077ec7 127 virtual void Output(const wxString& str);
74698d3a
MB
128};
129
ef357cda 130#endif // wxUSE_GUI
74698d3a 131
e2478fde
VZ
132// ----------------------------------------------------------------------------
133// implementation using the native way of outputting debug messages
134// ----------------------------------------------------------------------------
135
bddd7a8d 136class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
e2478fde
VZ
137{
138public:
139 wxMessageOutputDebug() { }
140
c9f78968 141protected:
5b077ec7 142 virtual void Output(const wxString& str);
e2478fde
VZ
143};
144
98020767
VZ
145// ----------------------------------------------------------------------------
146// implementation using wxLog (mainly for backwards compatibility)
147// ----------------------------------------------------------------------------
148
bddd7a8d 149class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
74698d3a
MB
150{
151public:
98020767 152 wxMessageOutputLog() { }
74698d3a 153
c9f78968 154protected:
5b077ec7 155 virtual void Output(const wxString& str);
74698d3a
MB
156};
157
74698d3a
MB
158#endif
159 // _WX_MSGOUT_H_