BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, -1)
+ DECLARE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, -1)
END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn))
#define EVT_DATAVIEW_ROW_SELECTED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_SELECTED, id, fn)
+#define EVT_DATAVIEW_ROW_ACTIVATED(id, fn) wx__DECLARE_DATAVIEWEVT(ROW_ACTIVATED, id, fn)
#if defined(wxUSE_GENERICDATAVIEWCTRL)
ID_EDIT_ROW_RIGHT,
ID_SORTED,
- ID_UNSORTED
+ ID_UNSORTED,
+ ID_ACTIVATED
};
class MySortingFrame: public wxFrame
void OnSelectedUnsorted(wxDataViewEvent &event);
void OnSelectedSorted(wxDataViewEvent &event);
+ void OnActivatedUnsorted(wxDataViewEvent &event);
private:
wxDataViewCtrl* dataview_left;
EVT_BUTTON( ID_UNSELECT_ALL, MySortingFrame::OnUnselectAll )
EVT_DATAVIEW_ROW_SELECTED( ID_SORTED, MySortingFrame::OnSelectedSorted )
EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted )
+ EVT_DATAVIEW_ROW_ACTIVATED( ID_UNSORTED, MySortingFrame::OnActivatedUnsorted )
END_EVENT_TABLE()
MySortingFrame::MySortingFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h):
wxLogMessage( wxT("OnSelected from sorted list, selected %d"), (int) event.GetRow() );
}
+void MySortingFrame::OnActivatedUnsorted(wxDataViewEvent &event)
+{
+ wxLogMessage( wxT("OnActivated from unsorted list, activated %d"), (int) event.GetRow() );
+}
+
void MySortingFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
Close(true);
IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED)
#endif
dv->GetEventHandler()->ProcessEvent( event );
}
+static void
+wxdataview_row_activated_callback( GtkTreeView* treeview, GtkTreePath *path,
+ GtkTreeViewColumn *column, wxDataViewCtrl *dv )
+{
+ wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, dv->GetId() );
+ unsigned int row = (unsigned int)gtk_tree_path_get_indices (path)[0];
+ event.SetRow( row );
+ event.SetModel( dv->GetModel() );
+ dv->GetEventHandler()->ProcessEvent( event );
+}
+
//-----------------------------------------------------------------------------
// wxDataViewCtrl
//-----------------------------------------------------------------------------
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
g_signal_connect_after (selection, "changed",
G_CALLBACK (wxdataview_selection_changed_callback), this);
+ g_signal_connect_after (m_treeview, "row_activated",
+ G_CALLBACK (wxdataview_row_activated_callback), this);
PostCreation(size);