bool editor/renderer added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6112 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-17 14:08:27 +00:00
parent 45816ddded
commit 508011ce6c
3 changed files with 265 additions and 35 deletions

View File

@@ -28,7 +28,6 @@
#include "wx/string.h"
#include "wx/scrolbar.h"
#include "wx/event.h"
#include "wx/textctrl.h"
#include "wx/combobox.h"
#include "wx/dynarray.h"
#include "wx/timer.h"
@@ -63,6 +62,9 @@ class WXDLLEXPORT wxGridRowLabelWindow;
class WXDLLEXPORT wxGridTableBase;
class WXDLLEXPORT wxGridWindow;
class WXDLLEXPORT wxCheckBox;
class WXDLLEXPORT wxTextCtrl;
// ----------------------------------------------------------------------------
// wxGridCellRenderer: this class is responsible for actually drawing the cell
// in the grid. You may pass it to the wxGridCellAttr (below) to change the
@@ -102,6 +104,19 @@ public:
bool isSelected);
};
// renderer for boolean fields
class WXDLLEXPORT wxGridCellBoolRenderer : public wxGridCellRenderer
{
public:
// draw a check mark or nothing
virtual void Draw(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
const wxRect& rect,
int row, int col,
bool isSelected);
};
// ----------------------------------------------------------------------------
// wxGridCellEditor: This class is responsible for providing and manipulating
@@ -168,7 +183,7 @@ protected:
wxFont m_fontOld;
};
// the editor for string/text data
class WXDLLEXPORT wxGridCellTextEditor : public wxGridCellEditor
{
public:
@@ -192,6 +207,32 @@ private:
wxString m_startValue;
};
// the editor for boolean data
class WXDLLEXPORT wxGridCellBoolEditor : public wxGridCellEditor
{
public:
virtual void Create(wxWindow* parent,
wxWindowID id,
wxEvtHandler* evtHandler);
virtual void SetSize(const wxRect& rect);
virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
virtual void BeginEdit(int row, int col, wxGrid* grid);
virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid);
virtual void Reset();
virtual void StartingKey(wxKeyEvent& event);
protected:
wxCheckBox *CBox() const { return (wxCheckBox *)m_control; }
private:
bool m_startValue;
wxRect m_rectCell; // the total size of the cell
};
// ----------------------------------------------------------------------------
// 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
@@ -541,17 +582,17 @@ public:
return *this;
}
bool operator==( const wxGridCellCoords& other )
bool operator==( const wxGridCellCoords& other ) const
{
return (m_row == other.m_row && m_col == other.m_col);
}
bool operator!=( const wxGridCellCoords& other )
bool operator!=( const wxGridCellCoords& other ) const
{
return (m_row != other.m_row || m_col != other.m_col);
}
bool operator!()
bool operator!() const
{
return (m_row == -1 && m_col == -1 );
}
@@ -1071,6 +1112,9 @@ public:
wxGRID_CHOICE,
wxGRID_COMBOBOX };
// for wxGridCellBoolEditor
wxWindow *GetGridWindow() const;
protected:
bool m_created;
bool m_displayed;