]>
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"
49 #if wxUSE_LOGGUI || wxUSE_LOGWINDOW
52 #include "wx/textfile.h"
53 #include "wx/statline.h"
56 // for OutputDebugString()
57 #include "wx/msw/private.h"
61 #include "wx/listctrl.h"
62 #include "wx/imaglist.h"
64 #else // !wxUSE_LOG_DIALOG
65 #include "wx/msgdlg.h"
66 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
74 // this function is a wrapper around strftime(3)
75 // allows to exclude the usage of wxDateTime
76 static wxString
TimeStamp(const wxChar
*format
, time_t t
)
79 if ( !wxStrftime(buf
, WXSIZEOF(buf
), format
, localtime(&t
)) )
81 // buffer is too small?
82 wxFAIL_MSG(_T("strftime() failed"));
88 class wxLogDialog
: public wxDialog
91 wxLogDialog(wxWindow
*parent
,
92 const wxArrayString
& messages
,
93 const wxArrayInt
& severity
,
94 const wxArrayLong
& timess
,
95 const wxString
& caption
,
97 virtual ~wxLogDialog();
100 void OnOk(wxCommandEvent
& event
);
101 void OnDetails(wxCommandEvent
& event
);
103 void OnSave(wxCommandEvent
& event
);
105 void OnListSelect(wxListEvent
& event
);
108 // create controls needed for the details display
109 void CreateDetailsControls();
111 // the data for the listctrl
112 wxArrayString m_messages
;
113 wxArrayInt m_severity
;
116 // the "toggle" button and its state
117 wxButton
*m_btnDetails
;
118 bool m_showingDetails
;
120 // the controls which are not shown initially (but only when details
121 // button is pressed)
122 wxListCtrl
*m_listctrl
;
124 wxStaticLine
*m_statline
;
125 #endif // wxUSE_STATLINE
130 // the translated "Details" string
131 static wxString ms_details
;
133 DECLARE_EVENT_TABLE()
136 BEGIN_EVENT_TABLE(wxLogDialog
, wxDialog
)
137 EVT_BUTTON(wxID_CANCEL
, wxLogDialog::OnOk
)
138 EVT_BUTTON(wxID_MORE
, wxLogDialog::OnDetails
)
140 EVT_BUTTON(wxID_SAVE
, wxLogDialog::OnSave
)
142 EVT_LIST_ITEM_SELECTED(-1, wxLogDialog::OnListSelect
)
145 #endif // wxUSE_LOG_DIALOG
147 // ----------------------------------------------------------------------------
149 // ----------------------------------------------------------------------------
151 #if wxUSE_FILE && wxUSE_FILEDLG
153 // pass an uninitialized file object, the function will ask the user for the
154 // filename and try to open it, returns TRUE on success (file was opened),
155 // FALSE if file couldn't be opened/created and -1 if the file selection
156 // dialog was cancelled
157 static int OpenLogFile(wxFile
& file
, wxString
*filename
= NULL
);
161 // ----------------------------------------------------------------------------
163 // ----------------------------------------------------------------------------
165 // we use a global variable to store the frame pointer for wxLogStatus - bad,
166 // but it's the easiest way
167 static wxFrame
*gs_pFrame
; // FIXME MT-unsafe
169 // ============================================================================
171 // ============================================================================
173 // ----------------------------------------------------------------------------
175 // ----------------------------------------------------------------------------
177 // accepts an additional argument which tells to which frame the output should
179 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
183 wxLog
*pLog
= wxLog::GetActiveTarget();
184 if ( pLog
!= NULL
) {
186 va_start(argptr
, szFormat
);
187 msg
.PrintfV(szFormat
, argptr
);
190 wxASSERT( gs_pFrame
== NULL
); // should be reset!
192 wxLog::OnLog(wxLOG_Status
, msg
, time(NULL
));
193 gs_pFrame
= (wxFrame
*) NULL
;
197 // ----------------------------------------------------------------------------
198 // wxLogGui implementation (FIXME MT-unsafe)
199 // ----------------------------------------------------------------------------
206 void wxLogGui::Clear()
210 m_bHasMessages
= FALSE
;
217 void wxLogGui::Flush()
219 if ( !m_bHasMessages
)
222 // do it right now to block any new calls to Flush() while we're here
223 m_bHasMessages
= FALSE
;
225 wxString appName
= wxTheApp
->GetAppName();
227 appName
[0u] = wxToupper(appName
[0u]);
230 wxString titleFormat
;
232 titleFormat
= _("%s Error");
235 else if ( m_bWarnings
) {
236 titleFormat
= _("%s Warning");
237 style
= wxICON_EXCLAMATION
;
240 titleFormat
= _("%s Information");
241 style
= wxICON_INFORMATION
;
245 title
.Printf(titleFormat
, appName
.c_str());
247 // this is the best we can do here
248 wxWindow
*parent
= wxTheApp
->GetTopWindow();
250 size_t nMsgCount
= m_aMessages
.Count();
253 if ( nMsgCount
== 1 )
255 str
= m_aMessages
[0];
257 else // more than one message
261 wxLogDialog
dlg(parent
,
262 m_aMessages
, m_aSeverity
, m_aTimes
,
265 // clear the message list before showing the dialog because while it's
266 // shown some new messages may appear
269 (void)dlg
.ShowModal();
270 #else // !wxUSE_LOG_DIALOG
271 // concatenate all strings (but not too many to not overfill the msg box)
274 // start from the most recent message
275 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
276 // for Windows strings longer than this value are wrapped (NT 4.0)
277 const size_t nMsgLineWidth
= 156;
279 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
281 if ( nLines
> 25 ) // don't put too many lines in message box
284 str
<< m_aMessages
[n
- 1] << wxT("\n");
286 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
289 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
290 // situation without it
293 wxMessageBox(str
, title
, wxOK
| style
, parent
);
295 // no undisplayed messages whatsoever
300 // log all kinds of messages
301 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
309 m_aMessages
.Add(szString
);
310 m_aSeverity
.Add(wxLOG_Message
);
311 m_aTimes
.Add((long)t
);
312 m_bHasMessages
= TRUE
;
320 // find the top window and set it's status text if it has any
321 wxFrame
*pFrame
= gs_pFrame
;
322 if ( pFrame
== NULL
) {
323 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
324 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
325 pFrame
= (wxFrame
*)pWin
;
329 if ( pFrame
&& pFrame
->GetStatusBar() )
330 pFrame
->SetStatusText(szString
);
332 #endif // wxUSE_STATUSBAR
339 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
340 // don't prepend debug/trace here: it goes to the
341 // debug window anyhow, but do put a timestamp
344 str
<< szString
<< wxT("\r\n");
345 OutputDebugString(str
);
347 // send them to stderr
348 wxFprintf(stderr
, wxT("%s: %s\n"),
349 level
== wxLOG_Trace
? wxT("Trace")
355 #endif // __WXDEBUG__
359 case wxLOG_FatalError
:
360 // show this one immediately
361 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
367 #if !wxUSE_LOG_DIALOG
368 // discard earlier informational messages if this is the 1st
369 // error because they might not make sense any more and showing
370 // them in a message box might be confusing
374 #endif // wxUSE_LOG_DIALOG
381 // for the warning we don't discard the info messages
385 m_aMessages
.Add(szString
);
386 m_aSeverity
.Add((int)level
);
387 m_aTimes
.Add((long)t
);
388 m_bHasMessages
= TRUE
;
393 // ----------------------------------------------------------------------------
394 // wxLogWindow and wxLogFrame implementation
395 // ----------------------------------------------------------------------------
399 class wxLogFrame
: public wxFrame
403 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
404 virtual ~wxLogFrame();
407 void OnClose(wxCommandEvent
& event
);
408 void OnCloseWindow(wxCloseEvent
& event
);
410 void OnSave (wxCommandEvent
& event
);
412 void OnClear(wxCommandEvent
& event
);
414 void OnIdle(wxIdleEvent
&);
417 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
420 // use standard ids for our commands!
423 Menu_Close
= wxID_CLOSE
,
424 Menu_Save
= wxID_SAVE
,
425 Menu_Clear
= wxID_CLEAR
428 // common part of OnClose() and OnCloseWindow()
431 wxTextCtrl
*m_pTextCtrl
;
434 DECLARE_EVENT_TABLE()
437 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
438 // wxLogWindow menu events
439 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
441 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
443 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
445 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
448 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
449 : wxFrame(pParent
, -1, szTitle
)
453 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
461 wxMenuBar
*pMenuBar
= new wxMenuBar
;
462 wxMenu
*pMenu
= new wxMenu
;
464 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
466 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
467 pMenu
->AppendSeparator();
468 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
469 pMenuBar
->Append(pMenu
, _("&Log"));
470 SetMenuBar(pMenuBar
);
471 #endif // wxUSE_MENUS
474 // status bar for menu prompts
476 #endif // wxUSE_STATUSBAR
478 m_log
->OnFrameCreate(this);
481 void wxLogFrame::DoClose()
483 if ( m_log
->OnFrameClose(this) )
485 // instead of closing just hide the window to be able to Show() it
491 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
496 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
502 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
507 int rc
= OpenLogFile(file
, &filename
);
516 // retrieve text and save it
517 // -------------------------
518 int nLines
= m_pTextCtrl
->GetNumberOfLines();
519 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
520 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
521 wxTextFile::GetEOL());
528 wxLogError(_("Can't save log contents to file."));
531 wxLogStatus(this, _("Log saved to the file '%s'."), filename
.c_str());
537 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
539 m_pTextCtrl
->Clear();
542 wxLogFrame::~wxLogFrame()
544 m_log
->OnFrameDelete(this);
549 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
550 const wxChar
*szTitle
,
554 m_bPassMessages
= bDoPass
;
556 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
557 m_pOldLog
= wxLog::SetActiveTarget(this);
560 m_pLogFrame
->Show(TRUE
);
563 void wxLogWindow::Show(bool bShow
)
565 m_pLogFrame
->Show(bShow
);
568 void wxLogWindow::Flush()
570 if ( m_pOldLog
!= NULL
)
573 m_bHasMessages
= FALSE
;
576 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
578 // first let the previous logger show it
579 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
580 // bogus cast just to access protected DoLog
581 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
587 // by default, these messages are ignored by wxLog, so process
589 if ( !wxIsEmpty(szString
) )
592 str
<< _("Status: ") << szString
;
597 // don't put trace messages in the text window for 2 reasons:
598 // 1) there are too many of them
599 // 2) they may provoke other trace messages thus sending a program
600 // into an infinite loop
605 // and this will format it nicely and call our DoLogString()
606 wxLog::DoLog(level
, szString
, t
);
610 m_bHasMessages
= TRUE
;
613 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
615 // put the text into our window
616 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
618 // remove selection (WriteText is in fact ReplaceSelection)
620 long nLen
= pText
->GetLastPosition();
621 pText
->SetSelection(nLen
, nLen
);
626 msg
<< szString
<< wxT('\n');
628 pText
->AppendText(msg
);
630 // TODO ensure that the line can be seen
633 wxFrame
*wxLogWindow::GetFrame() const
638 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
642 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
648 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
650 m_pLogFrame
= (wxLogFrame
*)NULL
;
653 wxLogWindow::~wxLogWindow()
657 // may be NULL if log frame already auto destroyed itself
661 // ----------------------------------------------------------------------------
663 // ----------------------------------------------------------------------------
667 static const size_t MARGIN
= 10;
669 wxString
wxLogDialog::ms_details
;
671 wxLogDialog::wxLogDialog(wxWindow
*parent
,
672 const wxArrayString
& messages
,
673 const wxArrayInt
& severity
,
674 const wxArrayLong
& times
,
675 const wxString
& caption
,
677 : wxDialog(parent
, -1, caption
)
679 if ( ms_details
.IsEmpty() )
681 // ensure that we won't loop here if wxGetTranslation()
682 // happens to pop up a Log message while translating this :-)
683 ms_details
= wxTRANSLATE("&Details");
684 ms_details
= wxGetTranslation(ms_details
);
687 size_t count
= messages
.GetCount();
688 m_messages
.Alloc(count
);
689 m_severity
.Alloc(count
);
690 m_times
.Alloc(count
);
692 for ( size_t n
= 0; n
< count
; n
++ )
694 wxString msg
= messages
[n
];
697 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
698 msg
= msg
.AfterFirst(_T('\n'));
700 m_severity
.Add(severity
[n
]);
701 m_times
.Add(times
[n
]);
706 m_showingDetails
= FALSE
; // not initially
707 m_listctrl
= (wxListCtrl
*)NULL
;
710 m_statline
= (wxStaticLine
*)NULL
;
711 #endif // wxUSE_STATLINE
714 m_btnSave
= (wxButton
*)NULL
;
717 // create the controls which are always shown and layout them: we use
718 // sizers even though our window is not resizeable to calculate the size of
719 // the dialog properly
720 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
721 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
722 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
724 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
725 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
726 // translates into click on cancel button)
727 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
728 sizerButtons
->Add(btnOk
, 0, wxCENTRE
|wxBOTTOM
, MARGIN
/2);
729 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
730 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
|wxTOP
, MARGIN
/2 - 1);
733 wxIcon icon
= wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
));
734 sizerAll
->Add(new wxStaticBitmap(this, -1, icon
), 0, wxCENTRE
);
737 const wxString
& message
= messages
.Last();
738 sizerAll
->Add(CreateTextSizer(message
), 0, wxCENTRE
|wxLEFT
|wxRIGHT
, MARGIN
);
739 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
|wxLEFT
, MARGIN
);
741 sizerTop
->Add(sizerAll
, 0, wxCENTRE
|wxALL
, MARGIN
);
746 sizerTop
->SetSizeHints(this);
751 // this can't happen any more as we don't use this dialog in this case
755 // no details... it's easier to disable a button than to change the
756 // dialog layout depending on whether we have details or not
757 m_btnDetails
->Disable();
764 void wxLogDialog::CreateDetailsControls()
766 // create the save button and separator line if possible
768 m_btnSave
= new wxButton(this, wxID_SAVE
, _("&Save..."));
772 m_statline
= new wxStaticLine(this, -1);
773 #endif // wxUSE_STATLINE
775 // create the list ctrl now
776 m_listctrl
= new wxListCtrl(this, -1,
777 wxDefaultPosition
, wxDefaultSize
,
783 // no need to translate these strings as they're not shown to the
784 // user anyhow (we use wxLC_NO_HEADER style)
785 m_listctrl
->InsertColumn(0, _T("Message"));
786 m_listctrl
->InsertColumn(1, _T("Time"));
788 // prepare the imagelist
789 static const int ICON_SIZE
= 16;
790 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
792 // order should be the same as in the switch below!
793 static const int icons
[] =
800 bool loadedIcons
= TRUE
;
803 for ( size_t icon
= 0; icon
< WXSIZEOF(icons
); icon
++ )
805 wxBitmap bmp
= wxTheApp
->GetStdIcon(icons
[icon
]);
807 // This may very well fail if there are insufficient
808 // colours available. Degrade gracefully.
813 imageList
->Add(wxImage(bmp
).
814 Rescale(ICON_SIZE
, ICON_SIZE
).
818 m_listctrl
->SetImageList(imageList
, wxIMAGE_LIST_SMALL
);
822 wxString fmt
= wxLog::GetTimestamp();
829 size_t count
= m_messages
.GetCount();
830 for ( size_t n
= 0; n
< count
; n
++ )
834 switch ( m_severity
[n
] )
853 m_listctrl
->InsertItem(n
, m_messages
[n
], image
);
855 m_listctrl
->InsertItem(n
, m_messages
[n
]);
857 m_listctrl
->SetItem(n
, 1,
858 TimeStamp(fmt
, (time_t)m_times
[n
]));
861 // let the columns size themselves
862 m_listctrl
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
863 m_listctrl
->SetColumnWidth(1, wxLIST_AUTOSIZE
);
865 // get the approx height of the listctrl
866 wxFont font
= GetFont();
868 font
= *wxSWISS_FONT
;
871 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
872 int height
= wxMax(y
*(count
+ 3), 100);
873 m_listctrl
->SetSize(-1, height
);
876 void wxLogDialog::OnListSelect(wxListEvent
& event
)
878 // we can't just disable the control because this looks ugly under Windows
879 // (wrong bg colour, no scrolling...), but we still want to disable
880 // selecting items - it makes no sense here
881 m_listctrl
->SetItemState(event
.GetIndex(), 0, wxLIST_STATE_SELECTED
);
884 void wxLogDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
891 void wxLogDialog::OnSave(wxCommandEvent
& WXUNUSED(event
))
895 int rc
= OpenLogFile(file
);
904 wxString fmt
= wxLog::GetTimestamp();
911 size_t count
= m_messages
.GetCount();
912 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
915 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
918 << wxTextFile::GetEOL();
920 ok
= file
.Write(line
);
927 wxLogError(_("Can't save log contents to file."));
933 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
935 wxSizer
*sizer
= GetSizer();
937 if ( m_showingDetails
)
939 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
941 sizer
->Remove(m_listctrl
);
944 sizer
->Remove(m_statline
);
945 #endif // wxUSE_STATLINE
948 sizer
->Remove(m_btnSave
);
951 else // show details now
953 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
957 CreateDetailsControls();
961 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
962 #endif // wxUSE_STATLINE
964 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
967 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
971 m_showingDetails
= !m_showingDetails
;
973 // in any case, our size changed - update
974 sizer
->SetSizeHints(this);
978 // VS: this is neccessary in order to force frame redraw under
979 // WindowMaker or fvwm2 (and probably other broken WMs).
980 // Otherwise, detailed list wouldn't be displayed.
985 wxLogDialog::~wxLogDialog()
989 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
993 #endif // wxUSE_LOG_DIALOG
995 #if wxUSE_FILE && wxUSE_FILEDLG
997 // pass an uninitialized file object, the function will ask the user for the
998 // filename and try to open it, returns TRUE on success (file was opened),
999 // FALSE if file couldn't be opened/created and -1 if the file selection
1000 // dialog was cancelled
1001 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1003 // get the file name
1004 // -----------------
1005 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1014 if ( wxFile::Exists(filename
) ) {
1015 bool bAppend
= FALSE
;
1017 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1019 switch ( wxMessageBox(strMsg
, _("Question"),
1020 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1033 wxFAIL_MSG(_("invalid message box return value"));
1037 bOk
= file
.Open(filename
, wxFile::write_append
);
1040 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1044 bOk
= file
.Create(filename
);
1048 *pFilename
= filename
;
1053 #endif // wxUSE_FILE
1055 #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1059 // ----------------------------------------------------------------------------
1060 // wxLogTextCtrl implementation
1061 // ----------------------------------------------------------------------------
1063 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
1065 m_pTextCtrl
= pTextCtrl
;
1068 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
1074 // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
1075 // translation must be done in wxTextCtrl, not here! (FIXME)
1076 msg
<< szString
<< wxT('\r');
1078 msg
<< szString
<< wxT('\n');
1081 m_pTextCtrl
->AppendText(msg
);
1084 #endif // wxUSE_TEXTCTRL