]> git.saurik.com Git - wxWidgets.git/blob - src/common/msgout.cpp
Slider Updates
[wxWidgets.git] / src / common / msgout.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/msgout.cpp
3 // Purpose: wxMessageOutput implementation
4 // Author: Mattia Barbon
5 // Modified by:
6 // Created: 17.07.02
7 // RCS-ID: $Id$
8 // Copyright: (c) the wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "msgout.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #if defined(__BORLANDC__)
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #include "wx/string.h"
33 #include "wx/ffile.h"
34 #include "wx/app.h"
35 #if wxUSE_GUI
36 #include "wx/msgdlg.h"
37 #endif // wxUSE_GUI
38 #endif
39
40 #include "wx/msgout.h"
41
42 #include <stdarg.h>
43 #include <stdio.h>
44
45 // ===========================================================================
46 // implementation
47 // ===========================================================================
48
49 wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
50
51 wxMessageOutput* wxMessageOutput::Get()
52 {
53 return ms_msgOut;
54 }
55
56 wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout)
57 {
58 wxMessageOutput* old = ms_msgOut;
59 ms_msgOut = msgout;
60 return old;
61 }
62
63 // ----------------------------------------------------------------------------
64 // wxMessageOutputStderr
65 // ----------------------------------------------------------------------------
66
67 void wxMessageOutputStderr::Printf(const wxChar* format, ...)
68 {
69 va_list args;
70 va_start(args, format);
71 wxString out;
72
73 out.PrintfV(format, args);
74 va_end(args);
75
76 fprintf(stderr, "%s", out.mb_str());
77 }
78
79 // ----------------------------------------------------------------------------
80 // wxMessageOutputMessageBox
81 // ----------------------------------------------------------------------------
82
83 #if wxUSE_GUI
84
85 void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
86 {
87 va_list args;
88 va_start(args, format);
89 wxString out;
90
91 out.PrintfV(format, args);
92 va_end(args);
93
94 #ifndef __WXMSW__
95 out.Replace("\t"," ");
96 #endif
97 ::wxMessageBox(out);
98 }
99
100 #endif // wxUSE_GUI
101
102 // ----------------------------------------------------------------------------
103 // wxMessageOutputLog
104 // ----------------------------------------------------------------------------
105
106 #if wxUSE_GUI && defined(__WXMOTIF__)
107
108 void wxMessageOutputLog::Printf(const wxChar* format, ...)
109 {
110 va_list args;
111 va_start(args, format);
112 wxString out;
113
114 out.PrintfV(format, args);
115 va_end(args);
116
117 out.Replace("\t"," ");
118 // under Motif, wxMessageDialog needs a parent window, so we use
119 // wxLog, which is better than nothing
120 ::wxLogMessage("%s", out.c_str());
121 }
122
123 #endif // wxUSE_GUI