]>
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"
60 // may be defined to 0 for old behavior (using wxMessageBox) - shouldn't be
61 // changed normally (that's why it's here and not in setup.h)
62 #define wxUSE_LOG_DIALOG 1
65 #include "wx/listctrl.h"
66 #include "wx/imaglist.h"
68 #else // !wxUSE_TEXTFILE
69 #include "wx/msgdlg.h"
70 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
78 // this function is a wrapper around strftime(3)
79 // allows to exclude the usage of wxDateTime
80 static wxString
TimeStamp(const wxChar
*format
, time_t t
)
83 if ( !wxStrftime(buf
, WXSIZEOF(buf
), format
, localtime(&t
)) )
85 // buffer is too small?
86 wxFAIL_MSG(_T("strftime() failed"));
92 class wxLogDialog
: public wxDialog
95 wxLogDialog(wxWindow
*parent
,
96 const wxArrayString
& messages
,
97 const wxArrayInt
& severity
,
98 const wxArrayLong
& timess
,
99 const wxString
& caption
,
101 virtual ~wxLogDialog();
104 void OnOk(wxCommandEvent
& event
);
105 void OnDetails(wxCommandEvent
& event
);
107 void OnSave(wxCommandEvent
& event
);
109 void OnListSelect(wxListEvent
& event
);
112 // create controls needed for the details display
113 void CreateDetailsControls();
115 // the data for the listctrl
116 wxArrayString m_messages
;
117 wxArrayInt m_severity
;
120 // the "toggle" button and its state
121 wxButton
*m_btnDetails
;
122 bool m_showingDetails
;
124 // the controls which are not shown initially (but only when details
125 // button is pressed)
126 wxListCtrl
*m_listctrl
;
128 wxStaticLine
*m_statline
;
129 #endif // wxUSE_STATLINE
134 // the translated "Details" string
135 static wxString ms_details
;
137 DECLARE_EVENT_TABLE()
140 BEGIN_EVENT_TABLE(wxLogDialog
, wxDialog
)
141 EVT_BUTTON(wxID_CANCEL
, wxLogDialog::OnOk
)
142 EVT_BUTTON(wxID_MORE
, wxLogDialog::OnDetails
)
144 EVT_BUTTON(wxID_SAVE
, wxLogDialog::OnSave
)
146 EVT_LIST_ITEM_SELECTED(-1, wxLogDialog::OnListSelect
)
149 #endif // wxUSE_LOG_DIALOG
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
157 // pass an uninitialized file object, the function will ask the user for the
158 // filename and try to open it, returns TRUE on success (file was opened),
159 // FALSE if file couldn't be opened/created and -1 if the file selection
160 // dialog was cancelled
161 static int OpenLogFile(wxFile
& file
, wxString
*filename
= NULL
);
165 // ----------------------------------------------------------------------------
167 // ----------------------------------------------------------------------------
169 // we use a global variable to store the frame pointer for wxLogStatus - bad,
170 // but it's he easiest way
171 static wxFrame
*gs_pFrame
; // FIXME MT-unsafe
173 // ============================================================================
175 // ============================================================================
177 // ----------------------------------------------------------------------------
179 // ----------------------------------------------------------------------------
181 // accepts an additional argument which tells to which frame the output should
183 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
187 wxLog
*pLog
= wxLog::GetActiveTarget();
188 if ( pLog
!= NULL
) {
190 va_start(argptr
, szFormat
);
191 msg
.PrintfV(szFormat
, argptr
);
194 wxASSERT( gs_pFrame
== NULL
); // should be reset!
196 wxLog::OnLog(wxLOG_Status
, msg
, time(NULL
));
197 gs_pFrame
= (wxFrame
*) NULL
;
201 // ----------------------------------------------------------------------------
202 // wxLogGui implementation (FIXME MT-unsafe)
203 // ----------------------------------------------------------------------------
210 void wxLogGui::Clear()
214 m_bHasMessages
= FALSE
;
221 void wxLogGui::Flush()
223 if ( !m_bHasMessages
)
226 // do it right now to block any new calls to Flush() while we're here
227 m_bHasMessages
= FALSE
;
229 wxString appName
= wxTheApp
->GetAppName();
231 appName
[0u] = wxToupper(appName
[0u]);
234 wxString titleFormat
;
236 titleFormat
= _("%s Error");
239 else if ( m_bWarnings
) {
240 titleFormat
= _("%s Warning");
241 style
= wxICON_EXCLAMATION
;
244 titleFormat
= _("%s Information");
245 style
= wxICON_INFORMATION
;
249 title
.Printf(titleFormat
, appName
.c_str());
251 // this is the best we can do here
252 wxWindow
*parent
= wxTheApp
->GetTopWindow();
254 size_t nMsgCount
= m_aMessages
.Count();
257 if ( nMsgCount
== 1 )
259 str
= m_aMessages
[0];
261 else // more than one message
264 wxLogDialog
dlg(parent
,
265 m_aMessages
, m_aSeverity
, m_aTimes
,
268 // clear the message list before showing the dialog because while it's
269 // shown some new messages may appear
272 (void)dlg
.ShowModal();
273 #else // !wxUSE_LOG_DIALOG
274 // concatenate all strings (but not too many to not overfill the msg box)
277 // start from the most recent message
278 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
279 // for Windows strings longer than this value are wrapped (NT 4.0)
280 const size_t nMsgLineWidth
= 156;
282 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
284 if ( nLines
> 25 ) // don't put too many lines in message box
287 str
<< m_aMessages
[n
- 1] << wxT("\n");
289 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
292 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
293 // situation without it
296 wxMessageBox(str
, title
, wxOK
| style
, parent
);
298 // no undisplayed messages whatsoever
303 // log all kinds of messages
304 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
312 m_aMessages
.Add(szString
);
313 m_aSeverity
.Add(wxLOG_Message
);
314 m_aTimes
.Add((long)t
);
315 m_bHasMessages
= TRUE
;
323 // find the top window and set it's status text if it has any
324 wxFrame
*pFrame
= gs_pFrame
;
325 if ( pFrame
== NULL
) {
326 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
327 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
328 pFrame
= (wxFrame
*)pWin
;
332 if ( pFrame
&& pFrame
->GetStatusBar() )
333 pFrame
->SetStatusText(szString
);
335 #endif // wxUSE_STATUSBAR
343 // don't prepend debug/trace here: it goes to the
344 // debug window anyhow, but do put a timestamp
347 str
<< szString
<< wxT("\r\n");
348 OutputDebugString(str
);
350 // send them to stderr
351 wxFprintf(stderr
, wxT("%s: %s\n"),
352 level
== wxLOG_Trace
? wxT("Trace")
358 #endif // __WXDEBUG__
362 case wxLOG_FatalError
:
363 // show this one immediately
364 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
370 #if !wxUSE_LOG_DIALOG
371 // discard earlier informational messages if this is the 1st
372 // error because they might not make sense any more and showing
373 // them in a message box might be confusing
377 #endif // wxUSE_LOG_DIALOG
384 // for the warning we don't discard the info messages
388 m_aMessages
.Add(szString
);
389 m_aSeverity
.Add((int)level
);
390 m_aTimes
.Add((long)t
);
391 m_bHasMessages
= TRUE
;
396 // ----------------------------------------------------------------------------
397 // wxLogWindow and wxLogFrame implementation
398 // ----------------------------------------------------------------------------
402 class wxLogFrame
: public wxFrame
406 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
407 virtual ~wxLogFrame();
410 void OnClose(wxCommandEvent
& event
);
411 void OnCloseWindow(wxCloseEvent
& event
);
413 void OnSave (wxCommandEvent
& event
);
415 void OnClear(wxCommandEvent
& event
);
417 void OnIdle(wxIdleEvent
&);
420 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
423 // use standard ids for our commands!
426 Menu_Close
= wxID_CLOSE
,
427 Menu_Save
= wxID_SAVE
,
428 Menu_Clear
= wxID_CLEAR
431 // common part of OnClose() and OnCloseWindow()
434 wxTextCtrl
*m_pTextCtrl
;
437 DECLARE_EVENT_TABLE()
440 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
441 // wxLogWindow menu events
442 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
444 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
446 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
448 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
451 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
452 : wxFrame(pParent
, -1, szTitle
)
456 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
463 wxMenuBar
*pMenuBar
= new wxMenuBar
;
464 wxMenu
*pMenu
= new wxMenu
;
466 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
468 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
469 pMenu
->AppendSeparator();
470 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
471 pMenuBar
->Append(pMenu
, _("&Log"));
472 SetMenuBar(pMenuBar
);
475 // status bar for menu prompts
477 #endif // wxUSE_STATUSBAR
479 m_log
->OnFrameCreate(this);
482 void wxLogFrame::DoClose()
484 if ( m_log
->OnFrameClose(this) )
486 // instead of closing just hide the window to be able to Show() it
492 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
497 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
503 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());
536 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
538 m_pTextCtrl
->Clear();
541 wxLogFrame::~wxLogFrame()
543 m_log
->OnFrameDelete(this);
548 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
549 const wxChar
*szTitle
,
553 m_bPassMessages
= bDoPass
;
555 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
556 m_pOldLog
= wxLog::SetActiveTarget(this);
559 m_pLogFrame
->Show(TRUE
);
562 void wxLogWindow::Show(bool bShow
)
564 m_pLogFrame
->Show(bShow
);
567 void wxLogWindow::Flush()
569 if ( m_pOldLog
!= NULL
)
572 m_bHasMessages
= FALSE
;
575 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
577 // first let the previous logger show it
578 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
579 // bogus cast just to access protected DoLog
580 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
586 // by default, these messages are ignored by wxLog, so process
588 if ( !wxIsEmpty(szString
) )
591 str
<< _("Status: ") << szString
;
596 // don't put trace messages in the text window for 2 reasons:
597 // 1) there are too many of them
598 // 2) they may provoke other trace messages thus sending a program
599 // into an infinite loop
604 // and this will format it nicely and call our DoLogString()
605 wxLog::DoLog(level
, szString
, t
);
609 m_bHasMessages
= TRUE
;
612 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
614 // put the text into our window
615 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
617 // remove selection (WriteText is in fact ReplaceSelection)
619 long nLen
= pText
->GetLastPosition();
620 pText
->SetSelection(nLen
, nLen
);
625 msg
<< szString
<< wxT('\n');
627 pText
->AppendText(msg
);
629 // TODO ensure that the line can be seen
632 wxFrame
*wxLogWindow::GetFrame() const
637 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
641 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
647 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
649 m_pLogFrame
= (wxLogFrame
*)NULL
;
652 wxLogWindow::~wxLogWindow()
656 // may be NULL if log frame already auto destroyed itself
660 // ----------------------------------------------------------------------------
662 // ----------------------------------------------------------------------------
666 static const size_t MARGIN
= 10;
668 wxString
wxLogDialog::ms_details
;
670 wxLogDialog::wxLogDialog(wxWindow
*parent
,
671 const wxArrayString
& messages
,
672 const wxArrayInt
& severity
,
673 const wxArrayLong
& times
,
674 const wxString
& caption
,
676 : wxDialog(parent
, -1, caption
)
678 if ( ms_details
.IsEmpty() )
680 // ensure that we won't loop here if wxGetTranslation()
681 // happens to pop up a Log message while translating this :-)
682 ms_details
= wxTRANSLATE("&Details");
683 ms_details
= wxGetTranslation(ms_details
);
686 size_t count
= messages
.GetCount();
687 m_messages
.Alloc(count
);
688 m_severity
.Alloc(count
);
689 m_times
.Alloc(count
);
691 for ( size_t n
= 0; n
< count
; n
++ )
693 wxString msg
= messages
[n
];
696 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
697 msg
= msg
.AfterFirst(_T('\n'));
699 m_severity
.Add(severity
[n
]);
700 m_times
.Add(times
[n
]);
705 m_showingDetails
= FALSE
; // not initially
706 m_listctrl
= (wxListCtrl
*)NULL
;
709 m_statline
= (wxStaticLine
*)NULL
;
710 #endif // wxUSE_STATLINE
713 m_btnSave
= (wxButton
*)NULL
;
716 // create the controls which are always shown and layout them: we use
717 // sizers even though our window is not resizeable to calculate the size of
718 // the dialog properly
719 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
720 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
721 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
723 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
724 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
725 // translates into click on cancel button)
726 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
727 sizerButtons
->Add(btnOk
, 0, wxCENTRE
|wxBOTTOM
, MARGIN
/2);
728 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
729 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
|wxTOP
, MARGIN
/2 - 1);
732 wxIcon icon
= wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
));
733 sizerAll
->Add(new wxStaticBitmap(this, -1, icon
), 0, wxCENTRE
);
736 const wxString
& message
= messages
.Last();
737 sizerAll
->Add(CreateTextSizer(message
), 0, wxCENTRE
|wxLEFT
|wxRIGHT
, MARGIN
);
738 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
|wxLEFT
, MARGIN
);
740 sizerTop
->Add(sizerAll
, 0, wxCENTRE
|wxALL
, MARGIN
);
745 sizerTop
->SetSizeHints(this);
750 // this can't happen any more as we don't use this dialog in this case
754 // no details... it's easier to disable a button than to change the
755 // dialog layout depending on whether we have details or not
756 m_btnDetails
->Disable();
763 void wxLogDialog::CreateDetailsControls()
765 // create the save button and separator line if possible
767 m_btnSave
= new wxButton(this, wxID_SAVE
, _("&Save..."));
771 m_statline
= new wxStaticLine(this, -1);
772 #endif // wxUSE_STATLINE
774 // create the list ctrl now
775 m_listctrl
= new wxListCtrl(this, -1,
776 wxDefaultPosition
, wxDefaultSize
,
782 // no need to translate these strings as they're not shown to the
783 // user anyhow (we use wxLC_NO_HEADER style)
784 m_listctrl
->InsertColumn(0, _T("Message"));
785 m_listctrl
->InsertColumn(1, _T("Time"));
787 // prepare the imagelist
788 static const int ICON_SIZE
= 16;
789 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
791 // order should be the same as in the switch below!
792 static const int icons
[] =
799 bool loadedIcons
= TRUE
;
802 for ( size_t icon
= 0; icon
< WXSIZEOF(icons
); icon
++ )
804 wxBitmap bmp
= wxTheApp
->GetStdIcon(icons
[icon
]);
806 // This may very well fail if there are insufficient
807 // colours available. Degrade gracefully.
812 imageList
->Add(wxImage(bmp
).
813 Rescale(ICON_SIZE
, ICON_SIZE
).
817 m_listctrl
->SetImageList(imageList
, wxIMAGE_LIST_SMALL
);
821 wxString fmt
= wxLog::GetTimestamp();
828 size_t count
= m_messages
.GetCount();
829 for ( size_t n
= 0; n
< count
; n
++ )
833 switch ( m_severity
[n
] )
852 m_listctrl
->InsertItem(n
, m_messages
[n
], image
);
854 m_listctrl
->InsertItem(n
, m_messages
[n
]);
856 m_listctrl
->SetItem(n
, 1,
857 TimeStamp(fmt
, (time_t)m_times
[n
]));
860 // let the columns size themselves
861 m_listctrl
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
862 m_listctrl
->SetColumnWidth(1, wxLIST_AUTOSIZE
);
864 // get the approx height of the listctrl
865 wxFont font
= GetFont();
867 font
= *wxSWISS_FONT
;
870 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
871 int height
= wxMax(y
*(count
+ 3), 100);
872 m_listctrl
->SetSize(-1, height
);
875 void wxLogDialog::OnListSelect(wxListEvent
& event
)
877 // we can't just disable the control because this looks ugly under Windows
878 // (wrong bg colour, no scrolling...), but we still want to disable
879 // selecting items - it makes no sense here
880 m_listctrl
->SetItemState(event
.GetIndex(), 0, wxLIST_STATE_SELECTED
);
883 void wxLogDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
890 void wxLogDialog::OnSave(wxCommandEvent
& WXUNUSED(event
))
893 int rc
= OpenLogFile(file
);
902 wxString fmt
= wxLog::GetTimestamp();
909 size_t count
= m_messages
.GetCount();
910 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
913 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
916 << wxTextFile::GetEOL();
918 ok
= file
.Write(line
);
925 wxLogError(_("Can't save log contents to file."));
930 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
932 wxSizer
*sizer
= GetSizer();
934 if ( m_showingDetails
)
936 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
938 sizer
->Remove(m_listctrl
);
941 sizer
->Remove(m_statline
);
942 #endif // wxUSE_STATLINE
945 sizer
->Remove(m_btnSave
);
948 else // show details now
950 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
954 CreateDetailsControls();
958 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
959 #endif // wxUSE_STATLINE
961 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
964 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
968 m_showingDetails
= !m_showingDetails
;
970 // in any case, our size changed - update
971 sizer
->SetSizeHints(this);
975 // VS: this is neccessary in order to force frame redraw under
976 // WindowMaker or fvwm2 (and probably other broken WMs).
977 // Otherwise, detailed list wouldn't be displayed.
982 wxLogDialog::~wxLogDialog()
986 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
990 #endif // wxUSE_LOG_DIALOG
994 // pass an uninitialized file object, the function will ask the user for the
995 // filename and try to open it, returns TRUE on success (file was opened),
996 // FALSE if file couldn't be opened/created and -1 if the file selection
997 // dialog was cancelled
998 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1000 // get the file name
1001 // -----------------
1002 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1011 if ( wxFile::Exists(filename
) ) {
1012 bool bAppend
= FALSE
;
1014 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1016 switch ( wxMessageBox(strMsg
, _("Question"),
1017 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1030 wxFAIL_MSG(_("invalid message box return value"));
1034 bOk
= file
.Open(filename
, wxFile::write_append
);
1037 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1041 bOk
= file
.Create(filename
);
1045 *pFilename
= filename
;
1050 #endif // wxUSE_FILE
1052 #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1056 // ----------------------------------------------------------------------------
1057 // wxLogTextCtrl implementation
1058 // ----------------------------------------------------------------------------
1060 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
1062 m_pTextCtrl
= pTextCtrl
;
1065 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
1071 // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
1072 // translation must be done in wxTextCtrl, not here! (FIXME)
1073 msg
<< szString
<< wxT('\r');
1075 msg
<< szString
<< wxT('\n');
1078 m_pTextCtrl
->AppendText(msg
);
1081 #endif // wxUSE_TEXTCTRL