]>
git.saurik.com Git - wxWidgets.git/blob - src/common/msgout.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/msgout.cpp
3 // Purpose: wxMessageOutput implementation
4 // Author: Mattia Barbon
8 // Copyright: (c) the wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && !defined(__EMX__)
21 // Some older compilers (such as EMX) cannot handle
22 // #pragma interface/implementation correctly, iff
23 // #pragma implementation is used in _two_ translation
24 // units (as created by e.g. event.cpp compiled for
25 // libwx_base and event.cpp compiled for libwx_gui_core).
26 // So we must not use those pragmas for those compilers in
28 #pragma implementation "msgout.h"
31 // For compilers that support precompilation, includes "wx.h".
32 #include "wx/wxprec.h"
34 #if defined(__BORLANDC__)
39 #include "wx/string.h"
44 #include "wx/msgdlg.h"
48 #include "wx/msgout.h"
49 #include "wx/apptrait.h"
56 #include "wx/msw/private.h"
59 #include "wx/mac/private.h"
62 // ===========================================================================
64 // ===========================================================================
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 wxMessageOutput
* wxMessageOutput::ms_msgOut
= 0;
74 wxMessageOutput
* wxMessageOutput::Get()
76 if ( !ms_msgOut
&& wxTheApp
)
78 ms_msgOut
= wxTheApp
->GetTraits()->CreateMessageOutput();
84 wxMessageOutput
* wxMessageOutput::Set(wxMessageOutput
* msgout
)
86 wxMessageOutput
* old
= ms_msgOut
;
91 // ----------------------------------------------------------------------------
92 // wxMessageOutputStderr
93 // ----------------------------------------------------------------------------
95 void wxMessageOutputStderr::Printf(const wxChar
* format
, ...)
98 va_start(args
, format
);
101 out
.PrintfV(format
, args
);
104 fprintf(stderr
, "%s", (const char*) out
.mb_str());
107 // ----------------------------------------------------------------------------
108 // wxMessageOutputDebug
109 // ----------------------------------------------------------------------------
111 void wxMessageOutputDebug::Printf(const wxChar
* format
, ...)
116 va_start(args
, format
);
118 out
.PrintfV(format
, args
);
121 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
122 out
.Replace(wxT("\t"), wxT(" "));
123 out
.Replace(wxT("\n"), wxT("\r\n"));
124 ::OutputDebugString(out
);
125 #elif defined(__WXMAC__) && !defined(__DARWIN__)
126 if ( wxIsDebuggerRunning() )
129 wxString output
= out
+ wxT(";g") ;
130 wxMacStringToPascal(output
.c_str(), pstr
);
139 // FIXME: why is wxFputs() not defined under Linux?
140 fputs(out
.mb_str(), stderr
);
145 // ----------------------------------------------------------------------------
146 // wxMessageOutputLog
147 // ----------------------------------------------------------------------------
149 void wxMessageOutputLog::Printf(const wxChar
* format
, ...)
154 va_start(args
, format
);
156 out
.PrintfV(format
, args
);
159 out
.Replace(wxT("\t"), wxT(" "));
161 ::wxLogMessage(wxT("%s"), out
.c_str());
166 // ----------------------------------------------------------------------------
167 // wxMessageOutputMessageBox
168 // ----------------------------------------------------------------------------
172 void wxMessageOutputMessageBox::Printf(const wxChar
* format
, ...)
175 va_start(args
, format
);
178 out
.PrintfV(format
, args
);
181 // the native MSW msg box understands the TABs, others don't
183 out
.Replace(wxT("\t"), wxT(" "));
188 title
.Printf(_("%s message"), wxTheApp
->GetAppName().c_str());
190 ::wxMessageBox(out
, title
);