]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/logg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxLog-derived classes which need GUI support (the rest is in
5 // Author: Vadim Zeitlin
7 // Created: 20.09.99 (extracted from src/common/log.cpp)
9 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 // no #pragma implementation "log.h" because it's already in src/common/log.cpp
23 // For compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
31 #error "This file can't be compiled without GUI!"
36 #include "wx/button.h"
41 #include "wx/filedlg.h"
42 #include "wx/msgdlg.h"
43 #include "wx/textctrl.h"
45 #include "wx/statbmp.h"
46 #include "wx/button.h"
47 #include "wx/settings.h"
50 #if wxUSE_LOGGUI || wxUSE_LOGWINDOW
53 #include "wx/textfile.h"
54 #include "wx/statline.h"
57 // for OutputDebugString()
58 #include "wx/msw/private.h"
62 #include "wx/listctrl.h"
63 #include "wx/imaglist.h"
65 #else // !wxUSE_LOG_DIALOG
66 #include "wx/msgdlg.h"
67 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
75 // this function is a wrapper around strftime(3)
76 // allows to exclude the usage of wxDateTime
77 static wxString
TimeStamp(const wxChar
*format
, time_t t
)
80 if ( !wxStrftime(buf
, WXSIZEOF(buf
), format
, localtime(&t
)) )
82 // buffer is too small?
83 wxFAIL_MSG(_T("strftime() failed"));
89 class wxLogDialog
: public wxDialog
92 wxLogDialog(wxWindow
*parent
,
93 const wxArrayString
& messages
,
94 const wxArrayInt
& severity
,
95 const wxArrayLong
& timess
,
96 const wxString
& caption
,
98 virtual ~wxLogDialog();
101 void OnOk(wxCommandEvent
& event
);
102 void OnDetails(wxCommandEvent
& event
);
104 void OnSave(wxCommandEvent
& event
);
106 void OnListSelect(wxListEvent
& event
);
109 // create controls needed for the details display
110 void CreateDetailsControls();
112 // the data for the listctrl
113 wxArrayString m_messages
;
114 wxArrayInt m_severity
;
117 // the "toggle" button and its state
118 wxButton
*m_btnDetails
;
119 bool m_showingDetails
;
121 // the controls which are not shown initially (but only when details
122 // button is pressed)
123 wxListCtrl
*m_listctrl
;
125 wxStaticLine
*m_statline
;
126 #endif // wxUSE_STATLINE
131 // the translated "Details" string
132 static wxString ms_details
;
134 DECLARE_EVENT_TABLE()
137 BEGIN_EVENT_TABLE(wxLogDialog
, wxDialog
)
138 EVT_BUTTON(wxID_CANCEL
, wxLogDialog::OnOk
)
139 EVT_BUTTON(wxID_MORE
, wxLogDialog::OnDetails
)
141 EVT_BUTTON(wxID_SAVE
, wxLogDialog::OnSave
)
143 EVT_LIST_ITEM_SELECTED(-1, wxLogDialog::OnListSelect
)
146 #endif // wxUSE_LOG_DIALOG
148 // ----------------------------------------------------------------------------
150 // ----------------------------------------------------------------------------
152 #if wxUSE_FILE && wxUSE_FILEDLG
154 // pass an uninitialized file object, the function will ask the user for the
155 // filename and try to open it, returns TRUE on success (file was opened),
156 // FALSE if file couldn't be opened/created and -1 if the file selection
157 // dialog was cancelled
158 static int OpenLogFile(wxFile
& file
, wxString
*filename
= NULL
);
162 // ----------------------------------------------------------------------------
164 // ----------------------------------------------------------------------------
166 // we use a global variable to store the frame pointer for wxLogStatus - bad,
167 // but it's the easiest way
168 static wxFrame
*gs_pFrame
= NULL
; // FIXME MT-unsafe
170 // ============================================================================
172 // ============================================================================
174 // ----------------------------------------------------------------------------
176 // ----------------------------------------------------------------------------
178 // accepts an additional argument which tells to which frame the output should
180 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
184 wxLog
*pLog
= wxLog::GetActiveTarget();
185 if ( pLog
!= NULL
) {
187 va_start(argptr
, szFormat
);
188 msg
.PrintfV(szFormat
, argptr
);
191 wxASSERT( gs_pFrame
== NULL
); // should be reset!
193 wxLog::OnLog(wxLOG_Status
, msg
, time(NULL
));
194 gs_pFrame
= (wxFrame
*) NULL
;
198 // ----------------------------------------------------------------------------
199 // wxLogGui implementation (FIXME MT-unsafe)
200 // ----------------------------------------------------------------------------
207 void wxLogGui::Clear()
211 m_bHasMessages
= FALSE
;
218 void wxLogGui::Flush()
220 if ( !m_bHasMessages
)
223 // do it right now to block any new calls to Flush() while we're here
224 m_bHasMessages
= FALSE
;
226 wxString appName
= wxTheApp
->GetAppName();
228 appName
[0u] = wxToupper(appName
[0u]);
231 wxString titleFormat
;
233 titleFormat
= _("%s Error");
236 else if ( m_bWarnings
) {
237 titleFormat
= _("%s Warning");
238 style
= wxICON_EXCLAMATION
;
241 titleFormat
= _("%s Information");
242 style
= wxICON_INFORMATION
;
246 title
.Printf(titleFormat
, appName
.c_str());
248 size_t nMsgCount
= m_aMessages
.Count();
250 // avoid showing other log dialogs until we're done with the dialog we're
251 // showing right now: nested modal dialogs make for really bad UI!
255 if ( nMsgCount
== 1 )
257 str
= m_aMessages
[0];
259 else // more than one message
263 wxLogDialog
dlg(NULL
,
264 m_aMessages
, m_aSeverity
, m_aTimes
,
267 // clear the message list before showing the dialog because while it's
268 // shown some new messages may appear
271 (void)dlg
.ShowModal();
272 #else // !wxUSE_LOG_DIALOG
273 // concatenate all strings (but not too many to not overfill the msg box)
276 // start from the most recent message
277 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
278 // for Windows strings longer than this value are wrapped (NT 4.0)
279 const size_t nMsgLineWidth
= 156;
281 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
283 if ( nLines
> 25 ) // don't put too many lines in message box
286 str
<< m_aMessages
[n
- 1] << wxT("\n");
288 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
291 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
292 // situation without it
295 wxMessageBox(str
, title
, wxOK
| style
);
297 // no undisplayed messages whatsoever
301 // allow flushing the logs again
305 // log all kinds of messages
306 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
314 m_aMessages
.Add(szString
);
315 m_aSeverity
.Add(wxLOG_Message
);
316 m_aTimes
.Add((long)t
);
317 m_bHasMessages
= TRUE
;
325 // find the top window and set it's status text if it has any
326 wxFrame
*pFrame
= gs_pFrame
;
327 if ( pFrame
== NULL
) {
328 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
329 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
330 pFrame
= (wxFrame
*)pWin
;
334 if ( pFrame
&& pFrame
->GetStatusBar() )
335 pFrame
->SetStatusText(szString
);
337 #endif // wxUSE_STATUSBAR
348 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
349 // don't prepend debug/trace here: it goes to the
350 // debug window anyhow
352 OutputDebugString(str
);
354 // send them to stderr
355 wxFprintf(stderr
, wxT("[%s] %s\n"),
356 level
== wxLOG_Trace
? wxT("Trace")
362 #endif // __WXDEBUG__
366 case wxLOG_FatalError
:
367 // show this one immediately
368 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
374 #if !wxUSE_LOG_DIALOG
375 // discard earlier informational messages if this is the 1st
376 // error because they might not make sense any more and showing
377 // them in a message box might be confusing
381 #endif // wxUSE_LOG_DIALOG
388 // for the warning we don't discard the info messages
392 m_aMessages
.Add(szString
);
393 m_aSeverity
.Add((int)level
);
394 m_aTimes
.Add((long)t
);
395 m_bHasMessages
= TRUE
;
400 // ----------------------------------------------------------------------------
401 // wxLogWindow and wxLogFrame implementation
402 // ----------------------------------------------------------------------------
406 class wxLogFrame
: public wxFrame
410 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
411 virtual ~wxLogFrame();
414 void OnClose(wxCommandEvent
& event
);
415 void OnCloseWindow(wxCloseEvent
& event
);
417 void OnSave (wxCommandEvent
& event
);
419 void OnClear(wxCommandEvent
& event
);
421 void OnIdle(wxIdleEvent
&);
424 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
427 // use standard ids for our commands!
430 Menu_Close
= wxID_CLOSE
,
431 Menu_Save
= wxID_SAVE
,
432 Menu_Clear
= wxID_CLEAR
435 // common part of OnClose() and OnCloseWindow()
438 wxTextCtrl
*m_pTextCtrl
;
441 DECLARE_EVENT_TABLE()
444 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
445 // wxLogWindow menu events
446 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
448 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
450 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
452 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
455 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
456 : wxFrame(pParent
, -1, szTitle
)
460 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
468 wxMenuBar
*pMenuBar
= new wxMenuBar
;
469 wxMenu
*pMenu
= new wxMenu
;
471 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
473 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
474 pMenu
->AppendSeparator();
475 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
476 pMenuBar
->Append(pMenu
, _("&Log"));
477 SetMenuBar(pMenuBar
);
478 #endif // wxUSE_MENUS
481 // status bar for menu prompts
483 #endif // wxUSE_STATUSBAR
485 m_log
->OnFrameCreate(this);
488 void wxLogFrame::DoClose()
490 if ( m_log
->OnFrameClose(this) )
492 // instead of closing just hide the window to be able to Show() it
498 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
503 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
509 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
514 int rc
= OpenLogFile(file
, &filename
);
523 // retrieve text and save it
524 // -------------------------
525 int nLines
= m_pTextCtrl
->GetNumberOfLines();
526 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
527 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
528 wxTextFile::GetEOL());
535 wxLogError(_("Can't save log contents to file."));
538 wxLogStatus(this, _("Log saved to the file '%s'."), filename
.c_str());
544 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
546 m_pTextCtrl
->Clear();
549 wxLogFrame::~wxLogFrame()
551 m_log
->OnFrameDelete(this);
557 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
558 const wxChar
*szTitle
,
562 PassMessages(bDoPass
);
564 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
567 m_pLogFrame
->Show(TRUE
);
570 void wxLogWindow::Show(bool bShow
)
572 m_pLogFrame
->Show(bShow
);
575 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
577 // first let the previous logger show it
578 wxLogPassThrough::DoLog(level
, szString
, t
);
583 // by default, these messages are ignored by wxLog, so process
585 if ( !wxIsEmpty(szString
) )
588 str
<< _("Status: ") << szString
;
593 // don't put trace messages in the text window for 2 reasons:
594 // 1) there are too many of them
595 // 2) they may provoke other trace messages thus sending a program
596 // into an infinite loop
601 // and this will format it nicely and call our DoLogString()
602 wxLog::DoLog(level
, szString
, t
);
606 m_bHasMessages
= TRUE
;
609 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
611 // put the text into our window
612 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
614 // remove selection (WriteText is in fact ReplaceSelection)
616 long nLen
= pText
->GetLastPosition();
617 pText
->SetSelection(nLen
, nLen
);
622 msg
<< szString
<< wxT('\n');
624 pText
->AppendText(msg
);
626 // TODO ensure that the line can be seen
629 wxFrame
*wxLogWindow::GetFrame() const
634 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
638 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
644 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
646 m_pLogFrame
= (wxLogFrame
*)NULL
;
649 wxLogWindow::~wxLogWindow()
651 // may be NULL if log frame already auto destroyed itself
655 // ----------------------------------------------------------------------------
657 // ----------------------------------------------------------------------------
661 static const size_t MARGIN
= 10;
663 wxString
wxLogDialog::ms_details
;
665 wxLogDialog::wxLogDialog(wxWindow
*parent
,
666 const wxArrayString
& messages
,
667 const wxArrayInt
& severity
,
668 const wxArrayLong
& times
,
669 const wxString
& caption
,
671 : wxDialog(parent
, -1, caption
,
672 wxDefaultPosition
, wxDefaultSize
,
673 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
675 if ( ms_details
.IsEmpty() )
677 // ensure that we won't loop here if wxGetTranslation()
678 // happens to pop up a Log message while translating this :-)
679 ms_details
= wxTRANSLATE("&Details");
680 ms_details
= wxGetTranslation(ms_details
);
683 size_t count
= messages
.GetCount();
684 m_messages
.Alloc(count
);
685 m_severity
.Alloc(count
);
686 m_times
.Alloc(count
);
688 for ( size_t n
= 0; n
< count
; n
++ )
690 wxString msg
= messages
[n
];
693 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
694 msg
= msg
.AfterFirst(_T('\n'));
696 m_severity
.Add(severity
[n
]);
697 m_times
.Add(times
[n
]);
702 m_showingDetails
= FALSE
; // not initially
703 m_listctrl
= (wxListCtrl
*)NULL
;
706 m_statline
= (wxStaticLine
*)NULL
;
707 #endif // wxUSE_STATLINE
710 m_btnSave
= (wxButton
*)NULL
;
713 // create the controls which are always shown and layout them: we use
714 // sizers even though our window is not resizeable to calculate the size of
715 // the dialog properly
716 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
717 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
718 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
720 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
721 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
722 // translates into click on cancel button)
723 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
724 sizerButtons
->Add(btnOk
, 0, wxCENTRE
| wxBOTTOM
, MARGIN
/2);
725 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
726 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
| wxTOP
, MARGIN
/2 - 1);
729 wxIcon icon
= wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
));
730 sizerAll
->Add(new wxStaticBitmap(this, -1, icon
), 0);
733 const wxString
& message
= messages
.Last();
734 sizerAll
->Add(CreateTextSizer(message
), 1,
735 wxALIGN_CENTRE_VERTICAL
| wxLEFT
| wxRIGHT
, MARGIN
);
736 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
| wxLEFT
, MARGIN
);
738 sizerTop
->Add(sizerAll
, 0, wxALL
| wxEXPAND
, MARGIN
);
743 sizerTop
->SetSizeHints(this);
748 // this can't happen any more as we don't use this dialog in this case
752 // no details... it's easier to disable a button than to change the
753 // dialog layout depending on whether we have details or not
754 m_btnDetails
->Disable();
761 void wxLogDialog::CreateDetailsControls()
763 // create the save button and separator line if possible
765 m_btnSave
= new wxButton(this, wxID_SAVE
, _("&Save..."));
769 m_statline
= new wxStaticLine(this, -1);
770 #endif // wxUSE_STATLINE
772 // create the list ctrl now
773 m_listctrl
= new wxListCtrl(this, -1,
774 wxDefaultPosition
, wxDefaultSize
,
780 // no need to translate these strings as they're not shown to the
781 // user anyhow (we use wxLC_NO_HEADER style)
782 m_listctrl
->InsertColumn(0, _T("Message"));
783 m_listctrl
->InsertColumn(1, _T("Time"));
785 // prepare the imagelist
786 static const int ICON_SIZE
= 16;
787 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
789 // order should be the same as in the switch below!
790 static const int icons
[] =
797 bool loadedIcons
= TRUE
;
800 for ( size_t icon
= 0; icon
< WXSIZEOF(icons
); icon
++ )
802 wxBitmap bmp
= wxTheApp
->GetStdIcon(icons
[icon
]);
804 // This may very well fail if there are insufficient
805 // colours available. Degrade gracefully.
810 imageList
->Add(wxImage(bmp
).
811 Rescale(ICON_SIZE
, ICON_SIZE
).
815 m_listctrl
->SetImageList(imageList
, wxIMAGE_LIST_SMALL
);
819 wxString fmt
= wxLog::GetTimestamp();
826 size_t count
= m_messages
.GetCount();
827 for ( size_t n
= 0; n
< count
; n
++ )
831 switch ( m_severity
[n
] )
850 m_listctrl
->InsertItem(n
, m_messages
[n
], image
);
852 m_listctrl
->InsertItem(n
, m_messages
[n
]);
854 m_listctrl
->SetItem(n
, 1,
855 TimeStamp(fmt
, (time_t)m_times
[n
]));
858 // let the columns size themselves
859 m_listctrl
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
860 m_listctrl
->SetColumnWidth(1, wxLIST_AUTOSIZE
);
862 // get the approx height of the listctrl
863 wxFont font
= GetFont();
865 font
= *wxSWISS_FONT
;
868 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
869 int height
= wxMax(y
*(count
+ 3), 100);
871 // if the height as computed from list items exceeds, together with the
872 // actual message & controls, the screen, make it smaller
874 (3*wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y
))/5 - GetSize().y
;
876 m_listctrl
->SetSize(-1, wxMin(height
, heightMax
));
879 void wxLogDialog::OnListSelect(wxListEvent
& event
)
881 // we can't just disable the control because this looks ugly under Windows
882 // (wrong bg colour, no scrolling...), but we still want to disable
883 // selecting items - it makes no sense here
884 m_listctrl
->SetItemState(event
.GetIndex(), 0, wxLIST_STATE_SELECTED
);
887 void wxLogDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
894 void wxLogDialog::OnSave(wxCommandEvent
& WXUNUSED(event
))
898 int rc
= OpenLogFile(file
);
907 wxString fmt
= wxLog::GetTimestamp();
914 size_t count
= m_messages
.GetCount();
915 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
918 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
921 << wxTextFile::GetEOL();
923 ok
= file
.Write(line
);
930 wxLogError(_("Can't save log contents to file."));
936 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
938 wxSizer
*sizer
= GetSizer();
940 if ( m_showingDetails
)
942 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
944 sizer
->Remove(m_listctrl
);
947 sizer
->Remove(m_statline
);
948 #endif // wxUSE_STATLINE
951 sizer
->Remove(m_btnSave
);
954 else // show details now
956 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
960 CreateDetailsControls();
964 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
965 #endif // wxUSE_STATLINE
967 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
970 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
974 m_showingDetails
= !m_showingDetails
;
976 // in any case, our size changed - update
977 sizer
->SetSizeHints(this);
981 // VS: this is neccessary in order to force frame redraw under
982 // WindowMaker or fvwm2 (and probably other broken WMs).
983 // Otherwise, detailed list wouldn't be displayed.
988 wxLogDialog::~wxLogDialog()
992 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
996 #endif // wxUSE_LOG_DIALOG
998 #if wxUSE_FILE && wxUSE_FILEDLG
1000 // pass an uninitialized file object, the function will ask the user for the
1001 // filename and try to open it, returns TRUE on success (file was opened),
1002 // FALSE if file couldn't be opened/created and -1 if the file selection
1003 // dialog was cancelled
1004 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1006 // get the file name
1007 // -----------------
1008 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1017 if ( wxFile::Exists(filename
) ) {
1018 bool bAppend
= FALSE
;
1020 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1022 switch ( wxMessageBox(strMsg
, _("Question"),
1023 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1036 wxFAIL_MSG(_("invalid message box return value"));
1040 bOk
= file
.Open(filename
, wxFile::write_append
);
1043 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1047 bOk
= file
.Create(filename
);
1051 *pFilename
= filename
;
1056 #endif // wxUSE_FILE
1058 #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1062 // ----------------------------------------------------------------------------
1063 // wxLogTextCtrl implementation
1064 // ----------------------------------------------------------------------------
1066 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
1068 m_pTextCtrl
= pTextCtrl
;
1071 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
1076 #if defined(__WXMAC__) && !defined(__DARWIN__)
1077 // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
1078 // translation must be done in wxTextCtrl, not here! (FIXME)
1079 msg
<< szString
<< wxT('\r');
1081 msg
<< szString
<< wxT('\n');
1084 m_pTextCtrl
->AppendText(msg
);
1087 #endif // wxUSE_TEXTCTRL