More selection work in GTK+ version.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#if defined(__WXGTK20__)
|
#if defined(__WXGTK20__)
|
||||||
// for testing
|
// for testing
|
||||||
#define wxUSE_GENERICDATAVIEWCTRL 1
|
// #define wxUSE_GENERICDATAVIEWCTRL 1
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#define wxUSE_GENERICDATAVIEWCTRL 1
|
#define wxUSE_GENERICDATAVIEWCTRL 1
|
||||||
#else
|
#else
|
||||||
@@ -312,6 +312,7 @@ public:
|
|||||||
|
|
||||||
virtual void SetSelection( int row ) = 0; // -1 for unselect
|
virtual void SetSelection( int row ) = 0; // -1 for unselect
|
||||||
inline void ClearSelection() { SetSelection( -1 ); }
|
inline void ClearSelection() { SetSelection( -1 ); }
|
||||||
|
virtual void Unselect( unsigned int row ) = 0;
|
||||||
virtual void SetSelectionRange( unsigned int from, unsigned int to ) = 0;
|
virtual void SetSelectionRange( unsigned int from, unsigned int to ) = 0;
|
||||||
virtual void SetSelections( const wxArrayInt& aSelections) = 0;
|
virtual void SetSelections( const wxArrayInt& aSelections) = 0;
|
||||||
|
|
||||||
|
@@ -267,6 +267,7 @@ public:
|
|||||||
virtual void SetSelection( int row ); // -1 for unselect
|
virtual void SetSelection( int row ); // -1 for unselect
|
||||||
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
||||||
virtual void SetSelections( const wxArrayInt& aSelections);
|
virtual void SetSelections( const wxArrayInt& aSelections);
|
||||||
|
virtual void Unselect( unsigned int row );
|
||||||
|
|
||||||
virtual bool IsSelected( unsigned int row ) const;
|
virtual bool IsSelected( unsigned int row ) const;
|
||||||
virtual int GetSelection() const;
|
virtual int GetSelection() const;
|
||||||
|
@@ -245,6 +245,7 @@ public:
|
|||||||
virtual void SetSelection( int row ); // -1 for unselect
|
virtual void SetSelection( int row ); // -1 for unselect
|
||||||
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
||||||
virtual void SetSelections( const wxArrayInt& aSelections);
|
virtual void SetSelections( const wxArrayInt& aSelections);
|
||||||
|
virtual void Unselect( unsigned int row );
|
||||||
|
|
||||||
virtual bool IsSelected( unsigned int row ) const;
|
virtual bool IsSelected( unsigned int row ) const;
|
||||||
virtual int GetSelection() const;
|
virtual int GetSelection() const;
|
||||||
|
@@ -294,6 +294,9 @@ enum my_events
|
|||||||
ID_INSERT_ROW_LEFT,
|
ID_INSERT_ROW_LEFT,
|
||||||
ID_DELETE_ROW_LEFT,
|
ID_DELETE_ROW_LEFT,
|
||||||
ID_EDIT_ROW_LEFT,
|
ID_EDIT_ROW_LEFT,
|
||||||
|
|
||||||
|
ID_SELECT,
|
||||||
|
ID_UNSELECT_ALL,
|
||||||
|
|
||||||
ID_APPEND_ROW_RIGHT,
|
ID_APPEND_ROW_RIGHT,
|
||||||
ID_PREPEND_ROW_RIGHT,
|
ID_PREPEND_ROW_RIGHT,
|
||||||
@@ -327,6 +330,9 @@ public:
|
|||||||
void OnDeleteRowRight(wxCommandEvent& event);
|
void OnDeleteRowRight(wxCommandEvent& event);
|
||||||
void OnEditRowRight(wxCommandEvent& event);
|
void OnEditRowRight(wxCommandEvent& event);
|
||||||
|
|
||||||
|
void OnSelect(wxCommandEvent& event);
|
||||||
|
void OnUnselectAll(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnSelectedUnsorted(wxDataViewEvent &event);
|
void OnSelectedUnsorted(wxDataViewEvent &event);
|
||||||
void OnSelectedSorted(wxDataViewEvent &event);
|
void OnSelectedSorted(wxDataViewEvent &event);
|
||||||
|
|
||||||
@@ -461,6 +467,8 @@ BEGIN_EVENT_TABLE(MySortingFrame,wxFrame)
|
|||||||
EVT_BUTTON( ID_PREPEND_ROW_LEFT, MySortingFrame::OnPrependRowLeft )
|
EVT_BUTTON( ID_PREPEND_ROW_LEFT, MySortingFrame::OnPrependRowLeft )
|
||||||
EVT_BUTTON( ID_INSERT_ROW_LEFT, MySortingFrame::OnInsertRowLeft )
|
EVT_BUTTON( ID_INSERT_ROW_LEFT, MySortingFrame::OnInsertRowLeft )
|
||||||
EVT_BUTTON( ID_DELETE_ROW_LEFT, MySortingFrame::OnDeleteRowLeft )
|
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_SORTED, MySortingFrame::OnSelectedSorted )
|
||||||
EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted )
|
EVT_DATAVIEW_ROW_SELECTED( ID_UNSORTED, MySortingFrame::OnSelectedUnsorted )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -528,6 +536,9 @@ MySortingFrame::MySortingFrame(wxFrame *frame, wxChar *title, int x, int y, int
|
|||||||
left_sizer->Add( new wxButton( this, ID_INSERT_ROW_LEFT, wxT("Insert") ), 0, wxALL, 5 );
|
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_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( 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( left_sizer );
|
||||||
button_sizer->Add( 10, 10, 2 );
|
button_sizer->Add( 10, 10, 2 );
|
||||||
wxFlexGridSizer *right_sizer = new wxFlexGridSizer( 2 );
|
wxFlexGridSizer *right_sizer = new wxFlexGridSizer( 2 );
|
||||||
@@ -561,7 +572,11 @@ MySortingFrame::~MySortingFrame()
|
|||||||
|
|
||||||
void MySortingFrame::OnSelectedUnsorted(wxDataViewEvent &event)
|
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)
|
void MySortingFrame::OnSelectedSorted(wxDataViewEvent &event)
|
||||||
@@ -582,6 +597,16 @@ void MySortingFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
|
|||||||
dialog.ShowModal();
|
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))
|
void MySortingFrame::OnAppendRowLeft(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxTextEntryDialog dialog( this, wxT("Enter text to append") );
|
wxTextEntryDialog dialog( this, wxT("Enter text to append") );
|
||||||
|
@@ -1809,6 +1809,10 @@ void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxDataViewCtrl::Unselect( unsigned int row )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::IsSelected( unsigned int row ) const
|
bool wxDataViewCtrl::IsSelected( unsigned int row ) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1583,6 +1583,33 @@ bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
|
|||||||
|
|
||||||
void wxDataViewCtrl::SetSelection( int row )
|
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 )
|
void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to )
|
||||||
@@ -1595,7 +1622,16 @@ void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections)
|
|||||||
|
|
||||||
bool wxDataViewCtrl::IsSelected( unsigned int row ) const
|
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
|
int wxDataViewCtrl::GetSelection() const
|
||||||
|
Reference in New Issue
Block a user