Refactor wxDataViewEvent constructors

Take care of all the common stuff such as setting the event object and the
model, which is used for all events, in the ctor. Also set both the column
pointer and the column index at once instead of having two separate setters
for them which could result in inconsistent event objects (and did, as
sometimes only one or only the other field was set).

This makes the code shorter (we save 160 lines) and more clear and ensures
that everything is always initialized.

Closes #12649.
This commit is contained in:
Vadim Zeitlin
2016-03-18 23:33:27 +01:00
parent e2e7d3d391
commit 9829446755
6 changed files with 166 additions and 325 deletions

View File

@@ -769,25 +769,32 @@ protected:
class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent class WXDLLIMPEXP_ADV wxDataViewEvent : public wxNotifyEvent
{ {
public: public:
wxDataViewEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) // Default ctor, normally shouldn't be used and mostly exists only for
: wxNotifyEvent(commandType, winid), // backwards compatibility.
m_item(0), wxDataViewEvent()
m_col(-1), : wxNotifyEvent()
m_model(NULL), {
m_value(wxNullVariant), Init(NULL, NULL, wxDataViewItem());
m_column(NULL), }
m_pos(-1,-1),
m_cacheFrom(0), // Constructor for the events affecting columns (and possibly also items).
m_cacheTo(0), wxDataViewEvent(wxEventType evtType,
m_editCancelled(false) wxDataViewCtrlBase* dvc,
#if wxUSE_DRAG_AND_DROP wxDataViewColumn* column,
, m_dataObject(NULL), const wxDataViewItem& item = wxDataViewItem())
m_dataBuffer(NULL), : wxNotifyEvent(evtType, dvc->GetId())
m_dataSize(0), {
m_dragFlags(0), Init(dvc, column, item);
m_dropEffect(wxDragNone) }
#endif
{ } // Constructor for the events affecting only the items.
wxDataViewEvent(wxEventType evtType,
wxDataViewCtrlBase* dvc,
const wxDataViewItem& item)
: wxNotifyEvent(evtType, dvc->GetId())
{
Init(dvc, NULL, item);
}
wxDataViewEvent(const wxDataViewEvent& event) wxDataViewEvent(const wxDataViewEvent& event)
: wxNotifyEvent(event), : wxNotifyEvent(event),
@@ -811,13 +818,8 @@ public:
{ } { }
wxDataViewItem GetItem() const { return m_item; } wxDataViewItem GetItem() const { return m_item; }
void SetItem( const wxDataViewItem &item ) { m_item = item; }
int GetColumn() const { return m_col; } int GetColumn() const { return m_col; }
void SetColumn( int col ) { m_col = col; }
wxDataViewModel* GetModel() const { return m_model; } wxDataViewModel* GetModel() const { return m_model; }
void SetModel( wxDataViewModel *model ) { m_model = model; }
const wxVariant &GetValue() const { return m_value; } const wxVariant &GetValue() const { return m_value; }
void SetValue( const wxVariant &value ) { m_value = value; } void SetValue( const wxVariant &value ) { m_value = value; }
@@ -827,7 +829,6 @@ public:
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; } void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only // for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
wxDataViewColumn *GetDataViewColumn() const { return m_column; } wxDataViewColumn *GetDataViewColumn() const { return m_column; }
// for wxEVT_DATAVIEW_CONTEXT_MENU only // for wxEVT_DATAVIEW_CONTEXT_MENU only
@@ -860,6 +861,20 @@ public:
virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); } virtual wxEvent *Clone() const wxOVERRIDE { return new wxDataViewEvent(*this); }
// These methods shouldn't be used outside of wxWidgets and wxWidgets
// itself doesn't use them any longer neither as it constructs the events
// with the appropriate ctors directly.
#if WXWIN_COMPATIBILITY_3_0
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetModel( wxDataViewModel *model ) { m_model = model; }
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetColumn( int col ) { m_col = col; }
wxDEPRECATED_MSG("Pass the argument to the ctor instead")
void SetItem( const wxDataViewItem &item ) { m_item = item; }
#endif // WXWIN_COMPATIBILITY_3_0
protected: protected:
wxDataViewItem m_item; wxDataViewItem m_item;
int m_col; int m_col;
@@ -883,6 +898,11 @@ protected:
#endif // wxUSE_DRAG_AND_DROP #endif // wxUSE_DRAG_AND_DROP
private: private:
// Common part of non-copy ctors.
void Init(wxDataViewCtrlBase* dvc,
wxDataViewColumn* column,
const wxDataViewItem& item);
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent); wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent);
}; };

View File

@@ -669,16 +669,13 @@ wxDataViewCtrl* wxDataViewRendererBase::GetView() const
bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect ) bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect )
{ {
wxDataViewCtrl* dv_ctrl = GetOwner()->GetOwner(); wxDataViewColumn* const column = GetOwner();
wxDataViewCtrl* const dv_ctrl = column->GetOwner();
// Before doing anything we send an event asking if editing of this item is really wanted. // Before doing anything we send an event asking if editing of this item is really wanted.
wxDataViewEvent start_event( wxEVT_DATAVIEW_ITEM_START_EDITING, dv_ctrl->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_START_EDITING, dv_ctrl, column, item);
start_event.SetDataViewColumn( GetOwner() ); dv_ctrl->GetEventHandler()->ProcessEvent( event );
start_event.SetModel( dv_ctrl->GetModel() ); if( !event.IsAllowed() )
start_event.SetItem( item );
start_event.SetEventObject( dv_ctrl );
dv_ctrl->GetEventHandler()->ProcessEvent( start_event );
if( !start_event.IsAllowed() )
return false; return false;
unsigned int col = GetOwner()->GetModelColumn(); unsigned int col = GetOwner()->GetModelColumn();
@@ -712,11 +709,7 @@ void wxDataViewRendererBase::NotifyEditingStarted(const wxDataViewItem& item)
wxDataViewColumn* const column = GetOwner(); wxDataViewColumn* const column = GetOwner();
wxDataViewCtrl* const dv_ctrl = column->GetOwner(); wxDataViewCtrl* const dv_ctrl = column->GetOwner();
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EDITING_STARTED, dv_ctrl->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_STARTED, dv_ctrl, column, item);
event.SetDataViewColumn( column );
event.SetModel( dv_ctrl->GetModel() );
event.SetItem( item );
event.SetEventObject( dv_ctrl );
dv_ctrl->GetEventHandler()->ProcessEvent( event ); dv_ctrl->GetEventHandler()->ProcessEvent( event );
} }
@@ -756,7 +749,8 @@ bool wxDataViewRendererBase::FinishEditing()
wxVariant value; wxVariant value;
const bool gotValue = GetValueFromEditorCtrl(m_editorCtrl, value); const bool gotValue = GetValueFromEditorCtrl(m_editorCtrl, value);
wxDataViewCtrl* dv_ctrl = GetOwner()->GetOwner(); wxDataViewColumn* const column = GetOwner();
wxDataViewCtrl* const dv_ctrl = column->GetOwner();
DestroyEditControl(); DestroyEditControl();
@@ -769,14 +763,9 @@ bool wxDataViewRendererBase::FinishEditing()
unsigned int col = GetOwner()->GetModelColumn(); unsigned int col = GetOwner()->GetModelColumn();
// Now we should send Editing Done event // Now we should send Editing Done event
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EDITING_DONE, dv_ctrl->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_DONE, dv_ctrl, column, m_item);
event.SetDataViewColumn( GetOwner() );
event.SetModel( dv_ctrl->GetModel() );
event.SetItem( m_item );
event.SetValue( value ); event.SetValue( value );
event.SetColumn( col );
event.SetEditCanceled( !isValid ); event.SetEditCanceled( !isValid );
event.SetEventObject( dv_ctrl );
dv_ctrl->GetEventHandler()->ProcessEvent( event ); dv_ctrl->GetEventHandler()->ProcessEvent( event );
bool accepted = false; bool accepted = false;
@@ -1591,6 +1580,29 @@ wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, wxDataViewEvent );
wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent ); wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, wxDataViewEvent );
wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent ); wxDEFINE_EVENT( wxEVT_DATAVIEW_ITEM_DROP, wxDataViewEvent );
// Common part of non-copy ctors.
void wxDataViewEvent::Init(wxDataViewCtrlBase* dvc,
wxDataViewColumn* column,
const wxDataViewItem& item)
{
m_item = item;
m_col = column ? column->GetModelColumn() : -1;
m_model = dvc->GetModel();
m_column = column;
m_pos = wxDefaultPosition;
m_cacheFrom = 0;
m_cacheTo = 0;
m_editCancelled = false;
#if wxUSE_DRAG_AND_DROP
m_dataObject = NULL;
m_dataBuffer = NULL;
m_dataSize = 0;
m_dragFlags = 0;
m_dropEffect = wxDragNone;
#endif // wxUSE_DRAG_AND_DROP
SetEventObject(dvc);
}
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL

View File

