X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/eb7f97f8d60ac6279f9335424a5fc91a8b1e809a..ce7208d49d5ce2ca1dc0b3b83f14f1d04f29c4bf:/src/common/datavcmn.cpp?ds=sidebyside diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 0ca43f9b00..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; @@ -676,12 +694,12 @@ bool wxDataViewSortedListModel::Cleared() } // --------------------------------------------------------- -// wxDataViewCellBase +// wxDataViewRendererBase // --------------------------------------------------------- -IMPLEMENT_ABSTRACT_CLASS(wxDataViewCellBase, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject) -wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewCellMode mode ) +wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, wxDataViewCellMode mode ) { m_variantType = varianttype; m_mode = mode; @@ -694,23 +712,37 @@ wxDataViewCellBase::wxDataViewCellBase( const wxString &varianttype, wxDataViewC IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject) wxDataViewColumnBase::wxDataViewColumnBase(const wxString& title, - wxDataViewCell *cell, + wxDataViewRenderer *renderer, unsigned int model_column, int WXUNUSED(width), int flags ) { - m_cell = cell; + m_renderer = renderer; m_model_column = model_column; m_flags = flags; m_title = title; m_owner = NULL; - m_cell->SetOwner( (wxDataViewColumn*) this ); + m_renderer->SetOwner( (wxDataViewColumn*) this ); +} + +wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap, + wxDataViewRenderer *renderer, + unsigned int model_column, + int WXUNUSED(width), + int flags ) +{ + m_renderer = renderer; + m_model_column = model_column; + m_flags = flags; + m_bitmap = bitmap; + m_owner = NULL; + m_renderer->SetOwner( (wxDataViewColumn*) this ); } wxDataViewColumnBase::~wxDataViewColumnBase() { - if (m_cell) - delete m_cell; + if (m_renderer) + delete m_renderer; if (GetOwner()) { @@ -728,6 +760,16 @@ wxString wxDataViewColumnBase::GetTitle() return m_title; } +void wxDataViewColumnBase::SetBitmap( const wxBitmap &bitmap ) +{ + m_bitmap = bitmap; +} + +const wxBitmap &wxDataViewColumnBase::GetBitmap() +{ + return m_bitmap; +} + // --------------------------------------------------------- // wxDataViewCtrlBase // --------------------------------------------------------- @@ -756,24 +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( wxT("string"), mode ), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) +{ + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) +{ + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) +{ + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewDateRenderer( wxT("datetime"), mode), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) +{ + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) +{ + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewTextRenderer( wxT("string"), mode ), model_column, width ) ); +} + +bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, + wxDataViewCellMode mode, int width ) { - return AppendColumn( new wxDataViewColumn( label, new wxDataViewTextCell(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewToggleRenderer( wxT("bool"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &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 wxDataViewToggleCell(), model_column, 30 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &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 wxDataViewProgressCell(), model_column, 70 ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewDateRenderer( wxT("datetime"), mode ), model_column, width ) ); } -bool wxDataViewCtrlBase::AppendDateColumn( const wxString &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 wxDataViewDateCell(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) ); } bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) @@ -811,6 +903,9 @@ wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) 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