+void wxLogDialog::CreateDetailsControls()
+{
+ // create the save button and separator line if possible
+#if wxUSE_FILE
+ m_btnSave = new wxButton(this, wxID_SAVE, _("&Save..."));
+#endif // wxUSE_FILE
+
+#if wxUSE_STATLINE
+ m_statline = new wxStaticLine(this, -1);
+#endif // wxUSE_STATLINE
+
+ // create the list ctrl now
+ m_listctrl = new wxListCtrl(this, -1,
+ wxDefaultPosition, wxDefaultSize,
+ wxSUNKEN_BORDER |
+ wxLC_REPORT |
+ wxLC_NO_HEADER |
+ wxLC_SINGLE_SEL);
+
+ // 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;
+ wxImageList *imageList = new wxImageList(ICON_SIZE, ICON_SIZE);
+
+ // order should be the same as in the switch below!
+ static const wxChar* icons[] =
+ {
+ wxART_ERROR,
+ wxART_WARNING,
+ wxART_INFORMATION
+ };
+
+ bool loadedIcons = TRUE;
+
+#ifndef __WIN16__
+ for ( size_t icon = 0; icon < WXSIZEOF(icons); icon++ )
+ {
+ wxBitmap bmp = wxArtProvider::GetBitmap(icons[icon], wxART_MESSAGE_BOX,
+ wxSize(ICON_SIZE, ICON_SIZE));
+
+ // This may very well fail if there are insufficient colours available.
+ // Degrade gracefully.
+ if ( !bmp.Ok() )
+ {
+ loadedIcons = FALSE;
+
+ break;
+ }
+
+ imageList->Add(bmp);
+ }
+
+ m_listctrl->SetImageList(imageList, wxIMAGE_LIST_SMALL);
+#endif // !Win16
+
+ // and fill it
+ wxString fmt = wxLog::GetTimestamp();
+ if ( !fmt )
+ {
+ // default format
+ fmt = _T("%c");
+ }
+
+ size_t count = m_messages.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ int image;
+
+#ifndef __WIN16__
+ if ( loadedIcons )
+ {
+ switch ( m_severity[n] )
+ {
+ case wxLOG_Error:
+ image = 0;
+ break;
+
+ case wxLOG_Warning:
+ image = 1;
+ break;
+
+ default:
+ image = 2;
+ }
+ }
+ else // failed to load images
+#endif // !Win16
+ {
+ image = -1;
+ }
+
+ m_listctrl->InsertItem(n, m_messages[n], image);
+ m_listctrl->SetItem(n, 1, TimeStamp(fmt, (time_t)m_times[n]));
+ }
+
+ // let the columns size themselves
+ m_listctrl->SetColumnWidth(0, wxLIST_AUTOSIZE);
+ m_listctrl->SetColumnWidth(1, wxLIST_AUTOSIZE);
+
+ // calculate an approximately nice height for the listctrl
+ int height = GetCharHeight()*(count + 4);
+
+ // but check that the dialog won't fall fown from the screen
+ //
+ // we use GetMinHeight() to get the height of the dialog part without the
+ // details and we consider that the "Save" button below and the separator
+ // line (and the margins around it) take about as much, hence double it
+ int heightMax = wxGetDisplaySize().y - GetPosition().y - 2*GetMinHeight();
+
+ // we should leave a margin
+ heightMax *= 9;
+ heightMax /= 10;
+
+ m_listctrl->SetSize(-1, wxMin(height, heightMax));
+}
+
+void wxLogDialog::OnListSelect(wxListEvent& event)
+{
+ // we can't just disable the control because this looks ugly under Windows
+ // (wrong bg colour, no scrolling...), but we still want to disable
+ // selecting items - it makes no sense here
+ m_listctrl->SetItemState(event.GetIndex(), 0, wxLIST_STATE_SELECTED);
+}
+