X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..5100cabffa34c38db26884577113d01f21cda446:/src/generic/listctrl.cpp diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 63e50fb380..8540ca21c1 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -730,6 +730,23 @@ void wxListLineData::CalculateSize( wxDC *dc, int spacing ) m_bound_all.width = 0; m_bound_all.height = 0; wxNode *node = m_items.First(); + if (node) + { + wxListItemData *item = (wxListItemData*)node->Data(); + if (item->HasImage()) + { + int w = 0; + int h = 0; + m_owner->GetImageSize( item->GetImage(), w, h ); + m_bound_icon.width = w; + m_bound_icon.height = h; + } + else + { + m_bound_icon.width = 0; + m_bound_icon.height = 0; + } + } while (node) { wxListItemData *item = (wxListItemData*)node->Data(); @@ -1231,7 +1248,8 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) // do *not* use the listctrl colour for headers - one day we will have a // function to set it separately - dc.SetTextForeground( *wxBLACK ); + //dc.SetTextForeground( *wxBLACK ); + dc.SetTextForeground(wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOWTEXT )); int x = 1; // left of the header rect const int y = 1; // top @@ -1297,12 +1315,12 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event ) { // we want to work with logical coords #if wxUSE_GENERIC_LIST_EXTENSIONS - int x, y; - m_owner->CalcUnscrolledPosition(event.GetX(), event.GetY(), &x, &y); + int x; + m_owner->CalcUnscrolledPosition(event.GetX(), 0, &x, NULL); #else // !wxUSE_GENERIC_LIST_EXTENSIONS int x = event.GetX(); - int y = event.GetY(); #endif // wxUSE_GENERIC_LIST_EXTENSIONS + int y = event.GetY(); if (m_isDragging) { @@ -1625,6 +1643,13 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) if (m_mode & wxLC_REPORT) { + wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + wxSize clientSize = GetClientSize(); + wxRect itemRect; + int lineSpacing = 0; wxListLineData *line = &m_lines[0]; int dummy = 0; @@ -1635,10 +1660,35 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) size_t i_to = y_s / lineSpacing + m_visibleLines+2; if (i_to >= m_lines.GetCount()) i_to = m_lines.GetCount(); - for (size_t i = y_s / lineSpacing; i < i_to; i++) + size_t i; + for (i = y_s / lineSpacing; i < i_to; i++) { m_lines[i].Draw( &dc ); + // Draw horizontal rule if required + if (GetWindowStyle() & wxLC_HRULES) + dc.DrawLine(0, i*lineSpacing, clientSize.x, i*lineSpacing); } + + // Draw last horizontal rule + if ((i > (size_t) (y_s / lineSpacing)) && (GetWindowStyle() & wxLC_HRULES)) + dc.DrawLine(0, i*lineSpacing, clientSize.x, i*lineSpacing); + + // Draw vertical rules if required + if ((GetWindowStyle() & wxLC_VRULES) && (GetItemCount() > 0)) + { + int col = 0; + wxRect firstItemRect; + wxRect lastItemRect; + GetItemRect(0, firstItemRect); + GetItemRect(GetItemCount() - 1, lastItemRect); + int x = firstItemRect.GetX(); + for (col = 0; col < GetColumnCount(); col++) + { + int colWidth = GetColumnWidth(col); + x += colWidth ; + dc.DrawLine(x, firstItemRect.GetY() - 1, x, lastItemRect.GetBottom() + 1); + } + } } else { @@ -1703,7 +1753,7 @@ void wxListMainWindow::DeleteLine( wxListLineData *line ) void wxListMainWindow::EditLabel( long item ) { - wxCHECK_RET( ((size_t)item < m_lines.GetCount()), + wxCHECK_RET( ((size_t)item < m_lines.GetCount()), wxT("wrong index in wxListCtrl::Edit()") ); m_currentEdit = &m_lines[(size_t)item]; @@ -1768,6 +1818,7 @@ void wxListMainWindow::OnRenameAccept() void wxListMainWindow::OnMouse( wxMouseEvent &event ) { + event.SetEventObject( GetParent() ); if (GetParent()->GetEventHandler()->ProcessEvent( event)) return; if (!m_current) return; @@ -1887,7 +1938,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) else if (event.ShiftDown()) { size_t j; - + m_current = line; int numOfCurrent = -1; @@ -2095,7 +2146,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) if (index != wxNOT_FOUND) { index -= steps; - if (index < 0) index = 0; + if (index < 0) index = 0; OnArrowChar( &m_lines[index], event.ShiftDown() ); } break; @@ -2116,7 +2167,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) if (index != wxNOT_FOUND) { index += steps; - if ((size_t)index >= m_lines.GetCount()) + if ((size_t)index >= m_lines.GetCount()) index = m_lines.GetCount()-1; OnArrowChar( &m_lines[index], event.ShiftDown() ); } @@ -2144,7 +2195,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) if (index != wxNOT_FOUND) { index += m_visibleLines; - if ((size_t)index >= m_lines.GetCount()) + if ((size_t)index >= m_lines.GetCount()) index = m_lines.GetCount()-1; OnArrowChar( &m_lines[index], event.ShiftDown() ); } @@ -2381,7 +2432,7 @@ void wxListMainWindow::SetColumnWidth( int col, int width ) wxClientDC dc(this); dc.SetFont( GetFont() ); int max = 10; - + for (size_t i = 0; i < m_lines.GetCount(); i++) { wxListLineData *line = &m_lines[i]; @@ -2499,6 +2550,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) UnfocusLine( m_current ); m_current = line; FocusLine( m_current ); + if ((m_mode & wxLC_SINGLE_SEL) && oldCurrent) oldCurrent->Hilight( FALSE ); RefreshLine( m_current ); if (oldCurrent) RefreshLine( oldCurrent ); } @@ -2879,7 +2931,7 @@ long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(p long pos = start; wxString tmp = str; if (pos < 0) pos = 0; - for (size_t i = pos; i < m_lines.GetCount(); i++) + for (size_t i = (size_t)pos; i < m_lines.GetCount(); i++) { wxListLineData *line = &m_lines[i]; wxString s = ""; @@ -2894,7 +2946,7 @@ long wxListMainWindow::FindItem(long start, long data) { long pos = start; if (pos < 0) pos = 0; - for (size_t i = pos; i < m_lines.GetCount(); i++) + for (size_t i = (size_t)pos; i < m_lines.GetCount(); i++) { wxListLineData *line = &m_lines[i]; wxListItem item; @@ -2953,6 +3005,7 @@ void wxListMainWindow::InsertItem( wxListItem &item ) else { m_lines.Add( line ); + item.m_itemId = m_lines.GetCount(); } }