X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f828871d12d34950779ed29599cbd13f05e00992..ce7208d49d5ce2ca1dc0b3b83f14f1d04f29c4bf:/src/common/datavcmn.cpp?ds=inline diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 2f7c9fe6a2..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; @@ -707,6 +725,20 @@ wxDataViewColumnBase::wxDataViewColumnBase(const wxString& title, 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_renderer) @@ -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 wxDataViewTextRenderer(), 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 wxDataViewToggleRenderer(), 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 wxDataViewProgressRenderer(), 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 wxDataViewDateRenderer(), model_column ) ); + return AppendColumn( new wxDataViewColumn( label, + new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode ), model_column, width ) ); } bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) @@ -812,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