#if wxUSE_LOG_DIALOG
#include "wx/datetime.h"
#include "wx/listctrl.h"
+ #include "wx/imaglist.h"
#include "wx/image.h"
#else // !wxUSE_TEXTFILE
#include "wx/msgdlg.h"
// the listctrl (not shown initially)
wxListCtrl *m_listctrl;
+ // the translated "Details" string
+ static wxString ms_details;
+
DECLARE_EVENT_TABLE()
};
wxLogGui::wxLogGui()
{
+ // we must translate them here in the very beginning or we risk to have
+ // reentrancy problems when called from inside wxGetTranslation() leading
+ // to inifnite recursion
+ m_error = _("Error");
+ m_warning = _("Warning");
+ m_info = _("Information");
+
Clear();
}
void wxLogGui::Clear()
{
- m_bErrors = m_bWarnings = FALSE;
+ m_bErrors =
+ m_bWarnings =
+ m_bHasMessages = FALSE;
+
m_aMessages.Empty();
m_aSeverity.Empty();
m_aTimes.Empty();
long style;
if ( m_bErrors ) {
- title += _("Error");
+ title += m_error;
style = wxICON_STOP;
}
else if ( m_bWarnings ) {
- title += _("Warning");
+ title += m_warning;
style = wxICON_EXCLAMATION;
}
else {
- title += _("Information");
+ title += m_info;
style = wxICON_INFORMATION;
}
// no undisplayed messages whatsoever
Clear();
}
-
- // do it here again
- m_bHasMessages = FALSE;
}
// log all kinds of messages
static const size_t MARGIN = 10;
+wxString wxLogDialog::ms_details;
+
wxLogDialog::wxLogDialog(wxWindow *parent,
const wxArrayString& messages,
const wxArrayInt& severity,
long style)
: wxDialog(parent, -1, caption )
{
+ if ( ms_details.IsEmpty() )
+ {
+ // ensure that we won't try to call wxGetTranslation() twice
+ ms_details = _T("&Details");
+ ms_details = wxGetTranslation(ms_details);
+ }
+
size_t count = messages.GetCount();
m_messages.Alloc(count);
m_severity.Alloc(count);
wxBoxSizer *sizerButtons = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *sizerAll = new wxBoxSizer(wxHORIZONTAL);
- wxButton *btnOk = new wxButton(this, wxID_OK, _T("OK"));
+ wxButton *btnOk = new wxButton(this, wxID_OK, _("OK"));
sizerButtons->Add(btnOk, 0, wxCENTRE|wxBOTTOM, MARGIN/2);
- m_btnDetails = new wxButton(this, wxID_MORE, _T("&Details >>"));
+ m_btnDetails = new wxButton(this, wxID_MORE, ms_details + _T(" >>"));
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);
+#endif
+
const wxString& message = messages.Last();
sizerAll->Add(CreateTextSizer(message), 0, wxCENTRE|wxLEFT|wxRIGHT, MARGIN);
sizerAll->Add(sizerButtons, 0, wxALIGN_RIGHT|wxLEFT, MARGIN);
if ( m_showingDetails )
{
- m_btnDetails->SetLabel(_T("&Details >>"));
+ m_btnDetails->SetLabel(ms_details + _T(">>"));
sizer->Remove(m_listctrl);
}
else // show details now
{
- m_btnDetails->SetLabel(_T("<< &Details"));
+ m_btnDetails->SetLabel(wxString(_T("<< ")) + ms_details);
if ( !m_listctrl )
{
wxLC_REPORT |
wxLC_NO_HEADER |
wxLC_SINGLE_SEL);
- m_listctrl->InsertColumn(0, _("Message"));
- m_listctrl->InsertColumn(1, _("Time"));
+ // no need to translate these strings as they're not shown to the
+ // user anyhow (we use wxLC_NO_HEADER style)
+ m_listctrl->InsertColumn(0, _T("Message"));
+ m_listctrl->InsertColumn(1, _T("Time"));
// prepare the imagelist
static const int ICON_SIZE = 16;
wxICON_INFORMATION
};
+#ifndef __WIN16__
for ( size_t icon = 0; icon < WXSIZEOF(icons); icon++ )
{
wxBitmap bmp = wxTheApp->GetStdIcon(icons[icon]);
}
m_listctrl->SetImageList(imageList, wxIMAGE_LIST_SMALL);
+#endif
// and fill it
wxString fmt = wxLog::GetTimestamp();
size_t count = m_messages.GetCount();
for ( size_t n = 0; n < count; n++ )
{
- int image;
+ int image = -1;
+#ifndef __WIN16__
switch ( m_severity[n] )
{
case wxLOG_Error:
default:
image = 2;
}
+#endif
m_listctrl->InsertItem(n, m_messages[n], image);
m_listctrl->SetItem(n, 1,