]>
Commit | Line | Data |
---|---|---|
b6b9d556 RR |
1 | |
2 | \section{\class{wxDataViewCtrl}}\label{wxdataviewctrl} | |
3 | ||
4 | This class and its documentation are work in progress and | |
305c49a1 | 5 | therefore subject to change. |
b6b9d556 RR |
6 | |
7 | wxDataViewCtrl is planned to be a control to display data either | |
305c49a1 RR |
8 | in a tree like fashion or in a tabular form or both. So far, |
9 | only the tabular form is implemented. | |
10 | ||
11 | Unlike \helpref{wxListCtrl}{wxlistctrl} wxDataViewCtrl doesn't | |
b6b9d556 RR |
12 | get its data from the user through virtual functions or events, |
13 | instead you need to write your own | |
14 | \helpref{wxDataViewListModel}{wxdataviewlistmodel} and associate | |
15 | it with this control. Then you need to add a number of | |
16 | \helpref{wxDataViewColumn}{wxdataviewcolumn} to this control to | |
17 | define what each column shall display. Each wxDataViewColumn | |
18 | in turn owns 1 instance of a | |
19 | \helpref{wxDataViewRenderer}{wxdataviewrenderer} to render its | |
20 | cells. A number of standard renderers for rendering text, dates, | |
21 | images, toggle, a progress bar etc. are provided. Additionally, | |
22 | the user can write custom renderes deriving from | |
23 | \helpref{wxDataViewCustomRenderer}{wxdataviewcustomrenderer} | |
24 | for displaying anything. | |
25 | ||
26 | All data transfer from the control to the model and the user | |
27 | code is done through \helpref{wxVariant}{wxvariant} which can | |
28 | be extended to support more data formats as necessary. | |
29 | Accordingly, all type information uses the strings returned | |
30 | from \helpref{wxVariant::GetType}{wxvariantgettype}. | |
31 | ||
305c49a1 RR |
32 | So far, this control has been implemented for GTK+ and there |
33 | is an almost complete generic implementation including several | |
34 | additions for a native Windows look and feel (in particular | |
35 | concerning the header). It is planned to implement the control | |
36 | natively under OS X. | |
b6b9d556 RR |
37 | |
38 | \wxheading{Window styles} | |
39 | ||
40 | \twocolwidtha{5cm} | |
41 | \begin{twocollist}\itemsep=0pt | |
42 | \twocolitem{\windowstyle{wxDV\_SINGLE}}{Single selection mode. This is the default.} | |
43 | \twocolitem{\windowstyle{wxDV\_MULTIPLE}}{Multiple selection mode.} | |
44 | \end{twocollist} | |
45 | ||
46 | ||
47 | \wxheading{Event handling} | |
48 | ||
49 | To process input from a dataview control, use the following event handler | |
50 | macros to direct input to member functions that take a | |
51 | \helpref{wxDataViewEvent}{wxdataviewevent} argument. | |
52 | ||
53 | \twocolwidtha{7cm} | |
54 | \begin{twocollist}\itemsep=0pt | |
55 | ||
56 | \twocolitem{{\bf EVT\_DATAVIEW\_ROW\_SELECTED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ROW\_SELECTED event.} | |
57 | \twocolitem{{\bf EVT\_DATAVIEW\_ROW\_ACTIVATED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_ROW\_ACTIVATED event.} | |
58 | \twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_CLICK(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_CLICKED event.} | |
59 | \twocolitem{{\bf EVT\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICK(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_COLUMN\_HEADER\_RIGHT\_CLICKED event.} | |
60 | ||
61 | \end{twocollist} | |
62 | ||
1821abd1 | 63 | Additionally, you can get informed about changes to the |
7ffc857f | 64 | \helpref{model}{wxdataviewlistmodel}, to which a wxDataViewCtrl |
1821abd1 RR |
65 | has been associated. These events correspond to the interface |
66 | offered by \helpref{wxDataViewListModelNotifier}{wxdataviewlistmodelnotifier}. | |
67 | ||
68 | \twocolwidtha{7cm} | |
69 | \begin{twocollist}\itemsep=0pt | |
70 | ||
71 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROW\_PREPENDED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROW\_PREPENDED event.} | |
72 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROW\_APPENDED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROW\_APPENDED event.} | |
73 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROW\_INSERTED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROW\_INSERTED event.} | |
74 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROW\_DELETED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROW\_DELETED event.} | |
75 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROW\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROW\_CHANGED event.} | |
76 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_VALUE\_CHANGED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_VALUE\_CHANGED event.} | |
77 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_ROWS\_REORDERED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_ROWS\_REORDERED event.} | |
78 | \twocolitem{{\bf EVT\_DATAVIEW\_MODEL\_CLEARED(id, func)}}{Processes a wxEVT\_COMMAND\_DATAVIEW\_MODEL\_CLEARED event.} | |
79 | ||
80 | \end{twocollist} | |
b6b9d556 RR |
81 | |
82 | ||
83 | \wxheading{Derived from} | |
84 | ||
7376079d VZ |
85 | \helpref{wxControl}{wxcontrol}\\ |
86 | \helpref{wxWindow}{wxwindow}\\ | |
87 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
88 | \helpref{wxObject}{wxobject} | |
b6b9d556 RR |
89 | |
90 | \wxheading{Include files} | |
91 | ||
92 | <wx/dataview.h> | |
93 | ||
a7af285d VZ |
94 | \wxheading{Library} |
95 | ||
96 | \helpref{wxAdv}{librarieslist} | |
97 | ||
b6b9d556 RR |
98 | |
99 | \membersection{wxDataViewCtrl::wxDataViewCtrl}\label{wxdataviewctrlwxdataviewctrl} | |
100 | ||
101 | \func{}{wxDataViewCtrl}{\void} | |
102 | ||
103 | \func{}{wxDataViewCtrl}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}} | |
104 | ||
105 | Constructor. Calls \helpref{Create}{wxdataviewctrlcreate}. | |
106 | ||
107 | \membersection{wxDataViewCtrl::\destruct{wxDataViewCtrl}}\label{wxdataviewctrldtor} | |
108 | ||
109 | \func{}{\destruct{wxDataViewCtrl}}{\void} | |
110 | ||
111 | Destructor. | |
112 | ||
113 | \membersection{wxDataViewCtrl::AppendColumn}\label{wxdataviewctrlappendcolumn} | |
114 | ||
115 | \func{virtual bool}{AppendColumn}{\param{wxDataViewColumn* }{col}} | |
116 | ||
117 | Add a \helpref{wxDataViewColumn}{wxdataviewcolumn} to the control. Note | |
118 | that there is a number of short cut methods which implicitly create | |
119 | a \helpref{wxDataViewColumn}{wxdataviewcolumn} and a | |
314cd032 | 120 | \helpref{wxDataViewRenderer}{wxdataviewrenderer} for it (see below). |
b6b9d556 RR |
121 | |
122 | ||
123 | \membersection{wxDataViewCtrl::AppendBitmapColumn}\label{wxdataviewctrlappendbitmapcolumn} | |
124 | ||
125 | \func{bool}{AppendBitmapColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} | |
126 | ||
127 | \func{bool}{AppendBitmapColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} | |
128 | ||
129 | Appends a column for rendering a bitmap. | |
130 | ||
131 | \membersection{wxDataViewCtrl::AppendDateColumn}\label{wxdataviewctrlappenddatecolumn} | |
132 | ||
133 | \func{bool}{AppendDateColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}} | |
134 | ||
135 | \func{bool}{AppendDateColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_ACTIVATABLE}, \param{int }{width = -1}} | |
136 | ||
137 | Appends a column for rendering a date. | |
138 | ||
139 | \membersection{wxDataViewCtrl::AppendProgressColumn}\label{wxdataviewctrlappendprogresscolumn} | |
140 | ||
141 | \func{bool}{AppendProgressColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}} | |
142 | ||
143 | \func{bool}{AppendProgressColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 80}} | |
144 | ||
145 | Appends a column for rendering a progress indicator. | |
146 | ||
147 | \membersection{wxDataViewCtrl::AppendTextColumn}\label{wxdataviewctrlappendtextcolumn} | |
148 | ||
149 | \func{bool}{AppendTextColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} | |
150 | ||
151 | \func{bool}{AppendTextColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = -1}} | |
152 | ||
153 | Appends a column for rendering text. | |
154 | ||
155 | \membersection{wxDataViewCtrl::AppendToggleColumn}\label{wxdataviewctrlappendtogglecolumn} | |
156 | ||
157 | \func{bool}{AppendToggleColumn}{\param{const wxString\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}} | |
158 | ||
159 | \func{bool}{AppendToggleColumn}{\param{const wxBitmap\& }{label}, \param{unsigned int }{model\_column}, \param{wxDataViewCellMode }{mode = wxDATAVIEW\_CELL\_INERT}, \param{int }{width = 30}} | |
160 | ||
161 | Appends a column for rendering a toggle. | |
162 | ||
163 | \membersection{wxDataViewCtrl::AssociateModel}\label{wxdataviewctrlassociatemodel} | |
164 | ||
165 | \func{virtual bool}{AssociateModel}{\param{wxDataViewListModel* }{model}} | |
166 | ||
167 | Associates a \helpref{wxDataViewListModel}{wxdataviewlistmodel} with the | |
168 | control. In the future this should be changed to supporting any data | |
169 | model including a to-be-written wxDataViewTreeModel. | |
170 | ||
171 | \membersection{wxDataViewCtrl::Create}\label{wxdataviewctrlcreate} | |
172 | ||
173 | \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}} | |
174 | ||
175 | Create the control. Useful for two step creation. | |
176 | ||
177 | \membersection{wxDataViewCtrl::ClearColumns}\label{wxdataviewctrlclearcolumns} | |
178 | ||
179 | \func{virtual bool}{ClearColumns}{\void} | |
180 | ||
181 | Removes all columns. | |
182 | ||
183 | \membersection{wxDataViewCtrl::ClearSelection}\label{wxdataviewctrlclearselection} | |
184 | ||
185 | \func{void}{ClearSelection}{\void} | |
186 | ||
187 | Unselects all rows. | |
188 | ||
189 | \membersection{wxDataViewCtrl::DeleteColumn}\label{wxdataviewctrldeletecolumn} | |
190 | ||
191 | \func{virtual bool}{DeleteColumn}{\param{unsigned int }{pos}} | |
192 | ||
193 | Deletes given column. | |
194 | ||
195 | \membersection{wxDataViewCtrl::GetColumn}\label{wxdataviewctrlgetcolumn} | |
196 | ||
197 | \func{virtual wxDataViewColumn*}{GetColumn}{\param{unsigned int }{pos}} | |
198 | ||
199 | Returns pointer to the column. | |
200 | ||
201 | \membersection{wxDataViewCtrl::GetModel}\label{wxdataviewctrlgetmodel} | |
202 | ||
203 | \func{virtual wxDataViewListModel*}{GetModel}{\void} | |
204 | ||
205 | Returns pointer to the data model associated with the | |
206 | control (if any). | |
207 | ||
a29d690d | 208 | \membersection{wxDataViewCtrl::GetColumnCount}\label{wxdataviewctrlgetcolumncount} |
b6b9d556 | 209 | |
a29d690d | 210 | \func{virtual unsigned int}{GetColumnCount}{\void} |
b6b9d556 RR |
211 | |
212 | Returns the number of columns. | |
213 | ||
214 | \membersection{wxDataViewCtrl::GetSelection}\label{wxdataviewctrlgetselection} | |
215 | ||
216 | \constfunc{virtual int}{GetSelection}{\void} | |
217 | ||
218 | Returns the index of the currently selected row. It will | |
219 | return -1 if no row is selected and the index of the first | |
220 | selected row if more than one row are selected. | |
221 | ||
222 | \membersection{wxDataViewCtrl::GetSelections}\label{wxdataviewctrlgetselections} | |
223 | ||
224 | \constfunc{virtual int}{GetSelections}{\param{wxArrayInt\& }{aSelections}} | |
225 | ||
226 | Returns the number of selected rows and fills an array of int | |
227 | with the indeces of the selected rows. | |
228 | ||
229 | \membersection{wxDataViewCtrl::IsSelected}\label{wxdataviewctrlisselected} | |
230 | ||
231 | \constfunc{virtual bool}{IsSelected}{\param{unsigned int }{row}} | |
232 | ||
233 | Returns {\it true} if the row is selected, {\it false} otherwise. | |
234 | ||
235 | \membersection{wxDataViewCtrl::SetSelection}\label{wxdataviewctrlsetselection} | |
236 | ||
237 | \func{virtual void}{SetSelection}{\param{int }{row}} | |
238 | ||
239 | Sets the selection. Use -1 to unselect all rows. | |
240 | ||
241 | \membersection{wxDataViewCtrl::SetSelectionRange}\label{wxdataviewctrlsetselectionrange} | |
242 | ||
243 | \func{virtual void}{SetSelectionRange}{\param{unsigned int }{from}, \param{unsigned int }{to}} | |
244 | ||
245 | Set a range of selection. | |
246 | ||
247 | \membersection{wxDataViewCtrl::SetSelections}\label{wxdataviewctrlsetselections} | |
248 | ||
249 | \func{virtual void}{SetSelections}{\param{const wxArrayInt\& }{aSelections}} | |
250 | ||
251 | Set the selection to the array of int. | |
252 | ||
253 | \membersection{wxDataViewCtrl::Unselect}\label{wxdataviewctrlunselect} | |
254 | ||
255 | \func{virtual void}{Unselect}{\param{unsigned int }{row}} | |
256 | ||
257 | Unselect a particular row. | |
258 |