X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e5d3d8ad459facd397afef9f1889f932c8a2f474..bb5b7285057aa71bd9d86aad6effb00dbfcd1f85:/src/mac/carbon/listctrl_mac.cpp diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index b614cf3877..3b4941dc08 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -646,12 +646,8 @@ void wxListCtrl::FireMouseEvent(wxEventType eventType, wxPoint position) if (flags & wxLIST_HITTEST_ONITEM) { le.m_itemIndex = item; - if (!IsVirtual()) - { - - le.m_item.m_itemId = item; - GetItem(le.m_item); - } + le.m_item.m_itemId = item; + GetItem(le.m_item); GetEventHandler()->ProcessEvent(le); } } @@ -668,11 +664,8 @@ void wxListCtrl::OnChar(wxKeyEvent& event) if (m_current != -1) { le.m_itemIndex = m_current; - if (!IsVirtual()) - { - le.m_item.m_itemId = m_current; - GetItem(le.m_item); - } + le.m_item.m_itemId = m_current; + GetItem(le.m_item); GetEventHandler()->ProcessEvent(le); } } @@ -1075,23 +1068,29 @@ bool wxListCtrl::GetItem(wxListItem& info) const if (m_dbImpl) { if (!IsVirtual()) - m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info); + { + if (info.m_itemId >= 0 && info.m_itemId < GetItemCount()) + m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info); + } else { - info.SetText( OnGetItemText(info.m_itemId, info.m_col) ); - info.SetImage( OnGetItemColumnImage(info.m_itemId, info.m_col) ); - if (info.GetMask() & wxLIST_MASK_STATE) + if (info.m_itemId >= 0 && info.m_itemId < GetItemCount()) { - if (IsDataBrowserItemSelected( m_dbImpl->GetControlRef(), info.m_itemId+1 )) - info.SetState(info.GetState() | wxLIST_STATE_SELECTED); - } + info.SetText( OnGetItemText(info.m_itemId, info.m_col) ); + info.SetImage( OnGetItemColumnImage(info.m_itemId, info.m_col) ); + if (info.GetMask() & wxLIST_MASK_STATE) + { + if (IsDataBrowserItemSelected( m_dbImpl->GetControlRef(), info.m_itemId+1 )) + info.SetState(info.GetState() | wxLIST_STATE_SELECTED); + } - wxListItemAttr* attrs = OnGetItemAttr( info.m_itemId ); - if (attrs) - { - info.SetFont( attrs->GetFont() ); - info.SetBackgroundColour( attrs->GetBackgroundColour() ); - info.SetTextColour( attrs->GetTextColour() ); + wxListItemAttr* attrs = OnGetItemAttr( info.m_itemId ); + if (attrs) + { + info.SetFont( attrs->GetFont() ); + info.SetBackgroundColour( attrs->GetBackgroundColour() ); + info.SetTextColour( attrs->GetTextColour() ); + } } } } @@ -1568,16 +1567,19 @@ long wxListCtrl::GetNextItem(long item, int geom, int state) const long count = m_dbImpl->MacGetCount() ; for ( long line = item + 1 ; line < count; line++ ) { - wxMacDataItem* id = m_dbImpl->GetItemFromLine(line); + DataBrowserItemID id = line + 1; + if ( !IsVirtual() ) + id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line); if ( (state == wxLIST_STATE_DONTCARE ) ) return line; - if ( (state & wxLIST_STATE_SELECTED) && m_dbImpl->IsItemSelected( id ) ) + if ( (state & wxLIST_STATE_SELECTED) && IsDataBrowserItemSelected(m_dbImpl->GetControlRef(), id ) ) return line; } } - else if ( geom == wxLIST_NEXT_ABOVE ) + + if ( geom == wxLIST_NEXT_ALL || geom == wxLIST_NEXT_ABOVE ) { int item2 = item; if ( item2 == -1 ) @@ -1585,12 +1587,14 @@ long wxListCtrl::GetNextItem(long item, int geom, int state) const for ( long line = item2 - 1 ; line >= 0; line-- ) { - wxMacDataItem* id = m_dbImpl->GetItemFromLine(line); + DataBrowserItemID id = line + 1; + if ( !IsVirtual() ) + id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line); if ( (state == wxLIST_STATE_DONTCARE ) ) return line; - if ( (state & wxLIST_STATE_SELECTED) && m_dbImpl->IsItemSelected( id ) ) + if ( (state & wxLIST_STATE_SELECTED) && IsDataBrowserItemSelected(m_dbImpl->GetControlRef(), id ) ) return line; } } @@ -2343,10 +2347,8 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner , event.SetEventObject( list ); event.m_itemIndex = owner->GetLineFromItem( this ) ; - if ( !list->IsVirtual() ) - { - lb->MacGetColumnInfo(event.m_itemIndex,0,event.m_item); - } + event.m_item.m_itemId = event.m_itemIndex; + list->GetItem(event.m_item); switch (message) { @@ -2589,17 +2591,21 @@ void wxMacDataBrowserListCtrlControl::DrawItem( } else { - text = list->OnGetItemText( (long)itemID-1, listColumn ); - imgIndex = list->OnGetItemColumnImage( (long)itemID-1, listColumn ); - wxListItemAttr* attrs = list->OnGetItemAttr( (long)itemID-1 ); - if (attrs) + long itemNum = (long)itemID-1; + if (itemNum >= 0 && itemNum < list->GetItemCount()) { - if (attrs->HasBackgroundColour()) - bgColor = attrs->GetBackgroundColour(); - if (attrs->HasTextColour()) - color = attrs->GetTextColour(); - if (attrs->HasFont()) - font = attrs->GetFont(); + text = list->OnGetItemText( itemNum, listColumn ); + imgIndex = list->OnGetItemColumnImage( itemNum, listColumn ); + wxListItemAttr* attrs = list->OnGetItemAttr( itemNum ); + if (attrs) + { + if (attrs->HasBackgroundColour()) + bgColor = attrs->GetBackgroundColour(); + if (attrs->HasTextColour()) + color = attrs->GetTextColour(); + if (attrs->HasFont()) + font = attrs->GetFont(); + } } } } @@ -2638,6 +2644,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem( enclosingRect.right - enclosingRect.left, enclosingRect.bottom - enclosingRect.top); + bool hasFocus = (wxWindow::FindFocus() == list); active = IsControlActive(GetControlRef()); // don't paint the background over the vertical rule line @@ -2651,7 +2658,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem( GetThemeDrawingState(&savedState); - if (active) + if (active && hasFocus) { GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &backgroundColor); GetThemeTextColor(kThemeTextColorWhite, gdDepth, colorDevice, &labelColor); @@ -2793,8 +2800,12 @@ OSStatus wxMacDataBrowserListCtrlControl::GetSetItemData(DataBrowserItemID itemI } else { - text = list->OnGetItemText( (long)itemID-1, listColumn ); - imgIndex = list->OnGetItemColumnImage( (long)itemID-1, listColumn ); + long itemNum = (long)itemID-1; + if (itemNum >= 0 && itemNum < list->GetItemCount()) + { + text = list->OnGetItemText( itemNum, listColumn ); + imgIndex = list->OnGetItemColumnImage( itemNum, listColumn ); + } } } @@ -2897,14 +2908,13 @@ void wxMacDataBrowserListCtrlControl::ItemNotification(DataBrowserItemID itemID, DataBrowserTableViewRowIndex result = 0; verify_noerr( GetItemRow( itemID, &result ) ) ; event.m_itemIndex = result; - - if (event.m_itemIndex >= 0) - MacGetColumnInfo(event.m_itemIndex,0,event.m_item); } else { event.m_itemIndex = (long)itemID-1; } + event.m_item.m_itemId = event.m_itemIndex; + list->GetItem(event.m_item); switch (message) { @@ -3006,9 +3016,7 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI long itemNum = (long)itemOneID; long otherItemNum = (long)itemTwoID; - itemText = list->OnGetItemText( itemNum-1, colId ); - otherItemText = list->OnGetItemText( otherItemNum-1, colId ); - + // virtual listctrls don't support sorting return itemNum < otherItemNum; }