int RecalculateCount();
- wxDataViewEvent SendExpanderEvent( wxEventType type, const wxDataViewItem & item );
+ // Return false only if the event was vetoed by its handler.
+ bool SendExpanderEvent(wxEventType type, const wxDataViewItem& item);
wxDataViewTreeNode * FindNode( const wxDataViewItem & item );
return job.GetResult();
}
-wxDataViewEvent wxDataViewMainWindow::SendExpanderEvent( wxEventType type,
- const wxDataViewItem & item )
+bool
+wxDataViewMainWindow::SendExpanderEvent(wxEventType type,
+ const wxDataViewItem& item)
{
wxWindow *parent = GetParent();
wxDataViewEvent le(type, parent->GetId());
le.SetModel(GetOwner()->GetModel());
le.SetItem( item );
- parent->GetEventHandler()->ProcessEvent(le);
- return le;
+ return !parent->ProcessWindowEvent(le) || le.IsAllowed();
}
bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
if (!node->IsOpen())
{
- wxDataViewEvent e =
- SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, node->GetItem());
-
- // Check if the user prevent expanding
- if( !e.IsAllowed() )
+ if ( !SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, node->GetItem()) )
+ {
+ // Vetoed by the event handler.
return;
+ }
node->ToggleOpen();
if (node->IsOpen())
{
- wxDataViewEvent e =
- SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,node->GetItem());
- if( !e.IsAllowed() )
+ if ( !SendExpanderEvent(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING,node->GetItem()) )
+ {
+ // Vetoed by the event handler.
return;
+ }
// Find out if there are selected items below the current node.
bool selectCollapsingRow = false;