]>
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)
21 #pragma implementation "msgout.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
27 #if defined(__BORLANDC__)
32 #include "wx/string.h"
37 #include "wx/msgdlg.h"
41 #include "wx/msgout.h"
42 #include "wx/apptrait.h"
49 #include "wx/msw/private.h"
52 #include "wx/mac/private.h"
55 // ===========================================================================
57 // ===========================================================================
61 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
65 wxMessageOutput
* wxMessageOutput::ms_msgOut
= 0;
67 wxMessageOutput
* wxMessageOutput::Get()
69 if ( !ms_msgOut
&& wxTheApp
)
71 ms_msgOut
= wxTheApp
->GetTraits()->CreateMessageOutput();
77 wxMessageOutput
* wxMessageOutput::Set(wxMessageOutput
* msgout
)
79 wxMessageOutput
* old
= ms_msgOut
;
84 // ----------------------------------------------------------------------------
85 // wxMessageOutputStderr
86 // ----------------------------------------------------------------------------
88 void wxMessageOutputStderr::Printf(const wxChar
* format
, ...)
91 va_start(args
, format
);
94 out
.PrintfV(format
, args
);
97 fprintf(stderr
, "%s", (const char*) out
.mb_str());
100 // ----------------------------------------------------------------------------
101 // wxMessageOutputDebug
102 // ----------------------------------------------------------------------------
104 void wxMessageOutputDebug::Printf(const wxChar
* format
, ...)
109 va_start(args
, format
);
111 out
.PrintfV(format
, args
);
114 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
115 out
.Replace(wxT("\t"), wxT(" "));
117 ::OutputDebugString(out
);
118 #elif defined(__WXMAC__) && !defined(__DARWIN__)
119 if ( wxIsDebuggerRunning() )
122 wxString output
= out
+ wxT(";g") ;
123 wxMacStringToPascal(output
.c_str(), pstr
);
132 // FIXME: why is wxFputs() not defined under Linux?
133 fputs(out
.mb_str(), stderr
);
138 // ----------------------------------------------------------------------------
139 // wxMessageOutputLog
140 // ----------------------------------------------------------------------------
142 void wxMessageOutputLog::Printf(const wxChar
* format
, ...)
147 va_start(args
, format
);
149 out
.PrintfV(format
, args
);
152 out
.Replace(wxT("\t"), wxT(" "));
154 ::wxLogMessage(wxT("%s"), out
.c_str());
159 // ----------------------------------------------------------------------------
160 // wxMessageOutputMessageBox
161 // ----------------------------------------------------------------------------
165 void wxMessageOutputMessageBox::Printf(const wxChar
* format
, ...)
168 va_start(args
, format
);
171 out
.PrintfV(format
, args
);
174 // the native MSW msg box understands the TABs, others don't
176 out
.Replace(wxT("\t"), wxT(" "));
181 title
.Printf(_("%s message"), wxTheApp
->GetAppName().c_str());
183 ::wxMessageBox(out
, title
);