+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 int icons[] =
+ {
+ wxICON_ERROR,
+ wxICON_EXCLAMATION,
+ wxICON_INFORMATION
+ };
+
+ bool loadedIcons = TRUE;
+
+#ifndef __WIN16__
+ for ( size_t icon = 0; icon < WXSIZEOF(icons); icon++ )
+ {
+ wxBitmap bmp = wxTheApp->GetStdIcon(icons[icon]);
+
+ // This may very well fail if there are insufficient
+ // colours available. Degrade gracefully.
+
+ if (!bmp.Ok())
+ loadedIcons = FALSE;
+ else
+ imageList->Add(wxImage(bmp).
+ Rescale(ICON_SIZE, ICON_SIZE).
+ ConvertToBitmap());
+ }
+
+ 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 = -1;
+#ifndef __WIN16__
+ switch ( m_severity[n] )
+ {
+ case wxLOG_Error:
+ image = 0;
+ break;
+
+ case wxLOG_Warning:
+ image = 1;
+ break;
+
+ default:
+ image = 2;
+ }
+#endif // !Win16
+
+ if (!loadedIcons)
+ image = -1;
+
+ if (image > -1)
+ m_listctrl->InsertItem(n, m_messages[n], image);
+ else
+ m_listctrl->InsertItem(n, m_messages[n]);
+
+ 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);
+
+ // get the approx height of the listctrl
+ wxFont font = GetFont();
+ if ( !font.Ok() )
+ font = *wxSWISS_FONT;
+
+ int y;
+ GetTextExtent(_T("H"), (int*)NULL, &y, (int*)NULL, (int*)NULL, &font);
+ int height = wxMax(y*(count + 3), 100);
+
+ // 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));
+}
+