]>
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
= NULL
; // 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();
252 // avoid showing other log dialogs until we're done with the dialog we're
253 // showing right now: nested modal dialogs make for really bad UI!
257 if ( nMsgCount
== 1 )
259 str
= m_aMessages
[0];
261 else // more than one message
265 wxLogDialog
dlg(parent
,
266 m_aMessages
, m_aSeverity
, m_aTimes
,
269 // clear the message list before showing the dialog because while it's
270 // shown some new messages may appear
273 (void)dlg
.ShowModal();
274 #else // !wxUSE_LOG_DIALOG
275 // concatenate all strings (but not too many to not overfill the msg box)
278 // start from the most recent message
279 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
280 // for Windows strings longer than this value are wrapped (NT 4.0)
281 const size_t nMsgLineWidth
= 156;
283 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
285 if ( nLines
> 25 ) // don't put too many lines in message box
288 str
<< m_aMessages
[n
- 1] << wxT("\n");
290 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
293 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
294 // situation without it
297 wxMessageBox(str
, title
, wxOK
| style
, parent
);
299 // no undisplayed messages whatsoever
303 // allow flushing the logs again
307 // log all kinds of messages
308 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
316 m_aMessages
.Add(szString
);
317 m_aSeverity
.Add(wxLOG_Message
);
318 m_aTimes
.Add((long)t
);
319 m_bHasMessages
= TRUE
;
327 // find the top window and set it's status text if it has any
328 wxFrame
*pFrame
= gs_pFrame
;
329 if ( pFrame
== NULL
) {
330 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
331 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
332 pFrame
= (wxFrame
*)pWin
;
336 if ( pFrame
&& pFrame
->GetStatusBar() )
337 pFrame
->SetStatusText(szString
);
339 #endif // wxUSE_STATUSBAR
350 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
351 // don't prepend debug/trace here: it goes to the
352 // debug window anyhow
354 OutputDebugString(str
);
356 // send them to stderr
357 wxFprintf(stderr
, wxT("[%s] %s\n"),
358 level
== wxLOG_Trace
? wxT("Trace")
364 #endif // __WXDEBUG__
368 case wxLOG_FatalError
:
369 // show this one immediately
370 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
376 #if !wxUSE_LOG_DIALOG
377 // discard earlier informational messages if this is the 1st
378 // error because they might not make sense any more and showing
379 // them in a message box might be confusing
383 #endif // wxUSE_LOG_DIALOG
390 // for the warning we don't discard the info messages
394 m_aMessages
.Add(szString
);
395 m_aSeverity
.Add((int)level
);
396 m_aTimes
.Add((long)t
);
397 m_bHasMessages
= TRUE
;
402 // ----------------------------------------------------------------------------
403 // wxLogWindow and wxLogFrame implementation
404 // ----------------------------------------------------------------------------
408 class wxLogFrame
: public wxFrame
412 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
413 virtual ~wxLogFrame();
416 void OnClose(wxCommandEvent
& event
);
417 void OnCloseWindow(wxCloseEvent
& event
);
419 void OnSave (wxCommandEvent
& event
);
421 void OnClear(wxCommandEvent
& event
);
423 void OnIdle(wxIdleEvent
&);
426 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
429 // use standard ids for our commands!
432 Menu_Close
= wxID_CLOSE
,
433 Menu_Save
= wxID_SAVE
,
434 Menu_Clear
= wxID_CLEAR
437 // common part of OnClose() and OnCloseWindow()
440 wxTextCtrl
*m_pTextCtrl
;
443 DECLARE_EVENT_TABLE()
446 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
447 // wxLogWindow menu events
448 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
450 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
452 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
454 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
457 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
458 : wxFrame(pParent
, -1, szTitle
)
462 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
470 wxMenuBar
*pMenuBar
= new wxMenuBar
;
471 wxMenu
*pMenu
= new wxMenu
;
473 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
475 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
476 pMenu
->AppendSeparator();
477 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
478 pMenuBar
->Append(pMenu
, _("&Log"));
479 SetMenuBar(pMenuBar
);
480 #endif // wxUSE_MENUS
483 // status bar for menu prompts
485 #endif // wxUSE_STATUSBAR
487 m_log
->OnFrameCreate(this);
490 void wxLogFrame::DoClose()
492 if ( m_log
->OnFrameClose(this) )
494 // instead of closing just hide the window to be able to Show() it
500 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
505 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
511 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
516 int rc
= OpenLogFile(file
, &filename
);
525 // retrieve text and save it
526 // -------------------------
527 int nLines
= m_pTextCtrl
->GetNumberOfLines();
528 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
529 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
530 wxTextFile::GetEOL());
537 wxLogError(_("Can't save log contents to file."));
540 wxLogStatus(this, _("Log saved to the file '%s'."), filename
.c_str());
546 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
548 m_pTextCtrl
->Clear();
551 wxLogFrame::~wxLogFrame()
553 m_log
->OnFrameDelete(this);
559 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
560 const wxChar
*szTitle
,
564 PassMessages(bDoPass
);
566 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
569 m_pLogFrame
->Show(TRUE
);
572 void wxLogWindow::Show(bool bShow
)
574 m_pLogFrame
->Show(bShow
);
577 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
579 // first let the previous logger show it
580 wxLogPassThrough::DoLog(level
, szString
, t
);
585 // by default, these messages are ignored by wxLog, so process
587 if ( !wxIsEmpty(szString
) )
590 str
<< _("Status: ") << szString
;
595 // don't put trace messages in the text window for 2 reasons:
596 // 1) there are too many of them
597 // 2) they may provoke other trace messages thus sending a program
598 // into an infinite loop
603 // and this will format it nicely and call our DoLogString()
604 wxLog::DoLog(level
, szString
, t
);
608 m_bHasMessages
= TRUE
;
611 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
613 // put the text into our window
614 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
616 // remove selection (WriteText is in fact ReplaceSelection)
618 long nLen
= pText
->GetLastPosition();
619 pText
->SetSelection(nLen
, nLen
);
624 msg
<< szString
<< wxT('\n');
626 pText
->AppendText(msg
);
628 // TODO ensure that the line can be seen
631 wxFrame
*wxLogWindow::GetFrame() const
636 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
640 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
646 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
648 m_pLogFrame
= (wxLogFrame
*)NULL
;
651 wxLogWindow::~wxLogWindow()
653 // may be NULL if log frame already auto destroyed itself
657 // ----------------------------------------------------------------------------
659 // ----------------------------------------------------------------------------
663 static const size_t MARGIN
= 10;
665 wxString
wxLogDialog::ms_details
;
667 wxLogDialog::wxLogDialog(wxWindow
*parent
,
668 const wxArrayString
& messages
,
669 const wxArrayInt
& severity
,
670 const wxArrayLong
& times
,
671 const wxString
& caption
,
673 : wxDialog(parent
, -1, caption
,
674 wxDefaultPosition
, wxDefaultSize
,
675 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
677 if ( ms_details
.IsEmpty() )
679 // ensure that we won't loop here if wxGetTranslation()
680 // happens to pop up a Log message while translating this :-)
681 ms_details
= wxTRANSLATE("&Details");
682 ms_details
= wxGetTranslation(ms_details
);
685 size_t count
= messages
.GetCount();
686 m_messages
.Alloc(count
);
687 m_severity
.Alloc(count
);
688 m_times
.Alloc(count
);
690 for ( size_t n
= 0; n
< count
; n
++ )
692 wxString msg
= messages
[n
];
695 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
696 msg
= msg
.AfterFirst(_T('\n'));
698 m_severity
.Add(severity
[n
]);
699 m_times
.Add(times
[n
]);
704 m_showingDetails
= FALSE
; // not initially
705 m_listctrl
= (wxListCtrl
*)NULL
;
708 m_statline
= (wxStaticLine
*)NULL
;
709 #endif // wxUSE_STATLINE
712 m_btnSave
= (wxButton
*)NULL
;
715 // create the controls which are always shown and layout them: we use
716 // sizers even though our window is not resizeable to calculate the size of
717 // the dialog properly
718 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
719 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
720 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
722 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
723 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
724 // translates into click on cancel button)
725 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
726 sizerButtons
->Add(btnOk
, 0, wxCENTRE
| wxBOTTOM
, MARGIN
/2);
727 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
728 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
| wxTOP
, MARGIN
/2 - 1);
731 wxIcon icon
= wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
));
732 sizerAll
->Add(new wxStaticBitmap(this, -1, icon
), 0);
735 const wxString
& message
= messages
.Last();
736 sizerAll
->Add(CreateTextSizer(message
), 1,
737 wxALIGN_CENTRE_VERTICAL
| wxLEFT
| wxRIGHT
, MARGIN
);
738 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
| wxLEFT
, MARGIN
);
740 sizerTop
->Add(sizerAll
, 0, wxALL
| wxEXPAND
, 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
))
894 int rc
= OpenLogFile(file
);
903 wxString fmt
= wxLog::GetTimestamp();
910 size_t count
= m_messages
.GetCount();
911 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
914 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
917 << wxTextFile::GetEOL();
919 ok
= file
.Write(line
);
926 wxLogError(_("Can't save log contents to file."));
932 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
934 wxSizer
*sizer
= GetSizer();
936 if ( m_showingDetails
)
938 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
940 sizer
->Remove(m_listctrl
);
943 sizer
->Remove(m_statline
);
944 #endif // wxUSE_STATLINE
947 sizer
->Remove(m_btnSave
);
950 else // show details now
952 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
956 CreateDetailsControls();
960 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
961 #endif // wxUSE_STATLINE
963 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
966 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
970 m_showingDetails
= !m_showingDetails
;
972 // in any case, our size changed - update
973 sizer
->SetSizeHints(this);
977 // VS: this is neccessary in order to force frame redraw under
978 // WindowMaker or fvwm2 (and probably other broken WMs).
979 // Otherwise, detailed list wouldn't be displayed.
984 wxLogDialog::~wxLogDialog()
988 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
992 #endif // wxUSE_LOG_DIALOG
994 #if wxUSE_FILE && wxUSE_FILEDLG
996 // pass an uninitialized file object, the function will ask the user for the
997 // filename and try to open it, returns TRUE on success (file was opened),
998 // FALSE if file couldn't be opened/created and -1 if the file selection
999 // dialog was cancelled
1000 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1002 // get the file name
1003 // -----------------
1004 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1013 if ( wxFile::Exists(filename
) ) {
1014 bool bAppend
= FALSE
;
1016 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1018 switch ( wxMessageBox(strMsg
, _("Question"),
1019 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1032 wxFAIL_MSG(_("invalid message box return value"));
1036 bOk
= file
.Open(filename
, wxFile::write_append
);
1039 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1043 bOk
= file
.Create(filename
);
1047 *pFilename
= filename
;
1052 #endif // wxUSE_FILE
1054 #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1058 // ----------------------------------------------------------------------------
1059 // wxLogTextCtrl implementation
1060 // ----------------------------------------------------------------------------
1062 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
1064 m_pTextCtrl
= pTextCtrl
;
1067 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
1073 // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
1074 // translation must be done in wxTextCtrl, not here! (FIXME)
1075 msg
<< szString
<< wxT('\r');
1077 msg
<< szString
<< wxT('\n');
1080 m_pTextCtrl
->AppendText(msg
);
1083 #endif // wxUSE_TEXTCTRL