dvrenderers.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/dvrenderers.h
  3. // Purpose: All generic wxDataViewCtrl renderer classes
  4. // Author: Robert Roebling, Vadim Zeitlin
  5. // Created: 2009-11-07 (extracted from wx/generic/dataview.h)
  6. // Copyright: (c) 2006 Robert Roebling
  7. // (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_GENERIC_DVRENDERERS_H_
  11. #define _WX_GENERIC_DVRENDERERS_H_
  12. // ---------------------------------------------------------
  13. // wxDataViewCustomRenderer
  14. // ---------------------------------------------------------
  15. class WXDLLIMPEXP_ADV wxDataViewCustomRenderer: public wxDataViewRenderer
  16. {
  17. public:
  18. wxDataViewCustomRenderer( const wxString &varianttype = wxT("string"),
  19. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  20. int align = wxDVR_DEFAULT_ALIGNMENT );
  21. // see the explanation of the following WXOnXXX() methods in wx/generic/dvrenderer.h
  22. virtual bool WXActivateCell(const wxRect& cell,
  23. wxDataViewModel *model,
  24. const wxDataViewItem& item,
  25. unsigned int col,
  26. const wxMouseEvent *mouseEvent)
  27. {
  28. return ActivateCell(cell, model, item, col, mouseEvent);
  29. }
  30. private:
  31. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomRenderer)
  32. };
  33. // ---------------------------------------------------------
  34. // wxDataViewTextRenderer
  35. // ---------------------------------------------------------
  36. class WXDLLIMPEXP_ADV wxDataViewTextRenderer: public wxDataViewRenderer
  37. {
  38. public:
  39. wxDataViewTextRenderer( const wxString &varianttype = wxT("string"),
  40. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  41. int align = wxDVR_DEFAULT_ALIGNMENT );
  42. bool SetValue( const wxVariant &value );
  43. bool GetValue( wxVariant &value ) const;
  44. virtual bool Render(wxRect cell, wxDC *dc, int state);
  45. virtual wxSize GetSize() const;
  46. // in-place editing
  47. virtual bool HasEditorCtrl() const;
  48. virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
  49. const wxVariant &value );
  50. virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value );
  51. protected:
  52. wxString m_text;
  53. protected:
  54. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextRenderer)
  55. };
  56. // ---------------------------------------------------------
  57. // wxDataViewBitmapRenderer
  58. // ---------------------------------------------------------
  59. class WXDLLIMPEXP_ADV wxDataViewBitmapRenderer: public wxDataViewRenderer
  60. {
  61. public:
  62. wxDataViewBitmapRenderer( const wxString &varianttype = wxT("wxBitmap"),
  63. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  64. int align = wxDVR_DEFAULT_ALIGNMENT );
  65. bool SetValue( const wxVariant &value );
  66. bool GetValue( wxVariant &value ) const;
  67. bool Render( wxRect cell, wxDC *dc, int state );
  68. wxSize GetSize() const;
  69. private:
  70. wxIcon m_icon;
  71. wxBitmap m_bitmap;
  72. protected:
  73. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewBitmapRenderer)
  74. };
  75. // ---------------------------------------------------------
  76. // wxDataViewToggleRenderer
  77. // ---------------------------------------------------------
  78. class WXDLLIMPEXP_ADV wxDataViewToggleRenderer: public wxDataViewRenderer
  79. {
  80. public:
  81. wxDataViewToggleRenderer( const wxString &varianttype = wxT("bool"),
  82. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  83. int align = wxDVR_DEFAULT_ALIGNMENT );
  84. bool SetValue( const wxVariant &value );
  85. bool GetValue( wxVariant &value ) const;
  86. bool Render( wxRect cell, wxDC *dc, int state );
  87. wxSize GetSize() const;
  88. // Implementation only, don't use nor override
  89. virtual bool WXActivateCell(const wxRect& cell,
  90. wxDataViewModel *model,
  91. const wxDataViewItem& item,
  92. unsigned int col,
  93. const wxMouseEvent *mouseEvent);
  94. private:
  95. bool m_toggle;
  96. protected:
  97. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer)
  98. };
  99. // ---------------------------------------------------------
  100. // wxDataViewProgressRenderer
  101. // ---------------------------------------------------------
  102. class WXDLLIMPEXP_ADV wxDataViewProgressRenderer: public wxDataViewRenderer
  103. {
  104. public:
  105. wxDataViewProgressRenderer( const wxString &label = wxEmptyString,
  106. const wxString &varianttype = wxT("long"),
  107. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  108. int align = wxDVR_DEFAULT_ALIGNMENT );
  109. bool SetValue( const wxVariant &value );
  110. bool GetValue( wxVariant& value ) const;
  111. virtual bool Render(wxRect cell, wxDC *dc, int state);
  112. virtual wxSize GetSize() const;
  113. private:
  114. wxString m_label;
  115. int m_value;
  116. protected:
  117. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressRenderer)
  118. };
  119. // ---------------------------------------------------------
  120. // wxDataViewIconTextRenderer
  121. // ---------------------------------------------------------
  122. class WXDLLIMPEXP_ADV wxDataViewIconTextRenderer: public wxDataViewRenderer
  123. {
  124. public:
  125. wxDataViewIconTextRenderer( const wxString &varianttype = wxT("wxDataViewIconText"),
  126. wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
  127. int align = wxDVR_DEFAULT_ALIGNMENT );
  128. bool SetValue( const wxVariant &value );
  129. bool GetValue( wxVariant &value ) const;
  130. virtual bool Render(wxRect cell, wxDC *dc, int state);
  131. virtual wxSize GetSize() const;
  132. virtual bool HasEditorCtrl() const { return true; }
  133. virtual wxWindow* CreateEditorCtrl( wxWindow *parent, wxRect labelRect,
  134. const wxVariant &value );
  135. virtual bool GetValueFromEditorCtrl( wxWindow* editor, wxVariant &value );
  136. private:
  137. wxDataViewIconText m_value;
  138. protected:
  139. DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
  140. };
  141. #endif // _WX_GENERIC_DVRENDERERS_H_