@@ -293,12 +293,7 @@ private:
bool SendEvent(wxEventType type, unsigned int n) bool SendEvent(wxEventType type, unsigned int n)
{ {
wxDataViewCtrl * const owner = GetOwner(); wxDataViewCtrl * const owner = GetOwner();
wxDataViewEvent event(type, owner->GetId()); wxDataViewEvent event(type, owner, owner->GetColumn(n));
event.SetEventObject(owner);
event.SetColumn(n);
event.SetDataViewColumn(owner->GetColumn(n));
event.SetModel(owner->GetModel());
// for events created by wxDataViewHeaderWindow the // for events created by wxDataViewHeaderWindow the
// row / value fields are not valid // row / value fields are not valid
@@ -1658,12 +1653,7 @@ wxDragResult wxDataViewMainWindow::OnDragOver( wxDataFormat format, wxCoord x,
if ( row < GetRowCount() && xx <= GetEndOfLastCol() ) if ( row < GetRowCount() && xx <= GetEndOfLastCol() )
item = GetItemByRow( row ); item = GetItemByRow( row );
wxDataViewModel *model = GetModel(); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner, item);
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( model );
event.SetDataFormat( format ); event.SetDataFormat( format );
event.SetDropEffect( def ); event.SetDropEffect( def );
if ( !m_owner->HandleWindowEvent( event ) || !event.IsAllowed() ) if ( !m_owner->HandleWindowEvent( event ) || !event.IsAllowed() )
@@ -1702,12 +1692,7 @@ bool wxDataViewMainWindow::OnDrop( wxDataFormat format, wxCoord x, wxCoord y )
if ( row < GetRowCount() && xx <= GetEndOfLastCol()) if ( row < GetRowCount() && xx <= GetEndOfLastCol())
item = GetItemByRow( row ); item = GetItemByRow( row );
wxDataViewModel *model = GetModel(); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner, item);
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( model );
event.SetDataFormat( format ); event.SetDataFormat( format );
if (!m_owner->HandleWindowEvent( event ) || !event.IsAllowed()) if (!m_owner->HandleWindowEvent( event ) || !event.IsAllowed())
return false; return false;
@@ -1728,14 +1713,9 @@ wxDragResult wxDataViewMainWindow::OnData( wxDataFormat format, wxCoord x, wxCoo
if ( row < GetRowCount() && xx <= GetEndOfLastCol() ) if ( row < GetRowCount() && xx <= GetEndOfLastCol() )
item = GetItemByRow( row ); item = GetItemByRow( row );
wxDataViewModel *model = GetModel();
wxCustomDataObject *obj = (wxCustomDataObject *) GetDropTarget()->GetDataObject(); wxCustomDataObject *obj = (wxCustomDataObject *) GetDropTarget()->GetDataObject();
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP, m_owner->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, m_owner, item);
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( model );
event.SetDataFormat( format ); event.SetDataFormat( format );
event.SetDataSize( obj->GetSize() ); event.SetDataSize( obj->GetSize() );
event.SetDataBuffer( obj->GetData() ); event.SetDataBuffer( obj->GetData() );
@@ -1851,11 +1831,9 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
unsigned int item_last = item_start + item_count; unsigned int item_last = item_start + item_count;
// Send the event to wxDataViewCtrl itself. // Send the event to wxDataViewCtrl itself.
wxWindow * const parent = GetParent(); wxDataViewEvent cache_event(wxEVT_DATAVIEW_CACHE_HINT, m_owner, NULL);
wxDataViewEvent cache_event(wxEVT_DATAVIEW_CACHE_HINT, parent->GetId());
cache_event.SetEventObject(parent);
cache_event.SetCache(item_start, item_last - 1); cache_event.SetCache(item_start, item_last - 1);
parent->ProcessWindowEvent(cache_event); m_owner->ProcessWindowEvent(cache_event);
// compute which columns needs to be redrawn // compute which columns needs to be redrawn
unsigned int cols = GetOwner()->GetColumnCount(); unsigned int cols = GetOwner()->GetColumnCount();
@@ -2537,12 +2515,8 @@ bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
GetOwner()->InvalidateColBestWidths(); GetOwner()->InvalidateColBestWidths();
// Send event // Send event
wxWindow *parent = GetParent(); wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner, item);
wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId()); m_owner->ProcessWindowEvent(le);
le.SetEventObject(parent);
le.SetModel(GetModel());
le.SetItem(item);
parent->ProcessWindowEvent(le);
return true; return true;
} }
@@ -2568,14 +2542,9 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
GetOwner()->InvalidateColBestWidth(view_column); GetOwner()->InvalidateColBestWidth(view_column);
// Send event // Send event
wxWindow *parent = GetParent(); wxDataViewColumn* const column = m_owner->GetColumn(view_column);
wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId()); wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner, column, item);
le.SetEventObject(parent); m_owner->ProcessWindowEvent(le);
le.SetModel(GetModel());
le.SetItem(item);
le.SetColumn(view_column);
le.SetDataViewColumn(GetOwner()->GetColumn(view_column));
parent->ProcessWindowEvent(le);
return true; return true;
} }
@@ -2824,14 +2793,8 @@ bool wxDataViewMainWindow::IsRowSelected( unsigned int row )
void wxDataViewMainWindow::SendSelectionChangedEvent( const wxDataViewItem& item) void wxDataViewMainWindow::SendSelectionChangedEvent( const wxDataViewItem& item)
{ {
wxWindow *parent = GetParent(); wxDataViewEvent le(wxEVT_DATAVIEW_SELECTION_CHANGED, m_owner, item);
wxDataViewEvent le(wxEVT_DATAVIEW_SELECTION_CHANGED, parent->GetId()); m_owner->ProcessWindowEvent(le);
le.SetEventObject(parent);
le.SetModel(GetModel());
le.SetItem( item );
parent->ProcessWindowEvent(le);
} }
void wxDataViewMainWindow::RefreshRow( unsigned int row ) void wxDataViewMainWindow::RefreshRow( unsigned int row )
@@ -3122,14 +3085,8 @@ bool
wxDataViewMainWindow::SendExpanderEvent(wxEventType type, wxDataViewMainWindow::SendExpanderEvent(wxEventType type,
const wxDataViewItem& item) const wxDataViewItem& item)
{ {
wxWindow *parent = GetParent(); wxDataViewEvent le(type, m_owner, item);
wxDataViewEvent le(type, parent->GetId()); return !m_owner->ProcessWindowEvent(le) || le.IsAllowed();
le.SetEventObject(parent);
le.SetModel(GetModel());
le.SetItem( item );
return !parent->ProcessWindowEvent(le) || le.IsAllowed();
} }
bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
@@ -3709,13 +3666,8 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
const wxDataViewItem item = GetItemByRow(m_currentRow); const wxDataViewItem item = GetItemByRow(m_currentRow);
wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, m_owner, item);
parent->GetId()); if ( m_owner->ProcessWindowEvent(le) )
le.SetItem(item);
le.SetEventObject(parent);
le.SetModel(GetModel());
if ( parent->ProcessWindowEvent(le) )
break; break;
// else: fall through to WXK_SPACE handling // else: fall through to WXK_SPACE handling
} }
@@ -4121,19 +4073,8 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
// the other ones. // the other ones.
if (event.RightUp()) if (event.RightUp())
{ {
wxWindow *parent = GetParent(); wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, m_owner, col, item);
wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, parent->GetId()); m_owner->ProcessWindowEvent(le);
le.SetEventObject(parent);
le.SetModel(model);
if ( item.IsOk() && col )
{
le.SetItem( item );
le.SetColumn( col->GetModelColumn() );
le.SetDataViewColumn( col );
}
parent->ProcessWindowEvent(le);
return; return;
} }
@@ -4162,10 +4103,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
wxDataViewItem itemDragged = GetItemByRow( drag_item_row ); wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
// Notify cell about drag // Notify cell about drag
wxDataViewEvent evt( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() ); wxDataViewEvent evt(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner, itemDragged);
evt.SetEventObject( m_owner );
evt.SetItem( itemDragged );
evt.SetModel( model );
if (!m_owner->HandleWindowEvent( evt )) if (!m_owner->HandleWindowEvent( evt ))
return; return;
@@ -4279,15 +4217,8 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
{ {
if ( !hoverOverExpander && (current == m_lineLastClicked) ) if ( !hoverOverExpander && (current == m_lineLastClicked) )
{ {
wxWindow *parent = GetParent(); wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, m_owner, col, item);
wxDataViewEvent le(wxEVT_DATAVIEW_ITEM_ACTIVATED, parent->GetId()); if ( m_owner->ProcessWindowEvent(le) )
le.SetItem( item );
le.SetColumn( col->GetModelColumn() );
le.SetDataViewColumn( col );
le.SetEventObject(parent);
le.SetModel(GetModel());
if ( parent->ProcessWindowEvent(le) )
{ {
// Item activation was handled from the user code. // Item activation was handled from the user code.
return; return;

View File

@@ -979,9 +979,8 @@ wxgtk_tree_model_set_sort_column_id (GtkTreeSortable *sortable,
if (gs_lastLeftClickHeader) if (gs_lastLeftClickHeader)
{ {
wxDataViewCtrl *dv = tree_model->internal->GetOwner(); wxDataViewCtrl *dv = tree_model->internal->GetOwner();
wxDataViewEvent event( wxEVT_DATAVIEW_COLUMN_SORTED, dv->GetId() ); wxDataViewEvent
event.SetDataViewColumn( gs_lastLeftClickHeader ); event(wxEVT_DATAVIEW_COLUMN_SORTED, dv, gs_lastLeftClickHeader);
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
} }
@@ -1129,11 +1128,7 @@ static GtkCellEditable *gtk_wx_cell_renderer_text_start_editing(
item(column->GetOwner()->GTKPathToItem(wxGtkTreePath(path))); item(column->GetOwner()->GTKPathToItem(wxGtkTreePath(path)));
wxDataViewCtrl *dv = column->GetOwner(); wxDataViewCtrl *dv = column->GetOwner();
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_START_EDITING, dv->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_START_EDITING, dv, column, item);
event.SetDataViewColumn( column );
event.SetModel( dv->GetModel() );
event.SetColumn( column->GetModelColumn() );
event.SetItem( item );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
if (event.IsAllowed()) if (event.IsAllowed())
@@ -3002,9 +2997,7 @@ gtk_dataview_header_button_press_callback( GtkWidget *WXUNUSED(widget),
gs_lastLeftClickHeader = column; gs_lastLeftClickHeader = column;
wxDataViewCtrl *dv = column->GetOwner(); wxDataViewCtrl *dv = column->GetOwner();
wxDataViewEvent event( wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, dv->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, dv, column);
event.SetDataViewColumn( column );
event.SetModel( dv->GetModel() );
if (dv->HandleWindowEvent( event )) if (dv->HandleWindowEvent( event ))
return FALSE; return FALSE;
} }
@@ -3012,9 +3005,8 @@ gtk_dataview_header_button_press_callback( GtkWidget *WXUNUSED(widget),
if (gdk_event->button == 3) if (gdk_event->button == 3)
{ {
wxDataViewCtrl *dv = column->GetOwner(); wxDataViewCtrl *dv = column->GetOwner();
wxDataViewEvent event( wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, dv->GetId() ); wxDataViewEvent
event.SetDataViewColumn( column ); event(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, dv, column);
event.SetModel( dv->GetModel() );
if (dv->HandleWindowEvent( event )) if (dv->HandleWindowEvent( event ))
return FALSE; return FALSE;
} }
@@ -3605,14 +3597,12 @@ gboolean wxDataViewCtrlInternal::row_draggable( GtkTreeDragSource *WXUNUSED(drag
delete m_dragDataObject; delete m_dragDataObject;
m_dragDataObject = NULL; m_dragDataObject = NULL;
wxDataViewItem item(GetOwner()->GTKPathToItem(path)); wxDataViewCtrl* const dvc = GetOwner();
wxDataViewItem item(dvc->GTKPathToItem(path));
if ( !item ) if ( !item )
return FALSE; return FALSE;
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, dvc, item);
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( m_wx_model );
gint x, y; gint x, y;
gtk_widget_get_pointer(m_owner->GtkGetTreeView(), &x, &y); gtk_widget_get_pointer(m_owner->GtkGetTreeView(), &x, &y);
event.SetPosition(x, y); event.SetPosition(x, y);
@@ -3676,10 +3666,7 @@ wxDataViewCtrlInternal::drag_data_received(GtkTreeDragDest *WXUNUSED(drag_dest),
{ {
wxDataViewItem item(GetOwner()->GTKPathToItem(path)); wxDataViewItem item(GetOwner()->GTKPathToItem(path));
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP, m_owner->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, m_owner, item);
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( m_wx_model );
event.SetDataFormat(gtk_selection_data_get_target(selection_data)); event.SetDataFormat(gtk_selection_data_get_target(selection_data));
event.SetDataSize(gtk_selection_data_get_length(selection_data)); event.SetDataSize(gtk_selection_data_get_length(selection_data));
event.SetDataBuffer(const_cast<guchar*>(gtk_selection_data_get_data(selection_data))); event.SetDataBuffer(const_cast<guchar*>(gtk_selection_data_get_data(selection_data)));
@@ -3699,10 +3686,7 @@ wxDataViewCtrlInternal::row_drop_possible(GtkTreeDragDest *WXUNUSED(drag_dest),
{ {
wxDataViewItem item(GetOwner()->GTKPathToItem(path)); wxDataViewItem item(GetOwner()->GTKPathToItem(path));
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner, item);
event.SetEventObject( m_owner );
event.SetItem( item );
event.SetModel( m_wx_model );
event.SetDataFormat(gtk_selection_data_get_target(selection_data)); event.SetDataFormat(gtk_selection_data_get_target(selection_data));
event.SetDataSize(gtk_selection_data_get_length(selection_data)); event.SetDataSize(gtk_selection_data_get_length(selection_data));
if (!m_owner->HandleWindowEvent( event )) if (!m_owner->HandleWindowEvent( event ))
@@ -3822,10 +3806,7 @@ bool wxDataViewCtrlInternal::ItemDeleted( const wxDataViewItem &parent, const wx
bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem &item ) bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem &item )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner->GetId() ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner, item);
event.SetEventObject( m_owner );
event.SetModel( m_owner->GetModel() );
event.SetItem( item );
m_owner->HandleWindowEvent( event ); m_owner->HandleWindowEvent( event );
return true; return true;
@@ -3833,12 +3814,9 @@ bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem &item )
bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned int view_column ) bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned int view_column )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner->GetId() ); wxDataViewColumn* const column = m_owner->GetColumn(view_column);
event.SetEventObject( m_owner ); wxDataViewEvent
event.SetModel( m_owner->GetModel() ); event(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_owner, column, item);
event.SetColumn( view_column );
event.SetDataViewColumn( GetOwner()->GetColumn(view_column) );
event.SetItem( item );
m_owner->HandleWindowEvent( event ); m_owner->HandleWindowEvent( event );
return true; return true;
@@ -4371,10 +4349,8 @@ wxdataview_selection_changed_callback( GtkTreeSelection* WXUNUSED(selection), wx
if (!gtk_widget_get_realized(dv->m_widget)) if (!gtk_widget_get_realized(dv->m_widget))
return; return;
wxDataViewEvent event( wxEVT_DATAVIEW_SELECTION_CHANGED, dv->GetId() ); wxDataViewEvent
event.SetEventObject( dv ); event(wxEVT_DATAVIEW_SELECTION_CHANGED, dv, dv->GetSelection());
event.SetItem( dv->GetSelection() );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
} }
@@ -4382,11 +4358,8 @@ static void
wxdataview_row_activated_callback( GtkTreeView* WXUNUSED(treeview), GtkTreePath *path, wxdataview_row_activated_callback( GtkTreeView* WXUNUSED(treeview), GtkTreePath *path,
GtkTreeViewColumn *WXUNUSED(column), wxDataViewCtrl *dv ) GtkTreeViewColumn *WXUNUSED(column), wxDataViewCtrl *dv )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_ACTIVATED, dv->GetId() );
wxDataViewItem item(dv->GTKPathToItem(path)); wxDataViewItem item(dv->GTKPathToItem(path));
event.SetItem( item ); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_ACTIVATED, dv, item);
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
} }
@@ -4394,11 +4367,8 @@ static gboolean
wxdataview_test_expand_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter, wxdataview_test_expand_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv ) GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EXPANDING, dv->GetId() ); wxDataViewItem item( (void*) iter->user_data );
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDING, dv, item);
wxDataViewItem item( (void*) iter->user_data );;
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
return !event.IsAllowed(); return !event.IsAllowed();
@@ -4408,11 +4378,8 @@ static void
wxdataview_row_expanded_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter, wxdataview_row_expanded_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv ) GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_EXPANDED, dv->GetId() ); wxDataViewItem item( (void*) iter->user_data );
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDED, dv, item);
wxDataViewItem item( (void*) iter->user_data );;
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
} }
@@ -4420,11 +4387,8 @@ static gboolean
wxdataview_test_collapse_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter, wxdataview_test_collapse_row_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv ) GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_COLLAPSING, dv->GetId() ); wxDataViewItem item( (void*) iter->user_data );
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSING, dv, item);
wxDataViewItem item( (void*) iter->user_data );;
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
return !event.IsAllowed(); return !event.IsAllowed();
@@ -4434,11 +4398,8 @@ static void
wxdataview_row_collapsed_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter, wxdataview_row_collapsed_callback( GtkTreeView* WXUNUSED(treeview), GtkTreeIter* iter,
GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv ) GtkTreePath *WXUNUSED(path), wxDataViewCtrl *dv )
{ {
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_COLLAPSED, dv->GetId() ); wxDataViewItem item( (void*) iter->user_data );
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSED, dv, item);
wxDataViewItem item( (void*) iter->user_data );;
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event ); dv->HandleWindowEvent( event );
} }
@@ -4531,10 +4492,8 @@ gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget),
gtk_tree_selection_select_path(selection, path); gtk_tree_selection_select_path(selection, path);
} }
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, dv->GetId() ); wxDataViewEvent
if (path) event(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, dv, dv->GTKPathToItem(path));
event.SetItem(dv->GTKPathToItem(path));
event.SetModel( dv->GetModel() );
return dv->HandleWindowEvent( event ); return dv->HandleWindowEvent( event );
} }

