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_
17 #if defined(__GNUG__) && !defined(__APPLE__)
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_EXPORTED_OBJARRAY(GenericKey
,keyarray
);
34 static const int wxUSE_QUERY
= -1;
36 class WXDLLIMPEXP_ODBC 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() {}
63 class WXDLLIMPEXP_ODBC wxDbGridColInfo
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); }
81 // Adds a new column info (2 step creation)
82 void AddColInfo (int colNo
,
86 GetLast()->m_next
= new wxDbGridColInfo (colNo
, type
, title
, NULL
);
90 wxDbGridColInfo
*GetLast() { return (m_next
? m_next
->GetLast() : this); }
94 wxDbGridColInfoBase m_data
;
95 wxDbGridColInfo
*m_next
;
97 friend class wxDbGridTableBase
;
101 class WXDLLIMPEXP_ODBC wxDbGridCellAttrProvider
: public wxGridCellAttrProvider
104 wxDbGridCellAttrProvider();
105 wxDbGridCellAttrProvider(wxDbTable
*tab
, wxDbGridColInfoBase
* ColInfo
);
106 virtual ~wxDbGridCellAttrProvider();
108 virtual wxGridCellAttr
*GetAttr(int row
, int col
,
109 wxGridCellAttr::wxAttrKind kind
) const;
110 virtual void AssignDbTable(wxDbTable
*tab
);
113 wxDbGridColInfoBase
*m_ColInfo
;
117 class WXDLLIMPEXP_ODBC wxDbGridTableBase
: public wxGridTableBase
120 wxDbGridTableBase(wxDbTable
*tab
, wxDbGridColInfo
*ColInfo
,
121 int count
= wxUSE_QUERY
, bool takeOwnership
= TRUE
);
122 ~wxDbGridTableBase();
124 virtual int GetNumberRows()
126 wxLogDebug(" GetNumberRows() = %i",m_rowtotal
);
129 virtual int GetNumberCols()
131 wxLogDebug(" GetNumberCols() = %i",m_nocols
);
134 virtual bool IsEmptyCell(int row
, int col
) ;
135 virtual wxString
GetValue(int row
, int col
) ;
136 virtual void SetValue(int row
, int col
, const wxString
& value
);
137 virtual bool CanHaveAttributes();
138 virtual wxString
GetTypeName(int row
, int col
);
139 virtual bool CanGetValueAs(int row
, int col
, const wxString
& typeName
);
140 virtual bool CanSetValueAs(int row
, int col
, const wxString
& typeName
);
141 virtual long GetValueAsLong(int row
, int col
);
142 virtual double GetValueAsDouble(int row
, int col
);
143 virtual bool GetValueAsBool(int row
, int col
);
144 virtual void SetValueAsLong(int row
, int col
, long value
);
145 virtual void SetValueAsDouble(int row
, int col
, double value
);
146 virtual void SetValueAsBool(int row
, int col
, bool value
);
147 virtual void *GetValueAsCustom(int row
, int col
, const wxString
& typeName
);
148 virtual void SetValueAsCustom(int row
, int col
, const wxString
& typeName
, void* value
);
151 virtual wxString
GetColLabelValue(int col
);
153 virtual bool AssignDbTable(wxDbTable
*tab
, int count
= wxUSE_QUERY
, bool takeOwnership
=TRUE
);
154 virtual void ValidateRow(int row
);
155 virtual bool UpdateRow(int row
) const
164 //Operates on the current row
165 bool Writeback() const;
167 typedef wxGridTableBase inherited
;
174 wxDbGridColInfoBase
*m_ColInfo
;
178 #endif // #if wxUSE_GRID
179 #endif // #if wxUSE_ODBC
181 #endif // _WX_GENERIC_DBGRID_H_