X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03147cd08e78ba8a709ee019a8a51ac6b57e6f32..e7ca6139d062c37cc7c056b6647097e999b714cd:/src/generic/logg.cpp diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index 911c39c5a7..155628d827 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -44,6 +44,7 @@ #include "wx/sizer.h" #include "wx/statbmp.h" #include "wx/button.h" + #include "wx/settings.h" #endif // WX_PRECOMP #if wxUSE_LOGGUI || wxUSE_LOGWINDOW @@ -164,7 +165,7 @@ static int OpenLogFile(wxFile& file, wxString *filename = NULL); // we use a global variable to store the frame pointer for wxLogStatus - bad, // but it's the easiest way -static wxFrame *gs_pFrame; // FIXME MT-unsafe +static wxFrame *gs_pFrame = NULL; // FIXME MT-unsafe // ============================================================================ // implementation @@ -244,11 +245,12 @@ void wxLogGui::Flush() wxString title; title.Printf(titleFormat, appName.c_str()); - // this is the best we can do here - wxWindow *parent = wxTheApp->GetTopWindow(); - size_t nMsgCount = m_aMessages.Count(); + // avoid showing other log dialogs until we're done with the dialog we're + // showing right now: nested modal dialogs make for really bad UI! + Suspend(); + wxString str; if ( nMsgCount == 1 ) { @@ -258,7 +260,7 @@ void wxLogGui::Flush() { #if wxUSE_LOG_DIALOG - wxLogDialog dlg(parent, + wxLogDialog dlg(NULL, m_aMessages, m_aSeverity, m_aTimes, title, style); @@ -290,11 +292,14 @@ void wxLogGui::Flush() // situation without it if ( !!str ) { - wxMessageBox(str, title, wxOK | style, parent); + wxMessageBox(str, title, wxOK | style); // no undisplayed messages whatsoever Clear(); } + + // allow flushing the logs again + Resume(); } // log all kinds of messages @@ -336,19 +341,21 @@ void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) case wxLOG_Debug: #ifdef __WXDEBUG__ { + wxString str; + TimeStamp(&str); + str += szString; + #if defined(__WXMSW__) && !defined(__WXMICROWIN__) // don't prepend debug/trace here: it goes to the - // debug window anyhow, but do put a timestamp - wxString str; - TimeStamp(&str); - str << szString << wxT("\r\n"); + // debug window anyhow + str += wxT("\r\n"); OutputDebugString(str); #else // send them to stderr - wxFprintf(stderr, wxT("%s: %s\n"), + wxFprintf(stderr, wxT("[%s] %s\n"), level == wxLOG_Trace ? wxT("Trace") : wxT("Debug"), - szString); + str.c_str()); fflush(stderr); #endif } @@ -661,7 +668,9 @@ wxLogDialog::wxLogDialog(wxWindow *parent, const wxArrayLong& times, const wxString& caption, long style) - : wxDialog(parent, -1, caption) + : wxDialog(parent, -1, caption, + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { if ( ms_details.IsEmpty() ) { @@ -712,20 +721,21 @@ wxLogDialog::wxLogDialog(wxWindow *parent, // to close the log dialog with which wouldn't work otherwise (as it // translates into click on cancel button) wxButton *btnOk = new wxButton(this, wxID_CANCEL, _("OK")); - sizerButtons->Add(btnOk, 0, wxCENTRE|wxBOTTOM, MARGIN/2); + sizerButtons->Add(btnOk, 0, wxCENTRE | wxBOTTOM, MARGIN/2); m_btnDetails = new wxButton(this, wxID_MORE, ms_details + _T(" >>")); - sizerButtons->Add(m_btnDetails, 0, wxCENTRE|wxTOP, MARGIN/2 - 1); + sizerButtons->Add(m_btnDetails, 0, wxCENTRE | wxTOP, MARGIN/2 - 1); #ifndef __WIN16__ wxIcon icon = wxTheApp->GetStdIcon((int)(style & wxICON_MASK)); - sizerAll->Add(new wxStaticBitmap(this, -1, icon), 0, wxCENTRE); + sizerAll->Add(new wxStaticBitmap(this, -1, icon), 0); #endif // !Win16 const wxString& message = messages.Last(); - sizerAll->Add(CreateTextSizer(message), 0, wxCENTRE|wxLEFT|wxRIGHT, MARGIN); - sizerAll->Add(sizerButtons, 0, wxALIGN_RIGHT|wxLEFT, MARGIN); + sizerAll->Add(CreateTextSizer(message), 1, + wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT, MARGIN); + sizerAll->Add(sizerButtons, 0, wxALIGN_RIGHT | wxLEFT, MARGIN); - sizerTop->Add(sizerAll, 0, wxCENTRE|wxALL, MARGIN); + sizerTop->Add(sizerAll, 0, wxALL | wxEXPAND, MARGIN); SetAutoLayout(TRUE); SetSizer(sizerTop); @@ -857,7 +867,13 @@ void wxLogDialog::CreateDetailsControls() int y; GetTextExtent(_T("H"), (int*)NULL, &y, (int*)NULL, (int*)NULL, &font); int height = wxMax(y*(count + 3), 100); - m_listctrl->SetSize(-1, height); + + // if the height as computed from list items exceeds, together with the + // actual message & controls, the screen, make it smaller + int heightMax = + (3*wxSystemSettings::GetSystemMetric(wxSYS_SCREEN_Y))/5 - GetSize().y; + + m_listctrl->SetSize(-1, wxMin(height, heightMax)); } void wxLogDialog::OnListSelect(wxListEvent& event) @@ -1057,7 +1073,7 @@ void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) wxString msg; TimeStamp(&msg); -#ifdef __WXMAC__ +#if defined(__WXMAC__) && !defined(__DARWIN__) // VZ: this is a bug in wxMac, it *must* accept '\n' as new line, the // translation must be done in wxTextCtrl, not here! (FIXME) msg << szString << wxT('\r');