]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msgout.h
added AutoHANDLE class to close a HANDLE automatically
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
20 // Some older compilers (such as EMX) cannot handle
21 // #pragma interface/implementation correctly, iff
22 // #pragma implementation is used in _two_ translation
23 // units (as created by e.g. event.cpp compiled for
24 // libwx_base and event.cpp compiled for libwx_gui_core).
25 // So we must not use those pragmas for those compilers in
26 // such files.
27 #pragma interface "msgout.h"
28 #endif
29
30 #include "wx/defs.h"
31 #include "wx/wxchar.h"
32
33 // ----------------------------------------------------------------------------
34 // wxMessageOutput is a class abstracting formatted output target, i.e.
35 // something you can printf() to
36 // ----------------------------------------------------------------------------
37
38 class WXDLLIMPEXP_BASE wxMessageOutput
39 {
40 public:
41 virtual ~wxMessageOutput() { }
42
43 // show a message to the user
44 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0;
45
46 // gets the current wxMessageOutput object (may be NULL during
47 // initialization or shutdown)
48 static wxMessageOutput* Get();
49
50 // sets the global wxMessageOutput instance; returns the previous one
51 static wxMessageOutput* Set(wxMessageOutput* msgout);
52
53 private:
54 static wxMessageOutput* ms_msgOut;
55 };
56
57 // ----------------------------------------------------------------------------
58 // implementation showing the message to the user in "best" possible way: uses
59 // native message box if available (currently only under Windows) and stderr
60 // otherwise; unlike wxMessageOutputMessageBox this class is always safe to use
61 // ----------------------------------------------------------------------------
62
63 class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput
64 {
65 public:
66 wxMessageOutputBest() { }
67
68 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
69 };
70
71 // ----------------------------------------------------------------------------
72 // implementation which sends output to stderr
73 // ----------------------------------------------------------------------------
74
75 class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
76 {
77 public:
78 wxMessageOutputStderr() { }
79
80 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
81 };
82
83 // ----------------------------------------------------------------------------
84 // implementation which shows output in a message box
85 // ----------------------------------------------------------------------------
86
87 #if wxUSE_GUI
88
89 class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput
90 {
91 public:
92 wxMessageOutputMessageBox() { }
93
94 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
95 };
96
97 #endif // wxUSE_GUI
98
99 // ----------------------------------------------------------------------------
100 // implementation using the native way of outputting debug messages
101 // ----------------------------------------------------------------------------
102
103 class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput
104 {
105 public:
106 wxMessageOutputDebug() { }
107
108 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
109 };
110
111 // ----------------------------------------------------------------------------
112 // implementation using wxLog (mainly for backwards compatibility)
113 // ----------------------------------------------------------------------------
114
115 class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput
116 {
117 public:
118 wxMessageOutputLog() { }
119
120 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2;
121 };
122
123 #endif
124 // _WX_MSGOUT_H_