fixing notifications

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41275 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2006-09-18 12:17:34 +00:00
parent 5942996c94
commit 2a81538d69

View File

@ -1234,7 +1234,7 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner ,
DataBrowserItemDataRef itemData ) const DataBrowserItemDataRef itemData ) const
{ {
wxMacDataBrowserListControl *lb = dynamic_cast<wxMacDataBrowserListControl*>(owner); wxMacDataBrowserListCtrlControl *lb = dynamic_cast<wxMacDataBrowserListCtrlControl*>(owner);
// we want to depend on as little as possible to make sure tear-down of controls is safe // we want to depend on as little as possible to make sure tear-down of controls is safe
if ( message == kDataBrowserItemRemoved) if ( message == kDataBrowserItemRemoved)
@ -1248,35 +1248,31 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner ,
return; return;
} }
// TO STEFAN: I'm getting a couple different problems here and I'd appreciate // CS : couldn't reproduce this problem, what are the steps to test ?
// if you could take a look at them.
// 1) wxDynamicCast fails during shutdown. This doesn't suprise me, but // 1) wxDynamicCast fails during shutdown. This doesn't suprise me, but
// you have similar listbox code, so I'm wondering why this case is different. // you have similar listbox code, so I'm wondering why this case is different.
// CS: these two should be fixed now
// 2) owner->GetLineFromItem( this ) always asserts. // 2) owner->GetLineFromItem( this ) always asserts.
// 3) the !lb->IsSelectionSuppressed code also fails with EXC_BAD_ACCESS // 3) the !lb->IsSelectionSuppressed code also fails with EXC_BAD_ACCESS
// To be honest, I think there are casting issues here, but I don't work enough
// in C++ that these things are clear to me, so I'm hoping another pair of eyes
// would help. ;-)
// In any case, I set trigger to false so that these events are not sent.
// during shutdown, this may fail. // during shutdown, this may fail.
wxListCtrl *list = wxDynamicCast( owner->GetPeer() , wxListCtrl ); wxListCtrl *list = wxDynamicCast( owner->GetPeer() , wxListCtrl );
if ( list ){ if ( list ){
bool trigger = false; bool trigger = false;
wxCommandEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() ); wxListEvent event( wxEVT_COMMAND_LIST_ITEM_SELECTED, list->GetId() );
bool isSingle = list->GetWindowStyle() | wxLC_SINGLE_SEL; bool isSingle = list->GetWindowStyle() | wxLC_SINGLE_SEL;
switch (message) switch (message)
{ {
case kDataBrowserItemDeselected: case kDataBrowserItemDeselected:
event.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED); event.SetEventType(wxEVT_COMMAND_LIST_ITEM_DESELECTED);
//if ( !isSingle ) if ( !isSingle )
// trigger = !lb->IsSelectionSuppressed(); trigger = !lb->IsSelectionSuppressed();
break; break;
case kDataBrowserItemSelected: case kDataBrowserItemSelected:
//trigger = !lb->IsSelectionSuppressed(); trigger = !lb->IsSelectionSuppressed();
break; break;
case kDataBrowserItemDoubleClicked: case kDataBrowserItemDoubleClicked:
@ -1291,17 +1287,13 @@ void wxMacListCtrlItem::Notification(wxMacDataItemBrowserControl *owner ,
if ( trigger ) if ( trigger )
{ {
event.SetEventObject( list ); event.SetEventObject( list );
//if ( list->HasClientObjectData() ) event.m_itemIndex = owner->GetLineFromItem( this ) ;
// event.SetClientObject( (wxClientData*) m_data ); if ( !list->IsVirtual() )
//else if ( list->HasClientUntypedData() ) {
// event.SetClientData( m_data ); lb->MacGetColumnInfo(event.m_itemIndex,0,event.m_item);
event.SetString( m_label ); }
event.SetInt( owner->GetLineFromItem( this ) );
event.SetExtraLong( !isSingle ? message == kDataBrowserItemSelected : true );
wxPostEvent( list->GetEventHandler(), event );
// direct notification is not always having the listbox GetSelection() having in synch with event // direct notification is not always having the listbox GetSelection() having in synch with event
// list->GetEventHandler()->ProcessEvent(event); wxPostEvent( list->GetEventHandler(), event );
} }
} }
@ -1417,7 +1409,9 @@ void wxMacDataBrowserListCtrlControl::UpdateState(wxMacDataItem* dataItem, wxLis
void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row, unsigned int column, wxListItem& item ) void wxMacDataBrowserListCtrlControl::MacGetColumnInfo( unsigned int row, unsigned int column, wxListItem& item )
{ {
wxMacDataItem* dataItem = GetItemFromLine(row); wxMacDataItem* dataItem = GetItemFromLine(row);
if (item){ // CS should this guard against dataItem = 0 ? , as item is not a pointer if (item) is not appropriate
//if (item)
{
wxMacListCtrlItem* listItem = dynamic_cast<wxMacListCtrlItem*>(dataItem); wxMacListCtrlItem* listItem = dynamic_cast<wxMacListCtrlItem*>(dataItem);
wxListItem* oldItem = listItem->GetColumnInfo( column ); wxListItem* oldItem = listItem->GetColumnInfo( column );