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: msgout.h 35690 2005-09-25 20:23:30Z VZ $ 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/wxchar.h" 21 22 // ---------------------------------------------------------------------------- 23 // wxMessageOutput is a class abstracting formatted output target, i.e. 24 // something you can printf() to 25 // ---------------------------------------------------------------------------- 26 27 class WXDLLIMPEXP_BASE wxMessageOutput 28 { 29 public: ~wxMessageOutput()30 virtual ~wxMessageOutput() { } 31 32 // show a message to the user 33 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2 = 0; 34 35 // gets the current wxMessageOutput object (may be NULL during 36 // initialization or shutdown) 37 static wxMessageOutput* Get(); 38 39 // sets the global wxMessageOutput instance; returns the previous one 40 static wxMessageOutput* Set(wxMessageOutput* msgout); 41 42 private: 43 static wxMessageOutput* ms_msgOut; 44 }; 45 46 // ---------------------------------------------------------------------------- 47 // implementation showing the message to the user in "best" possible way: uses 48 // native message box if available (currently only under Windows) and stderr 49 // otherwise; unlike wxMessageOutputMessageBox this class is always safe to use 50 // ---------------------------------------------------------------------------- 51 52 class WXDLLIMPEXP_BASE wxMessageOutputBest : public wxMessageOutput 53 { 54 public: wxMessageOutputBest()55 wxMessageOutputBest() { } 56 57 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; 58 }; 59 60 // ---------------------------------------------------------------------------- 61 // implementation which sends output to stderr 62 // ---------------------------------------------------------------------------- 63 64 class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput 65 { 66 public: wxMessageOutputStderr()67 wxMessageOutputStderr() { } 68 69 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; 70 }; 71 72 // ---------------------------------------------------------------------------- 73 // implementation which shows output in a message box 74 // ---------------------------------------------------------------------------- 75 76 #if wxUSE_GUI 77 78 class WXDLLIMPEXP_CORE wxMessageOutputMessageBox : public wxMessageOutput 79 { 80 public: wxMessageOutputMessageBox()81 wxMessageOutputMessageBox() { } 82 83 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; 84 }; 85 86 #endif // wxUSE_GUI 87 88 // ---------------------------------------------------------------------------- 89 // implementation using the native way of outputting debug messages 90 // ---------------------------------------------------------------------------- 91 92 class WXDLLIMPEXP_BASE wxMessageOutputDebug : public wxMessageOutput 93 { 94 public: wxMessageOutputDebug()95 wxMessageOutputDebug() { } 96 97 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; 98 }; 99 100 // ---------------------------------------------------------------------------- 101 // implementation using wxLog (mainly for backwards compatibility) 102 // ---------------------------------------------------------------------------- 103 104 class WXDLLIMPEXP_BASE wxMessageOutputLog : public wxMessageOutput 105 { 106 public: wxMessageOutputLog()107 wxMessageOutputLog() { } 108 109 virtual void Printf(const wxChar* format, ...) ATTRIBUTE_PRINTF_2; 110 }; 111 112 #endif 113 // _WX_MSGOUT_H_ 114