#define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16
// type names for grid table values
-#define wxGRID_VALUE_STRING _T("string")
-#define wxGRID_VALUE_BOOL _T("bool")
-#define wxGRID_VALUE_NUMBER _T("long")
-#define wxGRID_VALUE_FLOAT _T("double")
-#define wxGRID_VALUE_CHOICE _T("choice")
+#define wxGRID_VALUE_STRING wxT("string")
+#define wxGRID_VALUE_BOOL wxT("bool")
+#define wxGRID_VALUE_NUMBER wxT("long")
+#define wxGRID_VALUE_FLOAT wxT("double")
+#define wxGRID_VALUE_CHOICE wxT("choice")
#define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING
#define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER
// class is not documented and is not public at all
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer
+class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer, public wxRefCounter
{
public:
- wxGridCellWorker() { m_nRef = 1; }
-
- // this class is ref counted: it is created with ref count of 1, so
- // calling DecRef() once will delete it. Calling IncRef() allows to lock
- // it until the matching DecRef() is called
- void IncRef() { m_nRef++; }
- void DecRef() { if ( --m_nRef == 0 ) delete this; }
+ wxGridCellWorker() { }
// interpret renderer parameters: arbitrary string whose interpretatin is
// left to the derived classes
virtual ~wxGridCellWorker();
private:
- size_t m_nRef;
-
// suppress the stupid gcc warning about the class having private dtor and
// no friends
friend class wxGridCellWorkerDummyFriend;
wxDECLARE_NO_COPY_CLASS(wxGridCellEditor);
};
+// ----------------------------------------------------------------------------
+// wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers
+// ----------------------------------------------------------------------------
+
+// Base class for corner window renderer: it is the simplest of all renderers
+// and only has a single function
+class WXDLLIMPEXP_ADV wxGridCornerHeaderRenderer
+{
+public:
+ // Draw the border around the corner window.
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const = 0;
+
+ // make the dtor of a class with virtual functions virtual to avoid g++
+ // warnings, even though this class is not supposed to be used
+ // polymorphically
+ virtual ~wxGridCornerHeaderRenderer() { }
+};
+
+
+// Base class for the row/column header cells renderers
+class WXDLLIMPEXP_ADV wxGridHeaderLabelsRenderer
+ : public wxGridCornerHeaderRenderer
+{
+public:
+ // Draw header cell label
+ virtual void DrawLabel(const wxGrid& grid,
+ wxDC& dc,
+ const wxString& value,
+ const wxRect& rect,
+ int horizAlign,
+ int vertAlign,
+ int textOrientation) const;
+};
+
+// Currently the row/column/corner renders don't need any methods other than
+// those already in wxGridHeaderLabelsRenderer but still define separate classes
+// for them for future extensions and also for better type safety (i.e. to
+// avoid inadvertently using a column header renderer for the row headers)
+class WXDLLIMPEXP_ADV wxGridRowHeaderRenderer
+ : public wxGridHeaderLabelsRenderer
+{
+};
+
+class WXDLLIMPEXP_ADV wxGridColumnHeaderRenderer
+ : public wxGridHeaderLabelsRenderer
+{
+};
+
+// Also define the default renderers which are used by wxGridCellAttrProvider
+// by default
+class WXDLLIMPEXP_ADV wxGridRowHeaderRendererDefault
+ : public wxGridRowHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+// Column header cells renderers
+class WXDLLIMPEXP_ADV wxGridColumnHeaderRendererDefault
+ : public wxGridColumnHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
+// Header corner renderer
+class WXDLLIMPEXP_ADV wxGridCornerHeaderRendererDefault
+ : public wxGridCornerHeaderRenderer
+{
+public:
+ virtual void DrawBorder(const wxGrid& grid,
+ wxDC& dc,
+ wxRect& rect) const;
+};
+
// ----------------------------------------------------------------------------
// wxGridCellAttr: this class can be used to alter the cells appearance in
// class may be returned by wxGridTable::GetAttr().
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer
+class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer, public wxRefCounter
{
public:
enum wxAttrKind
wxGridCellAttr *Clone() const;
void MergeWith(wxGridCellAttr *mergefrom);
- // this class is ref counted: it is created with ref count of 1, so
- // calling DecRef() once will delete it. Calling IncRef() allows to lock
- // it until the matching DecRef() is called
- void IncRef() { m_nRef++; }
- void DecRef() { if ( --m_nRef == 0 ) delete this; }
-
// setters
void SetTextColour(const wxColour& colText) { m_colText = colText; }
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
void Init(wxGridCellAttr *attrDefault = NULL);
- // the ref count - when it goes to 0, we die
- size_t m_nRef;
-
wxColour m_colText,
m_colBack;
wxFont m_font;
void UpdateAttrRows( size_t pos, int numRows );
void UpdateAttrCols( size_t pos, int numCols );
+
+ // get renderers for the given row/column header label and the corner
+ // window: unlike cell renderers, these objects are not reference counted
+ // and are never NULL so they are returned by reference
+ virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col);
+ virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row);
+ virtual const wxGridCornerHeaderRenderer& GetCornerRenderer();
+
private:
void InitData();
void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
- int textOrientation = wxHORIZONTAL );
+ int textOrientation = wxHORIZONTAL ) const;
void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&,
int horizontalAlignment = wxALIGN_LEFT,
int verticalAlignment = wxALIGN_TOP,
- int textOrientation = wxHORIZONTAL );
+ int textOrientation = wxHORIZONTAL ) const;
// Split a string containing newline characters into an array of
friend class wxGridColLabelWindow;
friend class wxGridRowLabelWindow;
friend class wxGridWindow;
+ friend class wxGridHeaderRenderer;
friend class wxGridHeaderCtrl;
private:
+
// implement wxScrolledWindow method to return m_gridWin size
virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size);
// more than once
void Create(wxGrid *grid)
{
- wxASSERT_MSG( !m_grid, _T("shouldn't be called more than once") );
+ wxASSERT_MSG( !m_grid, wxT("shouldn't be called more than once") );
Init(grid);
}