X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/702f5349c6468baae69ce6b7b2c780c3be57ee7c..3427bc784ec7dae7d3830e8f2c61565587e8f791:/include/wx/generic/dataview.h diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index db9202eea9..a9c57e1c4e 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -38,12 +38,30 @@ public: int align = wxDVR_DEFAULT_ALIGNMENT ); virtual ~wxDataViewRenderer(); + // these methods are used to draw the cell contents, Render() doesn't care + // about the attributes while RenderWithAttr() does -- override it if you + // want to take the attributes defined for this cell into account, otherwise + // overriding Render() is enough virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0; + + // NB: RenderWithAttr() also has more standard parameter order and types + virtual bool + RenderWithAttr(wxDC& dc, + const wxRect& rect, + int align, // combination of horizontal and vertical + const wxDataViewItemAttr *attr, // may be NULL if none + int state); + virtual wxSize GetSize() const = 0; virtual void SetAlignment( int align ); virtual int GetAlignment() const; + virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE) + { m_ellipsizeMode = mode; } + virtual wxEllipsizeMode GetEllipsizeMode() const + { return m_ellipsizeMode; } + virtual void SetMode( wxDataViewCellMode mode ) { m_mode=mode; } virtual wxDataViewCellMode GetMode() const @@ -77,24 +95,28 @@ public: // Create DC on request virtual wxDC *GetDC(); - void SetHasAttr( bool set ) { m_hasAttr = set; } - void SetAttr( const wxDataViewItemAttr &attr ) { m_attr = attr; } - bool GetWantsAttr() { return m_wantsAttr; } - // implementation int CalculateAlignment() const; +protected: + // This is just a convenience for the derived classes overriding + // RenderWithAttr() to avoid repeating the same wxFAIL_MSG() in all of them + bool DummyRender(wxRect WXUNUSED(cell), + wxDC * WXUNUSED(dc), + int WXUNUSED(state)) + { + wxFAIL_MSG("shouldn't be called at all, use RenderWithAttr() instead"); + + return false; + } + private: wxDC *m_dc; int m_align; wxDataViewCellMode m_mode; -protected: - bool m_wantsAttr; - bool m_hasAttr; - wxDataViewItemAttr m_attr; + wxEllipsizeMode m_ellipsizeMode; -protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer) }; @@ -109,7 +131,24 @@ public: wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align = wxDVR_DEFAULT_ALIGNMENT ); - void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state ); + // Draw the text using the provided attributes + void RenderText(wxDC& dc, + const wxRect& rect, + int align, + const wxString& text, + const wxDataViewItemAttr *attr, // may be NULL if none + int state, + int xoffset = 0); + + // Overload using standard attributes + void RenderText(const wxString& text, + int xoffset, + wxRect cell, + wxDC *dc, + int state) + { + RenderText(*dc, cell, wxALIGN_NOT, text, NULL, state, xoffset); + } protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer) @@ -130,12 +169,22 @@ public: bool SetValue( const wxVariant &value ); bool GetValue( wxVariant &value ) const; - bool Render( wxRect cell, wxDC *dc, int state ); + virtual bool RenderWithAttr(wxDC& dc, + const wxRect& rect, + int align, + const wxDataViewItemAttr *attr, + int state); + virtual bool Render(wxRect cell, wxDC *dc, int state) + { + return DummyRender(cell, dc, state); + } + wxSize GetSize() const; // in-place editing - virtual bool HasEditorCtrl(); - virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); + virtual bool HasEditorCtrl() const; + virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, + const wxVariant &value ); virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); protected: @@ -145,23 +194,6 @@ protected: DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer) }; -// --------------------------------------------------------- -// wxDataViewTextRendererAttr -// --------------------------------------------------------- - -class WXDLLIMPEXP_ADV wxDataViewTextRendererAttr: public wxDataViewTextRenderer -{ -public: - wxDataViewTextRendererAttr( const wxString &varianttype = wxT("string"), - wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, - int align = wxDVR_DEFAULT_ALIGNMENT ); - - bool Render( wxRect cell, wxDC *dc, int state ); - -protected: - DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRendererAttr) -}; - // --------------------------------------------------------- // wxDataViewBitmapRenderer // --------------------------------------------------------- @@ -224,12 +256,19 @@ public: const wxString &varianttype = wxT("long"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align = wxDVR_DEFAULT_ALIGNMENT ); - virtual ~wxDataViewProgressRenderer(); bool SetValue( const wxVariant &value ); bool GetValue( wxVariant& value ) const; - virtual bool Render( wxRect cell, wxDC *dc, int state ); + virtual bool RenderWithAttr(wxDC& dc, + const wxRect& rect, + int align, + const wxDataViewItemAttr *attr, + int state); + virtual bool Render(wxRect cell, wxDC *dc, int state) + { + return DummyRender(cell, dc, state); + } virtual wxSize GetSize() const; private: @@ -250,16 +289,24 @@ public: wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align = wxDVR_DEFAULT_ALIGNMENT ); - virtual ~wxDataViewIconTextRenderer(); bool SetValue( const wxVariant &value ); bool GetValue( wxVariant &value ) const; - virtual bool Render( wxRect cell, wxDC *dc, int state ); + virtual bool RenderWithAttr(wxDC& dc, + const wxRect& rect, + int align, + const wxDataViewItemAttr *attr, + int state); + virtual bool Render(wxRect cell, wxDC *dc, int state) + { + return DummyRender(cell, dc, state); + } virtual wxSize GetSize() const; - virtual bool HasEditorCtrl() { return true; } - virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value ); + virtual bool HasEditorCtrl() const { return true; } + virtual wxControl* CreateEditorCtrl( wxWindow *parent, wxRect labelRect, + const wxVariant &value ); virtual bool GetValueFromEditorCtrl( wxControl* editor, wxVariant &value ); private: @@ -286,7 +333,9 @@ public: virtual bool Render( wxRect cell, wxDC *dc, int state ); virtual wxSize GetSize() const; virtual bool Activate( wxRect cell, - wxDataViewModel *model, const wxDataViewItem & item, unsigned int col ); + wxDataViewModel *model, + const wxDataViewItem& item, + unsigned int col ); private: wxDateTime m_date; @@ -379,8 +428,8 @@ private: WX_DECLARE_LIST_WITH_DECL(wxDataViewColumn, wxDataViewColumnList, class WXDLLIMPEXP_ADV); -class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase, - public wxScrollHelperNative +class WXDLLIMPEXP_ADV wxDataViewCtrl : public wxDataViewCtrlBase, + public wxScrollHelper { friend class wxDataViewMainWindow; friend class wxDataViewHeaderWindowBase; @@ -389,7 +438,7 @@ class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase, friend class wxDataViewColumn; public: - wxDataViewCtrl() : wxScrollHelperNative(this) + wxDataViewCtrl() : wxScrollHelper(this) { Init(); } @@ -398,7 +447,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator ) - : wxScrollHelperNative(this) + : wxScrollHelper(this) { Create(parent, id, pos, size, style, validator ); } @@ -408,9 +457,9 @@ public: void Init(); bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator ); + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = 0, + const wxValidator& validator = wxDefaultValidator ); virtual bool AssociateModel( wxDataViewModel *model ); @@ -441,14 +490,26 @@ public: virtual void EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ); - virtual void HitTest( const wxPoint & point, wxDataViewItem & item, wxDataViewColumn* &column ) const; - virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const; + virtual void HitTest( const wxPoint & point, wxDataViewItem & item, + wxDataViewColumn* &column ) const; + virtual wxRect GetItemRect( const wxDataViewItem & item, + const wxDataViewColumn *column = NULL ) const; virtual void Expand( const wxDataViewItem & item ); virtual void Collapse( const wxDataViewItem & item ); + virtual bool IsExpanded( const wxDataViewItem & item ) const; virtual void SetFocus(); +#if wxUSE_DRAG_AND_DROP + virtual bool EnableDragSource( const wxDataFormat &format ); + virtual bool EnableDropTarget( const wxDataFormat &format ); +#endif // wxUSE_DRAG_AND_DROP + + virtual wxBorder GetDefaultBorder() const; + + void StartEditor( const wxDataViewItem & item, unsigned int column ); + protected: virtual int GetSelections( wxArrayInt & sel ) const; virtual void SetSelections( const wxArrayInt & sel ); @@ -514,7 +575,7 @@ private: private: DECLARE_DYNAMIC_CLASS(wxDataViewCtrl) - DECLARE_NO_COPY_CLASS(wxDataViewCtrl) + wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl); DECLARE_EVENT_TABLE() };