X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/07a84e7bbb3ed346fff59aa3570a1f687a3c4d7b..8168167976dc3cc5f5223a21e1a62ba91a4f77b3:/src/common/datavcmn.cpp?ds=inline diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 976723b2f4..1094b1ebca 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -287,9 +287,15 @@ int wxCALLBACK wxDataViewListModelSortedDefaultCompare return 0; } +int wxCALLBACK wxDataViewListModelSortedDefaultCompareDescending + (unsigned int row1, unsigned int row2, unsigned int col, wxDataViewListModel* model ) +{ + return wxDataViewListModelSortedDefaultCompare( row2, row1, col, model ); +} + static wxDataViewListModelCompare s_CmpFunc; static wxDataViewListModel *s_CmpModel; -static unsigned int s_CmpCol; +static unsigned int s_CmpCol; int LINKAGEMODE wxDataViewIntermediateCmp( unsigned int row1, unsigned int row2 ) { @@ -306,9 +312,8 @@ wxDataViewSortedListModel::wxDataViewSortedListModel( wxDataViewListModel *child m_array( wxDataViewIntermediateCmp ) { m_child = child; - s_CmpCol = 0; - s_CmpModel = child; - s_CmpFunc = wxDataViewListModelSortedDefaultCompare; + + m_ascending = true; m_notifierOnChild = new wxDataViewSortedListModelNotifier( this ); m_child->AddNotifier( m_notifierOnChild ); @@ -321,8 +326,21 @@ wxDataViewSortedListModel::~wxDataViewSortedListModel() m_child->RemoveNotifier( m_notifierOnChild ); } +// FIXME +void wxDataViewSortedListModel::InitStatics() +{ + s_CmpCol = 0; + s_CmpModel = m_child; + if (m_ascending) + s_CmpFunc = wxDataViewListModelSortedDefaultCompare; + else + s_CmpFunc = wxDataViewListModelSortedDefaultCompareDescending; +} + void wxDataViewSortedListModel::Resort() { + InitStatics(); + m_array.Clear(); unsigned int n = m_child->GetNumberOfRows(); unsigned int i; @@ -780,54 +798,74 @@ wxDataViewListModel* wxDataViewCtrlBase::GetModel() return m_model; } -bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewTextRenderer( wxT("string"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleRenderer(), model_column, 30 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressRenderer(), model_column, 70 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewDateRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewDateRenderer( wxT("datetime"), mode), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewBitmapRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewTextRenderer( wxT("string"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewToggleRenderer(), model_column, 30 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewProgressRenderer(), model_column, 70 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewDateRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewDateRenderer( wxT("datetime"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column ) +bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewBitmapRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) ); } bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) @@ -866,6 +904,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_SELECTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ROW_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK) #endif