bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item)
{
- GetOwner()->InvalidateColBestWidths();
if (IsVirtualList())
{
wxDataViewVirtualListModel *list_model =
(wxDataViewVirtualListModel*) GetOwner()->GetModel();
m_count = list_model->GetCount();
- UpdateDisplay();
- return true;
}
+ else
+ {
+ SortPrepare();
- SortPrepare();
+ wxDataViewTreeNode * node;
+ node = FindNode(parent);
- wxDataViewTreeNode * node;
- node = FindNode(parent);
+ if( node == NULL )
+ return false;
- if( node == NULL )
- return false;
+ node->SetHasChildren( true );
- node->SetHasChildren( true );
+ if( g_model->IsContainer( item ) )
+ {
+ wxDataViewTreeNode * newnode = new wxDataViewTreeNode( node );
+ newnode->SetItem(item);
+ newnode->SetHasChildren( true );
+ node->AddNode( newnode);
+ }
+ else
+ node->AddLeaf( item.GetID() );
- if( g_model->IsContainer( item ) )
- {
- wxDataViewTreeNode * newnode = new wxDataViewTreeNode( node );
- newnode->SetItem(item);
- newnode->SetHasChildren( true );
- node->AddNode( newnode);
- }
- else
- node->AddLeaf( item.GetID() );
+ node->ChangeSubTreeCount(1);
- node->ChangeSubTreeCount(1);
+ m_count = -1;
+ }
- m_count = -1;
+ GetOwner()->UpdateColBestWidths();
UpdateDisplay();
return true;
bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
const wxDataViewItem& item)
{
- GetOwner()->InvalidateColBestWidths();
-
if (IsVirtualList())
{
wxDataViewVirtualListModel *list_model =
if( m_currentRow > GetRowCount() )
ChangeCurrentRow(m_count - 1);
+ GetOwner()->UpdateColBestWidths();
UpdateDisplay();
return true;
bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
{
- GetOwner()->InvalidateColBestWidths();
-
SortPrepare();
g_model->Resort();
+ GetOwner()->UpdateColBestWidths();
+
// Send event
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
if (view_column == -1)
return false;
- GetOwner()->InvalidateColBestWidth(view_column);
-
// NOTE: to be valid, we cannot use e.g. INT_MAX - 1
/*#define MAX_VIRTUAL_WIDTH 100000
SortPrepare();
g_model->Resort();
+ GetOwner()->UpdateColBestWidth(view_column);
+
// Send event
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, parent->GetId());
bool wxDataViewMainWindow::Cleared()
{
- GetOwner()->InvalidateColBestWidths();
-
DestroyTree();
m_selection.Clear();
SortPrepare();
BuildTree( GetOwner()->GetModel() );
+ GetOwner()->UpdateColBestWidths();
UpdateDisplay();
return true;
return;
}
- // Test whether the mouse is hovered on the tree item button
+ // Test whether the mouse is hovering over the expander (a.k.a tree "+"
+ // button) and also determine the offset of the real cell start, skipping
+ // the indentation and the expander itself.
bool hoverOverExpander = false;
+ int expanderOffset = 0;
if ((!IsList()) && (GetOwner()->GetExpanderColumn() == col))
{
wxDataViewTreeNode * node = GetTreeNodeByRow(current);
wxRect rect( xpos + indent,
GetLineStart( current ) + (GetLineHeight(current) - m_lineHeight)/2,
m_lineHeight, m_lineHeight);
+
+ expanderOffset = indent + m_lineHeight;
+
if( rect.Contains(x, y) )
{
// So the mouse is over the expander
// notify cell about click
cell->PrepareForItem(model, item, col->GetModelColumn());
- wxRect cell_rect( xpos, GetLineStart( current ),
- col->GetWidth(), GetLineHeight( current ) );
+ wxRect cell_rect( xpos + expanderOffset,
+ GetLineStart( current ),
+ col->GetWidth() - expanderOffset,
+ GetLineHeight( current ) );
// Report position relative to the cell's custom area, i.e.
// no the entire space as given by the control but the one
return true;
}
-void wxDataViewCtrl::InvalidateColBestWidth(int idx)
+void wxDataViewCtrl::UpdateColBestWidth(int idx)
{
m_colsBestWidths[idx] = 0;
m_headerArea->UpdateColumn(idx);
}
-void wxDataViewCtrl::InvalidateColBestWidths()
+void wxDataViewCtrl::UpdateColBestWidths()
{
m_colsBestWidths.clear();
m_colsBestWidths.resize(m_cols.size());