]> git.saurik.com Git - wxWidgets.git/blame - src/common/msgout.cpp
Added check for Refresh function.
[wxWidgets.git] / src / common / msgout.cpp
CommitLineData
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"
1303a240 41#include "wx/log.h"
f7a75af1 42
74698d3a
MB
43#include <stdarg.h>
44#include <stdio.h>
45
46// ===========================================================================
47// implementation
48// ===========================================================================
49
50wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
51
52wxMessageOutput* wxMessageOutput::Get()
53{
a69be60b 54 if ( !ms_msgOut && wxTheApp )
e02911a2 55 {
a69be60b 56 ms_msgOut = wxTheApp->CreateMessageOutput();
e02911a2
MB
57 }
58
74698d3a
MB
59 return ms_msgOut;
60}
61
62wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout)
63{
64 wxMessageOutput* old = ms_msgOut;
65 ms_msgOut = msgout;
66 return old;
67}
68
69// ----------------------------------------------------------------------------
70// wxMessageOutputStderr
71// ----------------------------------------------------------------------------
72
73void wxMessageOutputStderr::Printf(const wxChar* format, ...)
74{
75 va_list args;
76 va_start(args, format);
77 wxString out;
78
79 out.PrintfV(format, args);
80 va_end(args);
81
401eb3de 82 fprintf(stderr, "%s", (const char*) out.mb_str());
74698d3a
MB
83}
84
85// ----------------------------------------------------------------------------
86// wxMessageOutputMessageBox
87// ----------------------------------------------------------------------------
88
89#if wxUSE_GUI
90
91void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
92{
93 va_list args;
94 va_start(args, format);
95 wxString out;
96
97 out.PrintfV(format, args);
98 va_end(args);
99
100#ifndef __WXMSW__
401eb3de 101 out.Replace(wxT("\t"),wxT(" "));
74698d3a
MB
102#endif
103 ::wxMessageBox(out);
104}
105
106#endif // wxUSE_GUI
107
108// ----------------------------------------------------------------------------
109// wxMessageOutputLog
110// ----------------------------------------------------------------------------
111
74698d3a
MB
112void wxMessageOutputLog::Printf(const wxChar* format, ...)
113{
a69be60b
VZ
114 wxString out;
115
74698d3a
MB
116 va_list args;
117 va_start(args, format);
74698d3a
MB
118
119 out.PrintfV(format, args);
120 va_end(args);
121
8887e234 122 out.Replace(wxT("\t"),wxT(" "));
a69be60b 123
8887e234 124 ::wxLogMessage(wxT("%s"), out.c_str());
74698d3a 125}