]>
Commit | Line | Data |
---|---|---|
239eaa41 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/datavcmn.cpp | |
3 | // Purpose: wxDataViewCtrl base classes and common parts | |
4 | // Author: Robert Roebling | |
5 | // Created: 2006/02/20 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2006, Robert Roebling | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // For compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
8045736e RR |
18 | #if wxUSE_DATAVIEWCTRL |
19 | ||
e7445ff8 PC |
20 | #include "wx/dataview.h" |
21 | ||
f554a14b | 22 | #ifndef WX_PRECOMP |
f554a14b WS |
23 | #include "wx/log.h" |
24 | #endif | |
25 | ||
4a2e5ee8 | 26 | const wxChar wxDataViewCtrlNameStr[] = wxT("dataviewCtrl"); |
239eaa41 | 27 | |
239eaa41 | 28 | |
d5025dc0 RR |
29 | bool operator == (const wxDataViewItem &left, const wxDataViewItem &right) |
30 | { | |
31 | return (left.GetID() == right.GetID() ); | |
32 | } | |
33 | ||
34 | ||
f554a14b | 35 | // --------------------------------------------------------- |
d5025dc0 | 36 | // wxDataViewModel |
f554a14b | 37 | // --------------------------------------------------------- |
239eaa41 | 38 | |
e0062c04 | 39 | wxDataViewModel::wxDataViewModel() |
239eaa41 | 40 | { |
8f850e28 | 41 | m_notifiers.DeleteContents( true ); |
5732efaa | 42 | m_cmpFunc = NULL; |
239eaa41 RR |
43 | } |
44 | ||
e0062c04 | 45 | bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) |
239eaa41 | 46 | { |
8f850e28 RR |
47 | bool ret = true; |
48 | ||
85e5bb6a | 49 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
50 | while (node) |
51 | { | |
e0062c04 RR |
52 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
53 | if (!notifier->ItemAdded( parent, item )) | |
8f850e28 RR |
54 | ret = false; |
55 | node = node->GetNext(); | |
56 | } | |
f554a14b | 57 | |
8f850e28 | 58 | return ret; |
239eaa41 RR |
59 | } |
60 | ||
e0062c04 | 61 | bool wxDataViewModel::ItemDeleted( const wxDataViewItem &item ) |
239eaa41 | 62 | { |
8f850e28 RR |
63 | bool ret = true; |
64 | ||
85e5bb6a | 65 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
66 | while (node) |
67 | { | |
e0062c04 RR |
68 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
69 | if (!notifier->ItemDeleted( item )) | |
8f850e28 RR |
70 | ret = false; |
71 | node = node->GetNext(); | |
72 | } | |
f554a14b | 73 | |
8f850e28 | 74 | return ret; |
239eaa41 RR |
75 | } |
76 | ||
e0062c04 | 77 | bool wxDataViewModel::ItemChanged( const wxDataViewItem &item ) |
239eaa41 | 78 | { |
8f850e28 RR |
79 | bool ret = true; |
80 | ||
85e5bb6a | 81 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
8f850e28 RR |
82 | while (node) |
83 | { | |
e0062c04 RR |
84 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
85 | if (!notifier->ItemChanged( item )) | |
8f850e28 RR |
86 | ret = false; |
87 | node = node->GetNext(); | |
88 | } | |
f554a14b | 89 | |
8f850e28 | 90 | return ret; |
239eaa41 RR |
91 | } |
92 | ||
e0062c04 | 93 | bool wxDataViewModel::ValueChanged( const wxDataViewItem &item, unsigned int col ) |
239eaa41 | 94 | { |
8f850e28 | 95 | bool ret = true; |
b5d777c7 | 96 | |
85e5bb6a | 97 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
b5d777c7 RR |
98 | while (node) |
99 | { | |
e0062c04 RR |
100 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
101 | if (!notifier->ValueChanged( item, col )) | |
8f850e28 | 102 | ret = false; |
b5d777c7 RR |
103 | node = node->GetNext(); |
104 | } | |
f554a14b | 105 | |
b5d777c7 | 106 | return ret; |
239eaa41 RR |
107 | } |
108 | ||
e0062c04 | 109 | bool wxDataViewModel::Cleared() |
4eccd3a1 RR |
110 | { |
111 | bool ret = true; | |
112 | ||
85e5bb6a | 113 | wxList::compatibility_iterator node = m_notifiers.GetFirst(); |
4eccd3a1 RR |
114 | while (node) |
115 | { | |
e0062c04 | 116 | wxDataViewModelNotifier* notifier = (wxDataViewModelNotifier*) node->GetData(); |
8f850e28 RR |
117 | if (!notifier->Cleared()) |
118 | ret = false; | |
119 | node = node->GetNext(); | |
120 | } | |
f554a14b | 121 | |
8f850e28 | 122 | return ret; |
239eaa41 RR |
123 | } |
124 | ||
e0062c04 | 125 | void wxDataViewModel::AddNotifier( wxDataViewModelNotifier *notifier ) |
239eaa41 | 126 | { |
8f850e28 RR |
127 | m_notifiers.Append( notifier ); |
128 | notifier->SetOwner( this ); | |
239eaa41 RR |
129 | } |
130 | ||
e0062c04 | 131 | void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier ) |
239eaa41 | 132 | { |
8f850e28 | 133 | m_notifiers.DeleteObject( notifier ); |
239eaa41 RR |
134 | } |
135 | ||
f554a14b | 136 | // --------------------------------------------------------- |
baa9ebc4 | 137 | // wxDataViewRendererBase |
f554a14b | 138 | // --------------------------------------------------------- |
6842a71a | 139 | |
baa9ebc4 | 140 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewRendererBase, wxObject) |
6842a71a | 141 | |
9861f022 RR |
142 | wxDataViewRendererBase::wxDataViewRendererBase( const wxString &varianttype, |
143 | wxDataViewCellMode WXUNUSED(mode), | |
144 | int WXUNUSED(align) ) | |
6842a71a RR |
145 | { |
146 | m_variantType = varianttype; | |
1e510b1e | 147 | m_editorCtrl = NULL; |
9861f022 RR |
148 | } |
149 | ||
150 | const wxDataViewCtrl* wxDataViewRendererBase::GetView() const | |
151 | { | |
152 | return wx_const_cast(wxDataViewRendererBase*, this)->GetOwner()->GetOwner(); | |
6842a71a | 153 | } |
f554a14b | 154 | |
e0062c04 | 155 | bool wxDataViewRendererBase::StartEditing( const wxDataViewItem &item, wxRect labelRect ) |
1e510b1e | 156 | { |
e0062c04 | 157 | m_item = item; // remember for later |
1e510b1e RR |
158 | |
159 | unsigned int col = GetOwner()->GetModelColumn(); | |
160 | wxVariant value; | |
e0062c04 | 161 | GetOwner()->GetOwner()->GetModel()->GetValue( value, item, col ); |
1e510b1e RR |
162 | |
163 | m_editorCtrl = CreateEditorCtrl( GetOwner()->GetOwner()->GetMainWindow(), labelRect, value ); | |
164 | ||
30715fa1 RR |
165 | wxDataViewEditorCtrlEvtHandler *handler = |
166 | new wxDataViewEditorCtrlEvtHandler( m_editorCtrl, (wxDataViewRenderer*) this ); | |
167 | ||
168 | m_editorCtrl->PushEventHandler( handler ); | |
1e510b1e | 169 | |
30715fa1 RR |
170 | #if defined(__WXGTK20__) && !defined(wxUSE_GENERICDATAVIEWCTRL) |
171 | handler->SetFocusOnIdle(); | |
172 | #else | |
1e510b1e | 173 | m_editorCtrl->SetFocus(); |
30715fa1 RR |
174 | #endif |
175 | ||
1e510b1e RR |
176 | return true; |
177 | } | |
178 | ||
179 | void wxDataViewRendererBase::CancelEditing() | |
180 | { | |
2fa73716 | 181 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
182 | |
183 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
2fa73716 RR |
184 | |
185 | // m_editorCtrl->PopEventHandler( true ); | |
1e510b1e RR |
186 | } |
187 | ||
188 | bool wxDataViewRendererBase::FinishEditing() | |
189 | { | |
1e510b1e RR |
190 | wxVariant value; |
191 | GetValueFromEditorCtrl( m_editorCtrl, value ); | |
192 | ||
2fa73716 | 193 | wxPendingDelete.Append( m_editorCtrl ); |
1e510b1e RR |
194 | |
195 | GetOwner()->GetOwner()->GetMainWindow()->SetFocus(); | |
196 | ||
197 | if (!Validate(value)) | |
198 | return false; | |
199 | ||
200 | unsigned int col = GetOwner()->GetModelColumn(); | |
e0062c04 RR |
201 | GetOwner()->GetOwner()->GetModel()->SetValue( value, m_item, col ); |
202 | GetOwner()->GetOwner()->GetModel()->ValueChanged( m_item, col ); | |
1e510b1e | 203 | |
2fa73716 RR |
204 | // m_editorCtrl->PopEventHandler( true ); |
205 | ||
1e510b1e RR |
206 | return true; |
207 | } | |
208 | ||
209 | //----------------------------------------------------------------------------- | |
210 | // wxDataViewEditorCtrlEvtHandler | |
211 | //----------------------------------------------------------------------------- | |
212 | ||
213 | BEGIN_EVENT_TABLE(wxDataViewEditorCtrlEvtHandler, wxEvtHandler) | |
214 | EVT_CHAR (wxDataViewEditorCtrlEvtHandler::OnChar) | |
215 | EVT_KILL_FOCUS (wxDataViewEditorCtrlEvtHandler::OnKillFocus) | |
30715fa1 | 216 | EVT_IDLE (wxDataViewEditorCtrlEvtHandler::OnIdle) |
1e510b1e RR |
217 | END_EVENT_TABLE() |
218 | ||
219 | wxDataViewEditorCtrlEvtHandler::wxDataViewEditorCtrlEvtHandler( | |
220 | wxControl *editorCtrl, | |
221 | wxDataViewRenderer *owner ) | |
222 | { | |
223 | m_owner = owner; | |
224 | m_editorCtrl = editorCtrl; | |
225 | ||
226 | m_finished = false; | |
227 | } | |
228 | ||
30715fa1 RR |
229 | void wxDataViewEditorCtrlEvtHandler::OnIdle( wxIdleEvent &event ) |
230 | { | |
231 | if (m_focusOnIdle) | |
232 | { | |
233 | m_focusOnIdle = false; | |
234 | if (wxWindow::FindFocus() != m_editorCtrl) | |
235 | m_editorCtrl->SetFocus(); | |
236 | } | |
237 | ||
238 | event.Skip(); | |
239 | } | |
240 | ||
1e510b1e RR |
241 | void wxDataViewEditorCtrlEvtHandler::OnChar( wxKeyEvent &event ) |
242 | { | |
243 | switch ( event.m_keyCode ) | |
244 | { | |
245 | case WXK_RETURN: | |
246 | m_finished = true; | |
247 | m_owner->FinishEditing(); | |
248 | break; | |
249 | ||
250 | case WXK_ESCAPE: | |
251 | m_finished = true; | |
252 | m_owner->CancelEditing(); | |
253 | break; | |
254 | ||
255 | default: | |
256 | event.Skip(); | |
257 | } | |
258 | } | |
259 | ||
260 | void wxDataViewEditorCtrlEvtHandler::OnKillFocus( wxFocusEvent &event ) | |
261 | { | |
262 | if (!m_finished) | |
263 | { | |
264 | m_finished = true; | |
265 | m_owner->FinishEditing(); | |
266 | } | |
267 | ||
1e510b1e RR |
268 | event.Skip(); |
269 | } | |
270 | ||
f554a14b | 271 | // --------------------------------------------------------- |
fa28826d | 272 | // wxDataViewColumnBase |
f554a14b | 273 | // --------------------------------------------------------- |
fa28826d RR |
274 | |
275 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumnBase, wxObject) | |
276 | ||
9861f022 | 277 | wxDataViewColumnBase::wxDataViewColumnBase(const wxString& WXUNUSED(title), |
baa9ebc4 | 278 | wxDataViewRenderer *renderer, |
0a71f9e9 | 279 | unsigned int model_column, |
008b5a66 | 280 | int WXUNUSED(width), |
87f0efe2 | 281 | wxAlignment WXUNUSED(align), |
9861f022 | 282 | int WXUNUSED(flags)) |
fa28826d | 283 | { |
baa9ebc4 | 284 | m_renderer = renderer; |
6842a71a | 285 | m_model_column = model_column; |
6842a71a | 286 | m_owner = NULL; |
baa9ebc4 | 287 | m_renderer->SetOwner( (wxDataViewColumn*) this ); |
9861f022 RR |
288 | |
289 | // NOTE: the wxDataViewColumn's ctor must store the width, align, flags | |
290 | // parameters inside the native control! | |
6842a71a RR |
291 | } |
292 | ||
07a84e7b RR |
293 | wxDataViewColumnBase::wxDataViewColumnBase(const wxBitmap& bitmap, |
294 | wxDataViewRenderer *renderer, | |
295 | unsigned int model_column, | |
296 | int WXUNUSED(width), | |
87f0efe2 | 297 | wxAlignment WXUNUSED(align), |
9861f022 | 298 | int WXUNUSED(flags) ) |
07a84e7b RR |
299 | { |
300 | m_renderer = renderer; | |
301 | m_model_column = model_column; | |
07a84e7b RR |
302 | m_bitmap = bitmap; |
303 | m_owner = NULL; | |
304 | m_renderer->SetOwner( (wxDataViewColumn*) this ); | |
305 | } | |
306 | ||
6842a71a RR |
307 | wxDataViewColumnBase::~wxDataViewColumnBase() |
308 | { | |
baa9ebc4 RR |
309 | if (m_renderer) |
310 | delete m_renderer; | |
fa28826d RR |
311 | } |
312 | ||
9861f022 | 313 | int wxDataViewColumnBase::GetFlags() const |
fa28826d | 314 | { |
9861f022 | 315 | int ret = 0; |
fa28826d | 316 | |
9861f022 RR |
317 | if (IsSortable()) |
318 | ret |= wxDATAVIEW_COL_SORTABLE; | |
319 | if (IsResizeable()) | |
320 | ret |= wxDATAVIEW_COL_RESIZABLE; | |
321 | if (IsHidden()) | |
322 | ret |= wxDATAVIEW_COL_HIDDEN; | |
fa28826d | 323 | |
9861f022 | 324 | return ret; |
07a84e7b RR |
325 | } |
326 | ||
9861f022 | 327 | void wxDataViewColumnBase::SetFlags(int flags) |
07a84e7b | 328 | { |
9861f022 RR |
329 | SetSortable((flags & wxDATAVIEW_COL_SORTABLE) != 0); |
330 | SetResizeable((flags & wxDATAVIEW_COL_RESIZABLE) != 0); | |
331 | SetHidden((flags & wxDATAVIEW_COL_HIDDEN) != 0); | |
07a84e7b RR |
332 | } |
333 | ||
1821abd1 | 334 | // --------------------------------------------------------- |
e0062c04 | 335 | // wxDataViewEventModelNotifier |
1821abd1 RR |
336 | // --------------------------------------------------------- |
337 | ||
e0062c04 | 338 | class WXDLLIMPEXP_ADV wxDataViewEventModelNotifier: public wxDataViewModelNotifier |
1821abd1 RR |
339 | { |
340 | public: | |
e0062c04 | 341 | wxDataViewEventModelNotifier( wxDataViewCtrl *ctrl ) { m_ctrl = ctrl; } |
1821abd1 | 342 | |
e0062c04 | 343 | bool SendEvent( wxEventType event_type, const wxDataViewItem &item, unsigned int col = 0 ) |
1821abd1 RR |
344 | { |
345 | wxDataViewEvent event( event_type, m_ctrl->GetId() ); | |
346 | event.SetEventObject( m_ctrl ); | |
347 | event.SetModel( m_ctrl->GetModel() ); | |
e0062c04 | 348 | event.SetItem( item ); |
1821abd1 RR |
349 | event.SetColumn( col ); |
350 | m_ctrl->GetEventHandler()->ProcessEvent( event ); | |
351 | return true; | |
352 | } | |
353 | ||
e0062c04 RR |
354 | virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) |
355 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, item ); } | |
356 | virtual bool ItemDeleted( const wxDataViewItem &item ) | |
357 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED, item ); } | |
358 | virtual bool ItemChanged( const wxDataViewItem &item ) | |
359 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED, item ); } | |
360 | virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) | |
361 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED, item, col ); } | |
362 | virtual bool Cleared() | |
363 | { return SendEvent( wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED, wxDataViewItem(0) ); } | |
1821abd1 RR |
364 | |
365 | private: | |
366 | wxDataViewCtrl *m_ctrl; | |
367 | }; | |
368 | ||
9861f022 | 369 | |
f554a14b | 370 | // --------------------------------------------------------- |
239eaa41 | 371 | // wxDataViewCtrlBase |
f554a14b | 372 | // --------------------------------------------------------- |
239eaa41 RR |
373 | |
374 | IMPLEMENT_ABSTRACT_CLASS(wxDataViewCtrlBase, wxControl) | |
375 | ||
376 | wxDataViewCtrlBase::wxDataViewCtrlBase() | |
377 | { | |
378 | m_model = NULL; | |
fa28826d | 379 | m_cols.DeleteContents( true ); |
1821abd1 | 380 | m_eventNotifier = NULL; |
3b6280be RR |
381 | m_expander_column = 0; |
382 | m_indent = 8; | |
239eaa41 RR |
383 | } |
384 | ||
385 | wxDataViewCtrlBase::~wxDataViewCtrlBase() | |
386 | { | |
87f0efe2 RR |
387 | // IMPORTANT: before calling DecRef() on our model (since it may |
388 | // result in a free() call), erase all columns (since | |
389 | // they hold a pointer to our model) | |
390 | m_cols.Clear(); | |
391 | ||
392 | if (m_model) | |
393 | { | |
1821abd1 RR |
394 | if (m_eventNotifier) |
395 | m_model->RemoveNotifier( m_eventNotifier ); | |
396 | m_eventNotifier = NULL; | |
397 | ||
87f0efe2 RR |
398 | m_model->DecRef(); |
399 | m_model = NULL; | |
400 | } | |
239eaa41 RR |
401 | } |
402 | ||
e0062c04 | 403 | bool wxDataViewCtrlBase::AssociateModel( wxDataViewModel *model ) |
239eaa41 | 404 | { |
1821abd1 RR |
405 | if (m_model) |
406 | { | |
407 | if (m_eventNotifier) | |
408 | m_model->RemoveNotifier( m_eventNotifier ); | |
409 | m_eventNotifier = NULL; | |
410 | ||
87f0efe2 | 411 | m_model->DecRef(); // discard old model, if any |
1821abd1 | 412 | } |
87f0efe2 RR |
413 | |
414 | // add our own reference to the new model: | |
239eaa41 | 415 | m_model = model; |
1821abd1 RR |
416 | if (m_model) |
417 | { | |
87f0efe2 | 418 | m_model->IncRef(); |
e0062c04 | 419 | m_eventNotifier = new wxDataViewEventModelNotifier( (wxDataViewCtrl*) this ); |
1821abd1 RR |
420 | m_model->AddNotifier( m_eventNotifier ); |
421 | } | |
f554a14b | 422 | |
239eaa41 RR |
423 | return true; |
424 | } | |
425 | ||
e0062c04 | 426 | wxDataViewModel* wxDataViewCtrlBase::GetModel() |
239eaa41 RR |
427 | { |
428 | return m_model; | |
429 | } | |
430 | ||
1286b7ba | 431 | bool wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 432 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
fa28826d | 433 | { |
1286b7ba | 434 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
435 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
436 | model_column, width, align, flags ) ); | |
fa28826d RR |
437 | } |
438 | ||
1286b7ba | 439 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 440 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
605c2c4a | 441 | { |
1286b7ba | 442 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
443 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
444 | model_column, width, align, flags ) ); | |
605c2c4a RR |
445 | } |
446 | ||
1286b7ba | 447 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 448 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
ad63bf41 | 449 | { |
1286b7ba | 450 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
451 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
452 | model_column, width, align, flags ) ); | |
ad63bf41 RR |
453 | } |
454 | ||
1286b7ba | 455 | bool wxDataViewCtrlBase::AppendDateColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 456 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
4d496ecb | 457 | { |
1286b7ba | 458 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
459 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
460 | model_column, width, align, flags ) ); | |
4d496ecb RR |
461 | } |
462 | ||
1286b7ba | 463 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxString &label, unsigned int model_column, |
87f0efe2 | 464 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 465 | { |
1286b7ba | 466 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
467 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
468 | model_column, width, align, flags ) ); | |
07a84e7b RR |
469 | } |
470 | ||
1286b7ba | 471 | bool wxDataViewCtrlBase::AppendTextColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 472 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 473 | { |
1286b7ba | 474 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
475 | new wxDataViewTextRenderer( wxT("string"), mode, (int)align ), |
476 | model_column, width, align, flags ) ); | |
07a84e7b RR |
477 | } |
478 | ||
1286b7ba | 479 | bool wxDataViewCtrlBase::AppendToggleColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 480 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 481 | { |
1286b7ba | 482 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
483 | new wxDataViewToggleRenderer( wxT("bool"), mode, (int)align ), |
484 | model_column, width, align, flags ) ); | |
07a84e7b RR |
485 | } |
486 | ||
1286b7ba | 487 | bool wxDataViewCtrlBase::AppendProgressColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 488 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 489 | { |
1286b7ba | 490 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
491 | new wxDataViewProgressRenderer( wxEmptyString, wxT("long"), mode, (int)align ), |
492 | model_column, width, align, flags ) ); | |
07a84e7b RR |
493 | } |
494 | ||
1286b7ba | 495 | bool wxDataViewCtrlBase::AppendDateColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 496 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 497 | { |
1286b7ba | 498 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
499 | new wxDataViewDateRenderer( wxT("datetime"), mode, (int)align ), |
500 | model_column, width, align, flags ) ); | |
07a84e7b RR |
501 | } |
502 | ||
1286b7ba | 503 | bool wxDataViewCtrlBase::AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, |
87f0efe2 | 504 | wxDataViewCellMode mode, int width, wxAlignment align, int flags ) |
07a84e7b | 505 | { |
1286b7ba | 506 | return AppendColumn( new wxDataViewColumn( label, |
9861f022 RR |
507 | new wxDataViewBitmapRenderer( wxT("wxBitmap"), mode, (int)align ), |
508 | model_column, width, align, flags ) ); | |
07a84e7b RR |
509 | } |
510 | ||
fa28826d RR |
511 | bool wxDataViewCtrlBase::AppendColumn( wxDataViewColumn *col ) |
512 | { | |
513 | m_cols.Append( (wxObject*) col ); | |
6842a71a | 514 | col->SetOwner( (wxDataViewCtrl*) this ); |
fa28826d RR |
515 | return true; |
516 | } | |
517 | ||
9861f022 | 518 | unsigned int wxDataViewCtrlBase::GetColumnCount() const |
fa28826d RR |
519 | { |
520 | return m_cols.GetCount(); | |
521 | } | |
522 | ||
0a71f9e9 | 523 | bool wxDataViewCtrlBase::DeleteColumn( unsigned int WXUNUSED(pos) ) |
fa28826d RR |
524 | { |
525 | return false; | |
526 | } | |
527 | ||
528 | bool wxDataViewCtrlBase::ClearColumns() | |
529 | { | |
530 | return false; | |
531 | } | |
532 | ||
0a71f9e9 | 533 | wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) |
fa28826d RR |
534 | { |
535 | return (wxDataViewColumn*) m_cols[ pos ]; | |
536 | } | |
537 | ||
eb7f97f8 RR |
538 | // --------------------------------------------------------- |
539 | // wxDataViewEvent | |
540 | // --------------------------------------------------------- | |
541 | ||
542 | IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) | |
543 | ||
e0062c04 RR |
544 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED) |
545 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED) | |
31fb32e1 RR |
546 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK) |
547 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK) | |
c0a66d92 | 548 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED) |
eb7f97f8 | 549 | |
e0062c04 RR |
550 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED) |
551 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_DELETED) | |
552 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_CHANGED) | |
1821abd1 | 553 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_VALUE_CHANGED) |
1821abd1 | 554 | DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_MODEL_CLEARED) |
eb7f97f8 | 555 | |
8045736e | 556 | #endif |