#pragma hdrstop
#endif
-#include "wx/defs.h"
-
#if wxUSE_DATAVIEWCTRL
-#include "wx/object.h"
-#include "wx/dataview.h"
-#include "wx/log.h"
+#ifndef WX_PRECOMP
+ #include "wx/object.h"
+ #include "wx/log.h"
+#endif
+
#include "wx/image.h"
+#include "wx/dataview.h"
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject)
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewListModel
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel)
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
ret = false;
node = node->GetNext();
}
-
+
return ret;
}
while (node)
{
wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData();
-
+
if (tmp->m_viewColumn == column)
{
m_viewingColumns.DeleteObject( tmp );
return;
}
-
+
node = node->GetNext();
}
}
m_notifiers.DeleteObject( notifier );
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModelNotifier
-// ---------------------------------------------------------
+// ---------------------------------------------------------
class wxDataViewSortedListModelNotifier: public wxDataViewListModelNotifier
{
public:
wxDataViewSortedListModelNotifier( wxDataViewSortedListModel *model )
{ m_model = model; }
-
+
virtual bool RowAppended() { return true; }
virtual bool RowPrepended() { return true; }
- virtual bool RowInserted( size_t before ) { return true; }
- virtual bool RowDeleted( size_t row ) { return true; }
- virtual bool RowChanged( size_t row ) { return true; }
+ virtual bool RowInserted( size_t WXUNUSED(before) ) { return true; }
+ virtual bool RowDeleted( size_t WXUNUSED(row) ) { return true; }
+ virtual bool RowChanged( size_t WXUNUSED(row) ) { return true; }
virtual bool ValueChanged( size_t col, size_t row )
{ return m_model->ChildValueChanged( col, row); }
- virtual bool RowsReordered( size_t *new_order ) { return true; }
+ virtual bool RowsReordered( size_t *WXUNUSED(new_order) ) { return true; }
virtual bool Cleared() { return true; }
-
+
wxDataViewSortedListModel *m_model;
};
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModel compare function
-// ---------------------------------------------------------
+// ---------------------------------------------------------
int wxCALLBACK wxDataViewListModelSortedDefaultCompare
(size_t row1, size_t row2, size_t col, wxDataViewListModel* model )
{
- wxVariant value1 = model->GetValue( col, row1 );
- wxVariant value2 = model->GetValue( col, row2 );
+ wxVariant value1,value2;
+ model->GetValue( value1, col, row1 );
+ model->GetValue( value2, col, row2 );
if (value1.GetType() == wxT("string"))
{
wxString str1 = value1.GetString();
return s_CmpFunc( row1, row2, s_CmpCol, s_CmpModel );
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewSortedListModel
// ---------------------------------------------------------
s_CmpCol = 0;
s_CmpModel = child;
s_CmpFunc = wxDataViewListModelSortedDefaultCompare;
-
+
m_notifierOnChild = new wxDataViewSortedListModelNotifier( this );
m_child->AddNotifier( m_notifierOnChild );
-
- Resort();
+
+ Resort();
}
wxDataViewSortedListModel::~wxDataViewSortedListModel()
m_array.Add( i );
}
+#if 0
+static void Dump( wxDataViewListModel *model, size_t col )
+{
+ size_t n = model->GetNumberOfRows();
+ size_t i;
+ for (i = 0; i < n; i++)
+ {
+ wxVariant variant;
+ model->GetValue( variant, col, i );
+ wxString tmp;
+ tmp = variant.GetString();
+ wxPrintf( wxT("%d: %s\n"), (int) i, tmp.c_str() );
+ }
+}
+#endif
+
bool wxDataViewSortedListModel::ChildValueChanged( size_t col, size_t row )
{
size_t i;
size_t len = m_array.GetCount();
-
+
// Remove and readd sorted. Find out at which
// position it was and where it ended.
size_t start_pos = 0,end_pos = 0;
start_pos = i;
break;
}
- m_array.Remove( row );
+ m_array.RemoveAt( start_pos );
m_array.Add( row );
+
for (i = 0; i < len; i++)
if (m_array[i] == row)
{
end_pos = i;
break;
}
-
+
if (end_pos == start_pos)
return wxDataViewListModel::ValueChanged( col, start_pos );
-
+
// Create an array where order[old] -> new_pos, so that
// if nothing changed order[0] -> 0 etc.
size_t *order = new size_t[ len ];
for (i = end_pos; i > start_pos; i--)
order[i] = order[i-1];
order[start_pos] = end_pos;
- }
-
- RowsReordered( order );
-
+ }
+
+ wxDataViewListModel::RowsReordered( order );
+
delete [] order;
-
+
return true;
}
size_t wxDataViewSortedListModel::GetNumberOfRows()
{
- return m_child->GetNumberOfRows();
+ return m_array.GetCount();
}
size_t wxDataViewSortedListModel::GetNumberOfCols()
return m_child->GetColType( col );
}
-wxVariant wxDataViewSortedListModel::GetValue( size_t col, size_t row )
+void wxDataViewSortedListModel::GetValue( wxVariant &variant, size_t col, size_t row )
{
size_t child_row = m_array[row];
- return m_child->GetValue( col, child_row );
+ m_child->GetValue( variant, col, child_row );
}
bool wxDataViewSortedListModel::SetValue( wxVariant &variant, size_t col, size_t row )
{
size_t child_row = m_array[row];
bool ret = m_child->SetValue( variant, col, child_row );
-
+
// Resort in ::ChildValueChanged() which gets reported back.
-
+
return ret;
}
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report RowInsrted
-
+
return ret;
}
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report RowInsrted
-
+
return ret;
}
-bool wxDataViewSortedListModel::RowInserted( size_t before )
+bool wxDataViewSortedListModel::RowInserted( size_t WXUNUSED(before) )
{
// you can only append
bool ret = m_child->RowAppended();
-
+
// report different RowInsrted
-
+
return ret;
}
bool wxDataViewSortedListModel::RowDeleted( size_t row )
{
size_t child_row = m_array[row];
-
+
bool ret = m_child->RowDeleted( child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
{
size_t child_row = m_array[row];
bool ret = m_child->RowChanged( child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
{
size_t child_row = m_array[row];
bool ret = m_child->ValueChanged( col, child_row );
-
+
// Do nothing here as the change in the
// child model will be reported back.
-
+
return ret;
}
-bool wxDataViewSortedListModel::RowsReordered( size_t *new_order )
+bool wxDataViewSortedListModel::RowsReordered( size_t *WXUNUSED(new_order) )
{
// We sort them ourselves.
bool wxDataViewSortedListModel::Cleared()
{
bool ret = m_child->Cleared();
-
+
wxDataViewListModel::Cleared();
-
+
return ret;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCellBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject)
m_variantType = varianttype;
m_mode = mode;
}
-
-// ---------------------------------------------------------
+
+// ---------------------------------------------------------
// wxDataViewColumnBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject)
{
if (m_cell)
delete m_cell;
-
+
if (GetOwner())
{
GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn*) this );
return m_title;
}
-// ---------------------------------------------------------
+// ---------------------------------------------------------
// wxDataViewCtrlBase
-// ---------------------------------------------------------
+// ---------------------------------------------------------
IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl)
bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model )
{
m_model = model;
-
+
return true;
}
return m_cols.GetCount();
}
-bool wxDataViewCtrlBase::DeleteColumn( size_t pos )
+bool wxDataViewCtrlBase::DeleteColumn( size_t WXUNUSED(pos) )
{
return false;
}