]> git.saurik.com Git - wxWidgets.git/blame - src/common/msgout.cpp
fix typo in drawing slider ticks; added assert to check for it (slightly modified...
[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"
a90253f0 35 #include "wx/intl.h"
74698d3a
MB
36 #if wxUSE_GUI
37 #include "wx/msgdlg.h"
38 #endif // wxUSE_GUI
39#endif
40
41#include "wx/msgout.h"
1303a240 42#include "wx/log.h"
f7a75af1 43
74698d3a
MB
44#include <stdarg.h>
45#include <stdio.h>
46
47// ===========================================================================
48// implementation
49// ===========================================================================
50
51wxMessageOutput* wxMessageOutput::ms_msgOut = 0;
52
53wxMessageOutput* wxMessageOutput::Get()
54{
a69be60b 55 if ( !ms_msgOut && wxTheApp )
e02911a2 56 {
a69be60b 57 ms_msgOut = wxTheApp->CreateMessageOutput();
e02911a2
MB
58 }
59
74698d3a
MB
60 return ms_msgOut;
61}
62
63wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout)
64{
65 wxMessageOutput* old = ms_msgOut;
66 ms_msgOut = msgout;
67 return old;
68}
69
70// ----------------------------------------------------------------------------
71// wxMessageOutputStderr
72// ----------------------------------------------------------------------------
73
74void wxMessageOutputStderr::Printf(const wxChar* format, ...)
75{
76 va_list args;
77 va_start(args, format);
78 wxString out;
79
80 out.PrintfV(format, args);
81 va_end(args);
82
401eb3de 83 fprintf(stderr, "%s", (const char*) out.mb_str());
74698d3a
MB
84}
85
86// ----------------------------------------------------------------------------
87// wxMessageOutputMessageBox
88// ----------------------------------------------------------------------------
89
90#if wxUSE_GUI
91
92void wxMessageOutputMessageBox::Printf(const wxChar* format, ...)
93{
94 va_list args;
95 va_start(args, format);
96 wxString out;
97
98 out.PrintfV(format, args);
99 va_end(args);
100
311da78a 101 // the native MSW msg box understands the TABs, others don't
74698d3a 102#ifndef __WXMSW__
311da78a 103 out.Replace(wxT("\t"), wxT(" "));
74698d3a 104#endif
311da78a
VZ
105
106 wxString title;
107 if ( wxTheApp )
a90253f0 108 title.Printf(_("%s message"), wxTheApp->GetAppName().c_str());
311da78a
VZ
109
110 ::wxMessageBox(out, title);
74698d3a
MB
111}
112
113#endif // wxUSE_GUI
114
115// ----------------------------------------------------------------------------
116// wxMessageOutputLog
117// ----------------------------------------------------------------------------
118
74698d3a
MB
119void wxMessageOutputLog::Printf(const wxChar* format, ...)
120{
a69be60b
VZ
121 wxString out;
122
74698d3a
MB
123 va_list args;
124 va_start(args, format);
74698d3a
MB
125
126 out.PrintfV(format, args);
127 va_end(args);
128
311da78a 129 out.Replace(wxT("\t"), wxT(" "));
a69be60b 130
8887e234 131 ::wxLogMessage(wxT("%s"), out.c_str());
74698d3a 132}