Bo'd patch to make wxDataViewCtrl compile again (4th attempt
to actually commit). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47257 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,6 +83,8 @@ private:
|
|||||||
wxUint32 m_id;
|
wxUint32 m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool operator == ( const wxDataViewItem & left, const wxDataViewItem & right );
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxDataViewModel
|
// wxDataViewModel
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
@@ -51,28 +51,28 @@ public:
|
|||||||
{ return m_mode; }
|
{ return m_mode; }
|
||||||
|
|
||||||
virtual bool Activate( wxRect WXUNUSED(cell),
|
virtual bool Activate( wxRect WXUNUSED(cell),
|
||||||
wxDataViewListModel *WXUNUSED(model),
|
wxDataViewModel *WXUNUSED(model),
|
||||||
unsigned int WXUNUSED(col),
|
const wxDataViewItem & item,
|
||||||
unsigned int WXUNUSED(row) )
|
unsigned int WXUNUSED(col) )
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
virtual bool LeftClick( wxPoint WXUNUSED(cursor),
|
virtual bool LeftClick( wxPoint WXUNUSED(cursor),
|
||||||
wxRect WXUNUSED(cell),
|
wxRect WXUNUSED(cell),
|
||||||
wxDataViewListModel *WXUNUSED(model),
|
wxDataViewModel *WXUNUSED(model),
|
||||||
unsigned int WXUNUSED(col),
|
const wxDataViewItem & item,
|
||||||
unsigned int WXUNUSED(row) )
|
unsigned int WXUNUSED(col) )
|
||||||
{ return false; }
|
{ return false; }
|
||||||
virtual bool RightClick( wxPoint WXUNUSED(cursor),
|
virtual bool RightClick( wxPoint WXUNUSED(cursor),
|
||||||
wxRect WXUNUSED(cell),
|
wxRect WXUNUSED(cell),
|
||||||
wxDataViewListModel *WXUNUSED(model),
|
wxDataViewModel *WXUNUSED(model),
|
||||||
unsigned int WXUNUSED(col),
|
const wxDataViewItem & item,
|
||||||
unsigned int WXUNUSED(row) )
|
unsigned int WXUNUSED(col) )
|
||||||
{ return false; }
|
{ return false; }
|
||||||
virtual bool StartDrag( wxPoint WXUNUSED(cursor),
|
virtual bool StartDrag( wxPoint WXUNUSED(cursor),
|
||||||
wxRect WXUNUSED(cell),
|
wxRect WXUNUSED(cell),
|
||||||
wxDataViewListModel *WXUNUSED(model),
|
wxDataViewModel *WXUNUSED(model),
|
||||||
unsigned int WXUNUSED(col),
|
const wxDataViewItem & item,
|
||||||
unsigned int WXUNUSED(row) )
|
unsigned int WXUNUSED(col) )
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
// Create DC on request
|
// Create DC on request
|
||||||
@@ -172,8 +172,8 @@ public:
|
|||||||
bool GetValue( wxVariant &value ) const;
|
bool GetValue( wxVariant &value ) const;
|
||||||
|
|
||||||
bool Render( wxRect cell, wxDC *dc, int state );
|
bool Render( wxRect cell, wxDC *dc, int state );
|
||||||
bool Activate( wxRect cell, wxDataViewListModel *model, unsigned int col,
|
bool Activate( wxRect cell, wxDataViewModel *model, const wxDataViewItem & item,
|
||||||
unsigned int row );
|
unsigned int col );
|
||||||
wxSize GetSize() const;
|
wxSize GetSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -227,7 +227,7 @@ public:
|
|||||||
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
virtual bool Render( wxRect cell, wxDC *dc, int state );
|
||||||
virtual wxSize GetSize() const;
|
virtual wxSize GetSize() const;
|
||||||
virtual bool Activate( wxRect cell,
|
virtual bool Activate( wxRect cell,
|
||||||
wxDataViewListModel *model, unsigned int col, unsigned int row );
|
wxDataViewModel *model, const wxDataViewItem & item, unsigned int col );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDateTime m_date;
|
wxDateTime m_date;
|
||||||
@@ -346,9 +346,10 @@ public:
|
|||||||
const wxSize& size = wxDefaultSize, long style = 0,
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
const wxValidator& validator = wxDefaultValidator );
|
const wxValidator& validator = wxDefaultValidator );
|
||||||
|
|
||||||
virtual bool AssociateModel( wxDataViewListModel *model );
|
virtual bool AssociateModel( wxDataViewModel *model );
|
||||||
virtual bool AppendColumn( wxDataViewColumn *col );
|
virtual bool AppendColumn( wxDataViewColumn *col );
|
||||||
|
|
||||||
|
/********************selection code*********************
|
||||||
virtual void SetSelection( int row ); // -1 for unselect
|
virtual void SetSelection( int row ); // -1 for unselect
|
||||||
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
virtual void SetSelectionRange( unsigned int from, unsigned int to );
|
||||||
virtual void SetSelections( const wxArrayInt& aSelections);
|
virtual void SetSelections( const wxArrayInt& aSelections);
|
||||||
@@ -357,6 +358,7 @@ public:
|
|||||||
virtual bool IsSelected( unsigned int row ) const;
|
virtual bool IsSelected( unsigned int row ) const;
|
||||||
virtual int GetSelection() const;
|
virtual int GetSelection() const;
|
||||||
virtual int GetSelections(wxArrayInt& aSelections) const;
|
virtual int GetSelections(wxArrayInt& aSelections) const;
|
||||||
|
*****************************************************/
|
||||||
|
|
||||||
public: // utility functions not part of the API
|
public: // utility functions not part of the API
|
||||||
|
|
||||||
@@ -372,7 +374,7 @@ public: // utility functions not part of the API
|
|||||||
wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; }
|
wxWindow *GetMainWindow() { return (wxWindow*) m_clientArea; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDataViewListModelNotifier *m_notifier;
|
wxDataViewModelNotifier *m_notifier;
|
||||||
wxDataViewMainWindow *m_clientArea;
|
wxDataViewMainWindow *m_clientArea;
|
||||||
wxDataViewHeaderWindow *m_headerArea;
|
wxDataViewHeaderWindow *m_headerArea;
|
||||||
|
|
||||||
|
@@ -134,10 +134,15 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************
|
||||||
|
If wxDataViewItem is not valid in the two methods I quote above
|
||||||
|
then it means "return the child item from the invisible root".
|
||||||
|
******************************************************************/
|
||||||
|
|
||||||
virtual bool HasChildren( const wxDataViewItem &item ) const
|
virtual bool HasChildren( const wxDataViewItem &item ) const
|
||||||
{
|
{
|
||||||
int ID = item.GetID();
|
int ID = item.GetID();
|
||||||
return ((ID == 1) || (ID == 2) || (ID == 5));
|
return ((ID == 1) || (ID == 2) || (ID == 5) || (ID == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int GetChildCount( const wxDataViewItem &item ) const
|
virtual int GetChildCount( const wxDataViewItem &item ) const
|
||||||
@@ -145,6 +150,7 @@ public:
|
|||||||
int ID = item.GetID();
|
int ID = item.GetID();
|
||||||
switch (ID)
|
switch (ID)
|
||||||
{
|
{
|
||||||
|
case 0: return 1;
|
||||||
case 1: return 2;
|
case 1: return 2;
|
||||||
case 2: return 2;
|
case 2: return 2;
|
||||||
case 5: return 2;
|
case 5: return 2;
|
||||||
@@ -171,6 +177,7 @@ public:
|
|||||||
int ID = parent.GetID();
|
int ID = parent.GetID();
|
||||||
switch (ID)
|
switch (ID)
|
||||||
{
|
{
|
||||||
|
case 0: return wxDataViewItem( 1 );
|
||||||
case 1: return wxDataViewItem( 2 );
|
case 1: return wxDataViewItem( 2 );
|
||||||
case 2: return wxDataViewItem( 3 );
|
case 2: return wxDataViewItem( 3 );
|
||||||
case 5: return wxDataViewItem( 6 );
|
case 5: return wxDataViewItem( 6 );
|
||||||
|
@@ -58,6 +58,11 @@ static const int PADDING_RIGHTLEFT = 3;
|
|||||||
static const int PADDING_TOPBOTTOM = 1;
|
static const int PADDING_TOPBOTTOM = 1;
|
||||||
|
|
||||||
|
|
||||||
|
bool operator == ( const wxDataViewItem & left, const wxDataViewItem & right )
|
||||||
|
{
|
||||||
|
return left.GetID() == right.GetID();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDataViewHeaderWindow
|
// wxDataViewHeaderWindow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -246,6 +251,49 @@ public:
|
|||||||
void Notify();
|
void Notify();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxDataViewTreeNode
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class wxDataViewTreeNode;
|
||||||
|
WX_DEFINE_ARRAY_PTR( wxDataViewTreeNode *, wxDataViewTreeNodes );
|
||||||
|
|
||||||
|
class wxDataViewTreeNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDataViewTreeNode( wxDataViewTreeNode * parent )
|
||||||
|
{ this->parent = parent;
|
||||||
|
if( parent == NULL )
|
||||||
|
open = true;
|
||||||
|
else
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
|
//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 GetChildren() { return children; }
|
||||||
|
void SetChildren( wxDataViewTreeNodes children ) { this->children = children; }
|
||||||
|
|
||||||
|
wxDataViewTreeNode * GetChild( unsigned int n ) { return children.Item( n ); }
|
||||||
|
void InsertChild( wxDataViewTreeNode * child, unsigned int n) { children.Insert( child, n); }
|
||||||
|
void AppendChild( wxDataViewTreeNode * child ) { children.Add( child ); }
|
||||||
|
|
||||||
|
wxDataViewItem & GetItem() { return item; }
|
||||||
|
void SetItem( wxDataViewItem & item ) { this->item = item; }
|
||||||
|
|
||||||
|
unsigned int GetChildrenNumber() { return children.GetCount(); }
|
||||||
|
|
||||||
|
bool IsOpen() { return open; }
|
||||||
|
bool HasChildren() { return children.GetCount() != 0; }
|
||||||
|
private:
|
||||||
|
wxDataViewTreeNode * parent;
|
||||||
|
wxDataViewTreeNodes children;
|
||||||
|
wxDataViewItem item;
|
||||||
|
bool open;
|
||||||
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxDataViewMainWindow
|
// wxDataViewMainWindow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -263,14 +311,11 @@ public:
|
|||||||
const wxString &name = wxT("wxdataviewctrlmainwindow") );
|
const wxString &name = wxT("wxdataviewctrlmainwindow") );
|
||||||
virtual ~wxDataViewMainWindow();
|
virtual ~wxDataViewMainWindow();
|
||||||
|
|
||||||
// notifications from wxDataViewListModel
|
// notifications from wxDataViewModel
|
||||||
bool RowAppended();
|
bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
|
||||||
bool RowPrepended();
|
bool ItemDeleted( const wxDataViewItem &item );
|
||||||
bool RowInserted( unsigned int before );
|
bool ItemChanged( const wxDataViewItem &item );
|
||||||
bool RowDeleted( unsigned int row );
|
bool ValueChanged( const wxDataViewItem &item, unsigned int col );
|
||||||
bool RowChanged( unsigned int row );
|
|
||||||
bool ValueChanged( unsigned int col, unsigned int row );
|
|
||||||
bool RowsReordered( unsigned int *new_order );
|
|
||||||
bool Cleared();
|
bool Cleared();
|
||||||
|
|
||||||
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
|
||||||
@@ -324,6 +369,14 @@ public:
|
|||||||
//void EnsureVisible( unsigned int row );
|
//void EnsureVisible( unsigned int row );
|
||||||
wxRect GetLineRect( unsigned int row ) const;
|
wxRect GetLineRect( unsigned int row ) const;
|
||||||
|
|
||||||
|
//Some useful functions for row and item mapping
|
||||||
|
wxDataViewItem GetItemByRow( unsigned int row );
|
||||||
|
unsigned int GetRowByItem( const wxDataViewItem & item );
|
||||||
|
|
||||||
|
//Methods for building the mapping tree
|
||||||
|
void BuildTree( wxDataViewModel * model );
|
||||||
|
void DestroyTree();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDataViewCtrl *m_owner;
|
wxDataViewCtrl *m_owner;
|
||||||
int m_lineHeight;
|
int m_lineHeight;
|
||||||
@@ -349,35 +402,32 @@ private:
|
|||||||
// the pen used to draw horiz/vertical rules
|
// the pen used to draw horiz/vertical rules
|
||||||
wxPen m_penRule;
|
wxPen m_penRule;
|
||||||
|
|
||||||
|
//This is the tree structure of the model
|
||||||
|
wxDataViewTreeNode * m_root;
|
||||||
|
unsigned int m_count;
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow)
|
DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// wxGenericDataViewListModelNotifier
|
// wxGenericDataViewModelNotifier
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
class wxGenericDataViewListModelNotifier: public wxDataViewListModelNotifier
|
class wxGenericDataViewModelNotifier: public wxDataViewModelNotifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxGenericDataViewListModelNotifier( wxDataViewMainWindow *mainWindow )
|
wxGenericDataViewModelNotifier( wxDataViewMainWindow *mainWindow )
|
||||||
{ m_mainWindow = mainWindow; }
|
{ m_mainWindow = mainWindow; }
|
||||||
|
|
||||||
virtual bool RowAppended()
|
virtual bool ItemAdded( const wxDataViewItem & parent, const wxDataViewItem & item )
|
||||||
{ return m_mainWindow->RowAppended(); }
|
{ return m_mainWindow->ItemAdded( parent , item ); }
|
||||||
virtual bool RowPrepended()
|
virtual bool ItemDeleted( const wxDataViewItem & item )
|
||||||
{ return m_mainWindow->RowPrepended(); }
|
{ return m_mainWindow->ItemDeleted( item ); }
|
||||||
virtual bool RowInserted( unsigned int before )
|
virtual bool ItemChanged( const wxDataViewItem & item )
|
||||||
{ return m_mainWindow->RowInserted( before ); }
|
{ return m_mainWindow->ItemChanged(item); }
|
||||||
virtual bool RowDeleted( unsigned int row )
|
virtual bool ValueChanged( const wxDataViewItem & item , unsigned int col )
|
||||||
{ return m_mainWindow->RowDeleted( row ); }
|
{ return m_mainWindow->ValueChanged( item, col ); }
|
||||||
virtual bool RowChanged( unsigned int row )
|
|
||||||
{ return m_mainWindow->RowChanged( row ); }
|
|
||||||
virtual bool ValueChanged( unsigned int col, unsigned int row )
|
|
||||||
{ return m_mainWindow->ValueChanged( col, row ); }
|
|
||||||
virtual bool RowsReordered( unsigned int *new_order )
|
|
||||||
{ return m_mainWindow->RowsReordered( new_order ); }
|
|
||||||
virtual bool Cleared()
|
virtual bool Cleared()
|
||||||
{ return m_mainWindow->Cleared(); }
|
{ return m_mainWindow->Cleared(); }
|
||||||
|
|
||||||
@@ -599,13 +649,13 @@ bool wxDataViewToggleRenderer::Render( wxRect cell, wxDC *dc, int WXUNUSED(state
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewToggleRenderer::Activate( wxRect WXUNUSED(cell),
|
bool wxDataViewToggleRenderer::Activate( wxRect WXUNUSED(cell),
|
||||||
wxDataViewListModel *model,
|
wxDataViewModel *model,
|
||||||
unsigned int col, unsigned int row )
|
const wxDataViewItem & item, unsigned int col)
|
||||||
{
|
{
|
||||||
bool value = !m_toggle;
|
bool value = !m_toggle;
|
||||||
wxVariant variant = value;
|
wxVariant variant = value;
|
||||||
model->SetValue( variant, col, row );
|
model->SetValue( variant, item, col);
|
||||||
model->ValueChanged( col, row );
|
model->ValueChanged( item, col );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,12 +731,12 @@ class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
|
wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
|
||||||
wxDataViewListModel *model, unsigned int col, unsigned int row ) :
|
wxDataViewModel *model, const wxDataViewItem & item, unsigned int col) :
|
||||||
wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
|
wxPopupTransientWindow( parent, wxBORDER_SIMPLE ),
|
||||||
|
m_item( item )
|
||||||
{
|
{
|
||||||
m_model = model;
|
m_model = model;
|
||||||
m_col = col;
|
m_col = col;
|
||||||
m_row = row;
|
|
||||||
m_cal = new wxCalendarCtrl( this, wxID_ANY, *value );
|
m_cal = new wxCalendarCtrl( this, wxID_ANY, *value );
|
||||||
wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
|
wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
sizer->Add( m_cal, 1, wxGROW );
|
sizer->Add( m_cal, 1, wxGROW );
|
||||||
@@ -697,9 +747,9 @@ public:
|
|||||||
void OnCalendar( wxCalendarEvent &event );
|
void OnCalendar( wxCalendarEvent &event );
|
||||||
|
|
||||||
wxCalendarCtrl *m_cal;
|
wxCalendarCtrl *m_cal;
|
||||||
wxDataViewListModel *m_model;
|
wxDataViewModel *m_model;
|
||||||
unsigned int m_col;
|
unsigned int m_col;
|
||||||
unsigned int m_row;
|
const wxDataViewItem & m_item;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnDismiss()
|
virtual void OnDismiss()
|
||||||
@@ -718,8 +768,8 @@ void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
|
|||||||
{
|
{
|
||||||
wxDateTime date = event.GetDate();
|
wxDateTime date = event.GetDate();
|
||||||
wxVariant value = date;
|
wxVariant value = date;
|
||||||
m_model->SetValue( value, m_col, m_row );
|
m_model->SetValue( value, m_item, m_col );
|
||||||
m_model->ValueChanged( m_col, m_row );
|
m_model->ValueChanged( m_item, m_col );
|
||||||
DismissAndNotify();
|
DismissAndNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,16 +814,16 @@ wxSize wxDataViewDateRenderer::GetSize() const
|
|||||||
return wxSize(x,y+d);
|
return wxSize(x,y+d);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewListModel *model,
|
bool wxDataViewDateRenderer::Activate( wxRect WXUNUSED(cell), wxDataViewModel *model,
|
||||||
unsigned int col, unsigned int row )
|
const wxDataViewItem & item, unsigned int col )
|
||||||
{
|
{
|
||||||
wxVariant variant;
|
wxVariant variant;
|
||||||
model->GetValue( variant, col, row );
|
model->GetValue( variant, item, col );
|
||||||
wxDateTime value = variant.GetDateTime();
|
wxDateTime value = variant.GetDateTime();
|
||||||
|
|
||||||
#if wxUSE_DATE_RENDERER_POPUP
|
#if wxUSE_DATE_RENDERER_POPUP
|
||||||
wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
|
wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
|
||||||
GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
|
GetOwner()->GetOwner()->GetParent(), &value, model, item, col);
|
||||||
wxPoint pos = wxGetMousePosition();
|
wxPoint pos = wxGetMousePosition();
|
||||||
popup->Move( pos );
|
popup->Move( pos );
|
||||||
popup->Layout();
|
popup->Layout();
|
||||||
@@ -1570,11 +1620,15 @@ wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID i
|
|||||||
|
|
||||||
m_penRule = wxPen(GetRuleColour(), 1, wxSOLID);
|
m_penRule = wxPen(GetRuleColour(), 1, wxSOLID);
|
||||||
|
|
||||||
|
//Some new added code to deal with the tree structure
|
||||||
|
m_root = new wxDataViewTreeNode( NULL );
|
||||||
|
m_count = 0 ;
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewMainWindow::~wxDataViewMainWindow()
|
wxDataViewMainWindow::~wxDataViewMainWindow()
|
||||||
{
|
{
|
||||||
|
DestroyTree();
|
||||||
delete m_renameTimer;
|
delete m_renameTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1607,50 +1661,89 @@ void wxDataViewMainWindow::OnRenameTimer()
|
|||||||
m_currentCol->GetRenderer()->StartEditing( m_currentRow, labelRect );
|
m_currentCol->GetRenderer()->StartEditing( m_currentRow, labelRect );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowAppended()
|
class DoJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DoJob(){};
|
||||||
|
virtual ~DoJob(){};
|
||||||
|
|
||||||
|
virtual bool operator() ( wxDataViewTreeNode * node ) = 0 ;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ItemAddJob: public DoJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemAddJob( const wxDataViewItem & parent, const wxDataViewItem & item )
|
||||||
|
{ this->parent = parent ; this->item = item ; }
|
||||||
|
virtual ~ItemAddJob(){};
|
||||||
|
|
||||||
|
virtual bool operator() ( wxDataViewTreeNode * node )
|
||||||
|
{
|
||||||
|
if( node->GetItem() == parent )
|
||||||
|
{
|
||||||
|
wxDataViewTreeNode * newnode = new wxDataViewTreeNode( node );
|
||||||
|
newnode->SetItem(item);
|
||||||
|
node->AppendChild( newnode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
wxDataViewItem parent, item;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool Walker( wxDataViewTreeNode * node, DoJob & func )
|
||||||
|
{
|
||||||
|
if( !node->HasChildren())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wxDataViewTreeNodes nodes = node->GetChildren();
|
||||||
|
int len = node->GetChildrenNumber();
|
||||||
|
int i = 0 ;
|
||||||
|
for( ; i < len ; i ++ )
|
||||||
|
{
|
||||||
|
wxDataViewTreeNode * n = nodes[i];
|
||||||
|
if( func( n ) )
|
||||||
|
return true;
|
||||||
|
if( Walker( n , func ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem & parent, const wxDataViewItem & item)
|
||||||
|
{
|
||||||
|
ItemAddJob job( parent, item);
|
||||||
|
Walker( m_root , job);
|
||||||
|
UpdateDisplay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem & item)
|
||||||
{
|
{
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowPrepended()
|
bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem & item)
|
||||||
{
|
{
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowInserted( unsigned int WXUNUSED(before) )
|
bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem & item, unsigned int WXUNUSED(col) )
|
||||||
{
|
|
||||||
UpdateDisplay();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowDeleted( unsigned int WXUNUSED(row) )
|
|
||||||
{
|
|
||||||
UpdateDisplay();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowChanged( unsigned int WXUNUSED(row) )
|
|
||||||
{
|
|
||||||
UpdateDisplay();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxDataViewMainWindow::ValueChanged( unsigned int WXUNUSED(col), unsigned int row )
|
|
||||||
{
|
{
|
||||||
// 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
|
||||||
|
|
||||||
wxRect rect( 0, row*m_lineHeight, MAX_VIRTUAL_WIDTH, m_lineHeight );
|
wxRect rect( 0, row*m_lineHeight, MAX_VIRTUAL_WIDTH, m_lineHeight );
|
||||||
m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
|
||||||
Refresh( true, &rect );
|
Refresh( true, &rect );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
*/
|
||||||
|
|
||||||
bool wxDataViewMainWindow::RowsReordered( unsigned int *WXUNUSED(new_order) )
|
|
||||||
{
|
|
||||||
UpdateDisplay();
|
UpdateDisplay();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1679,7 +1772,7 @@ void wxDataViewMainWindow::OnInternalIdle()
|
|||||||
|
|
||||||
void wxDataViewMainWindow::RecalculateDisplay()
|
void wxDataViewMainWindow::RecalculateDisplay()
|
||||||
{
|
{
|
||||||
wxDataViewListModel *model = GetOwner()->GetModel();
|
wxDataViewModel *model = GetOwner()->GetModel();
|
||||||
if (!model)
|
if (!model)
|
||||||
{
|
{
|
||||||
Refresh();
|
Refresh();
|
||||||
@@ -1687,7 +1780,7 @@ void wxDataViewMainWindow::RecalculateDisplay()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int width = GetEndOfLastCol();
|
int width = GetEndOfLastCol();
|
||||||
int height = model->GetRowCount() * m_lineHeight;
|
int height = GetRowCount() * m_lineHeight;
|
||||||
|
|
||||||
SetVirtualSize( width, height );
|
SetVirtualSize( width, height );
|
||||||
GetOwner()->SetScrollRate( 10, m_lineHeight );
|
GetOwner()->SetScrollRate( 10, m_lineHeight );
|
||||||
@@ -1705,7 +1798,7 @@ void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
|
|||||||
|
|
||||||
void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxDataViewListModel *model = GetOwner()->GetModel();
|
wxDataViewModel *model = GetOwner()->GetModel();
|
||||||
wxAutoBufferedPaintDC dc( this );
|
wxAutoBufferedPaintDC dc( this );
|
||||||
|
|
||||||
// prepare the DC
|
// prepare the DC
|
||||||
@@ -1721,7 +1814,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
unsigned int item_start = wxMax( 0, (update.y / m_lineHeight) );
|
unsigned int item_start = wxMax( 0, (update.y / m_lineHeight) );
|
||||||
unsigned int item_count =
|
unsigned int item_count =
|
||||||
wxMin( (int)(((update.y + update.height) / m_lineHeight) - item_start + 1),
|
wxMin( (int)(((update.y + update.height) / m_lineHeight) - item_start + 1),
|
||||||
(int)(model->GetRowCount() - item_start) );
|
(int)(m_count- item_start) );
|
||||||
unsigned int item_last = item_start + item_count;
|
unsigned int item_last = item_start + item_count;
|
||||||
|
|
||||||
// compute which columns needs to be redrawn
|
// compute which columns needs to be redrawn
|
||||||
@@ -1832,7 +1925,8 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
|||||||
{
|
{
|
||||||
// get the cell value and set it into the renderer
|
// get the cell value and set it into the renderer
|
||||||
wxVariant value;
|
wxVariant value;
|
||||||
model->GetValue( value, col->GetModelColumn(), item );
|
wxDataViewItem dataitem = GetItemByRow(item);
|
||||||
|
model->GetValue( value, dataitem, col->GetModelColumn());
|
||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
|
|
||||||
// update the y offset
|
// update the y offset
|
||||||
@@ -1929,7 +2023,8 @@ unsigned int wxDataViewMainWindow::GetLastVisibleRow() const
|
|||||||
|
|
||||||
unsigned int wxDataViewMainWindow::GetRowCount() const
|
unsigned int wxDataViewMainWindow::GetRowCount() const
|
||||||
{
|
{
|
||||||
return wx_const_cast(wxDataViewCtrl*, GetOwner())->GetModel()->GetRowCount();
|
return m_count;
|
||||||
|
//return wx_const_cast(wxDataViewCtrl*, GetOwner())->GetModel()->GetRowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row )
|
void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row )
|
||||||
@@ -2142,6 +2237,137 @@ wxRect wxDataViewMainWindow::GetLineRect( unsigned int row ) const
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
static int tree_walk_current ;
|
||||||
|
wxDataViewTreeNode * TreeWalk( unsigned int row , wxDataViewTreeNode * node )
|
||||||
|
{
|
||||||
|
wxDataViewTreeNode * ret ;
|
||||||
|
if( tree_walk_current == row )
|
||||||
|
return node;
|
||||||
|
|
||||||
|
if( node->HasChildren() && node->IsOpen())
|
||||||
|
{
|
||||||
|
wxDataViewTreeNodes nodes = node->GetChildren();
|
||||||
|
int len = nodes.GetCount();
|
||||||
|
int i = 0 ;
|
||||||
|
for( ; i < len; i ++)
|
||||||
|
{
|
||||||
|
tree_walk_current ++;
|
||||||
|
ret = TreeWalk( row, nodes[i] );
|
||||||
|
if( ret != NULL )
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RowToItemJob: public DoJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RowToItemJob( unsigned int row , int current ) { this->row = row; this->current = current ;}
|
||||||
|
virtual ~RowToItemJob(){};
|
||||||
|
|
||||||
|
virtual bool operator() ( wxDataViewTreeNode * node )
|
||||||
|
{
|
||||||
|
if( current == row)
|
||||||
|
{
|
||||||
|
ret = node->GetItem() ;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
current ++;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDataViewItem GetResult(){ return ret; }
|
||||||
|
private:
|
||||||
|
unsigned int row;
|
||||||
|
int current ;
|
||||||
|
wxDataViewItem ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDataViewItem wxDataViewMainWindow::GetItemByRow(unsigned int row)
|
||||||
|
{
|
||||||
|
RowToItemJob job( row, 0 );
|
||||||
|
Walker( m_root , job );
|
||||||
|
return job.GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ItemToRowJob : public DoJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemToRowJob(const wxDataViewItem & item){ this->item = item ; }
|
||||||
|
virtual ~ItemToRowJob(){};
|
||||||
|
|
||||||
|
virtual bool operator() ( wxDataViewTreeNode * node)
|
||||||
|
{
|
||||||
|
ret ++;
|
||||||
|
if( node->GetItem() == item )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetResult(){ return ret; }
|
||||||
|
private:
|
||||||
|
wxDataViewItem item;
|
||||||
|
int ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem & item)
|
||||||
|
{
|
||||||
|
ItemToRowJob job( item );
|
||||||
|
Walker(m_root , job );
|
||||||
|
return job.GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int BuildTreeHelper( wxDataViewModel * model, wxDataViewItem & item, wxDataViewTreeNode * node)
|
||||||
|
{
|
||||||
|
int sum = 0 ;
|
||||||
|
if( !model->HasChildren( item ) )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
wxDataViewItem i = model->GetFirstChild( item );
|
||||||
|
while( i.IsOk() )
|
||||||
|
{
|
||||||
|
wxDataViewTreeNode * n = new wxDataViewTreeNode( node );
|
||||||
|
n->SetItem(i);
|
||||||
|
node->AppendChild(n);
|
||||||
|
int num = BuildTreeHelper( model, i, n) + 1;
|
||||||
|
sum += num ;
|
||||||
|
i = model->GetNextSibling( i );
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDataViewMainWindow::BuildTree(wxDataViewModel * model)
|
||||||
|
{
|
||||||
|
//First we define a invalid item to fetch the top-level elements
|
||||||
|
wxDataViewItem item;
|
||||||
|
m_count = BuildTreeHelper( model, item, m_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DestroyTreeHelper( wxDataViewTreeNode * node )
|
||||||
|
{
|
||||||
|
if( node->HasChildren() )
|
||||||
|
{
|
||||||
|
int len = node->GetChildrenNumber();
|
||||||
|
int i = 0 ;
|
||||||
|
wxDataViewTreeNodes nodes = node->GetChildren();
|
||||||
|
for( ; i < len; i ++ )
|
||||||
|
{
|
||||||
|
DestroyTreeHelper(nodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDataViewMainWindow::DestroyTree()
|
||||||
|
{
|
||||||
|
DestroyTreeHelper(m_root);
|
||||||
|
m_count = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
|
void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
if (event.GetKeyCode() == WXK_TAB)
|
if (event.GetKeyCode() == WXK_TAB)
|
||||||
@@ -2259,7 +2485,7 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewListModel *model = GetOwner()->GetModel();
|
wxDataViewModel *model = GetOwner()->GetModel();
|
||||||
|
|
||||||
if (event.Dragging())
|
if (event.Dragging())
|
||||||
{
|
{
|
||||||
@@ -2306,7 +2532,8 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
|
|||||||
cell->SetValue( value );
|
cell->SetValue( value );
|
||||||
wxRect cell_rect( xpos, current * m_lineHeight,
|
wxRect cell_rect( xpos, current * m_lineHeight,
|
||||||
col->GetWidth(), m_lineHeight );
|
col->GetWidth(), m_lineHeight );
|
||||||
cell->Activate( cell_rect, model, col->GetModelColumn(), current );
|
wxDataViewItem dataitem = GetItemByRow(current);
|
||||||
|
cell->Activate( cell_rect, model, dataitem, col->GetModelColumn() );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2551,15 +2778,17 @@ void wxDataViewCtrl::OnSize( wxSizeEvent &WXUNUSED(event) )
|
|||||||
AdjustScrollbars();
|
AdjustScrollbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
|
bool wxDataViewCtrl::AssociateModel( wxDataViewModel *model )
|
||||||
{
|
{
|
||||||
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
if (!wxDataViewCtrlBase::AssociateModel( model ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_notifier = new wxGenericDataViewListModelNotifier( m_clientArea );
|
m_notifier = new wxGenericDataViewModelNotifier( m_clientArea );
|
||||||
|
|
||||||
model->AddNotifier( m_notifier );
|
model->AddNotifier( m_notifier );
|
||||||
|
|
||||||
|
m_clientArea->BuildTree(model);
|
||||||
|
|
||||||
m_clientArea->UpdateDisplay();
|
m_clientArea->UpdateDisplay();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2581,7 +2810,7 @@ void wxDataViewCtrl::OnColumnChange()
|
|||||||
|
|
||||||
m_clientArea->UpdateDisplay();
|
m_clientArea->UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
/********************************************************************
|
||||||
void wxDataViewCtrl::SetSelection( int row )
|
void wxDataViewCtrl::SetSelection( int row )
|
||||||
{
|
{
|
||||||
m_clientArea->SelectRow(row, true);
|
m_clientArea->SelectRow(row, true);
|
||||||
@@ -2622,7 +2851,7 @@ int wxDataViewCtrl::GetSelections(wxArrayInt& WXUNUSED(aSelections) ) const
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*********************************************************************/
|
||||||
#endif
|
#endif
|
||||||
// !wxUSE_GENERICDATAVIEWCTRL
|
// !wxUSE_GENERICDATAVIEWCTRL
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user