View File

@@ -544,10 +544,7 @@ outlineView:(NSOutlineView*)outlineView
wxCHECK_MSG( dvc->GetModel(), false, wxCHECK_MSG( dvc->GetModel(), false,
"Pointer to model not set correctly." ); "Pointer to model not set correctly." );
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, dvc->GetId()); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP, dvc, wxDataViewItemFromItem(item));
event.SetEventObject(dvc);
event.SetItem(wxDataViewItemFromItem(item));
event.SetModel(dvc->GetModel());
BOOL dragSuccessful = false; BOOL dragSuccessful = false;
if ( [bestType compare:DataViewPboardType] == NSOrderedSame ) if ( [bestType compare:DataViewPboardType] == NSOrderedSame )
@@ -755,16 +752,10 @@ outlineView:(NSOutlineView*)outlineView
// send first the event to wxWidgets that the sorting has changed so that // send first the event to wxWidgets that the sorting has changed so that
// the program can do special actions before the sorting actually starts: // the program can do special actions before the sorting actually starts:
wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_SORTED,dvc->GetId()); // variable definition wxDataViewColumn* const col = noOfDescriptors > 0
? [[wxSortDescriptors objectAtIndex:0] columnPtr]
event.SetEventObject(dvc); : NULL;
if (noOfDescriptors > 0) wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_SORTED, dvc, col);
{
wxDataViewColumn* const col = [[wxSortDescriptors objectAtIndex:0] columnPtr];
event.SetColumn(dvc->GetColumnPosition(col));
event.SetDataViewColumn(col);
}
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
// start re-ordering the data; // start re-ordering the data;
@@ -793,12 +784,7 @@ outlineView:(NSOutlineView*)outlineView
wxCHECK_MSG(dvc, false, "Pointer to data view control not set correctly."); wxCHECK_MSG(dvc, false, "Pointer to data view control not set correctly.");
wxCHECK_MSG(dvc->GetModel(), false, "Pointer to model not set correctly."); wxCHECK_MSG(dvc->GetModel(), false, "Pointer to model not set correctly.");
wxDataViewEvent wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, dvc, wxDataViewItemFromItem(item));
event(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE,dvc->GetId());
event.SetEventObject(dvc);
event.SetItem(wxDataViewItemFromItem(item));
event.SetModel(dvc->GetModel());
if ([bestType compare:DataViewPboardType] == NSOrderedSame) if ([bestType compare:DataViewPboardType] == NSOrderedSame)
{ {
NSArray* dataArray((NSArray*)[pasteboard propertyListForType:DataViewPboardType]); NSArray* dataArray((NSArray*)[pasteboard propertyListForType:DataViewPboardType]);
@@ -898,22 +884,16 @@ outlineView:(NSOutlineView*)outlineView
// send a begin drag event for all selected items and proceed with // send a begin drag event for all selected items and proceed with
// dragging unless the event is vetoed: // dragging unless the event is vetoed:
wxDataViewEvent
event(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG,dvc->GetId());
event.SetEventObject(dvc);
event.SetModel(dvc->GetModel());
for (size_t itemCounter=0; itemCounter<[writeItems count]; ++itemCounter) for (size_t itemCounter=0; itemCounter<[writeItems count]; ++itemCounter)
{ {
bool itemStringAvailable(false); // a flag indicating if for the current item a string is available bool itemStringAvailable(false); // a flag indicating if for the current item a string is available
wxDataObjectComposite* itemObject(new wxDataObjectComposite()); // data object for current item wxDataObjectComposite* itemObject(new wxDataObjectComposite()); // data object for current item
wxString itemString; // contains the TAB concatenated data of an item wxString itemString; // contains the TAB concatenated data of an item
event.SetItem( const wxDataViewItem item = wxDataViewItemFromItem([writeItems objectAtIndex:itemCounter]);
wxDataViewItemFromItem([writeItems objectAtIndex:itemCounter])); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, dvc, item);
itemString = ::ConcatenateDataViewItemValues(dvc,event.GetItem()); itemString = ::ConcatenateDataViewItemValues(dvc, item);
itemObject->Add(new wxTextDataObject(itemString)); itemObject->Add(new wxTextDataObject(itemString));
event.SetDataObject(itemObject);
// check if event has not been vetoed: // check if event has not been vetoed:
if (dvc->HandleWindowEvent(event) && event.IsAllowed() && (event.GetDataObject()->GetFormatCount() > 0)) if (dvc->HandleWindowEvent(event) && event.IsAllowed() && (event.GetDataObject()->GetFormatCount() > 0))
{ {
@@ -1616,11 +1596,8 @@ outlineView:(NSOutlineView*)outlineView
// sent whether the cell is editable or not // sent whether the cell is editable or not
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_ACTIVATED,dvc->GetId()); const wxDataViewItem item = wxDataViewItemFromItem([self itemAtRow:[self clickedRow]]);
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_ACTIVATED, dvc, item);
event.SetEventObject(dvc);
event.SetItem(wxDataViewItemFromItem([self itemAtRow:[self clickedRow]]));
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
} }
@@ -1633,12 +1610,8 @@ outlineView:(NSOutlineView*)outlineView
characterAtIndex: 0] == NSCarriageReturnCharacter ) characterAtIndex: 0] == NSCarriageReturnCharacter )
{ {
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
const wxDataViewItem item = wxDataViewItem( [[self itemAtRow:[self selectedRow]] pointer]);
wxDataViewEvent eventDV( wxEVT_DATAVIEW_ITEM_ACTIVATED, dvc->GetId() ); wxDataViewEvent eventDV(wxEVT_DATAVIEW_ITEM_ACTIVATED, dvc, item);
eventDV.SetEventObject(dvc);
eventDV.SetItem( wxDataViewItem( [[self itemAtRow:[self selectedRow]] pointer]) );
eventDV.SetModel( dvc->GetModel() );
if ( !dvc->GetEventHandler()->ProcessEvent(eventDV) ) if ( !dvc->GetEventHandler()->ProcessEvent(eventDV) )
[super keyDown:event]; [super keyDown:event];
} }
@@ -1660,19 +1633,16 @@ outlineView:(NSOutlineView*)outlineView
// menu should be shown or not // menu should be shown or not
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU,dvc->GetId());
wxDataViewItemArray selectedItems;
event.SetEventObject(dvc);
event.SetModel(dvc->GetModel());
// get the item information; // get the item information;
// theoretically more than one ID can be returned but the event can only // theoretically more than one ID can be returned but the event can only
// handle one item, therefore only the first item of the array is // handle one item, therefore only the first item of the array is
// returned: // returned:
wxDataViewItem item;
wxDataViewItemArray selectedItems;
if (dvc->GetSelections(selectedItems) > 0) if (dvc->GetSelections(selectedItems) > 0)
event.SetItem(selectedItems[0]); item = selectedItems[0];
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, dvc, item);
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
// nothing is done: // nothing is done:
return nil; return nil;
@@ -1688,14 +1658,8 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent
event(wxEVT_DATAVIEW_COLUMN_HEADER_CLICK,dvc->GetId());
// first, send an event that the user clicked into a column's header: // first, send an event that the user clicked into a column's header:
event.SetEventObject(dvc); wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, dvc, col);
event.SetColumn(dvc->GetColumnPosition(col));
event.SetDataViewColumn(col);
dvc->HandleWindowEvent(event); dvc->HandleWindowEvent(event);
// now, check if the click may have had an influence on sorting, too; // now, check if the click may have had an influence on sorting, too;
@@ -1731,13 +1695,7 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSING,dvc->GetId()); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSING, dvc, wxDataViewItemFromItem(item));
event.SetEventObject(dvc);
event.SetItem (wxDataViewItemFromItem(item));
event.SetModel (dvc->GetModel());
// finally send the equivalent wxWidget event:
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
// opening the container is allowed if not vetoed: // opening the container is allowed if not vetoed:
return event.IsAllowed(); return event.IsAllowed();
@@ -1749,13 +1707,7 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDING,dvc->GetId()); wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDING, dvc, wxDataViewItemFromItem(item));
event.SetEventObject(dvc);
event.SetItem (wxDataViewItemFromItem(item));
event.SetModel (dvc->GetModel());
// finally send the equivalent wxWidget event:
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
// opening the container is allowed if not vetoed: // opening the container is allowed if not vetoed:
return event.IsAllowed(); return event.IsAllowed();
@@ -1818,12 +1770,7 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED,dvc->GetId()); wxDataViewEvent event(wxEVT_DATAVIEW_COLUMN_REORDERED, dvc, col);
event.SetEventObject(dvc);
event.SetColumn(dvc->GetColumnPosition(col));
event.SetDataViewColumn(col);
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
} }
@@ -1831,12 +1778,9 @@ outlineView:(NSOutlineView*)outlineView
{ {
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSED,dvc->GetId()); const wxDataViewItem item = wxDataViewItemFromItem(
[[notification userInfo] objectForKey:@"NSObject"]);
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_COLLAPSED, dvc, item);
event.SetEventObject(dvc);
event.SetItem(wxDataViewItemFromItem(
[[notification userInfo] objectForKey:@"NSObject"]));
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
} }
@@ -1844,12 +1788,9 @@ outlineView:(NSOutlineView*)outlineView
{ {
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDED,dvc->GetId()); const wxDataViewItem item = wxDataViewItemFromItem(
[[notification userInfo] objectForKey:@"NSObject"]);
wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EXPANDED, dvc, item);
event.SetEventObject(dvc);
event.SetItem(wxDataViewItemFromItem(
[[notification userInfo] objectForKey:@"NSObject"]));
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
} }
@@ -1859,11 +1800,7 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
wxDataViewEvent event(wxEVT_DATAVIEW_SELECTION_CHANGED,dvc->GetId()); wxDataViewEvent event(wxEVT_DATAVIEW_SELECTION_CHANGED, dvc, dvc->GetSelection());
event.SetEventObject(dvc);
event.SetModel(dvc->GetModel());
event.SetItem(dvc->GetSelection());
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);
} }
@@ -1928,15 +1865,11 @@ outlineView:(NSOutlineView*)outlineView
wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl(); wxDataViewCtrl* const dvc = implementation->GetDataViewCtrl();
// send event to wxWidgets: const wxDataViewItem
wxDataViewEvent item = wxDataViewItemFromItem([self itemAtRow:currentlyEditedRow]);
event(wxEVT_DATAVIEW_ITEM_EDITING_DONE,dvc->GetId());
event.SetEventObject(dvc); // send event to wxWidgets:
event.SetItem( wxDataViewEvent event(wxEVT_DATAVIEW_ITEM_EDITING_DONE, dvc, col, item);
wxDataViewItemFromItem([self itemAtRow:currentlyEditedRow]));
event.SetColumn(dvc->GetColumnPosition(col));
event.SetDataViewColumn(col);
dvc->GetEventHandler()->ProcessEvent(event); dvc->GetEventHandler()->ProcessEvent(event);

