dvrenderer.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/dvrenderer.h
  3. // Purpose: wxDataViewRenderer for OS X wxDataViewCtrl implementations
  4. // Author: Vadim Zeitlin
  5. // Created: 2009-11-07 (extracted from wx/osx/dataview.h)
  6. // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_OSX_DVRENDERER_H_
  10. #define _WX_OSX_DVRENDERER_H_
  11. class wxDataViewRendererNativeData;
  12. // ----------------------------------------------------------------------------
  13. // wxDataViewRenderer
  14. // ----------------------------------------------------------------------------
  15. class WXDLLIMPEXP_ADV wxDataViewRenderer : public wxDataViewRendererBase
  16. {
  17. public:
  18. // constructors / destructor
  19. // -------------------------
  20. wxDataViewRenderer(const wxString& varianttype,
  21. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  22. int align = wxDVR_DEFAULT_ALIGNMENT);
  23. virtual ~wxDataViewRenderer();
  24. // inherited methods from wxDataViewRendererBase
  25. // ---------------------------------------------
  26. virtual int GetAlignment() const
  27. {
  28. return m_alignment;
  29. }
  30. virtual wxDataViewCellMode GetMode() const
  31. {
  32. return m_mode;
  33. }
  34. virtual bool GetValue(wxVariant& value) const
  35. {
  36. value = m_value;
  37. return true;
  38. }
  39. // NB: in Carbon this is always identical to the header alignment
  40. virtual void SetAlignment(int align);
  41. virtual void SetMode(wxDataViewCellMode mode);
  42. virtual bool SetValue(const wxVariant& newValue)
  43. {
  44. m_value = newValue;
  45. return true;
  46. }
  47. virtual void EnableEllipsize(wxEllipsizeMode mode = wxELLIPSIZE_MIDDLE);
  48. virtual wxEllipsizeMode GetEllipsizeMode() const;
  49. // implementation
  50. // --------------
  51. const wxVariant& GetValue() const
  52. {
  53. return m_value;
  54. }
  55. wxDataViewRendererNativeData* GetNativeData() const
  56. {
  57. return m_NativeDataPtr;
  58. }
  59. // a call to the native data browser function to render the data;
  60. // returns true if the data value could be rendered, false otherwise
  61. virtual bool MacRender() = 0;
  62. void SetNativeData(wxDataViewRendererNativeData* newNativeDataPtr);
  63. #if wxOSX_USE_COCOA
  64. // called when a value was edited by user
  65. virtual void OSXOnCellChanged(NSObject *value,
  66. const wxDataViewItem& item,
  67. unsigned col);
  68. // called to ensure that the given attribute will be used for rendering the
  69. // next cell (which had been already associated with this renderer before)
  70. virtual void OSXApplyAttr(const wxDataViewItemAttr& attr);
  71. // called to set the state of the next cell to be rendered
  72. virtual void OSXApplyEnabled(bool enabled);
  73. #endif // Cocoa
  74. private:
  75. // contains the alignment flags
  76. int m_alignment;
  77. // storing the mode that determines how the cell is going to be shown
  78. wxDataViewCellMode m_mode;
  79. // data used by implementation of the native renderer
  80. wxDataViewRendererNativeData* m_NativeDataPtr;
  81. // value that is going to be rendered
  82. wxVariant m_value;
  83. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewRenderer)
  84. };
  85. #endif // _WX_OSX_DVRENDERER_H_