ID_INSERT_ROW_LEFT,
ID_DELETE_ROW_LEFT,
ID_EDIT_ROW_LEFT,
+
+ ID_SELECT,
+ ID_UNSELECT_ALL,
ID_APPEND_ROW_RIGHT,
ID_PREPEND_ROW_RIGHT,
void OnDeleteRowRight(wxCommandEvent& event);
void OnEditRowRight(wxCommandEvent& event);
+ void OnSelect(wxCommandEvent& event);
+ void OnUnselectAll(wxCommandEvent& event);
+
void OnSelectedUnsorted(wxDataViewEvent &event);
void OnSelectedSorted(wxDataViewEvent &event);
EVT_BUTTON( ID_PREPEND_ROW_LEFT, MySortingFrame::OnPrependRowLeft )
EVT_BUTTON( ID_INSERT_ROW_LEFT, MySortingFrame::OnInsertRowLeft )
EVT_BUTTON( ID_DELETE_ROW_LEFT, MySortingFrame::OnDeleteRowLeft )
+ EVT_BUTTON( ID_SELECT, MySortingFrame::OnSelect )
+ EVT_BUTTON( ID_UNSELECT_ALL, MySortingFrame::OnUnselectAll )
EVT_DATAVIEW_ROW_SELECTED( ID_SORTED, MySortingFrame::OnSelectedSorted )
EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted )
END_EVENT_TABLE()
left_sizer->Add( new wxButton( this, ID_INSERT_ROW_LEFT, wxT("Insert") ), 0, wxALL, 5 );
left_sizer->Add( new wxButton( this, ID_DELETE_ROW_LEFT, wxT("Delete second") ), 0, wxALL, 5 );
left_sizer->Add( new wxButton( this, ID_EDIT_ROW_LEFT, wxT("Edit") ), 0, wxALL, 5 );
+ left_sizer->Add( 5,5 );
+ left_sizer->Add( new wxButton( this, ID_SELECT, wxT("Select third") ), 0, wxALL, 5 );
+ left_sizer->Add( new wxButton( this, ID_UNSELECT_ALL, wxT("Unselect all") ), 0, wxALL, 5 );
button_sizer->Add( left_sizer );
button_sizer->Add( 10, 10, 2 );
wxFlexGridSizer *right_sizer = new wxFlexGridSizer( 2 );
void MySortingFrame::OnSelectedUnsorted(wxDataViewEvent &event)
{
- wxLogMessage( wxT("OnSelected from unsorted list, selected %d"), (int) event.GetRow() );
+ int row = event.GetRow();
+ wxLogMessage( wxT("OnSelected from unsorted list, selected %d"), row );
+ if (row >= 0)
+ wxLogMessage( wxT("wxDataViewCtrl::IsSelected( %d ): %d (as int)"),
+ row, (int) dataview_right->IsSelected( row ) );
}
void MySortingFrame::OnSelectedSorted(wxDataViewEvent &event)
dialog.ShowModal();
}
+void MySortingFrame::OnSelect(wxCommandEvent& WXUNUSED(event))
+{
+ dataview_left->SetSelection( 2 );
+}
+
+void MySortingFrame::OnUnselectAll(wxCommandEvent& WXUNUSED(event))
+{
+ dataview_left->ClearSelection();
+}
+
void MySortingFrame::OnAppendRowLeft(wxCommandEvent& WXUNUSED(event))
{
wxTextEntryDialog dialog( this, wxT("Enter text to append") );
void wxDataViewCtrl::SetSelection( int row )
{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
+
+ if (row < 0)
+ {
+ gtk_tree_selection_unselect_all( selection );
+ }
+ else
+ {
+ GtkTreePath *path = gtk_tree_path_new ();
+ gtk_tree_path_append_index( path, row );
+
+ gtk_tree_selection_select_path( selection, path );
+
+ gtk_tree_path_free( path );
+ }
+}
+
+void wxDataViewCtrl::Unselect( unsigned int row )
+{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
+
+ GtkTreePath *path = gtk_tree_path_new ();
+ gtk_tree_path_append_index( path, row );
+
+ gtk_tree_selection_unselect_path( selection, path );
+
+ gtk_tree_path_free( path );
}
void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to )
bool wxDataViewCtrl::IsSelected( unsigned int row ) const
{
- return false;
+ GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
+
+ GtkTreePath *path = gtk_tree_path_new ();
+ gtk_tree_path_append_index( path, row );
+
+ gboolean ret = gtk_tree_selection_path_is_selected( selection, path );
+
+ gtk_tree_path_free( path );
+
+ return ret;
}
int wxDataViewCtrl::GetSelection() const