Add row activated event.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41626 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-10-04 13:23:20 +00:00
parent 97c7099a70
commit f828871d12
4 changed files with 25 additions and 1 deletions

View File

@@ -382,6 +382,7 @@ private:
BEGIN_DECLARE_EVENT_TYPES() BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, -1) DECLARE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED, -1)
DECLARE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED, -1)
END_DECLARE_EVENT_TYPES() END_DECLARE_EVENT_TYPES()
typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
@@ -393,6 +394,7 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&);
wx__DECLARE_EVT1(wxEVT_COMMAND_DATAVIEW_ ## evt, id, wxDataViewEventHandler(fn)) 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_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) #if defined(wxUSE_GENERICDATAVIEWCTRL)

View File

@@ -305,7 +305,8 @@ enum my_events
ID_EDIT_ROW_RIGHT, ID_EDIT_ROW_RIGHT,
ID_SORTED, ID_SORTED,
ID_UNSORTED ID_UNSORTED,
ID_ACTIVATED
}; };
class MySortingFrame: public wxFrame class MySortingFrame: public wxFrame
@@ -335,6 +336,7 @@ public:
void OnSelectedUnsorted(wxDataViewEvent &event); void OnSelectedUnsorted(wxDataViewEvent &event);
void OnSelectedSorted(wxDataViewEvent &event); void OnSelectedSorted(wxDataViewEvent &event);
void OnActivatedUnsorted(wxDataViewEvent &event);
private: private:
wxDataViewCtrl* dataview_left; wxDataViewCtrl* dataview_left;
@@ -471,6 +473,7 @@ BEGIN_EVENT_TABLE(MySortingFrame,wxFrame)
EVT_BUTTON( ID_UNSELECT_ALL, MySortingFrame::OnUnselectAll ) EVT_BUTTON( ID_UNSELECT_ALL, MySortingFrame::OnUnselectAll )
EVT_DATAVIEW_ROW_SELECTED( ID_SORTED, MySortingFrame::OnSelectedSorted ) EVT_DATAVIEW_ROW_SELECTED( ID_SORTED, MySortingFrame::OnSelectedSorted )
EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted ) EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted )
EVT_DATAVIEW_ROW_ACTIVATED( ID_UNSORTED, MySortingFrame::OnActivatedUnsorted )
END_EVENT_TABLE() END_EVENT_TABLE()
MySortingFrame::MySortingFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h): 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() ); 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) ) void MySortingFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{ {
Close(true); Close(true);

View File

@@ -811,6 +811,7 @@ wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos )
IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED)
DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED)
#endif #endif

View File

@@ -1490,6 +1490,17 @@ wxdataview_selection_changed_callback( GtkTreeSelection* selection, wxDataViewCt
dv->GetEventHandler()->ProcessEvent( event ); 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 // wxDataViewCtrl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -1545,6 +1556,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) ); GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
g_signal_connect_after (selection, "changed", g_signal_connect_after (selection, "changed",
G_CALLBACK (wxdataview_selection_changed_callback), this); G_CALLBACK (wxdataview_selection_changed_callback), this);
g_signal_connect_after (m_treeview, "row_activated",
G_CALLBACK (wxdataview_row_activated_callback), this);
PostCreation(size); PostCreation(size);