Make generic wxDataViewCtrl draw its contents.
[wxWidgets.git] / src / generic / datavgen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: datavgen.cpp
3 // Purpose: wxDataViewCtrl generic implementation
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #include "wx/defs.h"
14
15 #if wxUSE_DATAVIEWCTRL
16
17 #include "wx/dataview.h"
18
19 #ifdef wxUSE_GENERICDATAVIEWCTRL
20
21 #include "wx/stockitem.h"
22 #include "wx/dcclient.h"
23 #include "wx/calctrl.h"
24 #include "wx/popupwin.h"
25 #include "wx/sizer.h"
26 #include "wx/log.h"
27 #include "wx/renderer.h"
28
29 #ifdef __WXMSW__
30 #include <windows.h> // for DLGC_WANTARROWS
31 #include "wx/msw/winundef.h"
32 #endif
33
34 //-----------------------------------------------------------------------------
35 // classes
36 //-----------------------------------------------------------------------------
37
38 class wxDataViewCtrl;
39
40 //-----------------------------------------------------------------------------
41 // wxDataViewHeaderWindow
42 //-----------------------------------------------------------------------------
43
44 class wxDataViewHeaderWindow: public wxWindow
45 {
46 public:
47 wxDataViewHeaderWindow( wxDataViewCtrl *parent,
48 wxWindowID id,
49 const wxPoint &pos = wxDefaultPosition,
50 const wxSize &size = wxDefaultSize,
51 const wxString &name = wxT("wxdataviewctrlheaderwindow") );
52 ~wxDataViewHeaderWindow();
53
54 void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
55 wxDataViewCtrl *GetOwner() { return m_owner; }
56
57 void OnPaint( wxPaintEvent &event );
58 void OnMouse( wxMouseEvent &event );
59 void OnSetFocus( wxFocusEvent &event );
60
61 private:
62 wxDataViewCtrl *m_owner;
63 wxCursor *m_resizeCursor;
64
65 private:
66 DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindow)
67 DECLARE_EVENT_TABLE()
68 };
69
70 //-----------------------------------------------------------------------------
71 // wxDataViewMainWindow
72 //-----------------------------------------------------------------------------
73
74 class wxDataViewMainWindow: public wxWindow
75 {
76 public:
77 wxDataViewMainWindow( wxDataViewCtrl *parent,
78 wxWindowID id,
79 const wxPoint &pos = wxDefaultPosition,
80 const wxSize &size = wxDefaultSize,
81 const wxString &name = wxT("wxdataviewctrlmainwindow") );
82 ~wxDataViewMainWindow();
83
84 // notifications from wxDataViewListModel
85 bool RowAppended();
86 bool RowPrepended();
87 bool RowInserted( size_t before );
88 bool RowDeleted( size_t row );
89 bool RowChanged( size_t row );
90 bool ValueChanged( size_t col, size_t row );
91 bool RowsReordered( size_t *new_order );
92 bool Cleared();
93
94 void SetOwner( wxDataViewCtrl* owner ) { m_owner = owner; }
95 wxDataViewCtrl *GetOwner() { return m_owner; }
96
97 void OnPaint( wxPaintEvent &event );
98 void OnMouse( wxMouseEvent &event );
99 void OnSetFocus( wxFocusEvent &event );
100
101 void UpdateDisplay();
102 void RecalculateDisplay();
103 void OnInternalIdle();
104
105 void ScrollWindow( int dx, int dy, const wxRect *rect );
106 private:
107 wxDataViewCtrl *m_owner;
108 int m_lineHeight;
109 bool m_dirty;
110
111 private:
112 DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow)
113 DECLARE_EVENT_TABLE()
114 };
115
116 // ---------------------------------------------------------
117 // wxGenericDataViewListModelNotifier
118 // ---------------------------------------------------------
119
120 class wxGenericDataViewListModelNotifier: public wxDataViewListModelNotifier
121 {
122 public:
123 wxGenericDataViewListModelNotifier( wxDataViewMainWindow *mainWindow )
124 { m_mainWindow = mainWindow; }
125
126 virtual bool RowAppended()
127 { return m_mainWindow->RowAppended(); }
128 virtual bool RowPrepended()
129 { return m_mainWindow->RowPrepended(); }
130 virtual bool RowInserted( size_t before )
131 { return m_mainWindow->RowInserted( before ); }
132 virtual bool RowDeleted( size_t row )
133 { return m_mainWindow->RowDeleted( row ); }
134 virtual bool RowChanged( size_t row )
135 { return m_mainWindow->RowChanged( row ); }
136 virtual bool ValueChanged( size_t col, size_t row )
137 { return m_mainWindow->ValueChanged( col, row ); }
138 virtual bool RowsReordered( size_t *new_order )
139 { return m_mainWindow->RowsReordered( new_order ); }
140 virtual bool Cleared()
141 { return m_mainWindow->Cleared(); }
142
143 wxDataViewMainWindow *m_mainWindow;
144 };
145
146 // ---------------------------------------------------------
147 // wxDataViewCell
148 // ---------------------------------------------------------
149
150 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCell, wxDataViewCellBase)
151
152 wxDataViewCell::wxDataViewCell( const wxString &varianttype, wxDataViewCellMode mode ) :
153 wxDataViewCellBase( varianttype, mode )
154 {
155 m_dc = NULL;
156 }
157
158 wxDataViewCell::~wxDataViewCell()
159 {
160 if (m_dc)
161 delete m_dc;
162 }
163
164 wxDC *wxDataViewCell::GetDC()
165 {
166 if (m_dc == NULL)
167 {
168 if (GetOwner() == NULL)
169 return NULL;
170 if (GetOwner()->GetOwner() == NULL)
171 return NULL;
172 m_dc = new wxClientDC( GetOwner()->GetOwner() );
173 }
174
175 return m_dc;
176 }
177
178 // ---------------------------------------------------------
179 // wxDataViewCustomCell
180 // ---------------------------------------------------------
181
182 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomCell, wxDataViewCell)
183
184 wxDataViewCustomCell::wxDataViewCustomCell( const wxString &varianttype,
185 wxDataViewCellMode mode ) :
186 wxDataViewCell( varianttype, mode )
187 {
188 }
189
190
191 // ---------------------------------------------------------
192 // wxDataViewTextCell
193 // ---------------------------------------------------------
194
195 IMPLEMENT_ABSTRACT_CLASS(wxDataViewTextCell, wxDataViewCustomCell)
196
197 wxDataViewTextCell::wxDataViewTextCell( const wxString &varianttype, wxDataViewCellMode mode ) :
198 wxDataViewCustomCell( varianttype, mode )
199 {
200 }
201
202 bool wxDataViewTextCell::SetValue( const wxVariant &value )
203 {
204 m_text = value.GetString();
205
206 return true;
207 }
208
209 bool wxDataViewTextCell::GetValue( wxVariant &value )
210 {
211 return false;
212 }
213
214 bool wxDataViewTextCell::Render( wxRect cell, wxDC *dc, int state )
215 {
216 dc->DrawText( m_text, cell.x, cell.y );
217
218 return true;
219 }
220
221 wxSize wxDataViewTextCell::GetSize()
222 {
223 return wxSize(80,20);
224 }
225
226 // ---------------------------------------------------------
227 // wxDataViewToggleCell
228 // ---------------------------------------------------------
229
230 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleCell, wxDataViewCustomCell)
231
232 wxDataViewToggleCell::wxDataViewToggleCell( const wxString &varianttype,
233 wxDataViewCellMode mode ) :
234 wxDataViewCustomCell( varianttype, mode )
235 {
236 m_toggle = false;
237 }
238
239 bool wxDataViewToggleCell::SetValue( const wxVariant &value )
240 {
241 m_toggle = value.GetBool();
242
243 return true;;
244 }
245
246 bool wxDataViewToggleCell::GetValue( wxVariant &value )
247 {
248 return false;
249 }
250
251 bool wxDataViewToggleCell::Render( wxRect cell, wxDC *dc, int state )
252 {
253 // User wxRenderer here
254
255 dc->SetPen( *wxBLACK_PEN );
256 dc->SetBrush( *wxTRANSPARENT_BRUSH );
257 wxRect rect;
258 rect.x = cell.x + cell.width/2 - 10;
259 rect.width = 20;
260 rect.y = cell.y + cell.height/2 - 10;
261 rect.height = 20;
262 dc->DrawRectangle( rect );
263 if (m_toggle)
264 {
265 rect.x += 2;
266 rect.y += 2;
267 rect.width -= 4;
268 rect.height -= 4;
269 dc->DrawLine( rect.x, rect.y, rect.x+rect.width, rect.y+rect.height );
270 dc->DrawLine( rect.x+rect.width, rect.y, rect.x, rect.y+rect.height );
271 }
272
273 return true;
274 }
275
276 wxSize wxDataViewToggleCell::GetSize()
277 {
278 return wxSize(20,20);
279 }
280
281 // ---------------------------------------------------------
282 // wxDataViewProgressCell
283 // ---------------------------------------------------------
284
285 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressCell, wxDataViewCustomCell)
286
287 wxDataViewProgressCell::wxDataViewProgressCell( const wxString &label,
288 const wxString &varianttype, wxDataViewCellMode mode ) :
289 wxDataViewCustomCell( varianttype, mode )
290 {
291 m_label = label;
292 m_value = 0;
293 }
294
295 wxDataViewProgressCell::~wxDataViewProgressCell()
296 {
297 }
298
299 bool wxDataViewProgressCell::SetValue( const wxVariant &value )
300 {
301 m_value = (long) value;
302
303 if (m_value < 0) m_value = 0;
304 if (m_value > 100) m_value = 100;
305
306 return true;
307 }
308
309 bool wxDataViewProgressCell::Render( wxRect cell, wxDC *dc, int state )
310 {
311 double pct = (double)m_value / 100.0;
312 wxRect bar = cell;
313 bar.width = (int)(cell.width * pct);
314 dc->SetPen( *wxTRANSPARENT_PEN );
315 dc->SetBrush( *wxBLUE_BRUSH );
316 dc->DrawRectangle( bar );
317
318 dc->SetBrush( *wxTRANSPARENT_BRUSH );
319 dc->SetPen( *wxBLACK_PEN );
320 dc->DrawRectangle( cell );
321
322 return true;
323 }
324
325 wxSize wxDataViewProgressCell::GetSize()
326 {
327 return wxSize(40,12);
328 }
329
330 // ---------------------------------------------------------
331 // wxDataViewDateCell
332 // ---------------------------------------------------------
333
334 class wxDataViewDateCellPopupTransient: public wxPopupTransientWindow
335 {
336 public:
337 wxDataViewDateCellPopupTransient( wxWindow* parent, wxDateTime *value,
338 wxDataViewListModel *model, size_t col, size_t row ) :
339 wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
340 {
341 m_model = model;
342 m_col = col;
343 m_row = row;
344 m_cal = new wxCalendarCtrl( this, -1, *value );
345 wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
346 sizer->Add( m_cal, 1, wxGROW );
347 SetSizer( sizer );
348 sizer->Fit( this );
349 }
350
351 virtual void OnDismiss()
352 {
353 }
354
355 void OnCalendar( wxCalendarEvent &event );
356
357 wxCalendarCtrl *m_cal;
358 wxDataViewListModel *m_model;
359 size_t m_col;
360 size_t m_row;
361
362 private:
363 DECLARE_EVENT_TABLE()
364 };
365
366 BEGIN_EVENT_TABLE(wxDataViewDateCellPopupTransient,wxPopupTransientWindow)
367 EVT_CALENDAR( -1, wxDataViewDateCellPopupTransient::OnCalendar )
368 END_EVENT_TABLE()
369
370 void wxDataViewDateCellPopupTransient::OnCalendar( wxCalendarEvent &event )
371 {
372 wxDateTime date = event.GetDate();
373 wxVariant value = date;
374 m_model->SetValue( value, m_col, m_row );
375 m_model->ValueChanged( m_col, m_row );
376 DismissAndNotify();
377 }
378
379 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateCell, wxDataViewCustomCell)
380
381 wxDataViewDateCell::wxDataViewDateCell( const wxString &varianttype,
382 wxDataViewCellMode mode ) :
383 wxDataViewCustomCell( varianttype, mode )
384 {
385 }
386
387 bool wxDataViewDateCell::SetValue( const wxVariant &value )
388 {
389 m_date = value.GetDateTime();
390
391 return true;
392 }
393
394 bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int state )
395 {
396 dc->SetFont( GetOwner()->GetOwner()->GetFont() );
397 wxString tmp = m_date.FormatDate();
398 dc->DrawText( tmp, cell.x, cell.y );
399
400 return true;
401 }
402
403 wxSize wxDataViewDateCell::GetSize()
404 {
405 wxDataViewCtrl* view = GetOwner()->GetOwner();
406 wxString tmp = m_date.FormatDate();
407 wxCoord x,y,d;
408 view->GetTextExtent( tmp, &x, &y, &d );
409 return wxSize(x,y+d);
410 }
411
412 bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
413 {
414 wxVariant variant;
415 model->GetValue( variant, col, row );
416 wxDateTime value = variant.GetDateTime();
417
418 wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
419 GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
420 wxPoint pos = wxGetMousePosition();
421 popup->Move( pos );
422 popup->Layout();
423 popup->Popup( popup->m_cal );
424
425 return true;
426 }
427
428 // ---------------------------------------------------------
429 // wxDataViewColumn
430 // ---------------------------------------------------------
431
432 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn, wxDataViewColumnBase)
433
434 wxDataViewColumn::wxDataViewColumn( const wxString &title, wxDataViewCell *cell,
435 size_t model_column, int flags ) :
436 wxDataViewColumnBase( title, cell, model_column, flags )
437 {
438 m_width = 80;
439 }
440
441 wxDataViewColumn::~wxDataViewColumn()
442 {
443 }
444
445 void wxDataViewColumn::SetTitle( const wxString &title )
446 {
447 wxDataViewColumnBase::SetTitle( title );
448
449 }
450
451 //-----------------------------------------------------------------------------
452 // wxDataViewHeaderWindow
453 //-----------------------------------------------------------------------------
454
455 IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindow, wxWindow)
456
457 BEGIN_EVENT_TABLE(wxDataViewHeaderWindow,wxWindow)
458 EVT_PAINT (wxDataViewHeaderWindow::OnPaint)
459 EVT_MOUSE_EVENTS (wxDataViewHeaderWindow::OnMouse)
460 EVT_SET_FOCUS (wxDataViewHeaderWindow::OnSetFocus)
461 END_EVENT_TABLE()
462
463 wxDataViewHeaderWindow::wxDataViewHeaderWindow( wxDataViewCtrl *parent, wxWindowID id,
464 const wxPoint &pos, const wxSize &size, const wxString &name ) :
465 wxWindow( parent, id, pos, size, 0, name )
466 {
467 SetOwner( parent );
468
469 m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
470
471 wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();
472 SetOwnForegroundColour( attr.colFg );
473 SetOwnBackgroundColour( attr.colBg );
474 if (!m_hasFont)
475 SetOwnFont( attr.font );
476 }
477
478 wxDataViewHeaderWindow::~wxDataViewHeaderWindow()
479 {
480 delete m_resizeCursor;
481 }
482
483 void wxDataViewHeaderWindow::OnPaint( wxPaintEvent &event )
484 {
485 int w, h;
486 GetClientSize( &w, &h );
487
488 wxPaintDC dc( this );
489
490 int xpix;
491 m_owner->GetScrollPixelsPerUnit( &xpix, NULL );
492
493 int x;
494 m_owner->GetViewStart( &x, NULL );
495
496 // account for the horz scrollbar offset
497 dc.SetDeviceOrigin( -x * xpix, 0 );
498
499 dc.SetFont( GetFont() );
500
501 size_t cols = GetOwner()->GetNumberOfColumns();
502 size_t i;
503 int xpos = 0;
504 for (i = 0; i < cols; i++)
505 {
506 wxDataViewColumn *col = GetOwner()->GetColumn( i );
507 int width = col->GetWidth();
508
509 // the width of the rect to draw: make it smaller to fit entirely
510 // inside the column rect
511 #ifdef __WXMAC__
512 int cw = width;
513 int ch = h;
514 #else
515 int cw = width - 2;
516 int ch = h - 2;
517 #endif
518
519 wxRendererNative::Get().DrawHeaderButton
520 (
521 this,
522 dc,
523 wxRect(xpos, 0, cw, ch),
524 m_parent->IsEnabled() ? 0
525 : (int)wxCONTROL_DISABLED
526 );
527
528 dc.DrawText( col->GetTitle(), xpos+3, 3 );
529
530 xpos += width;
531 }
532 }
533
534 void wxDataViewHeaderWindow::OnMouse( wxMouseEvent &event )
535 {
536 }
537
538 void wxDataViewHeaderWindow::OnSetFocus( wxFocusEvent &event )
539 {
540 event.Skip();
541 }
542
543 //-----------------------------------------------------------------------------
544 // wxDataViewMainWindow
545 //-----------------------------------------------------------------------------
546
547 IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow, wxWindow)
548
549 BEGIN_EVENT_TABLE(wxDataViewMainWindow,wxWindow)
550 EVT_PAINT (wxDataViewMainWindow::OnPaint)
551 EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse)
552 EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus)
553 END_EVENT_TABLE()
554
555 wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl *parent, wxWindowID id,
556 const wxPoint &pos, const wxSize &size, const wxString &name ) :
557 wxWindow( parent, id, pos, size, 0, name )
558 {
559 SetOwner( parent );
560
561 // We need to calculate this smartly..
562 m_lineHeight = 20;
563
564 UpdateDisplay();
565 }
566
567 wxDataViewMainWindow::~wxDataViewMainWindow()
568 {
569 }
570
571 bool wxDataViewMainWindow::RowAppended()
572 {
573 return false;
574 }
575
576 bool wxDataViewMainWindow::RowPrepended()
577 {
578 return false;
579 }
580
581 bool wxDataViewMainWindow::RowInserted( size_t before )
582 {
583 return false;
584 }
585
586 bool wxDataViewMainWindow::RowDeleted( size_t row )
587 {
588 return false;
589 }
590
591 bool wxDataViewMainWindow::RowChanged( size_t row )
592 {
593 return false;
594 }
595
596 bool wxDataViewMainWindow::ValueChanged( size_t col, size_t row )
597 {
598 return false;
599 }
600
601 bool wxDataViewMainWindow::RowsReordered( size_t *new_order )
602 {
603 return false;
604 }
605
606 bool wxDataViewMainWindow::Cleared()
607 {
608 return false;
609 }
610
611 void wxDataViewMainWindow::UpdateDisplay()
612 {
613 m_dirty = true;
614 }
615
616 void wxDataViewMainWindow::OnInternalIdle()
617 {
618 wxWindow::OnInternalIdle();
619
620 if (m_dirty)
621 {
622 RecalculateDisplay();
623 m_dirty = false;
624 }
625 }
626
627 void wxDataViewMainWindow::RecalculateDisplay()
628 {
629 wxDataViewListModel *model = GetOwner()->GetModel();
630 if (!model)
631 {
632 Refresh();
633 return;
634 }
635
636 int width = 0;
637 size_t cols = GetOwner()->GetNumberOfColumns();
638 size_t i;
639 for (i = 0; i < cols; i++)
640 {
641 wxDataViewColumn *col = GetOwner()->GetColumn( i );
642 width += col->GetWidth();
643 }
644
645 int height = model->GetNumberOfRows() * m_lineHeight;
646
647 SetVirtualSize( width, height );
648 GetOwner()->SetScrollRate( 10, m_lineHeight );
649
650 Refresh();
651 }
652
653 void wxDataViewMainWindow::ScrollWindow( int dx, int dy, const wxRect *rect )
654 {
655 wxWindow::ScrollWindow( dx, dy, rect );
656 GetOwner()->m_headerArea->ScrollWindow( dx, 0 );
657 }
658
659 void wxDataViewMainWindow::OnPaint( wxPaintEvent &event )
660 {
661 wxPaintDC dc( this );
662
663 GetOwner()->PrepareDC( dc );
664
665 dc.SetFont( GetFont() );
666
667 wxRect update = GetUpdateRegion().GetBox();
668 m_owner->CalcUnscrolledPosition( update.x, update.y, &update.x, &update.y );
669
670 wxDataViewListModel *model = GetOwner()->GetModel();
671
672 size_t item_start = update.y / m_lineHeight;
673 size_t item_count = (update.height / m_lineHeight) + 1;
674
675 wxRect cell_rect;
676 cell_rect.x = 0;
677 cell_rect.height = m_lineHeight;
678 size_t cols = GetOwner()->GetNumberOfColumns();
679 size_t i;
680 for (i = 0; i < cols; i++)
681 {
682 wxDataViewColumn *col = GetOwner()->GetColumn( i );
683 wxDataViewCell *cell = col->GetCell();
684 cell_rect.width = col->GetWidth();
685
686 size_t item;
687 for (item = item_start; item <= item_start+item_count; item++)
688 {
689 cell_rect.y = item*m_lineHeight;
690 wxVariant value;
691 model->GetValue( value, col->GetModelColumn(), item );
692 cell->SetValue( value );
693 cell->Render( cell_rect, &dc, 0 );
694 }
695
696 cell_rect.x += cell_rect.width;
697 }
698 }
699
700 void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
701 {
702 event.Skip();
703 }
704
705 void wxDataViewMainWindow::OnSetFocus( wxFocusEvent &event )
706 {
707 event.Skip();
708 }
709
710 //-----------------------------------------------------------------------------
711 // wxDataViewCtrl
712 //-----------------------------------------------------------------------------
713
714 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl, wxDataViewCtrlBase)
715
716 BEGIN_EVENT_TABLE(wxDataViewCtrl, wxDataViewCtrlBase)
717 EVT_SIZE(wxDataViewCtrl::OnSize)
718 END_EVENT_TABLE()
719
720 wxDataViewCtrl::~wxDataViewCtrl()
721 {
722 if (m_notifier)
723 GetModel()->RemoveNotifier( m_notifier );
724 }
725
726 void wxDataViewCtrl::Init()
727 {
728 m_notifier = NULL;
729 }
730
731 bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
732 const wxPoint& pos, const wxSize& size,
733 long style, const wxValidator& validator )
734 {
735 if (!wxControl::Create( parent, id, pos, size, style | wxScrolledWindowStyle|wxSUNKEN_BORDER, validator))
736 return false;
737
738 Init();
739
740 #ifdef __WXMAC__
741 MacSetClipChildren( true ) ;
742 #endif
743
744 m_clientArea = new wxDataViewMainWindow( this, -1 );
745 m_headerArea = new wxDataViewHeaderWindow( this, -1, wxDefaultPosition, wxSize(-1,25) );
746
747 SetTargetWindow( m_clientArea );
748
749 wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
750 sizer->Add( m_headerArea, 0, wxGROW );
751 sizer->Add( m_clientArea, 1, wxGROW );
752 SetSizer( sizer );
753
754 return true;
755 }
756
757 #ifdef __WXMSW__
758 WXLRESULT wxDataViewCtrl::MSWWindowProc(WXUINT nMsg,
759 WXWPARAM wParam,
760 WXLPARAM lParam)
761 {
762 WXLRESULT rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam);
763
764 #ifndef __WXWINCE__
765 // we need to process arrows ourselves for scrolling
766 if ( nMsg == WM_GETDLGCODE )
767 {
768 rc |= DLGC_WANTARROWS;
769 }
770 #endif
771
772 return rc;
773 }
774 #endif
775
776 void wxDataViewCtrl::OnSize( wxSizeEvent &event )
777 {
778 // We need to override OnSize so that our scrolled
779 // window a) does call Layout() to use sizers for
780 // positioning the controls but b) does not query
781 // the sizer for their size and use that for setting
782 // the scrollable area as set that ourselves by
783 // calling SetScrollbar() further down.
784
785 Layout();
786
787 AdjustScrollbars();
788 }
789
790 bool wxDataViewCtrl::AssociateModel( wxDataViewListModel *model )
791 {
792 if (!wxDataViewCtrlBase::AssociateModel( model ))
793 return false;
794
795 m_notifier = new wxGenericDataViewListModelNotifier( m_clientArea );
796
797 model->AddNotifier( m_notifier );
798
799 m_clientArea->UpdateDisplay();
800
801 return true;
802 }
803
804 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn *col )
805 {
806 if (!wxDataViewCtrlBase::AppendColumn(col))
807 return false;
808
809 m_clientArea->UpdateDisplay();
810
811 return true;
812 }
813
814 #endif
815 // !wxUSE_GENERICDATAVIEWCTRL
816
817 #endif
818 // wxUSE_DATAVIEWCTRL
819