]>
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"
55 #include "wx/artprov.h"
58 // for OutputDebugString()
59 #include "wx/msw/private.h"
63 #include "wx/listctrl.h"
64 #include "wx/imaglist.h"
66 #else // !wxUSE_LOG_DIALOG
67 #include "wx/msgdlg.h"
68 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
76 // this function is a wrapper around strftime(3)
77 // allows to exclude the usage of wxDateTime
78 static wxString
TimeStamp(const wxChar
*format
, time_t t
)
81 if ( !wxStrftime(buf
, WXSIZEOF(buf
), format
, localtime(&t
)) )
83 // buffer is too small?
84 wxFAIL_MSG(_T("strftime() failed"));
90 class wxLogDialog
: public wxDialog
93 wxLogDialog(wxWindow
*parent
,
94 const wxArrayString
& messages
,
95 const wxArrayInt
& severity
,
96 const wxArrayLong
& timess
,
97 const wxString
& caption
,
99 virtual ~wxLogDialog();
102 void OnOk(wxCommandEvent
& event
);
103 void OnDetails(wxCommandEvent
& event
);
105 void OnSave(wxCommandEvent
& event
);
107 void OnListSelect(wxListEvent
& event
);
110 // create controls needed for the details display
111 void CreateDetailsControls();
113 // the data for the listctrl
114 wxArrayString m_messages
;
115 wxArrayInt m_severity
;
118 // the "toggle" button and its state
119 wxButton
*m_btnDetails
;
120 bool m_showingDetails
;
122 // the controls which are not shown initially (but only when details
123 // button is pressed)
124 wxListCtrl
*m_listctrl
;
126 wxStaticLine
*m_statline
;
127 #endif // wxUSE_STATLINE
132 // the translated "Details" string
133 static wxString ms_details
;
135 DECLARE_EVENT_TABLE()
138 BEGIN_EVENT_TABLE(wxLogDialog
, wxDialog
)
139 EVT_BUTTON(wxID_CANCEL
, wxLogDialog::OnOk
)
140 EVT_BUTTON(wxID_MORE
, wxLogDialog::OnDetails
)
142 EVT_BUTTON(wxID_SAVE
, wxLogDialog::OnSave
)
144 EVT_LIST_ITEM_SELECTED(-1, wxLogDialog::OnListSelect
)
147 #endif // wxUSE_LOG_DIALOG
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
153 #if wxUSE_FILE && wxUSE_FILEDLG
155 // pass an uninitialized file object, the function will ask the user for the
156 // filename and try to open it, returns TRUE on success (file was opened),
157 // FALSE if file couldn't be opened/created and -1 if the file selection
158 // dialog was cancelled
159 static int OpenLogFile(wxFile
& file
, wxString
*filename
= NULL
);
163 // ----------------------------------------------------------------------------
165 // ----------------------------------------------------------------------------
167 // we use a global variable to store the frame pointer for wxLogStatus - bad,
168 // but it's the easiest way
169 static wxFrame
*gs_pFrame
= NULL
; // FIXME MT-unsafe
171 // ============================================================================
173 // ============================================================================
175 // ----------------------------------------------------------------------------
177 // ----------------------------------------------------------------------------
179 // accepts an additional argument which tells to which frame the output should
181 void wxVLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, va_list argptr
)
185 wxLog
*pLog
= wxLog::GetActiveTarget();
186 if ( pLog
!= NULL
) {
187 msg
.PrintfV(szFormat
, argptr
);
189 wxASSERT( gs_pFrame
== NULL
); // should be reset!
191 wxLog::OnLog(wxLOG_Status
, msg
, time(NULL
));
192 gs_pFrame
= (wxFrame
*) NULL
;
196 void wxLogStatus(wxFrame
*pFrame
, const wxChar
*szFormat
, ...)
199 va_start(argptr
, szFormat
);
200 wxVLogStatus(pFrame
, szFormat
, argptr
);
204 // ----------------------------------------------------------------------------
205 // wxLogGui implementation (FIXME MT-unsafe)
206 // ----------------------------------------------------------------------------
213 void wxLogGui::Clear()
217 m_bHasMessages
= FALSE
;
224 void wxLogGui::Flush()
226 if ( !m_bHasMessages
)
229 // do it right now to block any new calls to Flush() while we're here
230 m_bHasMessages
= FALSE
;
232 wxString appName
= wxTheApp
->GetAppName();
234 appName
[0u] = wxToupper(appName
[0u]);
237 wxString titleFormat
;
239 titleFormat
= _("%s Error");
242 else if ( m_bWarnings
) {
243 titleFormat
= _("%s Warning");
244 style
= wxICON_EXCLAMATION
;
247 titleFormat
= _("%s Information");
248 style
= wxICON_INFORMATION
;
252 title
.Printf(titleFormat
, appName
.c_str());
254 size_t nMsgCount
= m_aMessages
.Count();
256 // avoid showing other log dialogs until we're done with the dialog we're
257 // showing right now: nested modal dialogs make for really bad UI!
261 if ( nMsgCount
== 1 )
263 str
= m_aMessages
[0];
265 else // more than one message
269 wxLogDialog
dlg(NULL
,
270 m_aMessages
, m_aSeverity
, m_aTimes
,
273 // clear the message list before showing the dialog because while it's
274 // shown some new messages may appear
277 (void)dlg
.ShowModal();
278 #else // !wxUSE_LOG_DIALOG
279 // concatenate all strings (but not too many to not overfill the msg box)
282 // start from the most recent message
283 for ( size_t n
= nMsgCount
; n
> 0; n
-- ) {
284 // for Windows strings longer than this value are wrapped (NT 4.0)
285 const size_t nMsgLineWidth
= 156;
287 nLines
+= (m_aMessages
[n
- 1].Len() + nMsgLineWidth
- 1) / nMsgLineWidth
;
289 if ( nLines
> 25 ) // don't put too many lines in message box
292 str
<< m_aMessages
[n
- 1] << wxT("\n");
294 #endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG
297 // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any
298 // situation without it
301 wxMessageBox(str
, title
, wxOK
| style
);
303 // no undisplayed messages whatsoever
307 // allow flushing the logs again
311 // log all kinds of messages
312 void wxLogGui::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
319 m_aMessages
.Add(szString
);
320 m_aSeverity
.Add(wxLOG_Message
);
321 m_aTimes
.Add((long)t
);
322 m_bHasMessages
= TRUE
;
329 // find the top window and set it's status text if it has any
330 wxFrame
*pFrame
= gs_pFrame
;
331 if ( pFrame
== NULL
) {
332 wxWindow
*pWin
= wxTheApp
->GetTopWindow();
333 if ( pWin
!= NULL
&& pWin
->IsKindOf(CLASSINFO(wxFrame
)) ) {
334 pFrame
= (wxFrame
*)pWin
;
338 if ( pFrame
&& pFrame
->GetStatusBar() )
339 pFrame
->SetStatusText(szString
);
341 #endif // wxUSE_STATUSBAR
352 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
353 // don't prepend debug/trace here: it goes to the
354 // debug window anyhow
356 OutputDebugString(str
);
358 // send them to stderr
359 wxFprintf(stderr
, wxT("[%s] %s\n"),
360 level
== wxLOG_Trace
? wxT("Trace")
366 #endif // __WXDEBUG__
370 case wxLOG_FatalError
:
371 // show this one immediately
372 wxMessageBox(szString
, _("Fatal error"), wxICON_HAND
);
378 #if !wxUSE_LOG_DIALOG
379 // discard earlier informational messages if this is the 1st
380 // error because they might not make sense any more and showing
381 // them in a message box might be confusing
385 #endif // wxUSE_LOG_DIALOG
392 // for the warning we don't discard the info messages
396 m_aMessages
.Add(szString
);
397 m_aSeverity
.Add((int)level
);
398 m_aTimes
.Add((long)t
);
399 m_bHasMessages
= TRUE
;
404 // ----------------------------------------------------------------------------
405 // wxLogWindow and wxLogFrame implementation
406 // ----------------------------------------------------------------------------
410 class wxLogFrame
: public wxFrame
414 wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
);
415 virtual ~wxLogFrame();
418 void OnClose(wxCommandEvent
& event
);
419 void OnCloseWindow(wxCloseEvent
& event
);
421 void OnSave (wxCommandEvent
& event
);
423 void OnClear(wxCommandEvent
& event
);
425 void OnIdle(wxIdleEvent
&);
428 wxTextCtrl
*TextCtrl() const { return m_pTextCtrl
; }
431 // use standard ids for our commands!
434 Menu_Close
= wxID_CLOSE
,
435 Menu_Save
= wxID_SAVE
,
436 Menu_Clear
= wxID_CLEAR
439 // common part of OnClose() and OnCloseWindow()
442 wxTextCtrl
*m_pTextCtrl
;
445 DECLARE_EVENT_TABLE()
448 BEGIN_EVENT_TABLE(wxLogFrame
, wxFrame
)
449 // wxLogWindow menu events
450 EVT_MENU(Menu_Close
, wxLogFrame::OnClose
)
452 EVT_MENU(Menu_Save
, wxLogFrame::OnSave
)
454 EVT_MENU(Menu_Clear
, wxLogFrame::OnClear
)
456 EVT_CLOSE(wxLogFrame::OnCloseWindow
)
459 wxLogFrame::wxLogFrame(wxFrame
*pParent
, wxLogWindow
*log
, const wxChar
*szTitle
)
460 : wxFrame(pParent
, -1, szTitle
)
464 m_pTextCtrl
= new wxTextCtrl(this, -1, wxEmptyString
, wxDefaultPosition
,
468 // needed for Win32 to avoid 65Kb limit but it doesn't work well
469 // when using RichEdit 2.0 which we always do in the Unicode build
472 #endif // !wxUSE_UNICODE
477 wxMenuBar
*pMenuBar
= new wxMenuBar
;
478 wxMenu
*pMenu
= new wxMenu
;
480 pMenu
->Append(Menu_Save
, _("&Save..."), _("Save log contents to file"));
482 pMenu
->Append(Menu_Clear
, _("C&lear"), _("Clear the log contents"));
483 pMenu
->AppendSeparator();
484 pMenu
->Append(Menu_Close
, _("&Close"), _("Close this window"));
485 pMenuBar
->Append(pMenu
, _("&Log"));
486 SetMenuBar(pMenuBar
);
487 #endif // wxUSE_MENUS
490 // status bar for menu prompts
492 #endif // wxUSE_STATUSBAR
494 m_log
->OnFrameCreate(this);
497 void wxLogFrame::DoClose()
499 if ( m_log
->OnFrameClose(this) )
501 // instead of closing just hide the window to be able to Show() it
507 void wxLogFrame::OnClose(wxCommandEvent
& WXUNUSED(event
))
512 void wxLogFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))
518 void wxLogFrame::OnSave(wxCommandEvent
& WXUNUSED(event
))
523 int rc
= OpenLogFile(file
, &filename
);
532 // retrieve text and save it
533 // -------------------------
534 int nLines
= m_pTextCtrl
->GetNumberOfLines();
535 for ( int nLine
= 0; bOk
&& nLine
< nLines
; nLine
++ ) {
536 bOk
= file
.Write(m_pTextCtrl
->GetLineText(nLine
) +
537 wxTextFile::GetEOL());
544 wxLogError(_("Can't save log contents to file."));
547 wxLogStatus(this, _("Log saved to the file '%s'."), filename
.c_str());
553 void wxLogFrame::OnClear(wxCommandEvent
& WXUNUSED(event
))
555 m_pTextCtrl
->Clear();
558 wxLogFrame::~wxLogFrame()
560 m_log
->OnFrameDelete(this);
566 wxLogWindow::wxLogWindow(wxFrame
*pParent
,
567 const wxChar
*szTitle
,
571 PassMessages(bDoPass
);
573 m_pLogFrame
= new wxLogFrame(pParent
, this, szTitle
);
576 m_pLogFrame
->Show(TRUE
);
579 void wxLogWindow::Show(bool bShow
)
581 m_pLogFrame
->Show(bShow
);
584 void wxLogWindow::DoLog(wxLogLevel level
, const wxChar
*szString
, time_t t
)
586 // first let the previous logger show it
587 wxLogPassThrough::DoLog(level
, szString
, t
);
592 // by default, these messages are ignored by wxLog, so process
594 if ( !wxIsEmpty(szString
) )
597 str
<< _("Status: ") << szString
;
602 // don't put trace messages in the text window for 2 reasons:
603 // 1) there are too many of them
604 // 2) they may provoke other trace messages thus sending a program
605 // into an infinite loop
610 // and this will format it nicely and call our DoLogString()
611 wxLog::DoLog(level
, szString
, t
);
615 m_bHasMessages
= TRUE
;
618 void wxLogWindow::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
620 // put the text into our window
621 wxTextCtrl
*pText
= m_pLogFrame
->TextCtrl();
623 // remove selection (WriteText is in fact ReplaceSelection)
625 long nLen
= pText
->GetLastPosition();
626 pText
->SetSelection(nLen
, nLen
);
631 msg
<< szString
<< wxT('\n');
633 pText
->AppendText(msg
);
635 // TODO ensure that the line can be seen
638 wxFrame
*wxLogWindow::GetFrame() const
643 void wxLogWindow::OnFrameCreate(wxFrame
* WXUNUSED(frame
))
647 bool wxLogWindow::OnFrameClose(wxFrame
* WXUNUSED(frame
))
653 void wxLogWindow::OnFrameDelete(wxFrame
* WXUNUSED(frame
))
655 m_pLogFrame
= (wxLogFrame
*)NULL
;
658 wxLogWindow::~wxLogWindow()
660 // may be NULL if log frame already auto destroyed itself
664 // ----------------------------------------------------------------------------
666 // ----------------------------------------------------------------------------
670 static const size_t MARGIN
= 10;
672 wxString
wxLogDialog::ms_details
;
674 wxLogDialog::wxLogDialog(wxWindow
*parent
,
675 const wxArrayString
& messages
,
676 const wxArrayInt
& severity
,
677 const wxArrayLong
& times
,
678 const wxString
& caption
,
680 : wxDialog(parent
, -1, caption
,
681 wxDefaultPosition
, wxDefaultSize
,
682 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
684 if ( ms_details
.IsEmpty() )
686 // ensure that we won't loop here if wxGetTranslation()
687 // happens to pop up a Log message while translating this :-)
688 ms_details
= wxTRANSLATE("&Details");
689 ms_details
= wxGetTranslation(ms_details
);
692 size_t count
= messages
.GetCount();
693 m_messages
.Alloc(count
);
694 m_severity
.Alloc(count
);
695 m_times
.Alloc(count
);
697 for ( size_t n
= 0; n
< count
; n
++ )
699 wxString msg
= messages
[n
];
702 m_messages
.Add(msg
.BeforeFirst(_T('\n')));
703 msg
= msg
.AfterFirst(_T('\n'));
705 m_severity
.Add(severity
[n
]);
706 m_times
.Add(times
[n
]);
711 m_showingDetails
= FALSE
; // not initially
712 m_listctrl
= (wxListCtrl
*)NULL
;
715 m_statline
= (wxStaticLine
*)NULL
;
716 #endif // wxUSE_STATLINE
719 m_btnSave
= (wxButton
*)NULL
;
722 // create the controls which are always shown and layout them: we use
723 // sizers even though our window is not resizeable to calculate the size of
724 // the dialog properly
725 wxBoxSizer
*sizerTop
= new wxBoxSizer(wxVERTICAL
);
726 wxBoxSizer
*sizerButtons
= new wxBoxSizer(wxVERTICAL
);
727 wxBoxSizer
*sizerAll
= new wxBoxSizer(wxHORIZONTAL
);
729 // this "Ok" button has wxID_CANCEL id - not very logical, but this allows
730 // to close the log dialog with <Esc> which wouldn't work otherwise (as it
731 // translates into click on cancel button)
732 wxButton
*btnOk
= new wxButton(this, wxID_CANCEL
, _("OK"));
733 sizerButtons
->Add(btnOk
, 0, wxCENTRE
| wxBOTTOM
, MARGIN
/2);
734 m_btnDetails
= new wxButton(this, wxID_MORE
, ms_details
+ _T(" >>"));
735 sizerButtons
->Add(m_btnDetails
, 0, wxCENTRE
| wxTOP
, MARGIN
/2 - 1);
739 switch ( style
& wxICON_MASK
)
742 bitmap
= wxArtProvider::GetIcon(wxART_ERROR
, wxART_MESSAGE_BOX
); break;
743 case wxICON_INFORMATION
:
744 bitmap
= wxArtProvider::GetIcon(wxART_INFORMATION
, wxART_MESSAGE_BOX
); break;
746 bitmap
= wxArtProvider::GetIcon(wxART_WARNING
, wxART_MESSAGE_BOX
); break;
748 wxFAIL_MSG(_T("incorrect log style"));
750 sizerAll
->Add(new wxStaticBitmap(this, -1, bitmap
), 0);
753 const wxString
& message
= messages
.Last();
754 sizerAll
->Add(CreateTextSizer(message
), 1,
755 wxALIGN_CENTRE_VERTICAL
| wxLEFT
| wxRIGHT
, MARGIN
);
756 sizerAll
->Add(sizerButtons
, 0, wxALIGN_RIGHT
| wxLEFT
, MARGIN
);
758 sizerTop
->Add(sizerAll
, 0, wxALL
| wxEXPAND
, MARGIN
);
763 sizerTop
->SetSizeHints(this);
768 // this can't happen any more as we don't use this dialog in this case
772 // no details... it's easier to disable a button than to change the
773 // dialog layout depending on whether we have details or not
774 m_btnDetails
->Disable();
781 void wxLogDialog::CreateDetailsControls()
783 // create the save button and separator line if possible
785 m_btnSave
= new wxButton(this, wxID_SAVE
, _("&Save..."));
789 m_statline
= new wxStaticLine(this, -1);
790 #endif // wxUSE_STATLINE
792 // create the list ctrl now
793 m_listctrl
= new wxListCtrl(this, -1,
794 wxDefaultPosition
, wxDefaultSize
,
800 // no need to translate these strings as they're not shown to the
801 // user anyhow (we use wxLC_NO_HEADER style)
802 m_listctrl
->InsertColumn(0, _T("Message"));
803 m_listctrl
->InsertColumn(1, _T("Time"));
805 // prepare the imagelist
806 static const int ICON_SIZE
= 16;
807 wxImageList
*imageList
= new wxImageList(ICON_SIZE
, ICON_SIZE
);
809 // order should be the same as in the switch below!
810 static const wxChar
* icons
[] =
817 bool loadedIcons
= TRUE
;
820 for ( size_t icon
= 0; icon
< WXSIZEOF(icons
); icon
++ )
822 wxBitmap bmp
= wxArtProvider::GetBitmap(icons
[icon
], wxART_MESSAGE_BOX
,
823 wxSize(ICON_SIZE
, ICON_SIZE
));
825 // This may very well fail if there are insufficient colours available.
826 // Degrade gracefully.
837 m_listctrl
->SetImageList(imageList
, wxIMAGE_LIST_SMALL
);
841 wxString fmt
= wxLog::GetTimestamp();
848 size_t count
= m_messages
.GetCount();
849 for ( size_t n
= 0; n
< count
; n
++ )
856 switch ( m_severity
[n
] )
870 else // failed to load images
876 m_listctrl
->InsertItem(n
, m_messages
[n
], image
);
877 m_listctrl
->SetItem(n
, 1, TimeStamp(fmt
, (time_t)m_times
[n
]));
880 // let the columns size themselves
881 m_listctrl
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
882 m_listctrl
->SetColumnWidth(1, wxLIST_AUTOSIZE
);
884 // calculate an approximately nice height for the listctrl
885 int height
= GetCharHeight()*(count
+ 4);
887 // but check that the dialog won't fall fown from the screen
889 // we use GetMinHeight() to get the height of the dialog part without the
890 // details and we consider that the "Save" button below and the separator
891 // line (and the margins around it) take about as much, hence double it
892 int heightMax
= wxGetDisplaySize().y
- GetPosition().y
- 2*GetMinHeight();
894 // we should leave a margin
898 m_listctrl
->SetSize(-1, wxMin(height
, heightMax
));
901 void wxLogDialog::OnListSelect(wxListEvent
& event
)
903 // we can't just disable the control because this looks ugly under Windows
904 // (wrong bg colour, no scrolling...), but we still want to disable
905 // selecting items - it makes no sense here
906 m_listctrl
->SetItemState(event
.GetIndex(), 0, wxLIST_STATE_SELECTED
);
909 void wxLogDialog::OnOk(wxCommandEvent
& WXUNUSED(event
))
916 void wxLogDialog::OnSave(wxCommandEvent
& WXUNUSED(event
))
920 int rc
= OpenLogFile(file
);
929 wxString fmt
= wxLog::GetTimestamp();
936 size_t count
= m_messages
.GetCount();
937 for ( size_t n
= 0; ok
&& (n
< count
); n
++ )
940 line
<< TimeStamp(fmt
, (time_t)m_times
[n
])
943 << wxTextFile::GetEOL();
945 ok
= file
.Write(line
);
952 wxLogError(_("Can't save log contents to file."));
953 #endif // wxUSE_FILEDLG
958 void wxLogDialog::OnDetails(wxCommandEvent
& WXUNUSED(event
))
960 wxSizer
*sizer
= GetSizer();
962 if ( m_showingDetails
)
964 m_btnDetails
->SetLabel(ms_details
+ _T(">>"));
966 sizer
->Remove(m_listctrl
);
969 sizer
->Remove(m_statline
);
970 #endif // wxUSE_STATLINE
973 sizer
->Remove(m_btnSave
);
976 else // show details now
978 m_btnDetails
->SetLabel(wxString(_T("<< ")) + ms_details
);
982 CreateDetailsControls();
986 sizer
->Add(m_statline
, 0, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
987 #endif // wxUSE_STATLINE
989 sizer
->Add(m_listctrl
, 1, wxEXPAND
| (wxALL
& ~wxTOP
), MARGIN
);
991 // VZ: this doesn't work as this becomes the initial (and not only
992 // minimal) listctrl height as well - why?
994 // allow the user to make the dialog shorter than its initial height -
995 // without this it wouldn't work as the list ctrl would have been
997 sizer
->SetItemMinSize(m_listctrl
, 100, 3*GetCharHeight());
1001 sizer
->Add(m_btnSave
, 0, wxALIGN_RIGHT
| (wxALL
& ~wxTOP
), MARGIN
);
1002 #endif // wxUSE_FILE
1005 m_showingDetails
= !m_showingDetails
;
1007 // in any case, our size changed - update
1008 sizer
->SetSizeHints(this);
1012 // VS: this is neccessary in order to force frame redraw under
1013 // WindowMaker or fvwm2 (and probably other broken WMs).
1014 // Otherwise, detailed list wouldn't be displayed.
1019 wxLogDialog::~wxLogDialog()
1023 delete m_listctrl
->GetImageList(wxIMAGE_LIST_SMALL
);
1027 #endif // wxUSE_LOG_DIALOG
1029 #if wxUSE_FILE && wxUSE_FILEDLG
1031 // pass an uninitialized file object, the function will ask the user for the
1032 // filename and try to open it, returns TRUE on success (file was opened),
1033 // FALSE if file couldn't be opened/created and -1 if the file selection
1034 // dialog was cancelled
1035 static int OpenLogFile(wxFile
& file
, wxString
*pFilename
)
1037 // get the file name
1038 // -----------------
1039 wxString filename
= wxSaveFileSelector(wxT("log"), wxT("txt"), wxT("log.txt"));
1048 if ( wxFile::Exists(filename
) ) {
1049 bool bAppend
= FALSE
;
1051 strMsg
.Printf(_("Append log to file '%s' (choosing [No] will overwrite it)?"),
1053 switch ( wxMessageBox(strMsg
, _("Question"),
1054 wxICON_QUESTION
| wxYES_NO
| wxCANCEL
) ) {
1067 wxFAIL_MSG(_("invalid message box return value"));
1071 bOk
= file
.Open(filename
, wxFile::write_append
);
1074 bOk
= file
.Create(filename
, TRUE
/* overwrite */);
1078 bOk
= file
.Create(filename
);
1082 *pFilename
= filename
;
1087 #endif // wxUSE_FILE
1089 #endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
1093 // ----------------------------------------------------------------------------
1094 // wxLogTextCtrl implementation
1095 // ----------------------------------------------------------------------------
1097 wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl
*pTextCtrl
)
1099 m_pTextCtrl
= pTextCtrl
;
1102 void wxLogTextCtrl::DoLogString(const wxChar
*szString
, time_t WXUNUSED(t
))
1107 #if defined(__WXMAC__) && !defined(__DARWIN__)
1108 // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the
1109 // translation must be done in wxTextCtrl, not here! (FIXME)
1110 msg
<< szString
<< wxT('\r');
1112 msg
<< szString
<< wxT('\n');
1115 m_pTextCtrl
->AppendText(msg
);
1118 #endif // wxUSE_TEXTCTRL