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
// 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)
};
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)
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:
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
// ---------------------------------------------------------
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:
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:
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;
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 );
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;
private:
DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
- DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
+ wxDECLARE_NO_COPY_CLASS(wxDataViewCtrl);
DECLARE_EVENT_TABLE()
};