protected:
// implement/override wxHeaderCtrl functions by forwarding them to the main
// control
- virtual wxHeaderColumnBase& GetColumn(unsigned int idx)
+ virtual const wxHeaderColumn& GetColumn(unsigned int idx) const
{
return *(GetOwner()->GetColumn(idx));
}
void OnEndResize(wxHeaderCtrlEvent& event)
{
+ wxDataViewCtrl * const owner = GetOwner();
+
const unsigned col = event.GetColumn();
- GetColumn(col).SetWidth(event.GetWidth());
+ owner->GetColumn(col)->SetWidth(event.GetWidth());
GetOwner()->OnColumnChange(col);
}
void Expand( unsigned int row ) { OnExpanding( row ); }
void Collapse( unsigned int row ) { OnCollapsing( row ); }
+ bool IsExpanded( unsigned int row ) const;
private:
wxDataViewTreeNode * GetTreeNodeByRow( unsigned int row ) const;
//We did not need this temporarily
return le;
}
+
+bool wxDataViewMainWindow::IsExpanded( unsigned int row ) const
+{
+ if (IsVirtualList())
+ return false;
+
+ wxDataViewTreeNode * node = GetTreeNodeByRow(row);
+ if (!node)
+ return false;
+
+ if (!node->HasChildren())
+ {
+ delete node;
+ return false;
+ }
+
+ return node->IsOpen();
+}
+
+
void wxDataViewMainWindow::OnExpanding( unsigned int row )
{
if (IsVirtualList())
{
case WXK_RETURN:
{
- if (m_currentRow > 0)
+ if (m_currentRow >= 0)
{
wxWindow *parent = GetParent();
wxDataViewEvent le(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, parent->GetId());
wxDataViewRenderer *cell = col->GetRenderer();
unsigned int current = GetLineAt( y );
- if ((current > GetRowCount()) || (x > GetEndOfLastCol()))
+ if ((current >= GetRowCount()) || (x > GetEndOfLastCol()))
{
// Unselect all if below the last row ?
return;
// select single line
SelectAllRows( false );
SelectRow( m_lineSelectSingleOnUp, true );
+ SendSelectionChangedEvent( GetItemByRow(m_lineSelectSingleOnUp) );
}
//Process the event of user clicking the expander
void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
{
wxDataViewSelection selection(wxDataViewSelectionCmp);
+
+ wxDataViewItem last_parent;
+
int len = sel.GetCount();
for( int i = 0; i < len; i ++ )
{
- int row = m_clientArea->GetRowByItem( sel[i] );
+ wxDataViewItem item = sel[i];
+ wxDataViewItem parent = GetModel()->GetParent( item );
+ if (parent)
+ {
+ if (parent != last_parent)
+ ExpandAncestors(item);
+ }
+
+ last_parent = parent;
+ int row = m_clientArea->GetRowByItem( item );
if( row >= 0 )
selection.Add( static_cast<unsigned int>(row) );
}
+
m_clientArea->SetSelections( selection );
}
void wxDataViewCtrl::Select( const wxDataViewItem & item )
{
+ ExpandAncestors( item );
+
int row = m_clientArea->GetRowByItem( item );
if( row >= 0 )
{
void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn * column )
{
+ ExpandAncestors( item );
+
+ m_clientArea->RecalculateDisplay();
+
int row = m_clientArea->GetRowByItem(item);
if( row >= 0 )
{
m_clientArea->Collapse(row);
}
+bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const
+{
+ int row = m_clientArea->GetRowByItem( item );
+ if (row != -1)
+ return m_clientArea->IsExpanded(row);
+ return false;
+}
+
+
#endif
// !wxUSE_GENERICDATAVIEWCTRL