X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f1df09276caf8575eed4e9bf2689c69903a749a9..bbc3f89a8207a36a0700b0c7a9b95159f5d5a60f:/src/generic/logg.cpp?ds=sidebyside diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index e158cec030..01f50833e2 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -38,6 +38,7 @@ #include "wx/menu.h" #include "wx/frame.h" #include "wx/filedlg.h" + #include "wx/msgdlg.h" #include "wx/textctrl.h" #include "wx/sizer.h" #include "wx/statbmp.h" @@ -86,9 +87,9 @@ public: private: // the data for the listctrl - const wxArrayString& m_messages; - const wxArrayInt& m_severity; - const wxArrayLong& m_times; + wxArrayString m_messages; + wxArrayInt m_severity; + wxArrayLong m_times; // the "toggle" button and its state wxButton *m_btnDetails; @@ -211,6 +212,11 @@ void wxLogGui::Flush() wxLogDialog dlg(wxTheApp->GetTopWindow(), m_aMessages, m_aSeverity, m_aTimes, title, style); + + // clear the message list before showing the dialog because while it's + // shown some new messages may appear + Clear(); + (void)dlg.ShowModal(); #else // !wxUSE_LOG_DIALOG @@ -233,10 +239,10 @@ void wxLogGui::Flush() } wxMessageBox(str, title, wxOK | style); -#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG // no undisplayed messages whatsoever Clear(); +#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG // do it here again m_bHasMessages = FALSE; @@ -305,6 +311,7 @@ void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) case wxLOG_FatalError: // show this one immediately wxMessageBox(szString, _("Fatal error"), wxICON_HAND); + wxExit(); break; case wxLOG_Error: @@ -328,7 +335,7 @@ void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) } m_aMessages.Add(szString); - m_aSeverity.Add(level); + m_aSeverity.Add((int)level); m_aTimes.Add((long)t); m_bHasMessages = TRUE; break; @@ -635,7 +642,7 @@ wxLogDialog::wxLogDialog(wxWindow *parent, const wxArrayLong& times, const wxString& caption, long style) - : wxDialog(parent, -1, caption), + : wxDialog(parent, -1, caption ), m_messages(messages), m_severity(severity), m_times(times) { m_showingDetails = FALSE; // not initially @@ -648,12 +655,12 @@ wxLogDialog::wxLogDialog(wxWindow *parent, wxBoxSizer *sizerButtons = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sizerAll = new wxBoxSizer(wxHORIZONTAL); - wxButton *btnOk = new wxButton(this, wxID_OK, _T("Ok")); - m_btnDetails = new wxButton(this, wxID_MORE, _T("&Details >>")); + wxButton *btnOk = new wxButton(this, wxID_OK, _T("OK")); sizerButtons->Add(btnOk, 0, wxCENTRE|wxBOTTOM, MARGIN/2); + m_btnDetails = new wxButton(this, wxID_MORE, _T("&Details >>")); sizerButtons->Add(m_btnDetails, 0, wxCENTRE|wxTOP, MARGIN/2 - 1); - wxIcon icon = wxTheApp->GetStdIcon(style & wxICON_MASK); + wxIcon icon = wxTheApp->GetStdIcon((int)(style & wxICON_MASK)); sizerAll->Add(new wxStaticBitmap(this, -1, icon), 0, wxCENTRE); const wxString& message = messages.Last(); sizerAll->Add(CreateTextSizer(message), 0, wxCENTRE|wxLEFT|wxRIGHT, MARGIN); @@ -669,6 +676,13 @@ wxLogDialog::wxLogDialog(wxWindow *parent, btnOk->SetFocus(); + if ( m_messages.GetCount() == 1 ) + { + // no details... it's easier to disable a button than to change the + // dialog layout depending on whether we have details or not + m_btnDetails->Disable(); + } + Centre(); } @@ -696,7 +710,9 @@ void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event)) // create it now m_listctrl = new wxListCtrl(this, -1, wxDefaultPosition, wxDefaultSize, - wxLC_REPORT | wxLC_NO_HEADER); + wxSUNKEN_BORDER | + wxLC_REPORT | + wxLC_NO_HEADER ); m_listctrl->InsertColumn(0, _("Message")); m_listctrl->InsertColumn(1, _("Time")); @@ -753,7 +769,7 @@ void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event)) wxDateTime((time_t)m_times[n]).Format(fmt)); } - // let the columns size themselves (TODO does this work under GTK?) + // let the columns size themselves m_listctrl->SetColumnWidth(0, wxLIST_AUTOSIZE); m_listctrl->SetColumnWidth(1, wxLIST_AUTOSIZE); @@ -774,6 +790,7 @@ void wxLogDialog::OnDetails(wxCommandEvent& WXUNUSED(event)) m_showingDetails = !m_showingDetails; // in any case, our size changed - update + sizer->SetSizeHints(this); sizer->Fit(this); }