From f828871d12d34950779ed29599cbd13f05e00992 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Wed, 4 Oct 2006 13:23:20 +0000 Subject: [PATCH] Add row activated event. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dataview.h | 2 ++ samples/dataview/dataview.cpp | 10 +++++++++- src/common/datavcmn.cpp | 1 + src/gtk/dataview.cpp | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/wx/dataview.h b/include/wx/dataview.h index a27aed068d..2a25f409c0 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -382,6 +382,7 @@ private: 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&); @@ -393,6 +394,7 @@ 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) diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp index fb385b2012..55e5f7340e 100644 --- a/samples/dataview/dataview.cpp +++ b/samples/dataview/dataview.cpp @@ -305,7 +305,8 @@ enum my_events ID_EDIT_ROW_RIGHT, ID_SORTED, - ID_UNSORTED + ID_UNSORTED, + ID_ACTIVATED }; class MySortingFrame: public wxFrame @@ -335,6 +336,7 @@ public: void OnSelectedUnsorted(wxDataViewEvent &event); void OnSelectedSorted(wxDataViewEvent &event); + void OnActivatedUnsorted(wxDataViewEvent &event); private: wxDataViewCtrl* dataview_left; @@ -471,6 +473,7 @@ BEGIN_EVENT_TABLE(MySortingFrame,wxFrame) 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): @@ -584,6 +587,11 @@ void MySortingFrame::OnSelectedSorted(wxDataViewEvent &event) 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); diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 646005e095..2f7c9fe6a2 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -811,6 +811,7 @@ wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED) #endif diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 445ba52852..eec47ab88b 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1490,6 +1490,17 @@ wxdataview_selection_changed_callback( GtkTreeSelection* selection, wxDataViewCt 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 //----------------------------------------------------------------------------- @@ -1545,6 +1556,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, 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); -- 2.47.2