]>
Commit | Line | Data |
---|---|---|
74698d3a MB |
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 | { | |
a69be60b | 53 | if ( !ms_msgOut && wxTheApp ) |
e02911a2 | 54 | { |
a69be60b | 55 | ms_msgOut = wxTheApp->CreateMessageOutput(); |
e02911a2 MB |
56 | } |
57 | ||
74698d3a MB |
58 | return ms_msgOut; |
59 | } | |
60 | ||
61 | wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout) | |
62 | { | |
63 | wxMessageOutput* old = ms_msgOut; | |
64 | ms_msgOut = msgout; | |
65 | return old; | |
66 | } | |
67 | ||
68 | // ---------------------------------------------------------------------------- | |
69 | // wxMessageOutputStderr | |
70 | // ---------------------------------------------------------------------------- | |
71 | ||
72 | void wxMessageOutputStderr::Printf(const wxChar* format, ...) | |
73 | { | |
74 | va_list args; | |
75 | va_start(args, format); | |
76 | wxString out; | |
77 | ||
78 | out.PrintfV(format, args); | |
79 | va_end(args); | |
80 | ||
401eb3de | 81 | fprintf(stderr, "%s", (const char*) out.mb_str()); |
74698d3a MB |
82 | } |
83 | ||
84 | // ---------------------------------------------------------------------------- | |
85 | // wxMessageOutputMessageBox | |
86 | // ---------------------------------------------------------------------------- | |
87 | ||
88 | #if wxUSE_GUI | |
89 | ||
90 | void wxMessageOutputMessageBox::Printf(const wxChar* format, ...) | |
91 | { | |
92 | va_list args; | |
93 | va_start(args, format); | |
94 | wxString out; | |
95 | ||
96 | out.PrintfV(format, args); | |
97 | va_end(args); | |
98 | ||
99 | #ifndef __WXMSW__ | |
401eb3de | 100 | out.Replace(wxT("\t"),wxT(" ")); |
74698d3a MB |
101 | #endif |
102 | ::wxMessageBox(out); | |
103 | } | |
104 | ||
105 | #endif // wxUSE_GUI | |
106 | ||
107 | // ---------------------------------------------------------------------------- | |
108 | // wxMessageOutputLog | |
109 | // ---------------------------------------------------------------------------- | |
110 | ||
74698d3a MB |
111 | void wxMessageOutputLog::Printf(const wxChar* format, ...) |
112 | { | |
a69be60b VZ |
113 | wxString out; |
114 | ||
74698d3a MB |
115 | va_list args; |
116 | va_start(args, format); | |
74698d3a MB |
117 | |
118 | out.PrintfV(format, args); | |
119 | va_end(args); | |
120 | ||
8887e234 | 121 | out.Replace(wxT("\t"),wxT(" ")); |
a69be60b | 122 | |
8887e234 | 123 | ::wxLogMessage(wxT("%s"), out.c_str()); |
74698d3a | 124 | } |