#include "wx/dataview.h"
#include "wx/spinctrl.h"
-#include "wx/dc.h"
-#include "wx/settings.h"
#ifndef WX_PRECOMP
+ #include "wx/dc.h"
+ #include "wx/settings.h"
#include "wx/log.h"
#include "wx/icon.h"
+ #include "wx/crt.h"
#endif
const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl");
return (left.GetID() == right.GetID() );
}
+#ifdef __WXDEBUG__
+void wxDataViewItem::Print(const wxString& text) const
+{
+ wxPrintf("item %s: %l\n", text, (long)m_id);
+}
+#endif
// ---------------------------------------------------------
// wxDataViewModelNotifier
// ---------------------------------------------------------
#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxDataViewModelNotifiers);
+WX_DEFINE_LIST(wxDataViewModelNotifiers)
bool wxDataViewModelNotifier::ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items )
{
wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
{
+ m_ordered = true;
+
// build initial index
unsigned int i;
for (i = 1; i < initial_size+1; i++)
void wxDataViewIndexListModel::RowPrepended()
{
+ m_ordered = false;
+
unsigned int id = m_lastIndex++;
m_hash.Insert( (void*) id, 0 );
wxDataViewItem item( (void*) id );
void wxDataViewIndexListModel::RowInserted( unsigned int before )
{
+ m_ordered = false;
+
unsigned int id = m_lastIndex++;
m_hash.Insert( (void*) id, before );
wxDataViewItem item( (void*) id );
unsigned int wxDataViewIndexListModel::GetRow( const wxDataViewItem &item ) const
{
+ if (m_ordered)
+ {
+ unsigned int pos = wxPtrToUInt(item.GetID());
+ return pos-1;
+ }
+
// assert for not found
return (unsigned int) m_hash.Index( item.GetID() );
}
return wxDataViewItem( m_hash[row] );
}
+bool wxDataViewIndexListModel::HasDefaultCompare() const
+{
+ return !m_ordered;
+}
+
int wxDataViewIndexListModel::Compare(const wxDataViewItem& item1,
const wxDataViewItem& item2,
unsigned int WXUNUSED(column),
bool ascending)
{
+ if (m_ordered)
+ {
+ unsigned int pos1 = wxPtrToUInt(item1.GetID());
+ unsigned int pos2 = wxPtrToUInt(item2.GetID());
+
+ if (ascending)
+ return pos1 - pos2;
+ else
+ return pos2 - pos1;
+ }
+
if (ascending)
return GetRow(item1) - GetRow(item2);
return SetValue( variant, GetRow(item), col );
}
+bool wxDataViewIndexListModel::GetAttr( const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr )
+{
+ return GetAttr( GetRow(item), col, attr );
+}
+
wxDataViewItem wxDataViewIndexListModel::GetParent( const wxDataViewItem & WXUNUSED(item) ) const
{
return wxDataViewItem(0);
}
#include "wx/listimpl.cpp"
-WX_DEFINE_LIST(wxDataViewTreeStoreNodeList);
+WX_DEFINE_LIST(wxDataViewTreeStoreNodeList)
wxDataViewTreeStoreContainerNode::wxDataViewTreeStoreContainerNode(
wxDataViewTreeStoreNode *parent, const wxString &text,