// event handlers
void OnOk(wxCommandEvent& event);
void OnDetails(wxCommandEvent& event);
+ void OnListSelect(wxListEvent& event);
private:
// the data for the listctrl
BEGIN_EVENT_TABLE(wxLogDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxLogDialog::OnOk)
EVT_BUTTON(wxID_MORE, wxLogDialog::OnDetails)
+ EVT_LIST_ITEM_SELECTED(-1, wxLogDialog::OnListSelect)
END_EVENT_TABLE()
#endif // wxUSE_LOG_DIALOG
}
m_aMessages.Add(szString);
- m_aSeverity.Add(level);
+ m_aSeverity.Add((int)level);
m_aTimes.Add((long)t);
m_bHasMessages = TRUE;
break;
const wxArrayLong& times,
const wxString& caption,
long style)
- : wxDialog(parent, -1, caption ),
- m_messages(messages), m_severity(severity), m_times(times)
+ : wxDialog(parent, -1, caption )
{
+ size_t count = messages.GetCount();
+ m_messages.Alloc(count);
+ m_severity.Alloc(count);
+ m_times.Alloc(count);
+
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxString msg = messages[n];
+ do
+ {
+ m_messages.Add(msg.BeforeFirst(_T('\n')));
+ msg = msg.AfterFirst(_T('\n'));
+
+ m_severity.Add(severity[n]);
+ m_times.Add(times[n]);
+ }
+ while ( !!msg );
+ }
+
m_showingDetails = FALSE; // not initially
m_listctrl = (wxListCtrl *)NULL;
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);
btnOk->SetFocus();
- if ( m_messages.GetCount() == 1 )
+ if ( count == 1 )
{
// no details... it's easier to disable a button than to change the
// dialog layout depending on whether we have details or not
Centre();
}
+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.GetItem(), 0, wxLIST_STATE_SELECTED);
+}
+
void wxLogDialog::OnOk(wxCommandEvent& WXUNUSED(event))
{
EndModal(wxID_OK);
wxDefaultPosition, wxDefaultSize,
wxSUNKEN_BORDER |
wxLC_REPORT |
- wxLC_NO_HEADER );
+ wxLC_NO_HEADER |
+ wxLC_SINGLE_SEL);
m_listctrl->InsertColumn(0, _("Message"));
m_listctrl->InsertColumn(1, _("Time"));