+ // Reset the value in the control back to its starting value
+ virtual void Reset() = 0;
+
+ // Some types of controls on some platforms may need some help
+ // with the Return key.
+ virtual void HandleReturn(wxKeyEvent& event);
+
+ // Final cleanup
+ virtual void Destroy();
+
+protected:
+ wxControl* m_control;
+};
+
+
+class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor
+{
+public:
+ wxGridCellTextEditor();
+
+ virtual void Create(wxWindow* parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ wxEvtHandler* evtHandler);
+
+ virtual void BeginEdit(int row, int col, wxGrid* grid,
+ wxGridCellAttr* attr);
+
+ virtual bool EndEdit(int row, int col, bool saveValue,
+ wxGrid* grid, wxGridCellAttr* attr);
+
+ virtual void Reset();
+ virtual void HandleReturn(wxKeyEvent& event);
+
+
+private:
+ wxString m_startValue;
+};
+
+// ----------------------------------------------------------------------------
+// wxGridCellAttr: this class can be used to alter the cells appearance in
+// the grid by changing their colour/font/... from default. An object of this
+// class may be returned by wxGridTable::GetAttr().
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxGridCellAttr
+{
+public:
+ // ctors
+ wxGridCellAttr()
+ {
+ Init();
+ SetAlignment(0, 0);
+ }
+
+ wxGridCellAttr(const wxColour& colText,
+ const wxColour& colBack,
+ const wxFont& font,
+ int hAlign,
+ int vAlign)
+ : m_colText(colText), m_colBack(colBack), m_font(font)
+ {
+ Init();
+ SetAlignment(hAlign, vAlign);
+ }
+
+ // default copy ctor ok
+
+ // 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 ) delete this; }
+ void SafeIncRef() { if ( this ) IncRef(); }
+ void SafeDecRef() { if ( this ) DecRef(); }
+
+ // setters
+ void SetTextColour(const wxColour& colText) { m_colText = colText; }
+ void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
+ void SetFont(const wxFont& font) { m_font = font; }
+ void SetAlignment(int hAlign, int vAlign)
+ {
+ m_hAlign = hAlign;
+ m_vAlign = vAlign;
+ }
+
+ // takes ownership of the pointer
+ void SetRenderer(wxGridCellRenderer *renderer)
+ { delete m_renderer; m_renderer = renderer; }
+
+ // accessors
+ bool HasTextColour() const { return m_colText.Ok(); }
+ bool HasBackgroundColour() const { return m_colBack.Ok(); }
+ bool HasFont() const { return m_font.Ok(); }
+ bool HasAlignment() const { return m_hAlign || m_vAlign; }
+ bool HasRenderer() const { return m_renderer != NULL; }
+
+ const wxColour& GetTextColour() const;
+ const wxColour& GetBackgroundColour() const;
+ const wxFont& GetFont() const;
+ void GetAlignment(int *hAlign, int *vAlign) const;
+ wxGridCellRenderer *GetRenderer() const;
+
+ void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; }
+
+private:
+ // the common part of all ctors
+ void Init() { m_nRef = 1; m_renderer = (wxGridCellRenderer *)NULL; }
+
+ // the dtor is private because only DecRef() can delete us
+ ~wxGridCellAttr() { delete m_renderer; }
+
+ // the ref count - when it goes to 0, we die
+ size_t m_nRef;
+
+ wxColour m_colText,
+ m_colBack;
+ wxFont m_font;
+ int m_hAlign,
+ m_vAlign;
+
+ wxGridCellRenderer *m_renderer;
+ wxGridCellAttr* m_defGridAttr;
+
+ // suppress the stupid gcc warning about the class having private dtor and
+ // no friends
+ friend class wxGridCellAttrDummyFriend;
+};
+
+// ----------------------------------------------------------------------------
+// wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the
+// cell attributes.
+// ----------------------------------------------------------------------------
+
+// implementation note: we separate it from wxGridTableBase because we wish to
+// avoid deriving a new table class if possible, and sometimes it will be
+// enough to just derive another wxGridCellAttrProvider instead
+//
+// the default implementation is reasonably efficient for the generic case,
+// but you might still wish to implement your own for some specific situations
+// if you have performance problems with the stock one
+class WXDLLEXPORT wxGridCellAttrProvider
+{
+public:
+ wxGridCellAttrProvider();
+ virtual ~wxGridCellAttrProvider();
+
+ // DecRef() must be called on the returned pointer
+ virtual wxGridCellAttr *GetAttr(int row, int col) const;
+
+ // all these functions take ownership of the pointer, don't call DecRef()
+ // on it
+ virtual void SetAttr(wxGridCellAttr *attr, int row, int col);
+ virtual void SetRowAttr(wxGridCellAttr *attr, int row);
+ virtual void SetColAttr(wxGridCellAttr *attr, int col);
+
+private:
+ void InitData();
+
+ wxGridCellAttrProviderData *m_data;
+};