}
virtual void UpdateDisplay() { Refresh(); }
-
+
// event handlers:
void OnPaint( wxPaintEvent &event );
//-----------------------------------------------------------------------------
// wxDataViewTreeNode
//-----------------------------------------------------------------------------
-class wxDataViewTreeNode;
+class wxDataViewTreeNode;
WX_DEFINE_SORTED_ARRAY( wxDataViewTreeNode *, wxDataViewTreeNodes );
WX_DEFINE_SORTED_ARRAY( void* , wxDataViewTreeLeaves);
wxDataViewTreeNode( wxDataViewTreeNode * parent )
:leaves( wxGenericTreeModelItemCmp ),
nodes(wxGenericTreeModelNodeCmp)
- { this->parent = parent;
+ { this->parent = parent;
if( parent == NULL )
open = true;
else
//I don't know what I need to do in the destructure
~wxDataViewTreeNode()
{
-
+
}
wxDataViewTreeNode * GetParent() { return parent; }
void SetParent( wxDataViewTreeNode * parent ) { this->parent = parent; }
wxDataViewTreeNodes & GetNodes() { return nodes; }
wxDataViewTreeLeaves & GetChildren() { return leaves; }
-
- void AddNode( wxDataViewTreeNode * node )
+
+ void AddNode( wxDataViewTreeNode * node )
{
nodes.Add( node );
leaves.Add( node->GetItem().GetID() );
return ret;
}
- bool IsOpen()
- {
- return open ;
- }
+ bool IsOpen()
+ {
+ return open ;
+ }
void ToggleOpen()
- {
+ {
int len = nodes.GetCount();
int sum = 0;
for ( int i = 0 ;i < len ; i ++)
void SetSubTreeCount( int num ) { subTreeCount = num; }
int GetSubTreeCount() { return subTreeCount; }
- void ChangeSubTreeCount( int num )
+ void ChangeSubTreeCount( int num )
{
if( !open )
return ;
wxDataViewTreeNode * parent;
wxDataViewTreeNodes nodes;
wxDataViewTreeLeaves leaves;
- wxDataViewItem item;
+ wxDataViewItem item;
bool open;
bool hasChildren;
int subTreeCount;
void OnExpanding( unsigned int row );
void OnCollapsing( unsigned int row );
- wxDataViewTreeNode * FindNode( const wxDataViewItem & item );
+ wxDataViewTreeNode * FindNode( const wxDataViewItem & item );
private:
wxDataViewCtrl *m_owner;
wxPen m_penExpander;
//This is the tree structure of the model
- wxDataViewTreeNode * m_root;
+ wxDataViewTreeNode * m_root;
int m_count;
private:
DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow)
virtual bool ItemAdded( const wxDataViewItem & parent, const wxDataViewItem & item )
{ return m_mainWindow->ItemAdded( parent , item ); }
- virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0;
+ virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item )
{ return m_mainWindow->ItemDeleted( item ); }
virtual bool ItemChanged( const wxDataViewItem & item )
{ return m_mainWindow->ItemChanged(item); }
}
bool wxDataViewTextRenderer::HasEditorCtrl()
-{
+{
return true;
}
wxControl* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow *parent,
wxRect labelRect, const wxVariant &value )
{
- return new wxTextCtrl( parent, wxID_ANY, value,
+ return new wxTextCtrl( parent, wxID_ANY, value,
wxPoint(labelRect.x,labelRect.y),
wxSize(labelRect.width,labelRect.height) );
}
m_flags |= wxDATAVIEW_COL_SORTABLE;
else
m_flags &= ~wxDATAVIEW_COL_SORTABLE;
-
+
// Update header button
if (GetOwner())
GetOwner()->OnColumnChange();
void wxDataViewColumn::SetSortOrder( bool ascending )
{
m_ascending = ascending;
-
+
// Update header button
if (GetOwner())
GetOwner()->OnColumnChange();
default:
;
}
-
+
if( Walker( nd , func ) )
return true;
case DoJob::CONT:
default:
;
- }
+ }
}
return false;
}
node->SetHasChildren( false );
//Make the row number invalid and get a new valid one when user call GetRowCount
- m_count = -1;
+ m_count = -1;
node->ChangeSubTreeCount(sub);
//Change the current row to the last row if the current exceed the max row number
if( m_currentRow > GetRowCount() )
{
continue;
}
-
+
wxDataViewItem dataitem = node->GetItem();
model->GetValue( value, dataitem, col->GetModelColumn());
cell->SetValue( value );
// update the y offset
cell_rect.y = item * m_lineHeight;
- //Draw the expander here.
+ //Draw the expander here.
int indent = node->GetIndentLevel();
if( col->GetModelColumn() == GetOwner()->GetExpanderColumn() )
{
//force the expander column to left-center align
cell->SetAlignment( wxALIGN_CENTER_VERTICAL );
}
-
- // cannot be bigger than allocated space
+
+ // cannot be bigger than allocated space
wxSize size = cell->GetSize();
// Because of the tree structure indent, here we should minus the width of the cell for drawing
size.x = wxMin( size.x + 2*PADDING_RIGHTLEFT, cell_rect.width - indent );
//Here we add the tree indent
item_rect.x += indent;
-
+
int state = 0;
if (m_selection.Index(item) != wxNOT_FOUND)
state |= wxDATAVIEW_CELL_SELECTED;
return y / m_lineHeight;
}
-unsigned int wxDataViewMainWindow::GetLastVisibleRow()
+unsigned int wxDataViewMainWindow::GetLastVisibleRow()
{
wxSize client_size = GetClientSize();
m_owner->CalcUnscrolledPosition( client_size.x, client_size.y,
return wxMin( GetRowCount()-1, ((unsigned)client_size.y/m_lineHeight)+1 );
}
-unsigned int wxDataViewMainWindow::GetRowCount()
+unsigned int wxDataViewMainWindow::GetRowCount()
{
if ( m_count == -1 )
{
class RowToTreeNodeJob: public DoJob
{
public:
- RowToTreeNodeJob( unsigned int row , int current, wxDataViewTreeNode * node )
- {
- this->row = row;
- this->current = current ;
+ RowToTreeNodeJob( unsigned int row , int current, wxDataViewTreeNode * node )
+ {
+ this->row = row;
+ this->current = current ;
ret = NULL ;
parent = node;
}
ret->SetHasChildren(false);
return DoJob::OK;
}
-
+
return DoJob::CONT;
}
wxDataViewTreeNode * GetResult(){ return ret; }
public:
CountJob(){ count = 0 ; }
virtual ~CountJob(){};
-
+
virtual int operator () ( wxDataViewTreeNode * node )
{
count ++;
it = model->GetParent( it );
}
- //Find the item along the parent-chain.
+ //Find the item along the parent-chain.
//This algorithm is designed to speed up the node-finding method
bool found = true;
wxDataViewTreeNode * node = m_root;
{
node = nodes[j];
break;
- }
+ }
}
// Whenever we can't find the node in any level, return NULL to indicate the item can't be found
if( j == len )
return node;
}
-int wxDataViewMainWindow::RecalculateCount()
+int wxDataViewMainWindow::RecalculateCount()
{
return m_root->GetSubTreeCount();
}
ret += node->GetSubTreeCount();
return DoJob::IGR;
}
-
+
}
virtual int operator() ( void * n )
ItemList::Node * nd;
wxDataViewItem item;
int ret;
-
+
};
unsigned int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item)
{
if( !model->IsContainer( item ) )
return ;
-
+
wxDataViewItem i = model->GetFirstChild( item );
int num = 0;
while( i.IsOk() )
m_clientArea->UpdateDisplay();
}
-wxDataViewItem wxDataViewCtrl::GetSelection()
+wxDataViewItem wxDataViewCtrl::GetSelection()
{
return m_clientArea->GetSelection();
}