View File

@@ -122,13 +122,8 @@ bool wxOSXDataViewModelNotifier::ItemChanged(wxDataViewItem const& item)
wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized."); wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized.");
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item))
{ {
// sent the equivalent wxWidget event: // send the equivalent wxWidgets event:
wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_DataViewCtrlPtr, item);
dataViewEvent.SetEventObject(m_DataViewCtrlPtr);
dataViewEvent.SetModel(m_DataViewCtrlPtr->GetModel());
dataViewEvent.SetItem(item);
// sent the equivalent wxWidget event:
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
// row height may have to be adjusted: // row height may have to be adjusted:
AdjustRowHeight(item); AdjustRowHeight(item);
@@ -144,16 +139,11 @@ bool wxOSXDataViewModelNotifier::ItemsChanged(wxDataViewItemArray const& items)
{ {
size_t const noOfItems = items.GetCount(); size_t const noOfItems = items.GetCount();
wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId());
dataViewEvent.SetEventObject(m_DataViewCtrlPtr);
dataViewEvent.SetModel(m_DataViewCtrlPtr->GetModel());
for (size_t indexItem=0; indexItem<noOfItems; ++indexItem) for (size_t indexItem=0; indexItem<noOfItems; ++indexItem)
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(items[indexItem]),items[indexItem])) if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(items[indexItem]),items[indexItem]))
{ {
// send for all changed items a wxWidget event: // send for all changed items a wxWidgets event:
dataViewEvent.SetItem(items[indexItem]); wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr,items[indexItem]);
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
} }
else else
@@ -211,13 +201,9 @@ bool wxOSXDataViewModelNotifier::ValueChanged(wxDataViewItem const& item, unsign
wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized."); wxCHECK_MSG(GetOwner() != NULL,false,"Owner not initialized.");
if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item)) if (m_DataViewCtrlPtr->GetDataViewPeer()->Update(GetOwner()->GetParent(item),item))
{ {
wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED,m_DataViewCtrlPtr->GetId()); wxDataViewEvent dataViewEvent(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, m_DataViewCtrlPtr, m_DataViewCtrlPtr->GetColumn(col), item);
dataViewEvent.SetEventObject(m_DataViewCtrlPtr); // send the equivalent wxWidgets event:
dataViewEvent.SetModel(m_DataViewCtrlPtr->GetModel());
dataViewEvent.SetColumn(col);
dataViewEvent.SetItem(item);
// send the equivalent wxWidget event:
m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent); m_DataViewCtrlPtr->HandleWindowEvent(dataViewEvent);
AdjustAutosizedColumns(); AdjustAutosizedColumns();