#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxListItemList)
+// so we can check for column clicks
+static const EventTypeSpec eventList[] =
+{
+ { kEventClassControl, kEventControlHit },
+};
+
+static pascal OSStatus wxMacListCtrlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+{
+ OSStatus result = eventNotHandledErr ;
+
+ wxMacCarbonEvent cEvent( event ) ;
+
+ ControlRef controlRef ;
+ cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
+
+ wxListCtrl *window = (wxListCtrl*) data ;
+ wxListEvent le( wxEVT_COMMAND_LIST_COL_CLICK, window->GetId() );
+ le.SetEventObject( window );
+
+ switch ( GetEventKind( event ) )
+ {
+ // check if the column was clicked on and fire an event if so
+ case kEventControlHit :
+ {
+ ControlPartCode result = cEvent.GetParameter<ControlPartCode>(kEventParamControlPart, typeControlPartCode) ;
+ if (result == kControlButtonPart){
+ DataBrowserPropertyID col;
+ GetDataBrowserSortProperty(controlRef, &col);
+ int column = col - kMinColumnId;
+ le.m_col = column;
+ window->GetEventHandler()->ProcessEvent( le );
+ }
+ result = CallNextEventHandler(handler, event);
+ break;
+ }
+ default :
+ break ;
+ }
+
+
+ return result ;
+}
+
+DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacListCtrlEventHandler )
+
class wxMacListCtrlItem : public wxMacListBoxItem
{
public:
// create a list item (can be a subclass of wxMacListBoxItem)
- virtual wxMacListCtrlItem* CreateItem();
+ virtual wxMacDataItem* CreateItem();
virtual void MacInsertItem( unsigned int n, wxListItem* item );
virtual void MacSetColumnInfo( unsigned int row, unsigned int column, wxListItem* item );
m_textCtrl = NULL;
m_genericImpl = NULL;
m_dbImpl = NULL;
+ m_compareFunc = NULL;
+ m_compareFuncData = 0;
}
class wxGenericListCtrlHook : public wxGenericListCtrl
{
}
+protected:
virtual wxListItemAttr * OnGetItemAttr(long item) const
{
return m_nativeListCtrl->OnGetItemAttr(item);
return m_nativeListCtrl->OnGetItemText(item, column);
}
-protected:
wxListCtrl* m_nativeListCtrl;
};
return false;
m_dbImpl = new wxMacDataBrowserListCtrlControl( this, pos, size, style );
m_peer = m_dbImpl;
-
+
MacPostControlCreate( pos, size );
+
+ InstallControlEventHandler( m_peer->GetControlRef() , GetwxMacListCtrlEventHandlerUPP(),
+ GetEventTypeCount(eventList), eventList, this,
+ (EventHandlerRef *)&m_macListCtrlEventHandler);
}
return true;
{
if (m_genericImpl)
return m_genericImpl->SortItems(fn, data);
+
+ if (m_dbImpl)
+ {
+ m_compareFunc = fn;
+ m_compareFuncData = data;
+ }
return true;
}
bool trigger = false;
wxListEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() );
- bool isSingle = list->GetWindowStyle() | wxLC_SINGLE_SEL;
+ bool isSingle = (list->GetWindowStyle() & wxLC_SINGLE_SEL) != 0;
event.SetEventObject( list );
event.m_itemIndex = owner->GetLineFromItem( this ) ;
else if ( message == kDataBrowserItemAdded )
{
// we don't issue events on adding, the item is not really stored in the list yet, so we
- // avoid asserts by gettting out now
+ // avoid asserts by getting out now
return ;
}
bool trigger = false;
wxListEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() );
- bool isSingle = list->GetWindowStyle() | wxLC_SINGLE_SEL;
+ bool isSingle = (list->GetWindowStyle() & wxLC_SINGLE_SEL) != 0;
event.SetEventObject( list );
if ( !list->IsVirtual() )
{
wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID;
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
+ wxListCtrlCompare func = list->GetCompareFunc();
+ if (func != NULL && item->HasColumnInfo(colId) && otherItem->HasColumnInfo(colId))
+ return func(item->GetColumnInfo(colId)->GetData(), otherItem->GetColumnInfo(colId)->GetData(), list->GetCompareFuncData()) >= 0;
+
itemNum = item->GetOrder();
otherItemNum = otherItem->GetOrder();
if (item->HasColumnInfo(colId))
MacSetColumnInfo(n, 0, item);
}
-wxMacListCtrlItem* wxMacDataBrowserListCtrlControl::CreateItem()
+wxMacDataItem* wxMacDataBrowserListCtrlControl::CreateItem()
{
return new wxMacListCtrlItem();
}