Added ability for tables, grids, editors and renderers to handle nonstring data.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2000-02-21 23:17:40 +00:00
parent e0a4aa8a21
commit f2d7623799
4 changed files with 385 additions and 101 deletions

View File

@@ -61,6 +61,7 @@ class WXDLLEXPORT wxGridCornerLabelWindow;
class WXDLLEXPORT wxGridRowLabelWindow;
class WXDLLEXPORT wxGridTableBase;
class WXDLLEXPORT wxGridWindow;
class WXDLLEXPORT wxGridTypeRegistry;
class WXDLLEXPORT wxCheckBox;
class WXDLLEXPORT wxTextCtrl;
@@ -309,8 +310,8 @@ public:
const wxColour& GetBackgroundColour() const;
const wxFont& GetFont() const;
void GetAlignment(int *hAlign, int *vAlign) const;
wxGridCellRenderer *GetRenderer() const;
wxGridCellEditor *GetEditor() const;
wxGridCellRenderer *GetRenderer(wxGridCellRenderer* def) const;
wxGridCellEditor *GetEditor(wxGridCellEditor* def) const;
bool IsReadOnly() const { return m_isReadOnly; }
@@ -406,9 +407,27 @@ public:
//
virtual long GetNumberRows() = 0;
virtual long GetNumberCols() = 0;
virtual wxString GetValue( int row, int col ) = 0;
virtual void SetValue( int row, int col, const wxString& s ) = 0;
virtual bool IsEmptyCell( int row, int col ) = 0;
virtual wxString GetValue( int row, int col ) = 0;
virtual void SetValue( int row, int col, const wxString& value ) = 0;
// Data type determination and value access
virtual wxString GetTypeName( int row, int col );
virtual bool CanGetValueAs( int row, int col, const wxString& typeName );
virtual bool CanSetValueAs( int row, int col, const wxString& typeName );
virtual long GetValueAsLong( int row, int col );
virtual double GetValueAsDouble( int row, int col );
virtual bool GetValueAsBool( int row, int col );
virtual void SetValueAsLong( int row, int col, long value );
virtual void SetValueAsDouble( int row, int col, double value );
virtual void SetValueAsBool( int row, int col, bool value );
// For user defined types
virtual void* GetValueAsCustom( int row, int col, const wxString& typeName );
virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value );
// Overriding these is optional
//
@@ -437,12 +456,17 @@ public:
// get the currently used attr provider (may be NULL)
wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; }
// Does this table allow attributes? Default implementation creates
// a wxGridCellAttrProvider if necessary.
virtual bool CanHaveAttributes();
// change row/col number in attribute if needed
void UpdateAttrRows( size_t pos, int numRows );
void UpdateAttrCols( size_t pos, int numCols );
virtual void UpdateAttrRows( size_t pos, int numRows );
virtual void UpdateAttrCols( size_t pos, int numCols );
// by default forwarded to wxGridCellAttrProvider if any. May be
// overridden to handle attributes directly in this class.
// overridden to handle attributes directly in the table.
virtual wxGridCellAttr *GetAttr( int row, int col );
// these functions take ownership of the pointer
@@ -866,12 +890,13 @@ public:
wxGridCellRenderer* GetCellRenderer(int row, int col);
// takes ownership of the pointer
void SetDefaultEditor(wxGridCellEditor *editor);
// void SetDefaultEditor(wxGridCellEditor *editor);
void SetCellEditor(int row, int col, wxGridCellEditor *editor);
wxGridCellEditor *GetDefaultEditor() const;
// wxGridCellEditor *GetDefaultEditor() const;
wxGridCellEditor* GetCellEditor(int row, int col);
// ------ cell value accessors
//
wxString GetCellValue( int row, int col )
@@ -968,6 +993,16 @@ public:
void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; }
// Methods for a registry for mapping data types to Renderers/Editors
void RegisterDataType(const wxString& typeName,
wxGridCellRenderer* renderer,
wxGridCellEditor* editor);
wxGridCellEditor* GetDefaultEditorForCell(int row, int col);
wxGridCellRenderer* GetDefaultRendererForCell(int row, int col);
wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName);
wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName);
// ------ For compatibility with previous wxGrid only...
//
@@ -1259,6 +1294,9 @@ protected:
bool m_inOnKeyDown;
int m_batchCount;
wxGridTypeRegistry* m_typeRegistry;
enum CursorMode
{
WXGRID_CURSOR_SELECT_CELL,
@@ -1335,6 +1373,7 @@ protected:
};
// ----------------------------------------------------------------------------
// Grid event class and event types
// ----------------------------------------------------------------------------