X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f3af7e7f8625baf8e72951c066fecf61ea46821..5ac1d44aa499901b1a2e194292ba7a93112196ae:/src/common/datavcmn.cpp diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 268856c151..106bf563f8 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -15,24 +15,25 @@ #pragma hdrstop #endif -#include "wx/defs.h" - #if wxUSE_DATAVIEWCTRL -#include "wx/object.h" #include "wx/dataview.h" -#include "wx/log.h" -#include "wx/image.h" -// --------------------------------------------------------- +#ifndef WX_PRECOMP + #include "wx/log.h" +#endif + +const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl"); + +// --------------------------------------------------------- // wxDataViewModel -// --------------------------------------------------------- +// --------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxDataViewModel, wxObject) -// --------------------------------------------------------- +// --------------------------------------------------------- // wxDataViewListModel -// --------------------------------------------------------- +// --------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxDataViewListModel, wxDataViewModel) @@ -50,7 +51,7 @@ bool wxDataViewListModel::RowAppended() { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -58,7 +59,7 @@ bool wxDataViewListModel::RowAppended() ret = false; node = node->GetNext(); } - + return ret; } @@ -66,7 +67,7 @@ bool wxDataViewListModel::RowPrepended() { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -74,7 +75,7 @@ bool wxDataViewListModel::RowPrepended() ret = false; node = node->GetNext(); } - + return ret; } @@ -82,7 +83,7 @@ bool wxDataViewListModel::RowInserted( size_t before ) { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -90,7 +91,7 @@ bool wxDataViewListModel::RowInserted( size_t before ) ret = false; node = node->GetNext(); } - + return ret; } @@ -98,7 +99,7 @@ bool wxDataViewListModel::RowDeleted( size_t row ) { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -106,7 +107,7 @@ bool wxDataViewListModel::RowDeleted( size_t row ) ret = false; node = node->GetNext(); } - + return ret; } @@ -114,7 +115,7 @@ bool wxDataViewListModel::RowChanged( size_t row ) { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -122,7 +123,7 @@ bool wxDataViewListModel::RowChanged( size_t row ) ret = false; node = node->GetNext(); } - + return ret; } @@ -130,7 +131,7 @@ bool wxDataViewListModel::ValueChanged( size_t col, size_t row ) { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -138,7 +139,7 @@ bool wxDataViewListModel::ValueChanged( size_t col, size_t row ) ret = false; node = node->GetNext(); } - + return ret; } @@ -146,7 +147,7 @@ bool wxDataViewListModel::RowsReordered( size_t *new_order ) { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -154,7 +155,7 @@ bool wxDataViewListModel::RowsReordered( size_t *new_order ) ret = false; node = node->GetNext(); } - + return ret; } @@ -162,7 +163,7 @@ bool wxDataViewListModel::Cleared() { bool ret = true; - wxNode *node = m_notifiers.GetFirst(); + wxList::compatibility_iterator node = m_notifiers.GetFirst(); while (node) { wxDataViewListModelNotifier* notifier = (wxDataViewListModelNotifier*) node->GetData(); @@ -170,7 +171,7 @@ bool wxDataViewListModel::Cleared() ret = false; node = node->GetNext(); } - + return ret; } @@ -181,17 +182,17 @@ void wxDataViewListModel::AddViewingColumn( wxDataViewColumn *view_column, size_ void wxDataViewListModel::RemoveViewingColumn( wxDataViewColumn *column ) { - wxNode *node = m_viewingColumns.GetFirst(); + wxList::compatibility_iterator node = m_viewingColumns.GetFirst(); while (node) { wxDataViewViewingColumn* tmp = (wxDataViewViewingColumn*) node->GetData(); - + if (tmp->m_viewColumn == column) { m_viewingColumns.DeleteObject( tmp ); return; } - + node = node->GetNext(); } } @@ -207,32 +208,32 @@ void wxDataViewListModel::RemoveNotifier( wxDataViewListModelNotifier *notifier 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 ) @@ -281,7 +282,7 @@ int LINKAGEMODE wxDataViewIntermediateCmp( size_t row1, size_t row2 ) return s_CmpFunc( row1, row2, s_CmpCol, s_CmpModel ); } -// --------------------------------------------------------- +// --------------------------------------------------------- // wxDataViewSortedListModel // --------------------------------------------------------- @@ -294,11 +295,11 @@ wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child s_CmpCol = 0; s_CmpModel = child; s_CmpFunc = wxDataViewListModelSortedDefaultCompare; - + m_notifierOnChild = new wxDataViewSortedListModelNotifier( this ); m_child->AddNotifier( m_notifierOnChild ); - - Resort(); + + Resort(); } wxDataViewSortedListModel::~wxDataViewSortedListModel() @@ -335,7 +336,7 @@ 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; @@ -347,17 +348,17 @@ bool wxDataViewSortedListModel::ChildValueChanged( size_t col, size_t 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 ]; @@ -376,12 +377,12 @@ bool wxDataViewSortedListModel::ChildValueChanged( size_t col, size_t row ) for (i = end_pos; i > start_pos; i--) order[i] = order[i-1]; order[start_pos] = end_pos; - } - + } + wxDataViewListModel::RowsReordered( order ); - + delete [] order; - + return true; } @@ -410,9 +411,9 @@ bool wxDataViewSortedListModel::SetValue( wxVariant &variant, size_t col, size_t { 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; } @@ -420,9 +421,9 @@ bool wxDataViewSortedListModel::RowAppended() { // you can only append bool ret = m_child->RowAppended(); - + // report RowInsrted - + return ret; } @@ -430,31 +431,31 @@ bool wxDataViewSortedListModel::RowPrepended() { // 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; } @@ -462,10 +463,10 @@ bool wxDataViewSortedListModel::RowChanged( size_t row ) { 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; } @@ -473,14 +474,14 @@ bool wxDataViewSortedListModel::ValueChanged( size_t col, size_t row ) { 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. @@ -490,15 +491,15 @@ bool wxDataViewSortedListModel::RowsReordered( size_t *new_order ) bool wxDataViewSortedListModel::Cleared() { bool ret = m_child->Cleared(); - + wxDataViewListModel::Cleared(); - + return ret; } -// --------------------------------------------------------- +// --------------------------------------------------------- // wxDataViewCellBase -// --------------------------------------------------------- +// --------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject) @@ -507,14 +508,19 @@ wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewC m_variantType = varianttype; m_mode = mode; } - -// --------------------------------------------------------- + +// --------------------------------------------------------- // wxDataViewColumnBase -// --------------------------------------------------------- +// --------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject) -wxDataViewColumnBase::wxDataViewColumnBase( const wxString &title, wxDataViewCell *cell, size_t model_column, int flags) +wxDataViewColumnBase::wxDataViewColumnBase(const wxString& title, + wxDataViewCell *cell, + size_t model_column, + int WXUNUSED(fixed_width), + wxDataViewColumnSizing WXUNUSED(sizing), + int flags ) { m_cell = cell; m_model_column = model_column; @@ -528,7 +534,7 @@ wxDataViewColumnBase::~wxDataViewColumnBase() { if (m_cell) delete m_cell; - + if (GetOwner()) { GetOwner()->GetModel()->RemoveViewingColumn( (wxDataViewColumn*) this ); @@ -545,9 +551,9 @@ wxString wxDataViewColumnBase::GetTitle() return m_title; } -// --------------------------------------------------------- +// --------------------------------------------------------- // wxDataViewCtrlBase -// --------------------------------------------------------- +// --------------------------------------------------------- IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl) @@ -564,7 +570,7 @@ wxDataViewCtrlBase::~wxDataViewCtrlBase() bool wxDataViewCtrlBase::AssociateModel( wxDataViewListModel *model ) { m_model = model; - + return true; } @@ -580,12 +586,12 @@ bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, size_t model_c bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, size_t model_column ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleCell(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleCell(), model_column, 30 ) ); } bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, size_t model_column ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressCell(), model_column, 70 ) ); } bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, size_t model_column ) @@ -606,7 +612,7 @@ size_t wxDataViewCtrlBase::GetNumberOfColumns() return m_cols.GetCount(); } -bool wxDataViewCtrlBase::DeleteColumn( size_t pos ) +bool wxDataViewCtrlBase::DeleteColumn( size_t WXUNUSED(pos) ) { return false; }