]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/dataview.h
Escape underscores
[wxWidgets.git] / include / wx / generic / dataview.h
CommitLineData
4ed7af08
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/dataview.h
3// Purpose: wxDataViewCtrl generic implementation header
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifndef __GENERICDATAVIEWCTRLH__
11#define __GENERICDATAVIEWCTRLH__
12
13#include "wx/defs.h"
14#include "wx/object.h"
15#include "wx/list.h"
16#include "wx/control.h"
9d14de69 17#include "wx/scrolwin.h"
4ed7af08 18
f554a14b 19// ---------------------------------------------------------
4ed7af08 20// classes
f554a14b 21// ---------------------------------------------------------
4ed7af08 22
f460c29d
RD
23class WXDLLIMPEXP_ADV wxDataViewCtrl;
24class WXDLLIMPEXP_ADV wxDataViewMainWindow;
25class WXDLLIMPEXP_ADV wxDataViewHeaderWindow;
4ed7af08 26
f554a14b 27// ---------------------------------------------------------
4ed7af08 28// wxDataViewCell
f554a14b 29// ---------------------------------------------------------
4ed7af08 30
f460c29d 31class WXDLLIMPEXP_ADV wxDataViewCell: public wxDataViewCellBase
4ed7af08
RR
32{
33public:
34 wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
3d9d7cc4 35 ~wxDataViewCell();
4ed7af08 36
3d9d7cc4
RR
37 virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0;
38 virtual wxSize GetSize() = 0;
f554a14b
WS
39
40 virtual bool Activate( wxRect WXUNUSED(cell),
41 wxDataViewListModel *WXUNUSED(model),
42 size_t WXUNUSED(col),
43 size_t WXUNUSED(row) )
3d9d7cc4 44 { return false; }
f554a14b
WS
45
46 virtual bool LeftClick( wxPoint WXUNUSED(cursor),
47 wxRect WXUNUSED(cell),
48 wxDataViewListModel *WXUNUSED(model),
49 size_t WXUNUSED(col),
50 size_t WXUNUSED(row) )
51 { return false; }
52 virtual bool RightClick( wxPoint WXUNUSED(cursor),
53 wxRect WXUNUSED(cell),
54 wxDataViewListModel *WXUNUSED(model),
55 size_t WXUNUSED(col),
56 size_t WXUNUSED(row) )
57 { return false; }
58 virtual bool StartDrag( wxPoint WXUNUSED(cursor),
59 wxRect WXUNUSED(cell),
60 wxDataViewListModel *WXUNUSED(model),
61 size_t WXUNUSED(col),
62 size_t WXUNUSED(row) )
63 { return false; }
64
3d9d7cc4
RR
65 // Create DC on request
66 virtual wxDC *GetDC();
f554a14b 67
3d9d7cc4
RR
68private:
69 wxDC *m_dc;
f554a14b 70
4ed7af08
RR
71protected:
72 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCell)
73};
f554a14b
WS
74
75// ---------------------------------------------------------
3d9d7cc4 76// wxDataViewCustomCell
f554a14b 77// ---------------------------------------------------------
4ed7af08 78
f460c29d 79class WXDLLIMPEXP_ADV wxDataViewCustomCell: public wxDataViewCell
4ed7af08
RR
80{
81public:
f554a14b 82 wxDataViewCustomCell( const wxString &varianttype = wxT("string"),
3d9d7cc4 83 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
f554a14b 84
4ed7af08 85protected:
3d9d7cc4 86 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewCustomCell)
4ed7af08 87};
f554a14b
WS
88
89// ---------------------------------------------------------
3d9d7cc4 90// wxDataViewTextCell
f554a14b 91// ---------------------------------------------------------
4ed7af08 92
f460c29d 93class WXDLLIMPEXP_ADV wxDataViewTextCell: public wxDataViewCustomCell
4ed7af08
RR
94{
95public:
f554a14b 96 wxDataViewTextCell( const wxString &varianttype = wxT("string"),
4ed7af08
RR
97 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
98
99 bool SetValue( const wxVariant &value );
100 bool GetValue( wxVariant &value );
f554a14b 101
3d9d7cc4
RR
102 bool Render( wxRect cell, wxDC *dc, int state );
103 wxSize GetSize();
f554a14b 104
90675b95
RR
105private:
106 wxString m_text;
f554a14b 107
4ed7af08 108protected:
3d9d7cc4 109 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewTextCell)
4ed7af08 110};
f554a14b
WS
111
112// ---------------------------------------------------------
3d9d7cc4 113// wxDataViewToggleCell
f554a14b 114// ---------------------------------------------------------
4ed7af08 115
f460c29d 116class WXDLLIMPEXP_ADV wxDataViewToggleCell: public wxDataViewCustomCell
4ed7af08
RR
117{
118public:
f554a14b 119 wxDataViewToggleCell( const wxString &varianttype = wxT("bool"),
3d9d7cc4
RR
120 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
121
122 bool SetValue( const wxVariant &value );
123 bool GetValue( wxVariant &value );
f554a14b 124
3d9d7cc4 125 bool Render( wxRect cell, wxDC *dc, int state );
0fdc2321 126 bool Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row );
3d9d7cc4 127 wxSize GetSize();
f554a14b 128
90675b95
RR
129private:
130 bool m_toggle;
f554a14b 131
4ed7af08 132protected:
3d9d7cc4 133 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleCell)
4ed7af08 134};
f554a14b
WS
135
136// ---------------------------------------------------------
4ed7af08 137// wxDataViewProgressCell
f554a14b 138// ---------------------------------------------------------
4ed7af08 139
f460c29d 140class WXDLLIMPEXP_ADV wxDataViewProgressCell: public wxDataViewCustomCell
4ed7af08
RR
141{
142public:
f554a14b
WS
143 wxDataViewProgressCell( const wxString &label = wxEmptyString,
144 const wxString &varianttype = wxT("long"),
4ed7af08
RR
145 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT );
146 ~wxDataViewProgressCell();
f554a14b 147
4ed7af08 148 bool SetValue( const wxVariant &value );
f554a14b 149
4ed7af08
RR
150 virtual bool Render( wxRect cell, wxDC *dc, int state );
151 virtual wxSize GetSize();
f554a14b 152
4ed7af08
RR
153private:
154 wxString m_label;
155 int m_value;
f554a14b 156
4ed7af08
RR
157protected:
158 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewProgressCell)
159};
f554a14b
WS
160
161// ---------------------------------------------------------
4ed7af08 162// wxDataViewDateCell
f554a14b 163// ---------------------------------------------------------
4ed7af08 164
f460c29d 165class WXDLLIMPEXP_ADV wxDataViewDateCell: public wxDataViewCustomCell
4ed7af08
RR
166{
167public:
f554a14b 168 wxDataViewDateCell( const wxString &varianttype = wxT("datetime"),
4ed7af08 169 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE );
f554a14b 170
4ed7af08 171 bool SetValue( const wxVariant &value );
f554a14b 172
4ed7af08
RR
173 virtual bool Render( wxRect cell, wxDC *dc, int state );
174 virtual wxSize GetSize();
175 virtual bool Activate( wxRect cell,
176 wxDataViewListModel *model, size_t col, size_t row );
f554a14b 177
4ed7af08
RR
178private:
179 wxDateTime m_date;
f554a14b 180
4ed7af08
RR
181protected:
182 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateCell)
183};
f554a14b
WS
184
185// ---------------------------------------------------------
4ed7af08 186// wxDataViewColumn
f554a14b 187// ---------------------------------------------------------
4ed7af08 188
f460c29d 189class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
4ed7af08
RR
190{
191public:
533544f2
RR
192 wxDataViewColumn( const wxString &title, wxDataViewCell *cell, size_t model_column,
193 int fixed_width = 80, wxDataViewColumnSizing sizing = wxDATAVIEW_COL_WIDTH_FIXED, int flags = 0 );
4ed7af08
RR
194 virtual ~wxDataViewColumn();
195
196 virtual void SetTitle( const wxString &title );
f554a14b 197
533544f2 198 virtual int GetWidth();
f554a14b 199
533544f2
RR
200 virtual void SetFixedWidth( int width );
201 virtual int GetFixedWidth();
202
4ed7af08 203private:
533544f2
RR
204 int m_width;
205 wxDataViewColumnSizing m_sizing;
206 int m_fixedWidth;
4ed7af08
RR
207
208protected:
209 DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
210};
211
f554a14b 212// ---------------------------------------------------------
4ed7af08 213// wxDataViewCtrl
f554a14b 214// ---------------------------------------------------------
4ed7af08 215
f460c29d 216class WXDLLIMPEXP_ADV wxDataViewCtrl: public wxDataViewCtrlBase,
4ed7af08
RR
217 public wxScrollHelperNative
218{
219public:
220 wxDataViewCtrl() : wxScrollHelperNative(this)
221 {
222 Init();
223 }
f554a14b 224
4ed7af08
RR
225 wxDataViewCtrl( wxWindow *parent, wxWindowID id,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize, long style = 0,
f554a14b 228 const wxValidator& validator = wxDefaultValidator )
4b3feaa7 229 : wxScrollHelperNative(this)
4ed7af08
RR
230 {
231 Create(parent, id, pos, size, style, validator );
232 }
233
234 virtual ~wxDataViewCtrl();
235
236 void Init();
237
238 bool Create(wxWindow *parent, wxWindowID id,
239 const wxPoint& pos = wxDefaultPosition,
240 const wxSize& size = wxDefaultSize, long style = 0,
241 const wxValidator& validator = wxDefaultValidator );
242
243 virtual bool AssociateModel( wxDataViewListModel *model );
244 virtual bool AppendColumn( wxDataViewColumn *col );
f554a14b 245
4ed7af08 246private:
4b3feaa7 247 friend class wxDataViewMainWindow;
3d9d7cc4 248 friend class wxDataViewHeaderWindow;
4ed7af08 249 wxDataViewListModelNotifier *m_notifier;
4b3feaa7
RR
250 wxDataViewMainWindow *m_clientArea;
251 wxDataViewHeaderWindow *m_headerArea;
f554a14b 252
4ed7af08 253private:
4b3feaa7 254 void OnSize( wxSizeEvent &event );
f554a14b 255
4ed7af08
RR
256 // we need to return a special WM_GETDLGCODE value to process just the
257 // arrows but let the other navigation characters through
258#ifdef __WXMSW__
259 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
260#endif // __WXMSW__
261
262 WX_FORWARD_TO_SCROLL_HELPER()
4b3feaa7 263
4ed7af08
RR
264private:
265 DECLARE_DYNAMIC_CLASS(wxDataViewCtrl)
266 DECLARE_NO_COPY_CLASS(wxDataViewCtrl)
4b3feaa7 267 DECLARE_EVENT_TABLE()
4ed7af08
RR
268};
269
270
271#endif // __GENERICDATAVIEWCTRLH__