]> git.saurik.com Git - wxWidgets.git/commitdiff
Add row activated event.
authorRobert Roebling <robert@roebling.de>
Wed, 4 Oct 2006 13:23:20 +0000 (13:23 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 4 Oct 2006 13:23:20 +0000 (13:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dataview.h
samples/dataview/dataview.cpp
src/common/datavcmn.cpp
src/gtk/dataview.cpp

index a27aed068d7fb6d80ec4814cd6ac2ab8dc7504b4..2a25f409c098742696f2cc76fae60eb18b25d7f8 100644 (file)
@@ -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)
index fb385b20128509423eba9cddd7d8347e6c15c5a2..55e5f7340ed2c12a5aca49335745ae0085c794de 100644 (file)
@@ -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);
index 646005e09550274c5ff47b15f842d1688ba96d15..2f7c9fe6a2dd1e9d520d23dbaaa6cc76c652d7b8 100644 (file)
@@ -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
index 445ba528523311f9479c72e3c016230c3893551b..eec47ab88b70d021b6f126acc9c524ccf01cb2f1 100644 (file)
@@ -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);