1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: Displays a wxDbTable in a wxGrid.
4 // Author: Roger Gammans, Paul Gammans
8 // Copyright: (c) 1999 The Computer Surgery (roger@computer-surgery.co.uk)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11 // Branched From : dbgrid.h,v 1.19 2001/03/28 11:16:01
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_GENERIC_DBGRID_H_
15 #define _WX_GENERIC_DBGRID_H_
18 #pragma interface "dbgrid.h"
25 #include "wx/dbtable.h"
26 #include "wx/dynarray.h"
28 #include "wx/dbkeyg.h"
30 #define wxGRID_VALUE_DBAUTO _T("dbauto")
32 WX_DECLARE_OBJARRAY(GenericKey
,keyarray
);
34 static const int wxUSE_QUERY
= -1;
36 class wxDbGridColInfoBase
40 wxDbGridColInfoBase() { }
41 wxDbGridColInfoBase(int colNo
,
42 wxString type
, wxString title
) :
48 wxDbGridColInfoBase(const wxDbGridColInfoBase
& ref
)
51 wxtypename
= ref
.wxtypename
;
54 //Empty destructor for member obj's
55 ~wxDbGridColInfoBase() {}
66 wxDbGridColInfo(int colNo
,
69 wxDbGridColInfo
*next
) :
70 m_data(colNo
,type
,title
)
76 ~wxDbGridColInfo() { delete m_next
; }
78 //Recurse to find length.
79 int Length() { return (m_next
? m_next
->Length() +1 : 1); }
82 wxDbGridColInfoBase m_data
;
83 wxDbGridColInfo
*m_next
;
85 friend class wxDbGridTableBase
;
89 class wxDbGridCellAttrProvider
: public wxGridCellAttrProvider
92 wxDbGridCellAttrProvider();
93 wxDbGridCellAttrProvider(wxDbTable
*tab
, wxDbGridColInfoBase
* ColInfo
);
94 virtual ~wxDbGridCellAttrProvider();
96 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
97 wxGridCellAttr::wxAttrKind kind
) const;
98 virtual void AssignDbTable(wxDbTable
*tab
);
101 wxDbGridColInfoBase
*m_ColInfo
;
105 class wxDbGridTableBase
: public wxGridTableBase
108 wxDbGridTableBase(wxDbTable
*tab
, wxDbGridColInfo
*ColInfo
,
109 int count
= wxUSE_QUERY
, bool takeOwnership
= TRUE
);
110 ~wxDbGridTableBase();
112 virtual int GetNumberRows()
114 wxLogDebug(" GetNumberRows() = %i",m_rowtotal
);
117 virtual int GetNumberCols()
119 wxLogDebug(" GetNumberCols() = %i",m_nocols
);
122 virtual bool IsEmptyCell(int row
, int col
) ;
123 virtual wxString
GetValue(int row
, int col
) ;
124 virtual void SetValue(int row
, int col
, const wxString
& value
);
125 virtual bool CanHaveAttributes();
126 virtual wxString
GetTypeName(int row
, int col
);
127 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
128 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
129 virtual long GetValueAsLong(int row
, int col
);
130 virtual double GetValueAsDouble(int row
, int col
);
131 virtual bool GetValueAsBool(int row
, int col
);
132 virtual void SetValueAsLong(int row
, int col
, long value
);
133 virtual void SetValueAsDouble(int row
, int col
, double value
);
134 virtual void SetValueAsBool(int row
, int col
, bool value
);
135 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
136 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
, void* value
);
139 virtual wxString
wxDbGridTableBase::GetColLabelValue(int col
);
141 virtual bool AssignDbTable(wxDbTable
*tab
, int count
= wxUSE_QUERY
, bool takeOwnership
=TRUE
);
142 virtual void ValidateRow(int row
);
143 virtual bool UpdateRow(int row
) const
152 //Operates on the current row
153 bool Writeback() const;
155 typedef wxGridTableBase inherited
;
162 wxDbGridColInfoBase
*m_ColInfo
;
166 #endif // #if wxUSE_NEW_GRID
167 #endif // #if wxUSE_ODBC
169 #endif // _WX_GENERIC_DBGRID_H_