]>
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"
50 #include "wx/textfile.h"
51 #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 // wxLogTextCtrl implementation
203 // ----------------------------------------------------------------------------
205 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
207 m_pTextCtrl
= pTextCtrl
;
210 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
215 msg
<< szString
<< wxT('\r');
217 msg
<< szString
<< wxT('\n');
220 m_pTextCtrl
->AppendText(msg
);
223 // ----------------------------------------------------------------------------
224 // wxLogGui implementation (FIXME MT-unsafe)
225 // ----------------------------------------------------------------------------
232 void wxLogGui::Clear()
236 m_bHasMessages
= FALSE
;
243 void wxLogGui::Flush()
245 if ( !m_bHasMessages
)
248 // do it right now to block any new calls to Flush() while we're here
249 m_bHasMessages
= FALSE
;
251 wxString appName
= wxTheApp
->GetAppName();
253 appName
[0u] = wxToupper(appName
[0u]);
256 wxString titleFormat
;
258 titleFormat
= _("%s Error");
261 else if ( m_bWarnings
) {
262 titleFormat
= _("%s Warning");
263 style
= wxICON_EXCLAMATION
;
266 titleFormat
= _("%s Information");
267 style
= wxICON_INFORMATION
;
271 title
.Printf(titleFormat
, appName
.c_str());
273 // this is the best we can do here
274 wxWindow
*parent
= wxTheApp
->GetTopWindow();
276 size_t nMsgCount
= m_aMessages
.Count();
279 if ( nMsgCount
== 1 )
281 str
= m_aMessages
[0];
283 else // more than one message
286 wxLogDialog
dlg(parent
,
287 m_aMessages
, m_aSeverity
, m_aTimes
,
290 // clear the message list before showing the dialog because while it's
291 // shown some new messages may appear
294 (void)dlg
.ShowModal();
295 #else // !wxUSE_LOG_DIALOG
296 // concatenate all strings (but not too many to not overfill the msg box)
299 // start from the most recent message
300 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
301 // for Windows strings longer than this value are wrapped (NT 4.0)
302 const size_t nMsgLineWidth
= 156;
304 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
306 if ( nLines
> 25 ) // don't put too many lines in message box
309 str
<< m_aMessages
[n
- 1] << wxT("\n");
311 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
314 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
315 // situation without it
318 wxMessageBox(str
, title
, wxOK
| style
, parent
);
320 // no undisplayed messages whatsoever
325 // log all kinds of messages
326 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
334 m_aMessages
.Add(szString
);
335 m_aSeverity
.Add(wxLOG_Message
);
336 m_aTimes
.Add((long)t
);
337 m_bHasMessages
= TRUE
;
345 // find the top window and set it's status text if it has any
346 wxFrame
*pFrame
= gs_pFrame
;
347 if ( pFrame
== NULL
) {
348 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
349 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
350 pFrame
= (wxFrame
*)pWin
;
354 if ( pFrame
&& pFrame
->GetStatusBar() )
355 pFrame
->SetStatusText(szString
);
357 #endif // wxUSE_STATUSBAR
365 // don't prepend debug/trace here: it goes to the
366 // debug window anyhow, but do put a timestamp
369 str
<< szString
<< wxT("\r\n");
370 OutputDebugString(str
);
372 // send them to stderr
373 wxFprintf(stderr
, wxT("%s: %s\n"),
374 level
== wxLOG_Trace
? wxT("Trace")
380 #endif // __WXDEBUG__
384 case wxLOG_FatalError
:
385 // show this one immediately
386 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
392 #if !wxUSE_LOG_DIALOG
393 // discard earlier informational messages if this is the 1st
394 // error because they might not make sense any more and showing
395 // them in a message box might be confusing
399 #endif // wxUSE_LOG_DIALOG
406 // for the warning we don't discard the info messages
410 m_aMessages
.Add(szString
);
411 m_aSeverity
.Add((int)level
);
412 m_aTimes
.Add((long)t
);
413 m_bHasMessages
= TRUE
;
418 // ----------------------------------------------------------------------------
419 // wxLogWindow and wxLogFrame implementation
420 // ----------------------------------------------------------------------------
424 class wxLogFrame
: public wxFrame
428 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
429 virtual ~wxLogFrame();
432 void OnClose(wxCommandEvent
& event
);
433 void OnCloseWindow(wxCloseEvent
& event
);
435 void OnSave (wxCommandEvent
& event
);
437 void OnClear(wxCommandEvent
& event
);
439 void OnIdle(wxIdleEvent
&);
442 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
445 // use standard ids for our commands!
448 Menu_Close
= wxID_CLOSE
,
449 Menu_Save
= wxID_SAVE
,
450 Menu_Clear
= wxID_CLEAR
453 // common part of OnClose() and OnCloseWindow()
456 wxTextCtrl
*m_pTextCtrl
;
459 DECLARE_EVENT_TABLE()
462 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
463 // wxLogWindow menu events
464 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
466 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
468 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
470 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
473 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
474 : wxFrame(pParent
, -1, szTitle
)
478 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
485 wxMenuBar
*pMenuBar
= new wxMenuBar
;
486 wxMenu
*pMenu
= new wxMenu
;
488 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
490 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
491 pMenu
->AppendSeparator();
492 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
493 pMenuBar
->Append(pMenu
, _("&Log"));
494 SetMenuBar(pMenuBar
);
497 // status bar for menu prompts
499 #endif // wxUSE_STATUSBAR
501 m_log
->OnFrameCreate(this);
504 void wxLogFrame::DoClose()
506 if ( m_log
->OnFrameClose(this) )
508 // instead of closing just hide the window to be able to Show() it
514 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
519 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
525 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
529 int rc
= OpenLogFile(file
, &filename
);
538 // retrieve text and save it
539 // -------------------------
540 int nLines
= m_pTextCtrl
->GetNumberOfLines();
541 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
542 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
543 wxTextFile::GetEOL());
550 wxLogError(_("Can't save log contents to file."));
553 wxLogStatus(this, _("Log saved to the file '%s'."), filename
.c_str());
558 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
560 m_pTextCtrl
->Clear();
563 wxLogFrame::~wxLogFrame()
565 m_log
->OnFrameDelete(this);
570 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
571 const wxChar
*szTitle
,
575 m_bPassMessages
= bDoPass
;
577 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
578 m_pOldLog
= wxLog::SetActiveTarget(this);
581 m_pLogFrame
->Show(TRUE
);
584 void wxLogWindow::Show(bool bShow
)
586 m_pLogFrame
->Show(bShow
);
589 void wxLogWindow::Flush()
591 if ( m_pOldLog
!= NULL
)
594 m_bHasMessages
= FALSE
;
597 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
599 // first let the previous logger show it
600 if ( m_pOldLog
!= NULL
&& m_bPassMessages
) {
601 // bogus cast just to access protected DoLog
602 ((wxLogWindow
*)m_pOldLog
)->DoLog(level
, szString
, t
);
608 // by default, these messages are ignored by wxLog, so process
610 if ( !wxIsEmpty(szString
) )
613 str
<< _("Status: ") << szString
;
618 // don't put trace messages in the text window for 2 reasons:
619 // 1) there are too many of them
620 // 2) they may provoke other trace messages thus sending a program
621 // into an infinite loop
626 // and this will format it nicely and call our DoLogString()
627 wxLog::DoLog(level
, szString
, t
);
631 m_bHasMessages
= TRUE
;
634 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
636 // put the text into our window
637 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
639 // remove selection (WriteText is in fact ReplaceSelection)
641 long nLen
= pText
->GetLastPosition();
642 pText
->SetSelection(nLen
, nLen
);
647 msg
<< szString
<< wxT('\n');
649 pText
->AppendText(msg
);
651 // TODO ensure that the line can be seen
654 wxFrame
*wxLogWindow::GetFrame() const
659 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
663 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
669 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
671 m_pLogFrame
= (wxLogFrame
*)NULL
;
674 wxLogWindow::~wxLogWindow()
678 // may be NULL if log frame already auto destroyed itself
682 // ----------------------------------------------------------------------------
684 // ----------------------------------------------------------------------------
688 static const size_t MARGIN
= 10;
690 wxString
wxLogDialog::ms_details
;
692 wxLogDialog::wxLogDialog(wxWindow
*parent
,
693 const wxArrayString
& messages
,
694 const wxArrayInt
& severity
,
695 const wxArrayLong
& times
,
696 const wxString
& caption
,
698 : wxDialog(parent
, -1, caption
)
700 if ( ms_details
.IsEmpty() )
702 // ensure that we won't loop here if wxGetTranslation()
703 // happens to pop up a Log message while translating this :-)
704 ms_details
= wxTRANSLATE("&Details");
705 ms_details
= wxGetTranslation(ms_details
);
708 size_t count
= messages
.GetCount();
709 m_messages
.Alloc(count
);
710 m_severity
.Alloc(count
);
711 m_times
.Alloc(count
);
713 for ( size_t n
= 0; n
< count
; n
++ )
715 wxString msg
= messages
[n
];
718 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
719 msg
= msg
.AfterFirst(_T('\n'));
721 m_severity
.Add(severity
[n
]);
722 m_times
.Add(times
[n
]);
727 m_showingDetails
= FALSE
; // not initially
728 m_listctrl
= (wxListCtrl
*)NULL
;
731 m_statline
= (wxStaticLine
*)NULL
;
732 #endif // wxUSE_STATLINE
735 m_btnSave
= (wxButton
*)NULL
;
738 // create the controls which are always shown and layout them: we use
739 // sizers even though our window is not resizeable to calculate the size of
740 // the dialog properly
741 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
742 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
743 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
745 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
746 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
747 // translates into click on cancel button)
748 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
749 sizerButtons
->Add(btnOk
, 0, wxCENTRE
|wxBOTTOM
, MARGIN
/2);
750 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
751 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
|wxTOP
, MARGIN
/2 - 1);
754 wxIcon icon
= wxTheApp
->GetStdIcon((int)(style
& wxICON_MASK
));
755 sizerAll
->Add(new wxStaticBitmap(this, -1, icon
), 0, wxCENTRE
);
758 const wxString
& message
= messages
.Last();
759 sizerAll
->Add(CreateTextSizer(message
), 0, wxCENTRE
|wxLEFT
|wxRIGHT
, MARGIN
);
760 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
|wxLEFT
, MARGIN
);
762 sizerTop
->Add(sizerAll
, 0, wxCENTRE
|wxALL
, MARGIN
);
767 sizerTop
->SetSizeHints(this);
772 // this can't happen any more as we don't use this dialog in this case
776 // no details... it's easier to disable a button than to change the
777 // dialog layout depending on whether we have details or not
778 m_btnDetails
->Disable();
785 void wxLogDialog::CreateDetailsControls()
787 // create the save button and separator line if possible
789 m_btnSave
= new wxButton(this, wxID_SAVE
, _("&Save..."));
793 m_statline
= new wxStaticLine(this, -1);
794 #endif // wxUSE_STATLINE
796 // create the list ctrl now
797 m_listctrl
= new wxListCtrl(this, -1,
798 wxDefaultPosition
, wxDefaultSize
,
804 // no need to translate these strings as they're not shown to the
805 // user anyhow (we use wxLC_NO_HEADER style)
806 m_listctrl
->InsertColumn(0, _T("Message"));
807 m_listctrl
->InsertColumn(1, _T("Time"));
809 // prepare the imagelist
810 static const int ICON_SIZE
= 16;
811 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
813 // order should be the same as in the switch below!
814 static const int icons
[] =
821 bool loadedIcons
= TRUE
;
824 for ( size_t icon
= 0; icon
< WXSIZEOF(icons
); icon
++ )
826 wxBitmap bmp
= wxTheApp
->GetStdIcon(icons
[icon
]);
828 // This may very well fail if there are insufficient
829 // colours available. Degrade gracefully.
834 imageList
->Add(wxImage(bmp
).
835 Rescale(ICON_SIZE
, ICON_SIZE
).
839 m_listctrl
->SetImageList(imageList
, wxIMAGE_LIST_SMALL
);
843 wxString fmt
= wxLog::GetTimestamp();
850 size_t count
= m_messages
.GetCount();
851 for ( size_t n
= 0; n
< count
; n
++ )
855 switch ( m_severity
[n
] )
874 m_listctrl
->InsertItem(n
, m_messages
[n
], image
);
876 m_listctrl
->InsertItem(n
, m_messages
[n
]);
878 m_listctrl
->SetItem(n
, 1,
879 TimeStamp(fmt
, (time_t)m_times
[n
]));
882 // let the columns size themselves
883 m_listctrl
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
884 m_listctrl
->SetColumnWidth(1, wxLIST_AUTOSIZE
);
886 // get the approx height of the listctrl
887 wxFont font
= GetFont();
889 font
= *wxSWISS_FONT
;
892 GetTextExtent(_T("H"), (int*)NULL
, &y
, (int*)NULL
, (int*)NULL
, &font
);
893 int height
= wxMax(y
*(count
+ 3), 100);
894 m_listctrl
->SetSize(-1, height
);
897 void wxLogDialog::OnListSelect(wxListEvent
& event
)
899 // we can't just disable the control because this looks ugly under Windows
900 // (wrong bg colour, no scrolling...), but we still want to disable
901 // selecting items - it makes no sense here
902 m_listctrl
->SetItemState(event
.GetIndex(), 0, wxLIST_STATE_SELECTED
);
905 void wxLogDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
912 void wxLogDialog::OnSave(wxCommandEvent
& WXUNUSED(event
))
915 int rc
= OpenLogFile(file
);
924 wxString fmt
= wxLog::GetTimestamp();
931 size_t count
= m_messages
.GetCount();
932 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
935 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
938 << wxTextFile::GetEOL();
940 ok
= file
.Write(line
);
947 wxLogError(_("Can't save log contents to file."));
952 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
954 wxSizer
*sizer
= GetSizer();
956 if ( m_showingDetails
)
958 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
960 sizer
->Remove(m_listctrl
);
963 sizer
->Remove(m_statline
);
964 #endif // wxUSE_STATLINE
967 sizer
->Remove(m_btnSave
);
970 else // show details now
972 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
976 CreateDetailsControls();
980 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
981 #endif // wxUSE_STATLINE
983 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
986 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
990 m_showingDetails
= !m_showingDetails
;
992 // in any case, our size changed - update
993 sizer
->SetSizeHints(this);
997 // VS: this is neccessary in order to force frame redraw under
998 // WindowMaker or fvwm2 (and probably other broken WMs).
999 // Otherwise, detailed list wouldn't be displayed.
1004 wxLogDialog::~wxLogDialog()
1008 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
1012 #endif // wxUSE_LOG_DIALOG
1016 // pass an uninitialized file object, the function will ask the user for the
1017 // filename and try to open it, returns TRUE on success (file was opened),
1018 // FALSE if file couldn't be opened/created and -1 if the file selection
1019 // dialog was cancelled
1020 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1022 // get the file name
1023 // -----------------
1024 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1033 if ( wxFile::Exists(filename
) ) {
1034 bool bAppend
= FALSE
;
1036 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1038 switch ( wxMessageBox(strMsg
, _("Question"),
1039 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1052 wxFAIL_MSG(_("invalid message box return value"));
1056 bOk
= file
.Open(filename
, wxFile::write_append
);
1059 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1063 bOk
= file
.Create(filename
);
1067 *pFilename
= filename
;
1072 #endif // wxUSE_FILE