1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/datavgen.cpp
3 // Purpose: wxDataViewCtrl generic implementation
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_DATAVIEWCTRL
19 #include "wx/dataview.h"
21 #ifdef wxUSE_GENERICDATAVIEWCTRL
25 #include "wx/msw/wrapwin.h"
29 #include "wx/dcclient.h"
31 #include "wx/settings.h"
32 #include "wx/msgdlg.h"
35 #include "wx/stockitem.h"
36 #include "wx/calctrl.h"
37 #include "wx/popupwin.h"
38 #include "wx/renderer.h"
39 #include "wx/dcbuffer.h"
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 // wxDataViewHeaderWindow
50 //-----------------------------------------------------------------------------
52 class wxDataViewHeaderWindow
: public wxWindow
55 wxDataViewHeaderWindow( wxDataViewCtrl
*parent
,
57 const wxPoint
&pos
= wxDefaultPosition
,
58 const wxSize
&size
= wxDefaultSize
,
59 const wxString
&name
= wxT("wxdataviewctrlheaderwindow") );
60 virtual ~wxDataViewHeaderWindow();
62 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
63 wxDataViewCtrl
*GetOwner() { return m_owner
; }
65 void OnPaint( wxPaintEvent
&event
);
66 void OnMouse( wxMouseEvent
&event
);
67 void OnSetFocus( wxFocusEvent
&event
);
70 wxDataViewCtrl
*m_owner
;
71 wxCursor
*m_resizeCursor
;
74 DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindow
)
78 //-----------------------------------------------------------------------------
79 // wxDataViewRenameTimer
80 //-----------------------------------------------------------------------------
82 class wxDataViewRenameTimer
: public wxTimer
85 wxDataViewMainWindow
*m_owner
;
88 wxDataViewRenameTimer( wxDataViewMainWindow
*owner
);
92 //-----------------------------------------------------------------------------
93 // wxDataViewTextCtrlWrapper: wraps a wxTextCtrl for inline editing
94 //-----------------------------------------------------------------------------
96 class wxDataViewTextCtrlWrapper
: public wxEvtHandler
99 // NB: text must be a valid object but not Create()d yet
100 wxDataViewTextCtrlWrapper( wxDataViewMainWindow
*owner
,
102 wxDataViewListModel
*model
,
103 unsigned int col
, unsigned int row
,
106 wxTextCtrl
*GetText() const { return m_text
; }
108 void AcceptChangesAndFinish();
111 void OnChar( wxKeyEvent
&event
);
112 void OnKeyUp( wxKeyEvent
&event
);
113 void OnKillFocus( wxFocusEvent
&event
);
115 bool AcceptChanges();
119 wxDataViewMainWindow
*m_owner
;
121 wxString m_startValue
;
122 wxDataViewListModel
*m_model
;
126 bool m_aboutToFinish
;
128 DECLARE_EVENT_TABLE()
131 //-----------------------------------------------------------------------------
132 // wxDataViewMainWindow
133 //-----------------------------------------------------------------------------
135 WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection
, WXDLLIMPEXP_ADV
);
137 class wxDataViewMainWindow
: public wxWindow
140 wxDataViewMainWindow( wxDataViewCtrl
*parent
,
142 const wxPoint
&pos
= wxDefaultPosition
,
143 const wxSize
&size
= wxDefaultSize
,
144 const wxString
&name
= wxT("wxdataviewctrlmainwindow") );
145 virtual ~wxDataViewMainWindow();
147 // notifications from wxDataViewListModel
150 bool RowInserted( unsigned int before
);
151 bool RowDeleted( unsigned int row
);
152 bool RowChanged( unsigned int row
);
153 bool ValueChanged( unsigned int col
, unsigned int row
);
154 bool RowsReordered( unsigned int *new_order
);
157 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
158 wxDataViewCtrl
*GetOwner() { return m_owner
; }
160 void OnPaint( wxPaintEvent
&event
);
161 void OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
);
162 void OnChar( wxKeyEvent
&event
);
163 void OnMouse( wxMouseEvent
&event
);
164 void OnSetFocus( wxFocusEvent
&event
);
165 void OnKillFocus( wxFocusEvent
&event
);
167 void UpdateDisplay();
168 void RecalculateDisplay();
169 void OnInternalIdle();
171 void OnRenameTimer();
172 void FinishEditing( wxTextCtrl
*text
);
174 void ScrollWindow( int dx
, int dy
, const wxRect
*rect
);
176 bool HasCurrentRow() { return m_currentRow
!= (unsigned int)-1; }
177 void ChangeCurrentRow( unsigned int row
);
179 bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE
); };
180 bool IsEmpty() { return GetRowCount() == 0; }
182 int GetCountPerPage();
183 int GetEndOfLastCol();
184 unsigned int GetFirstVisibleRow();
185 unsigned int GetLastVisibleRow();
186 unsigned int GetRowCount();
188 void SelectAllRows( bool on
);
189 void SelectRow( unsigned int row
, bool on
);
190 void SelectRows( unsigned int from
, unsigned int to
, bool on
);
191 void ReverseRowSelection( unsigned int row
);
192 bool IsRowSelected( unsigned int row
);
194 void RefreshRow( unsigned int row
);
195 void RefreshRows( unsigned int from
, unsigned int to
);
196 void RefreshRowsAfter( unsigned int firstRow
);
199 wxDataViewCtrl
*m_owner
;
203 wxDataViewColumn
*m_currentCol
;
204 unsigned int m_currentRow
;
205 wxDataViewSelection m_selection
;
207 wxDataViewRenameTimer
*m_renameTimer
;
208 wxDataViewTextCtrlWrapper
*m_textctrlWrapper
;
216 // for double click logic
217 unsigned int m_lineLastClicked
,
218 m_lineBeforeLastClicked
,
219 m_lineSelectSingleOnUp
;
222 DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow
)
223 DECLARE_EVENT_TABLE()
226 // ---------------------------------------------------------
227 // wxGenericDataViewListModelNotifier
228 // ---------------------------------------------------------
230 class wxGenericDataViewListModelNotifier
: public wxDataViewListModelNotifier
233 wxGenericDataViewListModelNotifier( wxDataViewMainWindow
*mainWindow
)
234 { m_mainWindow
= mainWindow
; }
236 virtual bool RowAppended()
237 { return m_mainWindow
->RowAppended(); }
238 virtual bool RowPrepended()
239 { return m_mainWindow
->RowPrepended(); }
240 virtual bool RowInserted( unsigned int before
)
241 { return m_mainWindow
->RowInserted( before
); }
242 virtual bool RowDeleted( unsigned int row
)
243 { return m_mainWindow
->RowDeleted( row
); }
244 virtual bool RowChanged( unsigned int row
)
245 { return m_mainWindow
->RowChanged( row
); }
246 virtual bool ValueChanged( unsigned int col
, unsigned int row
)
247 { return m_mainWindow
->ValueChanged( col
, row
); }
248 virtual bool RowsReordered( unsigned int *new_order
)
249 { return m_mainWindow
->RowsReordered( new_order
); }
250 virtual bool Cleared()
251 { return m_mainWindow
->Cleared(); }
253 wxDataViewMainWindow
*m_mainWindow
;
256 // ---------------------------------------------------------
257 // wxDataViewRenderer
258 // ---------------------------------------------------------
260 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
262 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
263 wxDataViewRendererBase( varianttype
, mode
)
268 wxDataViewRenderer::~wxDataViewRenderer()
274 wxDC
*wxDataViewRenderer::GetDC()
278 if (GetOwner() == NULL
)
280 if (GetOwner()->GetOwner() == NULL
)
282 m_dc
= new wxClientDC( GetOwner()->GetOwner() );
288 // ---------------------------------------------------------
289 // wxDataViewCustomRenderer
290 // ---------------------------------------------------------
292 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
294 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
295 wxDataViewCellMode mode
) :
296 wxDataViewRenderer( varianttype
, mode
)
300 // ---------------------------------------------------------
301 // wxDataViewTextRenderer
302 // ---------------------------------------------------------
304 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewCustomRenderer
)
306 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
307 wxDataViewCustomRenderer( varianttype
, mode
)
311 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
313 m_text
= value
.GetString();
318 bool wxDataViewTextRenderer::GetValue( wxVariant
& WXUNUSED(value
) )
323 bool wxDataViewTextRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
325 dc
->DrawText( m_text
, cell
.x
, cell
.y
);
330 wxSize
wxDataViewTextRenderer::GetSize()
332 return wxSize(80,20);
335 // ---------------------------------------------------------
336 // wxDataViewBitmapRenderer
337 // ---------------------------------------------------------
339 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewCustomRenderer
)
341 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
342 wxDataViewCustomRenderer( varianttype
, mode
)
346 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
348 if (value
.GetType() == wxT("wxBitmap"))
350 if (value
.GetType() == wxT("wxIcon"))
356 bool wxDataViewBitmapRenderer::GetValue( wxVariant
& WXUNUSED(value
) )
361 bool wxDataViewBitmapRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
364 dc
->DrawBitmap( m_bitmap
, cell
.x
, cell
.y
);
365 else if (m_icon
.Ok())
366 dc
->DrawIcon( m_icon
, cell
.x
, cell
.y
);
371 wxSize
wxDataViewBitmapRenderer::GetSize()
374 return wxSize( m_bitmap
.GetWidth(), m_bitmap
.GetHeight() );
375 else if (m_icon
.Ok())
376 return wxSize( m_icon
.GetWidth(), m_icon
.GetHeight() );
378 return wxSize(16,16);
381 // ---------------------------------------------------------
382 // wxDataViewToggleRenderer
383 // ---------------------------------------------------------
385 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
, wxDataViewCustomRenderer
)
387 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
388 wxDataViewCellMode mode
) :
389 wxDataViewCustomRenderer( varianttype
, mode
)
394 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
396 m_toggle
= value
.GetBool();
401 bool wxDataViewToggleRenderer::GetValue( wxVariant
&WXUNUSED(value
) )
406 bool wxDataViewToggleRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
408 // User wxRenderer here
411 rect
.x
= cell
.x
+ cell
.width
/2 - 10;
413 rect
.y
= cell
.y
+ cell
.height
/2 - 10;
418 flags
|= wxCONTROL_CHECKED
;
419 if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE
)
420 flags
|= wxCONTROL_DISABLED
;
422 wxRendererNative::Get().DrawCheckBox(
423 GetOwner()->GetOwner(),
431 bool wxDataViewToggleRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
433 bool value
= !m_toggle
;
434 wxVariant variant
= value
;
435 model
->SetValue( variant
, col
, row
);
436 model
->ValueChanged( col
, row
);
440 wxSize
wxDataViewToggleRenderer::GetSize()
442 return wxSize(20,20);
445 // ---------------------------------------------------------
446 // wxDataViewProgressRenderer
447 // ---------------------------------------------------------
449 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
451 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
452 const wxString
&varianttype
, wxDataViewCellMode mode
) :
453 wxDataViewCustomRenderer( varianttype
, mode
)
459 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
463 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
465 m_value
= (long) value
;
467 if (m_value
< 0) m_value
= 0;
468 if (m_value
> 100) m_value
= 100;
473 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
475 double pct
= (double)m_value
/ 100.0;
477 bar
.width
= (int)(cell
.width
* pct
);
478 dc
->SetPen( *wxTRANSPARENT_PEN
);
479 dc
->SetBrush( *wxBLUE_BRUSH
);
480 dc
->DrawRectangle( bar
);
482 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
483 dc
->SetPen( *wxBLACK_PEN
);
484 dc
->DrawRectangle( cell
);
489 wxSize
wxDataViewProgressRenderer::GetSize()
491 return wxSize(40,12);
494 // ---------------------------------------------------------
495 // wxDataViewDateRenderer
496 // ---------------------------------------------------------
498 #if wxUSE_CALENDARCTRL
500 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
503 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
504 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
) :
505 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
)
510 m_cal
= new wxCalendarCtrl( this, wxID_ANY
, *value
);
511 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
512 sizer
->Add( m_cal
, 1, wxGROW
);
517 void OnCalendar( wxCalendarEvent
&event
);
519 wxCalendarCtrl
*m_cal
;
520 wxDataViewListModel
*m_model
;
525 virtual void OnDismiss()
530 DECLARE_EVENT_TABLE()
533 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
534 EVT_CALENDAR( wxID_ANY
, wxDataViewDateRendererPopupTransient::OnCalendar
)
537 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
539 wxDateTime date
= event
.GetDate();
540 wxVariant value
= date
;
541 m_model
->SetValue( value
, m_col
, m_row
);
542 m_model
->ValueChanged( m_col
, m_row
);
546 #endif // wxUSE_CALENDARCTRL
548 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
550 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
551 wxDataViewCellMode mode
) :
552 wxDataViewCustomRenderer( varianttype
, mode
)
556 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
558 m_date
= value
.GetDateTime();
563 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
565 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
566 wxString tmp
= m_date
.FormatDate();
567 dc
->DrawText( tmp
, cell
.x
, cell
.y
);
572 wxSize
wxDataViewDateRenderer::GetSize()
574 wxDataViewCtrl
* view
= GetOwner()->GetOwner();
575 wxString tmp
= m_date
.FormatDate();
577 view
->GetTextExtent( tmp
, &x
, &y
, &d
);
578 return wxSize(x
,y
+d
);
581 bool wxDataViewDateRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
584 model
->GetValue( variant
, col
, row
);
585 wxDateTime value
= variant
.GetDateTime();
587 #if wxUSE_CALENDARCTRL
588 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
589 GetOwner()->GetOwner()->GetParent(), &value
, model
, col
, row
);
590 wxPoint pos
= wxGetMousePosition();
593 popup
->Popup( popup
->m_cal
);
595 wxMessageBox(value
.Format());
600 // ---------------------------------------------------------
602 // ---------------------------------------------------------
604 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
606 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
, unsigned int model_column
,
607 int width
, int flags
) :
608 wxDataViewColumnBase( title
, cell
, model_column
, width
, flags
)
615 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
,
616 int width
, int flags
) :
617 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, flags
)
624 void wxDataViewColumn::SetAlignment( wxAlignment
WXUNUSED(align
) )
629 void wxDataViewColumn::SetSortable( bool WXUNUSED(sortable
) )
634 bool wxDataViewColumn::GetSortable()
640 void wxDataViewColumn::SetSortOrder( bool WXUNUSED(ascending
) )
645 bool wxDataViewColumn::IsSortOrderAscending()
652 wxDataViewColumn::~wxDataViewColumn()
656 void wxDataViewColumn::SetTitle( const wxString
&title
)
658 wxDataViewColumnBase::SetTitle( title
);
662 void wxDataViewColumn::SetBitmap( const wxBitmap
&bitmap
)
664 wxDataViewColumnBase::SetBitmap( bitmap
);
668 int wxDataViewColumn::GetWidth()
673 //-----------------------------------------------------------------------------
674 // wxDataViewHeaderWindow
675 //-----------------------------------------------------------------------------
677 IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindow
, wxWindow
)
679 BEGIN_EVENT_TABLE(wxDataViewHeaderWindow
,wxWindow
)
680 EVT_PAINT (wxDataViewHeaderWindow::OnPaint
)
681 EVT_MOUSE_EVENTS (wxDataViewHeaderWindow::OnMouse
)
682 EVT_SET_FOCUS (wxDataViewHeaderWindow::OnSetFocus
)
685 wxDataViewHeaderWindow::wxDataViewHeaderWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
686 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
687 wxWindow( parent
, id
, pos
, size
, 0, name
)
691 m_resizeCursor
= new wxCursor( wxCURSOR_SIZEWE
);
693 wxVisualAttributes attr
= wxPanel::GetClassDefaultAttributes();
694 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
695 SetOwnForegroundColour( attr
.colFg
);
696 SetOwnBackgroundColour( attr
.colBg
);
698 SetOwnFont( attr
.font
);
701 wxDataViewHeaderWindow::~wxDataViewHeaderWindow()
703 delete m_resizeCursor
;
706 void wxDataViewHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
709 GetClientSize( &w
, &h
);
711 wxAutoBufferedPaintDC
dc( this );
713 dc
.SetBackground(GetBackgroundColour());
717 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
720 m_owner
->GetViewStart( &x
, NULL
);
722 // account for the horz scrollbar offset
723 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
725 dc
.SetFont( GetFont() );
727 unsigned int cols
= GetOwner()->GetNumberOfColumns();
730 for (i
= 0; i
< cols
; i
++)
732 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
733 int width
= col
->GetWidth();
738 wxRendererNative::Get().DrawHeaderButton
742 wxRect(xpos
, 0, cw
, ch
-1),
743 m_parent
->IsEnabled() ? 0
744 : (int)wxCONTROL_DISABLED
747 dc
.DrawText( col
->GetTitle(), xpos
+3, 3 );
753 void wxDataViewHeaderWindow::OnMouse( wxMouseEvent
&WXUNUSED(event
) )
757 void wxDataViewHeaderWindow::OnSetFocus( wxFocusEvent
&event
)
759 GetParent()->SetFocus();
763 //-----------------------------------------------------------------------------
764 // wxDataViewRenameTimer
765 //-----------------------------------------------------------------------------
767 wxDataViewRenameTimer::wxDataViewRenameTimer( wxDataViewMainWindow
*owner
)
772 void wxDataViewRenameTimer::Notify()
774 m_owner
->OnRenameTimer();
777 //-----------------------------------------------------------------------------
778 // wxDataViewTextCtrlWrapper: wraps a wxTextCtrl for inline editing
779 //-----------------------------------------------------------------------------
781 BEGIN_EVENT_TABLE(wxDataViewTextCtrlWrapper
, wxEvtHandler
)
782 EVT_CHAR (wxDataViewTextCtrlWrapper::OnChar
)
783 EVT_KEY_UP (wxDataViewTextCtrlWrapper::OnKeyUp
)
784 EVT_KILL_FOCUS (wxDataViewTextCtrlWrapper::OnKillFocus
)
787 wxDataViewTextCtrlWrapper::wxDataViewTextCtrlWrapper(
788 wxDataViewMainWindow
*owner
,
790 wxDataViewListModel
*model
,
791 unsigned int col
, unsigned int row
,
801 m_aboutToFinish
= false;
804 model
->GetValue( value
, col
, row
);
805 m_startValue
= value
.GetString();
807 m_owner
->GetOwner()->CalcScrolledPosition(
808 rectLabel
.x
, rectLabel
.y
, &rectLabel
.x
, &rectLabel
.y
);
810 m_text
->Create( owner
, wxID_ANY
, m_startValue
,
811 wxPoint(rectLabel
.x
-2,rectLabel
.y
-2),
812 wxSize(rectLabel
.width
+7,rectLabel
.height
+4) );
815 m_text
->PushEventHandler(this);
818 void wxDataViewTextCtrlWrapper::AcceptChangesAndFinish()
820 m_aboutToFinish
= true;
822 // Notify the owner about the changes
825 // Even if vetoed, close the control (consistent with MSW)
829 void wxDataViewTextCtrlWrapper::OnChar( wxKeyEvent
&event
)
831 switch ( event
.m_keyCode
)
834 AcceptChangesAndFinish();
838 // m_owner->OnRenameCancelled( m_itemEdited );
847 void wxDataViewTextCtrlWrapper::OnKeyUp( wxKeyEvent
&event
)
855 // auto-grow the textctrl
856 wxSize parentSize
= m_owner
->GetSize();
857 wxPoint myPos
= m_text
->GetPosition();
858 wxSize mySize
= m_text
->GetSize();
860 m_text
->GetTextExtent(m_text
->GetValue() + _T("MM"), &sx
, &sy
);
861 if (myPos
.x
+ sx
> parentSize
.x
)
862 sx
= parentSize
.x
- myPos
.x
;
865 m_text
->SetSize(sx
, wxDefaultCoord
);
870 void wxDataViewTextCtrlWrapper::OnKillFocus( wxFocusEvent
&event
)
872 if ( !m_finished
&& !m_aboutToFinish
)
875 //if ( !AcceptChanges() )
876 // m_owner->OnRenameCancelled( m_itemEdited );
881 // We must let the native text control handle focus
885 bool wxDataViewTextCtrlWrapper::AcceptChanges()
887 const wxString value
= m_text
->GetValue();
889 if ( value
== m_startValue
)
890 // nothing changed, always accept
893 // if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
894 // vetoed by the user
897 // accepted, do rename the item
900 m_model
->SetValue( variant
, m_col
, m_row
);
901 m_model
->ValueChanged( m_col
, m_row
);
906 void wxDataViewTextCtrlWrapper::Finish()
912 m_text
->RemoveEventHandler(this);
913 m_owner
->FinishEditing(m_text
);
916 wxPendingDelete
.Append( this );
920 //-----------------------------------------------------------------------------
921 // wxDataViewMainWindow
922 //-----------------------------------------------------------------------------
924 int LINKAGEMODE
wxDataViewSelectionCmp( unsigned int row1
, unsigned int row2
)
926 if (row1
> row2
) return 1;
927 if (row1
== row2
) return 0;
932 IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow
, wxWindow
)
934 BEGIN_EVENT_TABLE(wxDataViewMainWindow
,wxWindow
)
935 EVT_PAINT (wxDataViewMainWindow::OnPaint
)
936 EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse
)
937 EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus
)
938 EVT_KILL_FOCUS (wxDataViewMainWindow::OnKillFocus
)
939 EVT_CHAR (wxDataViewMainWindow::OnChar
)
942 wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
943 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
944 wxWindow( parent
, id
, pos
, size
, wxWANTS_CHARS
, name
),
945 m_selection( wxDataViewSelectionCmp
)
950 m_lastOnSame
= false;
951 m_renameTimer
= new wxDataViewRenameTimer( this );
952 m_textctrlWrapper
= NULL
;
954 // TODO: user better initial values/nothing selected
958 // TODO: we need to calculate this smartly
962 m_dragStart
= wxPoint(0,0);
963 m_lineLastClicked
= (unsigned int) -1;
964 m_lineBeforeLastClicked
= (unsigned int) -1;
965 m_lineSelectSingleOnUp
= (unsigned int) -1;
969 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
970 SetBackgroundColour( *wxWHITE
);
975 wxDataViewMainWindow::~wxDataViewMainWindow()
977 delete m_renameTimer
;
980 void wxDataViewMainWindow::OnRenameTimer()
982 // We have to call this here because changes may just have
983 // been made and no screen update taken place.
989 unsigned int cols
= GetOwner()->GetNumberOfColumns();
991 for (i
= 0; i
< cols
; i
++)
993 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
994 if (c
== m_currentCol
)
996 xpos
+= c
->GetWidth();
998 wxRect
labelRect( xpos
, m_currentRow
* m_lineHeight
, m_currentCol
->GetWidth(), m_lineHeight
);
1000 wxClassInfo
*textControlClass
= CLASSINFO(wxTextCtrl
);
1002 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
1003 m_textctrlWrapper
= new wxDataViewTextCtrlWrapper(this, text
, GetOwner()->GetModel(),
1004 m_currentCol
->GetModelColumn(), m_currentRow
, labelRect
);
1007 void wxDataViewMainWindow::FinishEditing( wxTextCtrl
*text
)
1010 m_textctrlWrapper
= NULL
;
1012 // SetFocusIgnoringChildren();
1015 bool wxDataViewMainWindow::RowAppended()
1020 bool wxDataViewMainWindow::RowPrepended()
1025 bool wxDataViewMainWindow::RowInserted( unsigned int WXUNUSED(before
) )
1030 bool wxDataViewMainWindow::RowDeleted( unsigned int WXUNUSED(row
) )
1035 bool wxDataViewMainWindow::RowChanged( unsigned int WXUNUSED(row
) )
1040 bool wxDataViewMainWindow::ValueChanged( unsigned int WXUNUSED(col
), unsigned int row
)
1042 wxRect
rect( 0, row
*m_lineHeight
, 10000, m_lineHeight
);
1043 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1044 Refresh( true, &rect
);
1049 bool wxDataViewMainWindow::RowsReordered( unsigned int *WXUNUSED(new_order
) )
1056 bool wxDataViewMainWindow::Cleared()
1061 void wxDataViewMainWindow::UpdateDisplay()
1066 void wxDataViewMainWindow::OnInternalIdle()
1068 wxWindow::OnInternalIdle();
1072 RecalculateDisplay();
1077 void wxDataViewMainWindow::RecalculateDisplay()
1079 wxDataViewListModel
*model
= GetOwner()->GetModel();
1087 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1089 for (i
= 0; i
< cols
; i
++)
1091 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
1092 width
+= col
->GetWidth();
1095 int height
= model
->GetNumberOfRows() * m_lineHeight
;
1097 SetVirtualSize( width
, height
);
1098 GetOwner()->SetScrollRate( 10, m_lineHeight
);
1103 void wxDataViewMainWindow::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
1105 wxWindow::ScrollWindow( dx
, dy
, rect
);
1106 GetOwner()->m_headerArea
->ScrollWindow( dx
, 0 );
1109 void wxDataViewMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1111 wxAutoBufferedPaintDC
dc( this );
1113 dc
.SetBackground(GetBackgroundColour());
1116 GetOwner()->PrepareDC( dc
);
1118 dc
.SetFont( GetFont() );
1120 wxRect update
= GetUpdateRegion().GetBox();
1121 m_owner
->CalcUnscrolledPosition( update
.x
, update
.y
, &update
.x
, &update
.y
);
1123 wxDataViewListModel
*model
= GetOwner()->GetModel();
1125 unsigned int item_start
= wxMax( 0, (update
.y
/ m_lineHeight
) );
1126 unsigned int item_count
= wxMin( (int)(((update
.y
+ update
.height
) / m_lineHeight
) - item_start
+ 1),
1127 (int)(model
->GetNumberOfRows()-item_start
) );
1132 for (item
= item_start
; item
< item_start
+item_count
; item
++)
1134 if (m_selection
.Index( item
) != wxNOT_FOUND
)
1136 int flags
= wxCONTROL_SELECTED
;
1137 if (item
== m_currentRow
)
1138 flags
|= wxCONTROL_CURRENT
;
1140 flags
|= wxCONTROL_FOCUSED
;
1141 wxRect
rect( 0, item
*m_lineHeight
+1, GetEndOfLastCol(), m_lineHeight
-2 );
1142 wxRendererNative::Get().DrawItemSelectionRect
1152 if (item
== m_currentRow
)
1154 int flags
= wxCONTROL_CURRENT
;
1156 flags
|= wxCONTROL_FOCUSED
; // should have no effect
1157 wxRect
rect( 0, item
*m_lineHeight
+1, GetEndOfLastCol(), m_lineHeight
-2 );
1158 wxRendererNative::Get().DrawItemSelectionRect
1172 cell_rect
.height
= m_lineHeight
;
1173 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1175 for (i
= 0; i
< cols
; i
++)
1177 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
1178 wxDataViewRenderer
*cell
= col
->GetRenderer();
1179 cell_rect
.width
= col
->GetWidth();
1181 for (item
= item_start
; item
< item_start
+item_count
; item
++)
1183 cell_rect
.y
= item
*m_lineHeight
;
1185 model
->GetValue( value
, col
->GetModelColumn(), item
);
1186 cell
->SetValue( value
);
1187 wxSize size
= cell
->GetSize();
1188 // cannot be bigger than allocated space
1189 size
.x
= wxMin( size
.x
, cell_rect
.width
);
1190 size
.y
= wxMin( size
.y
, cell_rect
.height
);
1191 // TODO: check for left/right/centre alignment here
1194 item_rect
.x
= cell_rect
.x
+ (cell_rect
.width
/ 2) - (size
.x
/ 2);
1195 item_rect
.y
= cell_rect
.y
+ (cell_rect
.height
/ 2) - (size
.y
/ 2);
1197 item_rect
.width
= size
.x
;
1198 item_rect
.height
= size
.y
;
1201 if (item
== m_currentRow
)
1202 state
|= wxDATAVIEW_CELL_SELECTED
;
1203 cell
->Render( item_rect
, &dc
, state
);
1206 cell_rect
.x
+= cell_rect
.width
;
1210 int wxDataViewMainWindow::GetCountPerPage()
1212 wxSize size
= GetClientSize();
1213 return size
.y
/ m_lineHeight
;
1216 int wxDataViewMainWindow::GetEndOfLastCol()
1220 for (i
= 0; i
< GetOwner()->GetNumberOfColumns(); i
++)
1222 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1223 width
+= c
->GetWidth();
1228 unsigned int wxDataViewMainWindow::GetFirstVisibleRow()
1232 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
1234 return y
/ m_lineHeight
;
1237 unsigned int wxDataViewMainWindow::GetLastVisibleRow()
1239 wxSize client_size
= GetClientSize();
1240 m_owner
->CalcUnscrolledPosition( client_size
.x
, client_size
.y
, &client_size
.x
, &client_size
.y
);
1242 return wxMin( GetRowCount()-1, ((unsigned)client_size
.y
/m_lineHeight
)+1 );
1245 unsigned int wxDataViewMainWindow::GetRowCount()
1247 return GetOwner()->GetModel()->GetNumberOfRows();
1250 void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row
)
1257 void wxDataViewMainWindow::SelectAllRows( bool on
)
1264 m_selection
.Clear();
1265 for (unsigned int i
= 0; i
< GetRowCount(); i
++)
1266 m_selection
.Add( i
);
1271 unsigned int first_visible
= GetFirstVisibleRow();
1272 unsigned int last_visible
= GetLastVisibleRow();
1274 for (i
= 0; i
< m_selection
.GetCount(); i
++)
1276 unsigned int row
= m_selection
[i
];
1277 if ((row
>= first_visible
) && (row
<= last_visible
))
1280 m_selection
.Clear();
1284 void wxDataViewMainWindow::SelectRow( unsigned int row
, bool on
)
1286 if (m_selection
.Index( row
) == wxNOT_FOUND
)
1290 m_selection
.Add( row
);
1298 m_selection
.Remove( row
);
1304 void wxDataViewMainWindow::SelectRows( unsigned int from
, unsigned int to
, bool on
)
1308 unsigned int tmp
= from
;
1314 for (i
= from
; i
<= to
; i
++)
1316 if (m_selection
.Index( i
) == wxNOT_FOUND
)
1319 m_selection
.Add( i
);
1324 m_selection
.Remove( i
);
1327 RefreshRows( from
, to
);
1330 void wxDataViewMainWindow::ReverseRowSelection( unsigned int row
)
1332 if (m_selection
.Index( row
) == wxNOT_FOUND
)
1333 m_selection
.Add( row
);
1335 m_selection
.Remove( row
);
1339 bool wxDataViewMainWindow::IsRowSelected( unsigned int row
)
1341 return (m_selection
.Index( row
) != wxNOT_FOUND
);
1344 void wxDataViewMainWindow::RefreshRow( unsigned int row
)
1346 wxRect
rect( 0, row
*m_lineHeight
, GetEndOfLastCol(), m_lineHeight
);
1347 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1349 wxSize client_size
= GetClientSize();
1350 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1351 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1352 if (intersect_rect
.width
> 0)
1353 Refresh( true, &intersect_rect
);
1356 void wxDataViewMainWindow::RefreshRows( unsigned int from
, unsigned int to
)
1360 unsigned int tmp
= to
;
1365 wxRect
rect( 0, from
*m_lineHeight
, GetEndOfLastCol(), (to
-from
+1) * m_lineHeight
);
1366 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1368 wxSize client_size
= GetClientSize();
1369 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1370 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1371 if (intersect_rect
.width
> 0)
1372 Refresh( true, &intersect_rect
);
1375 void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow
)
1377 unsigned int count
= GetRowCount();
1378 if (firstRow
> count
)
1381 wxRect
rect( 0, firstRow
*m_lineHeight
, GetEndOfLastCol(), count
* m_lineHeight
);
1382 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1384 wxSize client_size
= GetClientSize();
1385 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1386 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1387 if (intersect_rect
.width
> 0)
1388 Refresh( true, &intersect_rect
);
1391 void wxDataViewMainWindow::OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
)
1393 wxCHECK_RET( newCurrent
< GetRowCount(),
1394 _T("invalid item index in OnArrowChar()") );
1396 // if there is no selection, we cannot move it anywhere
1397 if (!HasCurrentRow())
1400 unsigned int oldCurrent
= m_currentRow
;
1402 // in single selection we just ignore Shift as we can't select several
1404 if ( event
.ShiftDown() && !IsSingleSel() )
1406 RefreshRow( oldCurrent
);
1408 ChangeCurrentRow( newCurrent
);
1410 // select all the items between the old and the new one
1411 if ( oldCurrent
> newCurrent
)
1413 newCurrent
= oldCurrent
;
1414 oldCurrent
= m_currentRow
;
1417 SelectRows( oldCurrent
, newCurrent
, true );
1421 RefreshRow( oldCurrent
);
1423 // all previously selected items are unselected unless ctrl is held
1424 if ( !event
.ControlDown() )
1425 SelectAllRows(false);
1427 ChangeCurrentRow( newCurrent
);
1429 if ( !event
.ControlDown() )
1430 SelectRow( m_currentRow
, true );
1432 RefreshRow( m_currentRow
);
1438 void wxDataViewMainWindow::OnChar( wxKeyEvent
&event
)
1440 if (event
.GetKeyCode() == WXK_TAB
)
1442 wxNavigationKeyEvent nevent
;
1443 nevent
.SetWindowChange( event
.ControlDown() );
1444 nevent
.SetDirection( !event
.ShiftDown() );
1445 nevent
.SetEventObject( GetParent()->GetParent() );
1446 nevent
.SetCurrentFocus( m_parent
);
1447 if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent
))
1451 // no item -> nothing to do
1452 if (!HasCurrentRow())
1458 // don't use m_linesPerPage directly as it might not be computed yet
1459 const int pageSize
= GetCountPerPage();
1460 wxCHECK_RET( pageSize
, _T("should have non zero page size") );
1462 switch ( event
.GetKeyCode() )
1465 if ( m_currentRow
> 0 )
1466 OnArrowChar( m_currentRow
- 1, event
);
1470 if ( m_currentRow
< GetRowCount() - 1 )
1471 OnArrowChar( m_currentRow
+ 1, event
);
1476 OnArrowChar( GetRowCount() - 1, event
);
1481 OnArrowChar( 0, event
);
1486 int steps
= pageSize
- 1;
1487 int index
= m_currentRow
- steps
;
1491 OnArrowChar( index
, event
);
1497 int steps
= pageSize
- 1;
1498 unsigned int index
= m_currentRow
+ steps
;
1499 unsigned int count
= GetRowCount();
1500 if ( index
>= count
)
1503 OnArrowChar( index
, event
);
1512 void wxDataViewMainWindow::OnMouse( wxMouseEvent
&event
)
1514 if (event
.GetEventType() == wxEVT_MOUSEWHEEL
)
1516 // let the base handle mouse wheel events.
1521 int x
= event
.GetX();
1522 int y
= event
.GetY();
1523 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
1525 wxDataViewColumn
*col
= NULL
;
1528 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1530 for (i
= 0; i
< cols
; i
++)
1532 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1533 if (x
< xpos
+ c
->GetWidth())
1538 xpos
+= c
->GetWidth();
1542 wxDataViewRenderer
*cell
= col
->GetRenderer();
1544 unsigned int current
= y
/ m_lineHeight
;
1546 if ((current
> GetRowCount()) || (x
> GetEndOfLastCol()))
1548 // Unselect all if below the last row ?
1552 wxDataViewListModel
*model
= GetOwner()->GetModel();
1554 if (event
.Dragging())
1556 if (m_dragCount
== 0)
1558 // we have to report the raw, physical coords as we want to be
1559 // able to call HitTest(event.m_pointDrag) from the user code to
1560 // get the item being dragged
1561 m_dragStart
= event
.GetPosition();
1566 if (m_dragCount
!= 3)
1569 if (event
.LeftIsDown())
1571 // Notify cell about drag
1580 bool forceClick
= false;
1582 if (event
.ButtonDClick())
1584 m_renameTimer
->Stop();
1585 m_lastOnSame
= false;
1588 if (event
.LeftDClick())
1590 if ( current
== m_lineLastClicked
)
1592 if (cell
->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE
)
1595 model
->GetValue( value
, col
->GetModelColumn(), current
);
1596 cell
->SetValue( value
);
1597 wxRect
cell_rect( xpos
, current
* m_lineHeight
, col
->GetWidth(), m_lineHeight
);
1598 cell
->Activate( cell_rect
, model
, col
->GetModelColumn(), current
);
1604 // The first click was on another item, so don't interpret this as
1605 // a double click, but as a simple click instead
1612 if (m_lineSelectSingleOnUp
!= (unsigned int)-1)
1614 // select single line
1615 SelectAllRows( false );
1616 SelectRow( m_lineSelectSingleOnUp
, true );
1621 if ((col
== m_currentCol
) && (current
== m_currentRow
) &&
1622 (cell
->GetMode() == wxDATAVIEW_CELL_EDITABLE
) )
1624 m_renameTimer
->Start( 100, true );
1628 m_lastOnSame
= false;
1629 m_lineSelectSingleOnUp
= (unsigned int)-1;
1633 // This is necessary, because after a DnD operation in
1634 // from and to ourself, the up event is swallowed by the
1635 // DnD code. So on next non-up event (which means here and
1636 // now) m_lineSelectSingleOnUp should be reset.
1637 m_lineSelectSingleOnUp
= (unsigned int)-1;
1640 if (event
.RightDown())
1642 m_lineBeforeLastClicked
= m_lineLastClicked
;
1643 m_lineLastClicked
= current
;
1645 // If the item is already selected, do not update the selection.
1646 // Multi-selections should not be cleared if a selected item is clicked.
1647 if (!IsRowSelected(current
))
1649 SelectAllRows(false);
1650 ChangeCurrentRow(current
);
1651 SelectRow(m_currentRow
,true);
1654 // notify cell about right click
1657 // Allow generation of context menu event
1660 else if (event
.MiddleDown())
1662 // notify cell about middle click
1665 if (event
.LeftDown() || forceClick
)
1671 m_lineBeforeLastClicked
= m_lineLastClicked
;
1672 m_lineLastClicked
= current
;
1674 unsigned int oldCurrentRow
= m_currentRow
;
1675 bool oldWasSelected
= IsRowSelected(m_currentRow
);
1677 bool cmdModifierDown
= event
.CmdDown();
1678 if ( IsSingleSel() || !(cmdModifierDown
|| event
.ShiftDown()) )
1680 if ( IsSingleSel() || !IsRowSelected(current
) )
1682 SelectAllRows( false );
1684 ChangeCurrentRow(current
);
1686 SelectRow(m_currentRow
,true);
1688 else // multi sel & current is highlighted & no mod keys
1690 m_lineSelectSingleOnUp
= current
;
1691 ChangeCurrentRow(current
); // change focus
1694 else // multi sel & either ctrl or shift is down
1696 if (cmdModifierDown
)
1698 ChangeCurrentRow(current
);
1700 ReverseRowSelection(m_currentRow
);
1702 else if (event
.ShiftDown())
1704 ChangeCurrentRow(current
);
1706 unsigned int lineFrom
= oldCurrentRow
,
1709 if ( lineTo
< lineFrom
)
1712 lineFrom
= m_currentRow
;
1715 SelectRows(lineFrom
, lineTo
, true);
1717 else // !ctrl, !shift
1719 // test in the enclosing if should make it impossible
1720 wxFAIL_MSG( _T("how did we get here?") );
1724 if (m_currentRow
!= oldCurrentRow
)
1725 RefreshRow( oldCurrentRow
);
1727 wxDataViewColumn
*oldCurrentCol
= m_currentCol
;
1729 // Update selection here...
1732 m_lastOnSame
= !forceClick
&& ((col
== oldCurrentCol
) && (current
== oldCurrentRow
)) && oldWasSelected
;
1736 void wxDataViewMainWindow::OnSetFocus( wxFocusEvent
&event
)
1740 if (HasCurrentRow())
1746 void wxDataViewMainWindow::OnKillFocus( wxFocusEvent
&event
)
1750 if (HasCurrentRow())
1756 //-----------------------------------------------------------------------------
1758 //-----------------------------------------------------------------------------
1760 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
1762 BEGIN_EVENT_TABLE(wxDataViewCtrl
, wxDataViewCtrlBase
)
1763 EVT_SIZE(wxDataViewCtrl::OnSize
)
1766 wxDataViewCtrl::~wxDataViewCtrl()
1769 GetModel()->RemoveNotifier( m_notifier
);
1772 void wxDataViewCtrl::Init()
1777 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
1778 const wxPoint
& pos
, const wxSize
& size
,
1779 long style
, const wxValidator
& validator
)
1781 if (!wxControl::Create( parent
, id
, pos
, size
, style
| wxScrolledWindowStyle
|wxSUNKEN_BORDER
, validator
))
1787 MacSetClipChildren( true ) ;
1790 m_clientArea
= new wxDataViewMainWindow( this, wxID_ANY
);
1792 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
, wxDefaultPosition
, wxSize(wxDefaultCoord
,22) );
1794 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
, wxDefaultPosition
, wxSize(wxDefaultCoord
,25) );
1797 SetTargetWindow( m_clientArea
);
1799 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
1800 sizer
->Add( m_headerArea
, 0, wxGROW
);
1801 sizer
->Add( m_clientArea
, 1, wxGROW
);
1808 WXLRESULT
wxDataViewCtrl::MSWWindowProc(WXUINT nMsg
,
1812 WXLRESULT rc
= wxDataViewCtrlBase::MSWWindowProc(nMsg
, wParam
, lParam
);
1815 // we need to process arrows ourselves for scrolling
1816 if ( nMsg
== WM_GETDLGCODE
)
1818 rc
|= DLGC_WANTARROWS
;
1826 void wxDataViewCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1828 // We need to override OnSize so that our scrolled
1829 // window a) does call Layout() to use sizers for
1830 // positioning the controls but b) does not query
1831 // the sizer for their size and use that for setting
1832 // the scrollable area as set that ourselves by
1833 // calling SetScrollbar() further down.
1840 bool wxDataViewCtrl::AssociateModel( wxDataViewListModel
*model
)
1842 if (!wxDataViewCtrlBase::AssociateModel( model
))
1845 m_notifier
= new wxGenericDataViewListModelNotifier( m_clientArea
);
1847 model
->AddNotifier( m_notifier
);
1849 m_clientArea
->UpdateDisplay();
1854 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
1856 if (!wxDataViewCtrlBase::AppendColumn(col
))
1859 m_clientArea
->UpdateDisplay();
1864 void wxDataViewCtrl::SetSelection( int WXUNUSED(row
) )
1869 void wxDataViewCtrl::SetSelectionRange( unsigned int WXUNUSED(from
), unsigned int WXUNUSED(to
) )
1874 void wxDataViewCtrl::SetSelections( const wxArrayInt
& WXUNUSED(aSelections
) )
1879 void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row
) )
1884 bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row
) ) const
1891 int wxDataViewCtrl::GetSelection() const
1898 int wxDataViewCtrl::GetSelections(wxArrayInt
& WXUNUSED(aSelections
) ) const
1906 // !wxUSE_GENERICDATAVIEWCTRL
1909 // wxUSE_DATAVIEWCTRL