model column and index of column in the dataview can be different, correct this and also make wxGTK and wxMSW report the same thing in the event following wxDataViewModel::SetValue(), fixes #12755: wxDataViewCtrl bug when the column is mapped to different model column. Also commit some older change reseting the cursor under the mouse.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66423 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2010-12-21 19:27:35 +00:00
parent 925a662ab0
commit d93cc83080
2 changed files with 31 additions and 13 deletions

View File

@ -435,7 +435,7 @@ public:
bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
bool ItemChanged( const wxDataViewItem &item ); bool ItemChanged( const wxDataViewItem &item );
bool ValueChanged( const wxDataViewItem &item, unsigned int col ); bool ValueChanged( const wxDataViewItem &item, unsigned int model_column );
bool Cleared(); bool Cleared();
void Resort() void Resort()
{ {
@ -2073,9 +2073,23 @@ bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
return true; return true;
} }
bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int col ) bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int model_column )
{ {
GetOwner()->InvalidateColBestWidth(col); int view_column = -1;
unsigned int n_col = m_owner->GetColumnCount();
for (unsigned i = 0; i < n_col; i++)
{
wxDataViewColumn *column = m_owner->GetColumn( i );
if (column->GetModelColumn() == model_column)
{
view_column = (int) i;
break;
}
}
if (view_column == -1)
return false;
GetOwner()->InvalidateColBestWidth(view_column);
// NOTE: to be valid, we cannot use e.g. INT_MAX - 1 // NOTE: to be valid, we cannot use e.g. INT_MAX - 1
/*#define MAX_VIRTUAL_WIDTH 100000 /*#define MAX_VIRTUAL_WIDTH 100000
@ -2095,8 +2109,8 @@ bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned i
le.SetEventObject(parent); le.SetEventObject(parent);
le.SetModel(GetOwner()->GetModel()); le.SetModel(GetOwner()->GetModel());
le.SetItem(item); le.SetItem(item);
le.SetColumn(col); le.SetColumn(view_column);
le.SetDataViewColumn(GetOwner()->GetColumn(col)); le.SetDataViewColumn(GetOwner()->GetColumn(view_column));
parent->GetEventHandler()->ProcessEvent(le); parent->GetEventHandler()->ProcessEvent(le);
return true; return true;
@ -2154,6 +2168,8 @@ void wxDataViewMainWindow::RecalculateDisplay()
void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect ) void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
{ {
m_underMouse = NULL;
wxWindow::ScrollWindow( dx, dy, rect ); wxWindow::ScrollWindow( dx, dy, rect );
if (GetOwner()->m_headerArea) if (GetOwner()->m_headerArea)
@ -2162,6 +2178,8 @@ void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
void wxDataViewMainWindow::ScrollTo( int rows, int column ) void wxDataViewMainWindow::ScrollTo( int rows, int column )
{ {
m_underMouse = NULL;
int x, y; int x, y;
m_owner->GetScrollPixelsPerUnit( &x, &y ); m_owner->GetScrollPixelsPerUnit( &x, &y );
int sy = GetLineStart( rows )/y; int sy = GetLineStart( rows )/y;

View File

@ -231,7 +231,7 @@ public:
bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
bool ItemChanged( const wxDataViewItem &item ); bool ItemChanged( const wxDataViewItem &item );
bool ValueChanged( const wxDataViewItem &item, unsigned int col ); bool ValueChanged( const wxDataViewItem &item, unsigned int model_column );
bool Cleared(); bool Cleared();
bool BeforeReset(); bool BeforeReset();
bool AfterReset(); bool AfterReset();
@ -1490,7 +1490,7 @@ public:
virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
virtual bool ItemChanged( const wxDataViewItem &item ); virtual bool ItemChanged( const wxDataViewItem &item );
virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ); virtual bool ValueChanged( const wxDataViewItem &item, unsigned int model_column );
virtual bool Cleared(); virtual bool Cleared();
virtual void Resort(); virtual void Resort();
virtual bool BeforeReset(); virtual bool BeforeReset();
@ -1591,7 +1591,7 @@ bool wxGtkDataViewModelNotifier::ItemChanged( const wxDataViewItem &item )
return true; return true;
} }
bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsigned int model_col ) bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsigned int model_column )
{ {
GtkWxTreeModel *wxgtk_model = m_internal->GetGtkModel(); GtkWxTreeModel *wxgtk_model = m_internal->GetGtkModel();
wxDataViewCtrl *ctrl = m_internal->GetOwner(); wxDataViewCtrl *ctrl = m_internal->GetOwner();
@ -1601,7 +1601,7 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
for (index = 0; index < ctrl->GetColumnCount(); index++) for (index = 0; index < ctrl->GetColumnCount(); index++)
{ {
wxDataViewColumn *column = ctrl->GetColumn( index ); wxDataViewColumn *column = ctrl->GetColumn( index );
if (column->GetModelColumn() == model_col) if (column->GetModelColumn() == model_column)
{ {
GtkTreeView *widget = GTK_TREE_VIEW(ctrl->GtkGetTreeView()); GtkTreeView *widget = GTK_TREE_VIEW(ctrl->GtkGetTreeView());
GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()); GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle());
@ -1624,7 +1624,7 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
gtk_widget_queue_draw_area( GTK_WIDGET(widget), gtk_widget_queue_draw_area( GTK_WIDGET(widget),
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height ); cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
m_internal->ValueChanged( item, model_col ); m_internal->ValueChanged( item, model_column );
return true; return true;
} }
@ -3705,13 +3705,13 @@ bool wxDataViewCtrlInternal::ItemChanged( const wxDataViewItem &item )
return true; return true;
} }
bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned int col ) bool wxDataViewCtrlInternal::ValueChanged( const wxDataViewItem &item, unsigned int view_column )
{ {
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, m_owner->GetId() ); wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, m_owner->GetId() );
event.SetEventObject( m_owner ); event.SetEventObject( m_owner );
event.SetModel( m_owner->GetModel() ); event.SetModel( m_owner->GetModel() );
event.SetColumn( col ); event.SetColumn( view_column );
event.SetDataViewColumn( GetOwner()->GetColumn(col) ); event.SetDataViewColumn( GetOwner()->GetColumn(view_column) );
event.SetItem( item ); event.SetItem( item );
m_owner->HandleWindowEvent( event ); m_owner->HandleWindowEvent( event );