BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
EVT_LEFT_DOWN(wxListCtrl::OnLeftDown)
EVT_LEFT_DCLICK(wxListCtrl::OnDblClick)
+ EVT_RIGHT_DOWN(wxListCtrl::OnRightDown)
END_EVENT_TABLE()
// ============================================================================
event.Skip();
}
+void wxListCtrl::OnRightDown(wxMouseEvent& event)
+{
+ wxListEvent le( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, GetId() );
+ le.SetEventObject(this);
+ le.m_pointDrag = event.GetPosition();
+ le.m_itemIndex = -1;
+
+ int flags;
+ long item = HitTest(event.GetPosition(), flags);
+ if (flags & wxLIST_HITTEST_ONITEM)
+ {
+ le.m_itemIndex = item;
+ if (!IsVirtual())
+ {
+
+ le.m_item.m_itemId = item;
+ GetItem(le.m_item);
+ }
+ }
+
+ GetEventHandler()->ProcessEvent(le);
+ event.Skip();
+}
+
void wxListCtrl::OnDblClick(wxMouseEvent& event)
{
m_current = -1;
SetSortProperty( kMinColumnId - 1 );
else
SetSortProperty( kMinColumnId );
- if ( style & wxLC_SORT_ASCENDING )
- {
- m_sortOrder = SortOrder_Text_Ascending;
- SetSortOrder( kDataBrowserOrderIncreasing );
- }
- else if ( style & wxLC_SORT_DESCENDING )
+
+ m_sortOrder = SortOrder_None;
+
+ if ( style & wxLC_SORT_DESCENDING )
{
- m_sortOrder = SortOrder_Text_Descending;
SetSortOrder( kDataBrowserOrderDecreasing );
}
- else
+ else if ( style & wxLC_SORT_ASCENDING )
{
- m_sortOrder = SortOrder_None;
+ SetSortOrder( kDataBrowserOrderIncreasing );
}
if ( style & wxLC_VRULES )
wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID;
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
+ itemOrder = item->GetOrder();
+ otherItemOrder = item->GetOrder();
+
wxListCtrlCompare func = list->GetCompareFunc();
if (func != NULL)
{
return result < 0;
}
}
-
- if (item->HasColumnInfo(colId))
- {
- wxListItem* colItem = item->GetColumnInfo(colId);
- itemText = colItem->GetText();
- itemOrder = colItem->GetId();
- }
- if (otherItem->HasColumnInfo(colId))
- {
- wxListItem* colItem = otherItem->GetColumnInfo(colId);
- otherItemText = colItem->GetText();
- otherItemOrder = colItem->GetId();
- }
+
+ // we can't use the native control's sorting abilities, so just
+ // sort by item id.
+ return itemOrder < otherItemOrder;
}
else
{
// virtual listctrls don't support sorting
return itemNum < otherItemNum;
-
-
- }
-
- if ( sort == kDataBrowserOrderIncreasing && !m_sortOrder == SortOrder_None )
- {
- retval = itemText.CmpNoCase( otherItemText ) > 0;
- }
- else if ( sort == kDataBrowserOrderDecreasing && !m_sortOrder == SortOrder_None )
- {
- retval = itemText.CmpNoCase( otherItemText ) < 0;
- }
- else
- {
- retval = itemOrder < otherItemOrder;
}
}
else{
wxMacListCtrlItem* listItem = wx_static_cast(wxMacListCtrlItem*,dataItem);
bool hasInfo = listItem->HasColumnInfo( column );
listItem->SetColumnInfo( column, item );
+ listItem->SetOrder(row);
UpdateState(dataItem, item);
wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );