Allow NULL model in wxGTK's wxDataViewCtrl.
This is consistent with other ports. Fixes #14616. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75272 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4598,6 +4598,9 @@ void wxDataViewCtrl::OnInternalIdle()
|
||||
{
|
||||
wxWindow::OnInternalIdle();
|
||||
|
||||
if ( !m_internal )
|
||||
return;
|
||||
|
||||
m_internal->OnInternalIdle();
|
||||
|
||||
unsigned int cols = GetColumnCount();
|
||||
@@ -4629,18 +4632,21 @@ bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
||||
bool fixed = (((GetWindowStyle() & wxDV_VARIABLE_LINE_HEIGHT) == 0) || (model->IsVirtualListModel()));
|
||||
gtk_tree_view_set_fixed_height_mode( GTK_TREE_VIEW(m_treeview), fixed );
|
||||
|
||||
m_internal = new wxDataViewCtrlInternal( this, model );
|
||||
if ( model )
|
||||
m_internal = new wxDataViewCtrlInternal( this, model );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::EnableDragSource( const wxDataFormat &format )
|
||||
{
|
||||
wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragSource" );
|
||||
return m_internal->EnableDragSource( format );
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::EnableDropTarget( const wxDataFormat &format )
|
||||
{
|
||||
wxCHECK_MSG( m_internal, false, "model must be associated before calling EnableDragTarget" );
|
||||
return m_internal->EnableDropTarget( format );
|
||||
}
|
||||
|
||||
@@ -4769,6 +4775,7 @@ int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const
|
||||
|
||||
wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const
|
||||
{
|
||||
wxCHECK_MSG( m_internal, NULL, "model must be associated before calling GetSortingColumn" );
|
||||
return m_internal->GetDataViewSortColumn();
|
||||
}
|
||||
|
||||
@@ -4782,6 +4789,8 @@ void wxDataViewCtrl::Expand( const wxDataViewItem & item )
|
||||
|
||||
void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling Collapse" );
|
||||
|
||||
GtkTreeIter iter;
|
||||
iter.user_data = item.GetID();
|
||||
wxGtkTreePath path(m_internal->get_path( &iter ));
|
||||
@@ -4790,6 +4799,8 @@ void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
|
||||
|
||||
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
|
||||
{
|
||||
wxCHECK_MSG( m_internal, false, "model must be associated before calling IsExpanded" );
|
||||
|
||||
GtkTreeIter iter;
|
||||
iter.user_data = item.GetID();
|
||||
wxGtkTreePath path(m_internal->get_path( &iter ));
|
||||
@@ -4801,7 +4812,7 @@ wxDataViewItem wxDataViewCtrl::DoGetCurrentItem() const
|
||||
// The tree doesn't have any current item if it hadn't been created yet but
|
||||
// it's arguably not an error to call this function in this case so just
|
||||
// return an invalid item without asserting.
|
||||
if ( !m_treeview )
|
||||
if ( !m_treeview || !m_internal )
|
||||
return wxDataViewItem();
|
||||
|
||||
wxGtkTreePath path;
|
||||
@@ -4814,6 +4825,7 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
|
||||
{
|
||||
wxCHECK_RET( m_treeview,
|
||||
"Current item can't be set before creating the control." );
|
||||
wxCHECK_RET( m_internal, "model must be associated before setting current item" );
|
||||
|
||||
// We need to make sure the model knows about this item or the path would
|
||||
// be invalid and gtk_tree_view_set_cursor() would silently do nothing.
|
||||
@@ -4849,7 +4861,8 @@ wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
|
||||
void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column)
|
||||
{
|
||||
wxCHECK_RET( m_treeview,
|
||||
"Current item can't be set before creating the control." );
|
||||
"item can't be edited before creating the control." );
|
||||
wxCHECK_RET( m_internal, "model must be associated before editing an item" );
|
||||
wxCHECK_RET( item.IsOk(), "invalid item" );
|
||||
wxCHECK_RET( column, "no column provided" );
|
||||
|
||||
@@ -4882,6 +4895,8 @@ int wxDataViewCtrl::GetSelectedItemsCount() const
|
||||
|
||||
int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
|
||||
{
|
||||
wxCHECK_MSG( m_internal, 0, "model must be associated before calling GetSelections" );
|
||||
|
||||
sel.Clear();
|
||||
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
|
||||
@@ -4911,6 +4926,8 @@ int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
|
||||
|
||||
void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling SetSelections" );
|
||||
|
||||
GtkDisableSelectionEvents();
|
||||
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
|
||||
@@ -4942,6 +4959,8 @@ void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
|
||||
|
||||
void wxDataViewCtrl::Select( const wxDataViewItem & item )
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling Select" );
|
||||
|
||||
ExpandAncestors(item);
|
||||
|
||||
GtkDisableSelectionEvents();
|
||||
@@ -4958,6 +4977,8 @@ void wxDataViewCtrl::Select( const wxDataViewItem & item )
|
||||
|
||||
void wxDataViewCtrl::Unselect( const wxDataViewItem & item )
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling Unselect" );
|
||||
|
||||
GtkDisableSelectionEvents();
|
||||
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
|
||||
@@ -4972,6 +4993,8 @@ void wxDataViewCtrl::Unselect( const wxDataViewItem & item )
|
||||
|
||||
bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
|
||||
{
|
||||
wxCHECK_MSG( m_internal, false, "model must be associated before calling IsSelected" );
|
||||
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );
|
||||
|
||||
GtkTreeIter iter;
|
||||
@@ -5006,6 +5029,8 @@ void wxDataViewCtrl::UnselectAll()
|
||||
void wxDataViewCtrl::EnsureVisible(const wxDataViewItem& item,
|
||||
const wxDataViewColumn *WXUNUSED(column))
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling EnsureVisible" );
|
||||
|
||||
m_ensureVisibleDefered = item;
|
||||
ExpandAncestors(item);
|
||||
|
||||
@@ -5019,6 +5044,8 @@ void wxDataViewCtrl::HitTest(const wxPoint& point,
|
||||
wxDataViewItem& item,
|
||||
wxDataViewColumn *& column) const
|
||||
{
|
||||
wxCHECK_RET( m_internal, "model must be associated before calling HitTest" );
|
||||
|
||||
// gtk_tree_view_get_dest_row_at_pos() is the right one. But it does not tell the column.
|
||||
// gtk_tree_view_get_path_at_pos() is the wrong function. It doesn't mind the header but returns column.
|
||||
// See http://mail.gnome.org/archives/gtkmm-list/2005-January/msg00080.html
|
||||
|
Reference in New Issue
Block a user