]> git.saurik.com Git - wxWidgets.git/blame - src/generic/logg.cpp
don't crash when destroying a not initialized socket (patch 1489095)
[wxWidgets.git] / src / generic / logg.cpp
CommitLineData
dd85fc6b 1/////////////////////////////////////////////////////////////////////////////
8ff41136 2// Name: src/generic/logg.cpp
dd85fc6b
VZ
3// Purpose: wxLog-derived classes which need GUI support (the rest is in
4// src/common/log.cpp)
5// Author: Vadim Zeitlin
6// Modified by:
7// Created: 20.09.99 (extracted from src/common/log.cpp)
8// RCS-ID: $Id$
9// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 10// Licence: wxWindows licence
dd85fc6b
VZ
11/////////////////////////////////////////////////////////////////////////////
12
13// ============================================================================
14// declarations
15// ============================================================================
16
17// ----------------------------------------------------------------------------
18// headers
19// ----------------------------------------------------------------------------
20
dd85fc6b
VZ
21// For compilers that support precompilation, includes "wx.h".
22#include "wx/wxprec.h"
23
24#ifdef __BORLANDC__
f1e01716 25 #pragma hdrstop
dd85fc6b
VZ
26#endif
27
dd85fc6b
VZ
28#ifndef WX_PRECOMP
29 #include "wx/app.h"
f6bcfd97 30 #include "wx/button.h"
dd85fc6b
VZ
31 #include "wx/intl.h"
32 #include "wx/log.h"
33 #include "wx/menu.h"
34 #include "wx/frame.h"
35 #include "wx/filedlg.h"
8ca2f11c 36 #include "wx/msgdlg.h"
dd85fc6b 37 #include "wx/textctrl.h"
f1df0927
VZ
38 #include "wx/sizer.h"
39 #include "wx/statbmp.h"
a0145564 40 #include "wx/settings.h"
dd85fc6b
VZ
41#endif // WX_PRECOMP
42
1e6feb95
VZ
43#if wxUSE_LOGGUI || wxUSE_LOGWINDOW
44
dd85fc6b
VZ
45#include "wx/file.h"
46#include "wx/textfile.h"
f6bcfd97 47#include "wx/statline.h"
389d906b 48#include "wx/artprov.h"
dd85fc6b 49
39a7c7e1 50#ifdef __WXMSW__
f1e01716
WS
51 // for OutputDebugString()
52 #include "wx/msw/private.h"
39a7c7e1
VZ
53#endif // Windows
54
2eb96d03 55#ifdef __WXPM__
f1e01716 56 #include <time.h>
2eb96d03
DW
57#endif
58
f1df0927 59#if wxUSE_LOG_DIALOG
f1df0927 60 #include "wx/listctrl.h"
de8e98f1 61 #include "wx/imaglist.h"
f1df0927 62 #include "wx/image.h"
f1df0927
VZ
63#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
64
ed4e170a
SC
65#if defined(__MWERKS__) && wxUSE_UNICODE
66 #include <wtime.h>
67#endif
68
1aaf88d2
WS
69#include "wx/datetime.h"
70
8ff41136
VZ
71// the suffix we add to the button to show that the dialog can be expanded
72#define EXPAND_SUFFIX _T(" >>")
73
f1df0927
VZ
74// ----------------------------------------------------------------------------
75// private classes
76// ----------------------------------------------------------------------------
77
78#if wxUSE_LOG_DIALOG
79
f94dfb38
VS
80// this function is a wrapper around strftime(3)
81// allows to exclude the usage of wxDateTime
82static wxString TimeStamp(const wxChar *format, time_t t)
83{
84 wxChar buf[4096];
85 if ( !wxStrftime(buf, WXSIZEOF(buf), format, localtime(&t)) )
86 {
87 // buffer is too small?
88 wxFAIL_MSG(_T("strftime() failed"));
89 }
90 return wxString(buf);
91}
92
93
f1df0927
VZ
94class wxLogDialog : public wxDialog
95{
96public:
97 wxLogDialog(wxWindow *parent,
98 const wxArrayString& messages,
99 const wxArrayInt& severity,
100 const wxArrayLong& timess,
101 const wxString& caption,
102 long style);
103 virtual ~wxLogDialog();
104
105 // event handlers
106 void OnOk(wxCommandEvent& event);
107 void OnDetails(wxCommandEvent& event);
f6bcfd97
BP
108#if wxUSE_FILE
109 void OnSave(wxCommandEvent& event);
110#endif // wxUSE_FILE
4aff28fc 111 void OnListSelect(wxListEvent& event);
f1df0927
VZ
112
113private:
f6bcfd97
BP
114 // create controls needed for the details display
115 void CreateDetailsControls();
116
f1df0927 117 // the data for the listctrl
224ff7a5
VZ
118 wxArrayString m_messages;
119 wxArrayInt m_severity;
120 wxArrayLong m_times;
f1df0927
VZ
121
122 // the "toggle" button and its state
5e63b67d 123#ifndef __SMARTPHONE__
f1df0927 124 wxButton *m_btnDetails;
5e63b67d 125#endif
f1df0927
VZ
126 bool m_showingDetails;
127
f6bcfd97
BP
128 // the controls which are not shown initially (but only when details
129 // button is pressed)
f1df0927 130 wxListCtrl *m_listctrl;
5e63b67d 131#ifndef __SMARTPHONE__
f6bcfd97
BP
132#if wxUSE_STATLINE
133 wxStaticLine *m_statline;
134#endif // wxUSE_STATLINE
135#if wxUSE_FILE
136 wxButton *m_btnSave;
137#endif // wxUSE_FILE
5e63b67d 138#endif // __SMARTPHONE__
f1df0927 139
5f170f33
VZ
140 // the translated "Details" string
141 static wxString ms_details;
142
f1df0927 143 DECLARE_EVENT_TABLE()
22f3361e 144 DECLARE_NO_COPY_CLASS(wxLogDialog)
f1df0927
VZ
145};
146
147BEGIN_EVENT_TABLE(wxLogDialog, wxDialog)
eb3e6de3 148 EVT_BUTTON(wxID_OK, wxLogDialog::OnOk)
f1df0927 149 EVT_BUTTON(wxID_MORE, wxLogDialog::OnDetails)
f6bcfd97
BP
150#if wxUSE_FILE
151 EVT_BUTTON(wxID_SAVE, wxLogDialog::OnSave)
152#endif // wxUSE_FILE
dabbc6a5 153 EVT_LIST_ITEM_SELECTED(wxID_ANY, wxLogDialog::OnListSelect)
f1df0927
VZ
154END_EVENT_TABLE()
155
156#endif // wxUSE_LOG_DIALOG
157
f6bcfd97
BP
158// ----------------------------------------------------------------------------
159// private functions
160// ----------------------------------------------------------------------------
161
3e6e2754 162#if wxUSE_FILE && wxUSE_FILEDLG
f6bcfd97
BP
163
164// pass an uninitialized file object, the function will ask the user for the
dabbc6a5
DS
165// filename and try to open it, returns true on success (file was opened),
166// false if file couldn't be opened/created and -1 if the file selection
f6bcfd97 167// dialog was cancelled
73ff84ff 168static int OpenLogFile(wxFile& file, wxString *filename = NULL, wxWindow *parent = NULL);
f6bcfd97
BP
169
170#endif // wxUSE_FILE
171
dd85fc6b
VZ
172// ----------------------------------------------------------------------------
173// global variables
174// ----------------------------------------------------------------------------
175
176// we use a global variable to store the frame pointer for wxLogStatus - bad,
3e6e2754 177// but it's the easiest way
63617fb5 178static wxFrame *gs_pFrame = NULL; // FIXME MT-unsafe
dd85fc6b
VZ
179
180// ============================================================================
181// implementation
182// ============================================================================
183
184// ----------------------------------------------------------------------------
185// global functions
186// ----------------------------------------------------------------------------
187
188// accepts an additional argument which tells to which frame the output should
189// be directed
1d63fd6b 190void wxVLogStatus(wxFrame *pFrame, const wxChar *szFormat, va_list argptr)
dd85fc6b
VZ
191{
192 wxString msg;
193
194 wxLog *pLog = wxLog::GetActiveTarget();
195 if ( pLog != NULL ) {
dd85fc6b 196 msg.PrintfV(szFormat, argptr);
dd85fc6b
VZ
197
198 wxASSERT( gs_pFrame == NULL ); // should be reset!
199 gs_pFrame = pFrame;
4676948b
JS
200#ifdef __WXWINCE__
201 wxLog::OnLog(wxLOG_Status, msg, 0);
202#else
dd85fc6b 203 wxLog::OnLog(wxLOG_Status, msg, time(NULL));
4676948b 204#endif
dd85fc6b
VZ
205 gs_pFrame = (wxFrame *) NULL;
206 }
207}
208
42fa962e
GD
209void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...)
210{
211 va_list argptr;
212 va_start(argptr, szFormat);
1d63fd6b 213 wxVLogStatus(pFrame, szFormat, argptr);
42fa962e
GD
214 va_end(argptr);
215}
216
dd85fc6b
VZ
217// ----------------------------------------------------------------------------
218// wxLogGui implementation (FIXME MT-unsafe)
219// ----------------------------------------------------------------------------
220
461dae94
VZ
221#if wxUSE_LOGGUI
222
dd85fc6b
VZ
223wxLogGui::wxLogGui()
224{
225 Clear();
226}
227
228void wxLogGui::Clear()
229{
5f170f33
VZ
230 m_bErrors =
231 m_bWarnings =
dabbc6a5 232 m_bHasMessages = false;
5f170f33 233
dd85fc6b 234 m_aMessages.Empty();
f1df0927 235 m_aSeverity.Empty();
dd85fc6b
VZ
236 m_aTimes.Empty();
237}
238
239void wxLogGui::Flush()
240{
241 if ( !m_bHasMessages )
242 return;
243
244 // do it right now to block any new calls to Flush() while we're here
dabbc6a5 245 m_bHasMessages = false;
dd85fc6b 246
f6bcfd97 247 wxString appName = wxTheApp->GetAppName();
32b13913 248 if ( !appName.empty() )
8253f2e0 249 appName[0u] = (wxChar)wxToupper(appName[0u]);
f1df0927
VZ
250
251 long style;
f6bcfd97 252 wxString titleFormat;
f1df0927 253 if ( m_bErrors ) {
f6bcfd97 254 titleFormat = _("%s Error");
f1df0927
VZ
255 style = wxICON_STOP;
256 }
257 else if ( m_bWarnings ) {
f6bcfd97 258 titleFormat = _("%s Warning");
f1df0927
VZ
259 style = wxICON_EXCLAMATION;
260 }
261 else {
f6bcfd97 262 titleFormat = _("%s Information");
f1df0927
VZ
263 style = wxICON_INFORMATION;
264 }
1e6feb95 265
f6bcfd97
BP
266 wxString title;
267 title.Printf(titleFormat, appName.c_str());
f1df0927 268
23f681ec 269 size_t nMsgCount = m_aMessages.Count();
224ff7a5 270
69c916e9
VZ
271 // avoid showing other log dialogs until we're done with the dialog we're
272 // showing right now: nested modal dialogs make for really bad UI!
273 Suspend();
274
23f681ec
VZ
275 wxString str;
276 if ( nMsgCount == 1 )
277 {
278 str = m_aMessages[0];
279 }
280 else // more than one message
281 {
282#if wxUSE_LOG_DIALOG
3e6e2754 283
39cc7a0b 284 wxLogDialog dlg(NULL,
23f681ec
VZ
285 m_aMessages, m_aSeverity, m_aTimes,
286 title, style);
f1df0927 287
23f681ec
VZ
288 // clear the message list before showing the dialog because while it's
289 // shown some new messages may appear
290 Clear();
291
292 (void)dlg.ShowModal();
f1df0927 293#else // !wxUSE_LOG_DIALOG
23f681ec
VZ
294 // concatenate all strings (but not too many to not overfill the msg box)
295 size_t nLines = 0;
dd85fc6b 296
23f681ec
VZ
297 // start from the most recent message
298 for ( size_t n = nMsgCount; n > 0; n-- ) {
299 // for Windows strings longer than this value are wrapped (NT 4.0)
300 const size_t nMsgLineWidth = 156;
dd85fc6b 301
23f681ec 302 nLines += (m_aMessages[n - 1].Len() + nMsgLineWidth - 1) / nMsgLineWidth;
dd85fc6b 303
23f681ec
VZ
304 if ( nLines > 25 ) // don't put too many lines in message box
305 break;
dd85fc6b 306
23f681ec
VZ
307 str << m_aMessages[n - 1] << wxT("\n");
308 }
309#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
dd85fc6b
VZ
310 }
311
23f681ec
VZ
312 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
313 // situation without it
32b13913 314 if ( !str.empty() )
23f681ec 315 {
39cc7a0b 316 wxMessageBox(str, title, wxOK | style);
dd85fc6b 317
23f681ec
VZ
318 // no undisplayed messages whatsoever
319 Clear();
320 }
69c916e9
VZ
321
322 // allow flushing the logs again
323 Resume();
dd85fc6b
VZ
324}
325
23f681ec 326// log all kinds of messages
dd85fc6b
VZ
327void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
328{
329 switch ( level ) {
330 case wxLOG_Info:
331 if ( GetVerbose() )
332 case wxLOG_Message:
f1df0927 333 {
a250392c
VZ
334 m_aMessages.Add(szString);
335 m_aSeverity.Add(wxLOG_Message);
336 m_aTimes.Add((long)t);
dabbc6a5 337 m_bHasMessages = true;
f1df0927
VZ
338 }
339 break;
dd85fc6b
VZ
340
341 case wxLOG_Status:
342#if wxUSE_STATUSBAR
f1df0927
VZ
343 {
344 // find the top window and set it's status text if it has any
345 wxFrame *pFrame = gs_pFrame;
346 if ( pFrame == NULL ) {
347 wxWindow *pWin = wxTheApp->GetTopWindow();
348 if ( pWin != NULL && pWin->IsKindOf(CLASSINFO(wxFrame)) ) {
349 pFrame = (wxFrame *)pWin;
dd85fc6b 350 }
dd85fc6b 351 }
f1df0927
VZ
352
353 if ( pFrame && pFrame->GetStatusBar() )
354 pFrame->SetStatusText(szString);
355 }
dd85fc6b 356#endif // wxUSE_STATUSBAR
f1df0927 357 break;
dd85fc6b
VZ
358
359 case wxLOG_Trace:
360 case wxLOG_Debug:
f1df0927
VZ
361 #ifdef __WXDEBUG__
362 {
3a57b93d
VZ
363 wxString str;
364 TimeStamp(&str);
365 str += szString;
366
8a46f9b1 367 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
f1df0927 368 // don't prepend debug/trace here: it goes to the
3a57b93d
VZ
369 // debug window anyhow
370 str += wxT("\r\n");
f1df0927
VZ
371 OutputDebugString(str);
372 #else
373 // send them to stderr
3a57b93d 374 wxFprintf(stderr, wxT("[%s] %s\n"),
f1df0927
VZ
375 level == wxLOG_Trace ? wxT("Trace")
376 : wxT("Debug"),
3a57b93d 377 str.c_str());
f1df0927
VZ
378 fflush(stderr);
379 #endif
380 }
381 #endif // __WXDEBUG__
dd85fc6b 382
f1df0927 383 break;
dd85fc6b
VZ
384
385 case wxLOG_FatalError:
f1df0927
VZ
386 // show this one immediately
387 wxMessageBox(szString, _("Fatal error"), wxICON_HAND);
a2a0d40d 388 wxExit();
f1df0927 389 break;
dd85fc6b
VZ
390
391 case wxLOG_Error:
f1df0927
VZ
392 if ( !m_bErrors ) {
393#if !wxUSE_LOG_DIALOG
dd85fc6b 394 // discard earlier informational messages if this is the 1st
f1df0927
VZ
395 // error because they might not make sense any more and showing
396 // them in a message box might be confusing
397 m_aMessages.Empty();
398 m_aSeverity.Empty();
399 m_aTimes.Empty();
400#endif // wxUSE_LOG_DIALOG
dabbc6a5 401 m_bErrors = true;
f1df0927
VZ
402 }
403 // fall through
dd85fc6b
VZ
404
405 case wxLOG_Warning:
f1df0927
VZ
406 if ( !m_bErrors ) {
407 // for the warning we don't discard the info messages
dabbc6a5 408 m_bWarnings = true;
f1df0927
VZ
409 }
410
411 m_aMessages.Add(szString);
06b466c7 412 m_aSeverity.Add((int)level);
f1df0927 413 m_aTimes.Add((long)t);
dabbc6a5 414 m_bHasMessages = true;
f1df0927 415 break;
dd85fc6b
VZ
416 }
417}
418
461dae94
VZ
419#endif // wxUSE_LOGGUI
420
dd85fc6b
VZ
421// ----------------------------------------------------------------------------
422// wxLogWindow and wxLogFrame implementation
423// ----------------------------------------------------------------------------
424
c54a8b64
VZ
425#if wxUSE_LOGWINDOW
426
dd85fc6b
VZ
427// log frame class
428// ---------------
429class wxLogFrame : public wxFrame
430{
431public:
432 // ctor & dtor
55c9a186 433 wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxChar *szTitle);
dd85fc6b
VZ
434 virtual ~wxLogFrame();
435
436 // menu callbacks
437 void OnClose(wxCommandEvent& event);
438 void OnCloseWindow(wxCloseEvent& event);
439#if wxUSE_FILE
440 void OnSave (wxCommandEvent& event);
441#endif // wxUSE_FILE
442 void OnClear(wxCommandEvent& event);
443
dd85fc6b
VZ
444 // accessors
445 wxTextCtrl *TextCtrl() const { return m_pTextCtrl; }
446
447private:
857eb081 448 // use standard ids for our commands!
dd85fc6b
VZ
449 enum
450 {
857eb081
VZ
451 Menu_Close = wxID_CLOSE,
452 Menu_Save = wxID_SAVE,
453 Menu_Clear = wxID_CLEAR
dd85fc6b
VZ
454 };
455
f6bcfd97
BP
456 // common part of OnClose() and OnCloseWindow()
457 void DoClose();
dd85fc6b
VZ
458
459 wxTextCtrl *m_pTextCtrl;
460 wxLogWindow *m_log;
461
462 DECLARE_EVENT_TABLE()
22f3361e 463 DECLARE_NO_COPY_CLASS(wxLogFrame)
dd85fc6b
VZ
464};
465
466BEGIN_EVENT_TABLE(wxLogFrame, wxFrame)
467 // wxLogWindow menu events
468 EVT_MENU(Menu_Close, wxLogFrame::OnClose)
469#if wxUSE_FILE
470 EVT_MENU(Menu_Save, wxLogFrame::OnSave)
471#endif // wxUSE_FILE
472 EVT_MENU(Menu_Clear, wxLogFrame::OnClear)
473
474 EVT_CLOSE(wxLogFrame::OnCloseWindow)
475END_EVENT_TABLE()
476
55c9a186 477wxLogFrame::wxLogFrame(wxWindow *pParent, wxLogWindow *log, const wxChar *szTitle)
dabbc6a5 478 : wxFrame(pParent, wxID_ANY, szTitle)
dd85fc6b
VZ
479{
480 m_log = log;
481
dabbc6a5 482 m_pTextCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
dd85fc6b
VZ
483 wxDefaultSize,
484 wxTE_MULTILINE |
485 wxHSCROLL |
46d52925
VZ
486 // needed for Win32 to avoid 65Kb limit but it doesn't work well
487 // when using RichEdit 2.0 which we always do in the Unicode build
488#if !wxUSE_UNICODE
489 wxTE_RICH |
490#endif // !wxUSE_UNICODE
dd85fc6b
VZ
491 wxTE_READONLY);
492
3a8c693a 493#if wxUSE_MENUS
dd85fc6b
VZ
494 // create menu
495 wxMenuBar *pMenuBar = new wxMenuBar;
496 wxMenu *pMenu = new wxMenu;
497#if wxUSE_FILE
498 pMenu->Append(Menu_Save, _("&Save..."), _("Save log contents to file"));
499#endif // wxUSE_FILE
500 pMenu->Append(Menu_Clear, _("C&lear"), _("Clear the log contents"));
501 pMenu->AppendSeparator();
502 pMenu->Append(Menu_Close, _("&Close"), _("Close this window"));
503 pMenuBar->Append(pMenu, _("&Log"));
504 SetMenuBar(pMenuBar);
3a8c693a 505#endif // wxUSE_MENUS
dd85fc6b
VZ
506
507#if wxUSE_STATUSBAR
508 // status bar for menu prompts
509 CreateStatusBar();
510#endif // wxUSE_STATUSBAR
511
512 m_log->OnFrameCreate(this);
513}
514
f6bcfd97
BP
515void wxLogFrame::DoClose()
516{
517 if ( m_log->OnFrameClose(this) )
518 {
519 // instead of closing just hide the window to be able to Show() it
520 // later
dabbc6a5 521 Show(false);
f6bcfd97
BP
522 }
523}
524
dd85fc6b
VZ
525void wxLogFrame::OnClose(wxCommandEvent& WXUNUSED(event))
526{
527 DoClose();
528}
529
530void wxLogFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
531{
532 DoClose();
533}
534
535#if wxUSE_FILE
536void wxLogFrame::OnSave(wxCommandEvent& WXUNUSED(event))
537{
3e6e2754 538#if wxUSE_FILEDLG
f6bcfd97
BP
539 wxString filename;
540 wxFile file;
73ff84ff 541 int rc = OpenLogFile(file, &filename, this);
f6bcfd97
BP
542 if ( rc == -1 )
543 {
dd85fc6b
VZ
544 // cancelled
545 return;
546 }
547
f6bcfd97 548 bool bOk = rc != 0;
dd85fc6b
VZ
549
550 // retrieve text and save it
551 // -------------------------
552 int nLines = m_pTextCtrl->GetNumberOfLines();
553 for ( int nLine = 0; bOk && nLine < nLines; nLine++ ) {
554 bOk = file.Write(m_pTextCtrl->GetLineText(nLine) +
f6bcfd97 555 wxTextFile::GetEOL());
dd85fc6b
VZ
556 }
557
558 if ( bOk )
559 bOk = file.Close();
560
561 if ( !bOk ) {
562 wxLogError(_("Can't save log contents to file."));
563 }
564 else {
f6bcfd97 565 wxLogStatus(this, _("Log saved to the file '%s'."), filename.c_str());
dd85fc6b 566 }
3e6e2754 567#endif
dd85fc6b
VZ
568}
569#endif // wxUSE_FILE
570
571void wxLogFrame::OnClear(wxCommandEvent& WXUNUSED(event))
572{
573 m_pTextCtrl->Clear();
574}
575
576wxLogFrame::~wxLogFrame()
577{
578 m_log->OnFrameDelete(this);
579}
580
581// wxLogWindow
582// -----------
03147cd0 583
55c9a186 584wxLogWindow::wxLogWindow(wxWindow *pParent,
dd85fc6b
VZ
585 const wxChar *szTitle,
586 bool bShow,
587 bool bDoPass)
588{
03147cd0 589 PassMessages(bDoPass);
dd85fc6b
VZ
590
591 m_pLogFrame = new wxLogFrame(pParent, this, szTitle);
dd85fc6b
VZ
592
593 if ( bShow )
dabbc6a5 594 m_pLogFrame->Show();
dd85fc6b
VZ
595}
596
597void wxLogWindow::Show(bool bShow)
598{
599 m_pLogFrame->Show(bShow);
600}
601
dd85fc6b
VZ
602void wxLogWindow::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
603{
604 // first let the previous logger show it
03147cd0 605 wxLogPassThrough::DoLog(level, szString, t);
dd85fc6b
VZ
606
607 if ( m_pLogFrame ) {
608 switch ( level ) {
609 case wxLOG_Status:
610 // by default, these messages are ignored by wxLog, so process
611 // them ourselves
612 if ( !wxIsEmpty(szString) )
613 {
614 wxString str;
615 str << _("Status: ") << szString;
616 DoLogString(str, t);
617 }
618 break;
619
620 // don't put trace messages in the text window for 2 reasons:
621 // 1) there are too many of them
622 // 2) they may provoke other trace messages thus sending a program
623 // into an infinite loop
624 case wxLOG_Trace:
625 break;
626
627 default:
628 // and this will format it nicely and call our DoLogString()
629 wxLog::DoLog(level, szString, t);
630 }
631 }
dd85fc6b
VZ
632}
633
634void wxLogWindow::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
635{
636 // put the text into our window
637 wxTextCtrl *pText = m_pLogFrame->TextCtrl();
638
639 // remove selection (WriteText is in fact ReplaceSelection)
640#ifdef __WXMSW__
7d8268a1 641 wxTextPos nLen = pText->GetLastPosition();
dd85fc6b
VZ
642 pText->SetSelection(nLen, nLen);
643#endif // Windows
644
645 wxString msg;
646 TimeStamp(&msg);
223d09f6 647 msg << szString << wxT('\n');
dd85fc6b
VZ
648
649 pText->AppendText(msg);
650
651 // TODO ensure that the line can be seen
652}
653
654wxFrame *wxLogWindow::GetFrame() const
655{
656 return m_pLogFrame;
657}
658
659void wxLogWindow::OnFrameCreate(wxFrame * WXUNUSED(frame))
660{
661}
662
f6bcfd97
BP
663bool wxLogWindow::OnFrameClose(wxFrame * WXUNUSED(frame))
664{
665 // allow to close
dabbc6a5 666 return true;
f6bcfd97
BP
667}
668
dd85fc6b
VZ
669void wxLogWindow::OnFrameDelete(wxFrame * WXUNUSED(frame))
670{
671 m_pLogFrame = (wxLogFrame *)NULL;
672}
673
674wxLogWindow::~wxLogWindow()
675{
dd85fc6b
VZ
676 // may be NULL if log frame already auto destroyed itself
677 delete m_pLogFrame;
678}
679
c54a8b64
VZ
680#endif // wxUSE_LOGWINDOW
681
f1df0927
VZ
682// ----------------------------------------------------------------------------
683// wxLogDialog
684// ----------------------------------------------------------------------------
685
686#if wxUSE_LOG_DIALOG
687
5e63b67d 688#ifndef __SMARTPHONE__
f1df0927 689static const size_t MARGIN = 10;
5e63b67d
WS
690#else
691static const size_t MARGIN = 0;
692#endif
f1df0927 693
5f170f33
VZ
694wxString wxLogDialog::ms_details;
695
f1df0927
VZ
696wxLogDialog::wxLogDialog(wxWindow *parent,
697 const wxArrayString& messages,
698 const wxArrayInt& severity,
699 const wxArrayLong& times,
700 const wxString& caption,
701 long style)
dabbc6a5 702 : wxDialog(parent, wxID_ANY, caption,
0b165ed6
VZ
703 wxDefaultPosition, wxDefaultSize,
704 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
f1df0927 705{
32b13913 706 if ( ms_details.empty() )
5f170f33 707 {
f6bcfd97
BP
708 // ensure that we won't loop here if wxGetTranslation()
709 // happens to pop up a Log message while translating this :-)
710 ms_details = wxTRANSLATE("&Details");
5f170f33 711 ms_details = wxGetTranslation(ms_details);
5e63b67d
WS
712#ifdef __SMARTPHONE__
713 ms_details = wxStripMenuCodes(ms_details);
714#endif
5f170f33
VZ
715 }
716
4aff28fc
VZ
717 size_t count = messages.GetCount();
718 m_messages.Alloc(count);
719 m_severity.Alloc(count);
720 m_times.Alloc(count);
721
722 for ( size_t n = 0; n < count; n++ )
723 {
724 wxString msg = messages[n];
ff0a9f8d 725 msg.Replace(wxT("\n"), wxT(" "));
786c4e23
VZ
726 m_messages.Add(msg);
727 m_severity.Add(severity[n]);
728 m_times.Add(times[n]);
4aff28fc
VZ
729 }
730
dabbc6a5 731 m_showingDetails = false; // not initially
f1df0927
VZ
732 m_listctrl = (wxListCtrl *)NULL;
733
5e63b67d
WS
734#ifndef __SMARTPHONE__
735
f6bcfd97
BP
736#if wxUSE_STATLINE
737 m_statline = (wxStaticLine *)NULL;
738#endif // wxUSE_STATLINE
739
740#if wxUSE_FILE
741 m_btnSave = (wxButton *)NULL;
742#endif // wxUSE_FILE
743
5e63b67d
WS
744#endif // __SMARTPHONE__
745
94f53923 746 bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
5e63b67d 747
f1df0927
VZ
748 // create the controls which are always shown and layout them: we use
749 // sizers even though our window is not resizeable to calculate the size of
750 // the dialog properly
751 wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
5e63b67d 752#ifndef __SMARTPHONE__
94f53923 753 wxBoxSizer *sizerButtons = new wxBoxSizer(isPda ? wxHORIZONTAL : wxVERTICAL);
5e63b67d 754#endif
94f53923 755 wxBoxSizer *sizerAll = new wxBoxSizer(isPda ? wxVERTICAL : wxHORIZONTAL);
f1df0927 756
5e63b67d
WS
757#ifdef __SMARTPHONE__
758 SetLeftMenu(wxID_OK);
759 SetRightMenu(wxID_MORE, ms_details + EXPAND_SUFFIX);
760#else
eb3e6de3 761 wxButton *btnOk = new wxButton(this, wxID_OK);
94f53923 762 sizerButtons->Add(btnOk, 0, isPda ? wxCENTRE : wxCENTRE|wxBOTTOM, MARGIN/2);
8ff41136 763 m_btnDetails = new wxButton(this, wxID_MORE, ms_details + EXPAND_SUFFIX);
94f53923 764 sizerButtons->Add(m_btnDetails, 0, isPda ? wxCENTRE|wxLEFT : wxCENTRE | wxTOP, MARGIN/2 - 1);
5e63b67d 765#endif
f1df0927 766
389d906b
VS
767 wxBitmap bitmap;
768 switch ( style & wxICON_MASK )
769 {
770 case wxICON_ERROR:
5854bb83 771 bitmap = wxArtProvider::GetBitmap(wxART_ERROR, wxART_MESSAGE_BOX);
f1ecc5db
DW
772#ifdef __WXPM__
773 bitmap.SetId(wxICON_SMALL_ERROR);
774#endif
775 break;
776
389d906b 777 case wxICON_INFORMATION:
5854bb83 778 bitmap = wxArtProvider::GetBitmap(wxART_INFORMATION, wxART_MESSAGE_BOX);
f1ecc5db
DW
779#ifdef __WXPM__
780 bitmap.SetId(wxICON_SMALL_INFO);
781#endif
782 break;
783
389d906b 784 case wxICON_WARNING:
5854bb83 785 bitmap = wxArtProvider::GetBitmap(wxART_WARNING, wxART_MESSAGE_BOX);
f1ecc5db
DW
786#ifdef __WXPM__
787 bitmap.SetId(wxICON_SMALL_WARNING);
788#endif
789 break;
790
389d906b
VS
791 default:
792 wxFAIL_MSG(_T("incorrect log style"));
793 }
5e63b67d 794
94f53923
JS
795 if (!isPda)
796 sizerAll->Add(new wxStaticBitmap(this, wxID_ANY, bitmap), 0,
c9ecfbe4 797 wxALIGN_CENTRE_VERTICAL);
669f7a11 798
f1df0927 799 const wxString& message = messages.Last();
0b165ed6
VZ
800 sizerAll->Add(CreateTextSizer(message), 1,
801 wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT, MARGIN);
5e63b67d 802#ifndef __SMARTPHONE__
94f53923 803 sizerAll->Add(sizerButtons, 0, isPda ? wxCENTRE|wxTOP|wxBOTTOM : (wxALIGN_RIGHT | wxLEFT), MARGIN);
5e63b67d 804#endif
f1df0927 805
0b165ed6 806 sizerTop->Add(sizerAll, 0, wxALL | wxEXPAND, MARGIN);
f1df0927 807
f1df0927
VZ
808 SetSizer(sizerTop);
809
238d33aa 810 // see comments in OnDetails()
801225c1
RL
811 //
812 // Note: Doing this, this way, triggered a nasty bug in
813 // wxTopLevelWindowGTK::GtkOnSize which took -1 literally once
814 // either of maxWidth or maxHeight was set. This symptom has been
815 // fixed there, but it is a problem that remains as long as we allow
816 // unchecked access to the internal size members. We really need to
817 // encapuslate window sizes more cleanly and make it clear when -1 will
818 // be substituted and when it will not.
819
238d33aa
VZ
820 wxSize size = sizerTop->Fit(this);
821 m_maxHeight = size.y;
822 SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight);
f1df0927 823
5e63b67d 824#ifndef __SMARTPHONE__
f1df0927 825 btnOk->SetFocus();
5e63b67d 826#endif
f1df0927
VZ
827
828 Centre();
5e63b67d 829
94f53923
JS
830 if (isPda)
831 {
832 // Move up the screen so that when we expand the dialog,
833 // there's enough space.
834 Move(wxPoint(GetPosition().x, GetPosition().y / 2));
835 }
f1df0927
VZ
836}
837
f6bcfd97
BP
838void wxLogDialog::CreateDetailsControls()
839{
5e63b67d 840#ifndef __SMARTPHONE__
f6bcfd97
BP
841 // create the save button and separator line if possible
842#if wxUSE_FILE
5f7bcb48 843 m_btnSave = new wxButton(this, wxID_SAVE);
f6bcfd97
BP
844#endif // wxUSE_FILE
845
846#if wxUSE_STATLINE
dabbc6a5 847 m_statline = new wxStaticLine(this, wxID_ANY);
f6bcfd97
BP
848#endif // wxUSE_STATLINE
849
5e63b67d
WS
850#endif // __SMARTPHONE__
851
f6bcfd97 852 // create the list ctrl now
dabbc6a5 853 m_listctrl = new wxListCtrl(this, wxID_ANY,
f6bcfd97
BP
854 wxDefaultPosition, wxDefaultSize,
855 wxSUNKEN_BORDER |
856 wxLC_REPORT |
857 wxLC_NO_HEADER |
858 wxLC_SINGLE_SEL);
94f53923
JS
859#ifdef __WXWINCE__
860 // This maks a big aesthetic difference on WinCE but I
861 // don't want to risk problems on other platforms
862 m_listctrl->Hide();
5e63b67d 863#endif
f6bcfd97
BP
864
865 // no need to translate these strings as they're not shown to the
866 // user anyhow (we use wxLC_NO_HEADER style)
867 m_listctrl->InsertColumn(0, _T("Message"));
868 m_listctrl->InsertColumn(1, _T("Time"));
869
870 // prepare the imagelist
871 static const int ICON_SIZE = 16;
872 wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE);
873
874 // order should be the same as in the switch below!
389d906b 875 static const wxChar* icons[] =
f6bcfd97 876 {
389d906b
VS
877 wxART_ERROR,
878 wxART_WARNING,
879 wxART_INFORMATION
f6bcfd97
BP
880 };
881
dabbc6a5 882 bool loadedIcons = true;
f6bcfd97 883
f6bcfd97
BP
884 for ( size_t icon = 0; icon < WXSIZEOF(icons); icon++ )
885 {
389d906b
VS
886 wxBitmap bmp = wxArtProvider::GetBitmap(icons[icon], wxART_MESSAGE_BOX,
887 wxSize(ICON_SIZE, ICON_SIZE));
f6bcfd97 888
9f14a818
VZ
889 // This may very well fail if there are insufficient colours available.
890 // Degrade gracefully.
891 if ( !bmp.Ok() )
892 {
dabbc6a5 893 loadedIcons = false;
9f14a818
VZ
894
895 break;
896 }
897
389d906b 898 imageList->Add(bmp);
f6bcfd97
BP
899 }
900
901 m_listctrl->SetImageList(imageList, wxIMAGE_LIST_SMALL);
f6bcfd97
BP
902
903 // and fill it
904 wxString fmt = wxLog::GetTimestamp();
905 if ( !fmt )
906 {
907 // default format
c54a8b64 908 fmt = _T("%c");
f6bcfd97
BP
909 }
910
911 size_t count = m_messages.GetCount();
912 for ( size_t n = 0; n < count; n++ )
913 {
9f14a818
VZ
914 int image;
915
9f14a818 916 if ( loadedIcons )
f6bcfd97 917 {
9f14a818
VZ
918 switch ( m_severity[n] )
919 {
920 case wxLOG_Error:
921 image = 0;
922 break;
f6bcfd97 923
9f14a818
VZ
924 case wxLOG_Warning:
925 image = 1;
926 break;
f6bcfd97 927
9f14a818
VZ
928 default:
929 image = 2;
930 }
f6bcfd97 931 }
9f14a818 932 else // failed to load images
9f14a818 933 {
f6bcfd97 934 image = -1;
9f14a818 935 }
f6bcfd97 936
9f14a818
VZ
937 m_listctrl->InsertItem(n, m_messages[n], image);
938 m_listctrl->SetItem(n, 1, TimeStamp(fmt, (time_t)m_times[n]));
f6bcfd97
BP
939 }
940
941 // let the columns size themselves
942 m_listctrl->SetColumnWidth(0, wxLIST_AUTOSIZE);
943 m_listctrl->SetColumnWidth(1, wxLIST_AUTOSIZE);
944
9f14a818 945 // calculate an approximately nice height for the listctrl
7b82d782 946 int height = GetCharHeight()*(count + 4);
f6bcfd97 947
9f14a818
VZ
948 // but check that the dialog won't fall fown from the screen
949 //
950 // we use GetMinHeight() to get the height of the dialog part without the
951 // details and we consider that the "Save" button below and the separator
952 // line (and the margins around it) take about as much, hence double it
953 int heightMax = wxGetDisplaySize().y - GetPosition().y - 2*GetMinHeight();
4d509295 954
9f14a818
VZ
955 // we should leave a margin
956 heightMax *= 9;
957 heightMax /= 10;
4d509295 958
422d0ff0 959 m_listctrl->SetSize(wxDefaultCoord, wxMin(height, heightMax));
f6bcfd97
BP
960}
961
4aff28fc
VZ
962void wxLogDialog::OnListSelect(wxListEvent& event)
963{
964 // we can't just disable the control because this looks ugly under Windows
965 // (wrong bg colour, no scrolling...), but we still want to disable
966 // selecting items - it makes no sense here
225fe9d6 967 m_listctrl->SetItemState(event.GetIndex(), 0, wxLIST_STATE_SELECTED);
4aff28fc
VZ
968}
969
f1df0927
VZ
970void wxLogDialog::OnOk(wxCommandEvent& WXUNUSED(event))
971{
972 EndModal(wxID_OK);
973}
974
f6bcfd97
BP
975#if wxUSE_FILE
976
977void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event))
978{
3e6e2754 979#if wxUSE_FILEDLG
f6bcfd97 980 wxFile file;
73ff84ff 981 int rc = OpenLogFile(file, NULL, this);
f6bcfd97
BP
982 if ( rc == -1 )
983 {
984 // cancelled
985 return;
986 }
987
988 bool ok = rc != 0;
989
990 wxString fmt = wxLog::GetTimestamp();
991 if ( !fmt )
992 {
993 // default format
c54a8b64 994 fmt = _T("%c");
f6bcfd97
BP
995 }
996
997 size_t count = m_messages.GetCount();
998 for ( size_t n = 0; ok && (n < count); n++ )
999 {
1000 wxString line;
f94dfb38 1001 line << TimeStamp(fmt, (time_t)m_times[n])
f6bcfd97
BP
1002 << _T(": ")
1003 << m_messages[n]
1004 << wxTextFile::GetEOL();
1005
1006 ok = file.Write(line);
1007 }
1008
1009 if ( ok )
1010 ok = file.Close();
1011
1012 if ( !ok )
1013 wxLogError(_("Can't save log contents to file."));
9f14a818 1014#endif // wxUSE_FILEDLG
f6bcfd97
BP
1015}
1016
1017#endif // wxUSE_FILE
1018
f1df0927
VZ
1019void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event))
1020{
1021 wxSizer *sizer = GetSizer();
1022
1023 if ( m_showingDetails )
1024 {
5e63b67d
WS
1025#ifdef __SMARTPHONE__
1026 SetRightMenu(wxID_MORE, ms_details + EXPAND_SUFFIX);
1027#else
8ff41136 1028 m_btnDetails->SetLabel(ms_details + EXPAND_SUFFIX);
5e63b67d 1029#endif
f1df0927 1030
12a3f227 1031 sizer->Detach( m_listctrl );
f6bcfd97 1032
5e63b67d
WS
1033#ifndef __SMARTPHONE__
1034
f6bcfd97 1035#if wxUSE_STATLINE
12a3f227 1036 sizer->Detach( m_statline );
f6bcfd97
BP
1037#endif // wxUSE_STATLINE
1038
1039#if wxUSE_FILE
12a3f227 1040 sizer->Detach( m_btnSave );
f6bcfd97 1041#endif // wxUSE_FILE
5e63b67d
WS
1042
1043#endif // __SMARTPHONE__
f1df0927
VZ
1044 }
1045 else // show details now
1046 {
5e63b67d
WS
1047#ifdef __SMARTPHONE__
1048 SetRightMenu(wxID_MORE, wxString(_T("<< ")) + ms_details);
1049#else
5f170f33 1050 m_btnDetails->SetLabel(wxString(_T("<< ")) + ms_details);
5e63b67d 1051#endif
f1df0927
VZ
1052
1053 if ( !m_listctrl )
1054 {
f6bcfd97
BP
1055 CreateDetailsControls();
1056 }
f1df0927 1057
5e63b67d 1058#if wxUSE_STATLINE && !defined(__SMARTPHONE__)
94f53923
JS
1059 bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA);
1060 if (!isPda)
1061 sizer->Add(m_statline, 0, wxEXPAND | (wxALL & ~wxTOP), MARGIN);
f6bcfd97 1062#endif // wxUSE_STATLINE
f1df0927 1063
f6bcfd97 1064 sizer->Add(m_listctrl, 1, wxEXPAND | (wxALL & ~wxTOP), MARGIN);
f1df0927 1065
9f14a818
VZ
1066 // VZ: this doesn't work as this becomes the initial (and not only
1067 // minimal) listctrl height as well - why?
1068#if 0
1069 // allow the user to make the dialog shorter than its initial height -
1070 // without this it wouldn't work as the list ctrl would have been
1071 // incompressible
1072 sizer->SetItemMinSize(m_listctrl, 100, 3*GetCharHeight());
1073#endif // 0
1074
5e63b67d 1075#if wxUSE_FILE && !defined(__SMARTPHONE__)
f6bcfd97
BP
1076 sizer->Add(m_btnSave, 0, wxALIGN_RIGHT | (wxALL & ~wxTOP), MARGIN);
1077#endif // wxUSE_FILE
f1df0927
VZ
1078 }
1079
1080 m_showingDetails = !m_showingDetails;
1081
238d33aa
VZ
1082 // in any case, our size changed - relayout everything and set new hints
1083 // ---------------------------------------------------------------------
1084
1085 // we have to reset min size constraints or Fit() would never reduce the
1086 // dialog size when collapsing it and we have to reset max constraint
1087 // because it wouldn't expand it otherwise
801225c1 1088
238d33aa
VZ
1089 m_minHeight =
1090 m_maxHeight = -1;
1091
1092 // wxSizer::FitSize() is private, otherwise we might use it directly...
1093 wxSize sizeTotal = GetSize(),
1094 sizeClient = GetClientSize();
1095
1096 wxSize size = sizer->GetMinSize();
1097 size.x += sizeTotal.x - sizeClient.x;
1098 size.y += sizeTotal.y - sizeClient.y;
1099
1100 // we don't want to allow expanding the dialog in vertical direction as
1101 // this would show the "hidden" details but we can resize the dialog
1102 // vertically while the details are shown
1103 if ( !m_showingDetails )
1104 m_maxHeight = size.y;
1105
1106 SetSizeHints(size.x, size.y, m_maxWidth, m_maxHeight);
1107
94f53923
JS
1108#ifdef __WXWINCE__
1109 if (m_showingDetails)
1110 m_listctrl->Show();
5e63b67d 1111#endif
94f53923 1112
238d33aa 1113 // don't change the width when expanding/collapsing
422d0ff0 1114 SetSize(wxDefaultCoord, size.y);
f6bcfd97
BP
1115
1116#ifdef __WXGTK__
3103e8a9 1117 // VS: this is necessary in order to force frame redraw under
f6bcfd97
BP
1118 // WindowMaker or fvwm2 (and probably other broken WMs).
1119 // Otherwise, detailed list wouldn't be displayed.
dabbc6a5 1120 Show();
f6bcfd97 1121#endif // wxGTK
f1df0927
VZ
1122}
1123
1124wxLogDialog::~wxLogDialog()
1125{
1126 if ( m_listctrl )
1127 {
1128 delete m_listctrl->GetImageList(wxIMAGE_LIST_SMALL);
1129 }
1130}
1131
1132#endif // wxUSE_LOG_DIALOG
f6bcfd97 1133
3e6e2754 1134#if wxUSE_FILE && wxUSE_FILEDLG
f6bcfd97
BP
1135
1136// pass an uninitialized file object, the function will ask the user for the
dabbc6a5
DS
1137// filename and try to open it, returns true on success (file was opened),
1138// false if file couldn't be opened/created and -1 if the file selection
f6bcfd97 1139// dialog was cancelled
73ff84ff 1140static int OpenLogFile(wxFile& file, wxString *pFilename, wxWindow *parent)
f6bcfd97
BP
1141{
1142 // get the file name
1143 // -----------------
73ff84ff 1144 wxString filename = wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"), parent);
f6bcfd97
BP
1145 if ( !filename ) {
1146 // cancelled
1147 return -1;
1148 }
1149
1150 // open file
1151 // ---------
ba9bbf13 1152 bool bOk wxDUMMY_INITIALIZE(false);
f6bcfd97 1153 if ( wxFile::Exists(filename) ) {
dabbc6a5 1154 bool bAppend = false;
f6bcfd97
BP
1155 wxString strMsg;
1156 strMsg.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1157 filename.c_str());
1158 switch ( wxMessageBox(strMsg, _("Question"),
1159 wxICON_QUESTION | wxYES_NO | wxCANCEL) ) {
1160 case wxYES:
dabbc6a5 1161 bAppend = true;
f6bcfd97
BP
1162 break;
1163
1164 case wxNO:
dabbc6a5 1165 bAppend = false;
f6bcfd97
BP
1166 break;
1167
1168 case wxCANCEL:
1169 return -1;
1170
1171 default:
1172 wxFAIL_MSG(_("invalid message box return value"));
1173 }
1174
1175 if ( bAppend ) {
1176 bOk = file.Open(filename, wxFile::write_append);
1177 }
1178 else {
dabbc6a5 1179 bOk = file.Create(filename, true /* overwrite */);
f6bcfd97
BP
1180 }
1181 }
1182 else {
1183 bOk = file.Create(filename);
1184 }
1185
1186 if ( pFilename )
1187 *pFilename = filename;
1188
1189 return bOk;
1190}
1191
1192#endif // wxUSE_FILE
1193
1e6feb95
VZ
1194#endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1195
f561a4e0 1196#if wxUSE_LOG && wxUSE_TEXTCTRL
1e6feb95
VZ
1197
1198// ----------------------------------------------------------------------------
1199// wxLogTextCtrl implementation
1200// ----------------------------------------------------------------------------
1201
1202wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
1203{
1204 m_pTextCtrl = pTextCtrl;
1205}
1206
1207void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
1208{
1209 wxString msg;
1210 TimeStamp(&msg);
1211
1e6feb95 1212 msg << szString << wxT('\n');
1e6feb95
VZ
1213 m_pTextCtrl->AppendText(msg);
1214}
1215
f561a4e0 1216#endif // wxUSE_LOG && wxUSE_TEXTCTRL