void OnHeaderRightClick( wxDataViewEvent &event );
void OnSorted( wxDataViewEvent &event );
+ void OnContextMenu( wxDataViewEvent &event );
+
void OnRightClick( wxMouseEvent &event );
void OnGoto( wxCommandEvent &event);
EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderClick)
EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick)
EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
+
+ EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu)
EVT_RIGHT_UP(MyFrame::OnRightClick)
END_EVENT_TABLE()
wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title );
}
+void MyFrame::OnContextMenu( wxDataViewEvent &event )
+{
+ if (!m_log)
+ return;
+
+ wxString title = m_music_model->GetTitle( event.GetItem() );
+ wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, Item: %s", title );
+}
+
void MyFrame::OnHeaderClick( wxDataViewEvent &event )
{
if(!m_log)
static gboolean
gtk_dataview_motion_notify_callback( GtkWidget *widget,
- GdkEventMotion *gdk_event,
- wxDataViewCtrl *dv )
+ GdkEventMotion *gdk_event,
+ wxDataViewCtrl *dv )
{
if (gdk_event->is_hint)
{
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "button_press_event"
+//-----------------------------------------------------------------------------
+
+static gboolean
+gtk_dataview_button_press_callback( GtkWidget *WXUNUSED(widget),
+ GdkEventButton *gdk_event,
+ wxDataViewCtrl *dv )
+{
+ if ((gdk_event->button == 3) && (gdk_event->type == GDK_BUTTON_PRESS))
+ {
+ GtkTreePath *path = NULL;
+ GtkTreeViewColumn *column = NULL;
+ gint cell_x = 0;
+ gint cell_y = 0;
+ if (gtk_tree_view_get_path_at_pos(
+ GTK_TREE_VIEW(dv->GtkGetTreeView()),
+ (int) gdk_event->x, (int) gdk_event->y,
+ &path,
+ &column,
+ &cell_x,
+ &cell_y))
+ {
+ if (path)
+ {
+ GtkTreeIter iter;
+ dv->GtkGetInternal()->get_iter( &iter, path );
+
+ wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, dv->GetId() );
+ wxDataViewItem item( (void*) iter.user_data );;
+ event.SetItem( item );
+ event.SetModel( dv->GetModel() );
+ bool ret = dv->HandleWindowEvent( event );
+ gtk_tree_path_free( path );
+ return ret;
+ }
+ }
+ }
+
+ return FALSE;
+}
IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase)
g_signal_connect (m_treeview, "motion_notify_event",
G_CALLBACK (gtk_dataview_motion_notify_callback), this);
+ g_signal_connect (m_treeview, "button_press_event",
+ G_CALLBACK (gtk_dataview_button_press_callback), this);
+
return true;
}