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"
34 #include "wx/stockitem.h"
35 #include "wx/calctrl.h"
36 #include "wx/popupwin.h"
37 #include "wx/renderer.h"
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
47 // wxDataViewHeaderWindow
48 //-----------------------------------------------------------------------------
50 class wxDataViewHeaderWindow
: public wxWindow
53 wxDataViewHeaderWindow( wxDataViewCtrl
*parent
,
55 const wxPoint
&pos
= wxDefaultPosition
,
56 const wxSize
&size
= wxDefaultSize
,
57 const wxString
&name
= wxT("wxdataviewctrlheaderwindow") );
58 virtual ~wxDataViewHeaderWindow();
60 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
61 wxDataViewCtrl
*GetOwner() { return m_owner
; }
63 void OnPaint( wxPaintEvent
&event
);
64 void OnMouse( wxMouseEvent
&event
);
65 void OnSetFocus( wxFocusEvent
&event
);
68 wxDataViewCtrl
*m_owner
;
69 wxCursor
*m_resizeCursor
;
72 DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindow
)
76 //-----------------------------------------------------------------------------
77 // wxDataViewRenameTimer
78 //-----------------------------------------------------------------------------
80 class wxDataViewRenameTimer
: public wxTimer
83 wxDataViewMainWindow
*m_owner
;
86 wxDataViewRenameTimer( wxDataViewMainWindow
*owner
);
90 //-----------------------------------------------------------------------------
91 // wxDataViewTextCtrlWrapper: wraps a wxTextCtrl for inline editing
92 //-----------------------------------------------------------------------------
94 class wxDataViewTextCtrlWrapper
: public wxEvtHandler
97 // NB: text must be a valid object but not Create()d yet
98 wxDataViewTextCtrlWrapper( wxDataViewMainWindow
*owner
,
100 wxDataViewListModel
*model
,
101 unsigned int col
, unsigned int row
,
104 wxTextCtrl
*GetText() const { return m_text
; }
106 void AcceptChangesAndFinish();
109 void OnChar( wxKeyEvent
&event
);
110 void OnKeyUp( wxKeyEvent
&event
);
111 void OnKillFocus( wxFocusEvent
&event
);
113 bool AcceptChanges();
117 wxDataViewMainWindow
*m_owner
;
119 wxString m_startValue
;
120 wxDataViewListModel
*m_model
;
124 bool m_aboutToFinish
;
126 DECLARE_EVENT_TABLE()
129 //-----------------------------------------------------------------------------
130 // wxDataViewMainWindow
131 //-----------------------------------------------------------------------------
133 WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection
, WXDLLIMPEXP_ADV
);
135 class wxDataViewMainWindow
: public wxWindow
138 wxDataViewMainWindow( wxDataViewCtrl
*parent
,
140 const wxPoint
&pos
= wxDefaultPosition
,
141 const wxSize
&size
= wxDefaultSize
,
142 const wxString
&name
= wxT("wxdataviewctrlmainwindow") );
143 virtual ~wxDataViewMainWindow();
145 // notifications from wxDataViewListModel
148 bool RowInserted( unsigned int before
);
149 bool RowDeleted( unsigned int row
);
150 bool RowChanged( unsigned int row
);
151 bool ValueChanged( unsigned int col
, unsigned int row
);
152 bool RowsReordered( unsigned int *new_order
);
155 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
156 wxDataViewCtrl
*GetOwner() { return m_owner
; }
158 void OnPaint( wxPaintEvent
&event
);
159 void OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
);
160 void OnChar( wxKeyEvent
&event
);
161 void OnMouse( wxMouseEvent
&event
);
162 void OnSetFocus( wxFocusEvent
&event
);
163 void OnKillFocus( wxFocusEvent
&event
);
165 void UpdateDisplay();
166 void RecalculateDisplay();
167 void OnInternalIdle();
169 void OnRenameTimer();
170 void FinishEditing( wxTextCtrl
*text
);
172 void ScrollWindow( int dx
, int dy
, const wxRect
*rect
);
174 bool HasCurrentRow() { return m_currentRow
!= (unsigned int)-1; }
175 void ChangeCurrentRow( unsigned int row
);
177 bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE
); };
178 bool IsEmpty() { return GetRowCount() == 0; }
180 int GetCountPerPage();
181 int GetEndOfLastCol();
182 unsigned int GetFirstVisibleRow();
183 unsigned int GetLastVisibleRow();
184 unsigned int GetRowCount();
186 void SelectAllRows( bool on
);
187 void SelectRow( unsigned int row
, bool on
);
188 void SelectRows( unsigned int from
, unsigned int to
, bool on
);
189 void ReverseRowSelection( unsigned int row
);
190 bool IsRowSelected( unsigned int row
);
192 void RefreshRow( unsigned int row
);
193 void RefreshRows( unsigned int from
, unsigned int to
);
194 void RefreshRowsAfter( unsigned int firstRow
);
197 wxDataViewCtrl
*m_owner
;
201 wxDataViewColumn
*m_currentCol
;
202 unsigned int m_currentRow
;
203 wxDataViewSelection m_selection
;
205 wxDataViewRenameTimer
*m_renameTimer
;
206 wxDataViewTextCtrlWrapper
*m_textctrlWrapper
;
214 // for double click logic
215 unsigned int m_lineLastClicked
,
216 m_lineBeforeLastClicked
,
217 m_lineSelectSingleOnUp
;
220 DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow
)
221 DECLARE_EVENT_TABLE()
224 // ---------------------------------------------------------
225 // wxGenericDataViewListModelNotifier
226 // ---------------------------------------------------------
228 class wxGenericDataViewListModelNotifier
: public wxDataViewListModelNotifier
231 wxGenericDataViewListModelNotifier( wxDataViewMainWindow
*mainWindow
)
232 { m_mainWindow
= mainWindow
; }
234 virtual bool RowAppended()
235 { return m_mainWindow
->RowAppended(); }
236 virtual bool RowPrepended()
237 { return m_mainWindow
->RowPrepended(); }
238 virtual bool RowInserted( unsigned int before
)
239 { return m_mainWindow
->RowInserted( before
); }
240 virtual bool RowDeleted( unsigned int row
)
241 { return m_mainWindow
->RowDeleted( row
); }
242 virtual bool RowChanged( unsigned int row
)
243 { return m_mainWindow
->RowChanged( row
); }
244 virtual bool ValueChanged( unsigned int col
, unsigned int row
)
245 { return m_mainWindow
->ValueChanged( col
, row
); }
246 virtual bool RowsReordered( unsigned int *new_order
)
247 { return m_mainWindow
->RowsReordered( new_order
); }
248 virtual bool Cleared()
249 { return m_mainWindow
->Cleared(); }
251 wxDataViewMainWindow
*m_mainWindow
;
254 // ---------------------------------------------------------
255 // wxDataViewRenderer
256 // ---------------------------------------------------------
258 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
260 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
261 wxDataViewRendererBase( varianttype
, mode
)
266 wxDataViewRenderer::~wxDataViewRenderer()
272 wxDC
*wxDataViewRenderer::GetDC()
276 if (GetOwner() == NULL
)
278 if (GetOwner()->GetOwner() == NULL
)
280 m_dc
= new wxClientDC( GetOwner()->GetOwner() );
286 // ---------------------------------------------------------
287 // wxDataViewCustomRenderer
288 // ---------------------------------------------------------
290 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
292 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
293 wxDataViewCellMode mode
) :
294 wxDataViewRenderer( varianttype
, mode
)
298 // ---------------------------------------------------------
299 // wxDataViewTextRenderer
300 // ---------------------------------------------------------
302 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewCustomRenderer
)
304 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
305 wxDataViewCustomRenderer( varianttype
, mode
)
309 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
311 m_text
= value
.GetString();
316 bool wxDataViewTextRenderer::GetValue( wxVariant
& WXUNUSED(value
) )
321 bool wxDataViewTextRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
323 dc
->DrawText( m_text
, cell
.x
, cell
.y
);
328 wxSize
wxDataViewTextRenderer::GetSize()
330 return wxSize(80,20);
333 // ---------------------------------------------------------
334 // wxDataViewBitmapRenderer
335 // ---------------------------------------------------------
337 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewCustomRenderer
)
339 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
, wxDataViewCellMode mode
) :
340 wxDataViewCustomRenderer( varianttype
, mode
)
344 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
346 if (value
.GetType() == wxT("wxBitmap"))
348 if (value
.GetType() == wxT("wxIcon"))
354 bool wxDataViewBitmapRenderer::GetValue( wxVariant
& WXUNUSED(value
) )
359 bool wxDataViewBitmapRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
362 dc
->DrawBitmap( m_bitmap
, cell
.x
, cell
.y
);
363 else if (m_icon
.Ok())
364 dc
->DrawIcon( m_icon
, cell
.x
, cell
.y
);
369 wxSize
wxDataViewBitmapRenderer::GetSize()
372 return wxSize( m_bitmap
.GetWidth(), m_bitmap
.GetHeight() );
373 else if (m_icon
.Ok())
374 return wxSize( m_icon
.GetWidth(), m_icon
.GetHeight() );
376 return wxSize(16,16);
379 // ---------------------------------------------------------
380 // wxDataViewToggleRenderer
381 // ---------------------------------------------------------
383 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
, wxDataViewCustomRenderer
)
385 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
386 wxDataViewCellMode mode
) :
387 wxDataViewCustomRenderer( varianttype
, mode
)
392 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
394 m_toggle
= value
.GetBool();
399 bool wxDataViewToggleRenderer::GetValue( wxVariant
&WXUNUSED(value
) )
404 bool wxDataViewToggleRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
406 // User wxRenderer here
409 rect
.x
= cell
.x
+ cell
.width
/2 - 10;
411 rect
.y
= cell
.y
+ cell
.height
/2 - 10;
416 flags
|= wxCONTROL_CHECKED
;
417 if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE
)
418 flags
|= wxCONTROL_DISABLED
;
420 wxRendererNative::Get().DrawCheckBox(
421 GetOwner()->GetOwner(),
429 bool wxDataViewToggleRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
431 bool value
= !m_toggle
;
432 wxVariant variant
= value
;
433 model
->SetValue( variant
, col
, row
);
434 model
->ValueChanged( col
, row
);
438 wxSize
wxDataViewToggleRenderer::GetSize()
440 return wxSize(20,20);
443 // ---------------------------------------------------------
444 // wxDataViewProgressRenderer
445 // ---------------------------------------------------------
447 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
449 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
450 const wxString
&varianttype
, wxDataViewCellMode mode
) :
451 wxDataViewCustomRenderer( varianttype
, mode
)
457 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
461 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
463 m_value
= (long) value
;
465 if (m_value
< 0) m_value
= 0;
466 if (m_value
> 100) m_value
= 100;
471 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
473 double pct
= (double)m_value
/ 100.0;
475 bar
.width
= (int)(cell
.width
* pct
);
476 dc
->SetPen( *wxTRANSPARENT_PEN
);
477 dc
->SetBrush( *wxBLUE_BRUSH
);
478 dc
->DrawRectangle( bar
);
480 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
481 dc
->SetPen( *wxBLACK_PEN
);
482 dc
->DrawRectangle( cell
);
487 wxSize
wxDataViewProgressRenderer::GetSize()
489 return wxSize(40,12);
492 // ---------------------------------------------------------
493 // wxDataViewDateRenderer
494 // ---------------------------------------------------------
496 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
499 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
500 wxDataViewListModel
*model
, unsigned int col
, unsigned int row
) :
501 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
)
506 m_cal
= new wxCalendarCtrl( this, wxID_ANY
, *value
);
507 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
508 sizer
->Add( m_cal
, 1, wxGROW
);
513 void OnCalendar( wxCalendarEvent
&event
);
515 wxCalendarCtrl
*m_cal
;
516 wxDataViewListModel
*m_model
;
521 virtual void OnDismiss()
526 DECLARE_EVENT_TABLE()
529 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
530 EVT_CALENDAR( wxID_ANY
, wxDataViewDateRendererPopupTransient::OnCalendar
)
533 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
535 wxDateTime date
= event
.GetDate();
536 wxVariant value
= date
;
537 m_model
->SetValue( value
, m_col
, m_row
);
538 m_model
->ValueChanged( m_col
, m_row
);
542 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
544 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
545 wxDataViewCellMode mode
) :
546 wxDataViewCustomRenderer( varianttype
, mode
)
550 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
552 m_date
= value
.GetDateTime();
557 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
559 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
560 wxString tmp
= m_date
.FormatDate();
561 dc
->DrawText( tmp
, cell
.x
, cell
.y
);
566 wxSize
wxDataViewDateRenderer::GetSize()
568 wxDataViewCtrl
* view
= GetOwner()->GetOwner();
569 wxString tmp
= m_date
.FormatDate();
571 view
->GetTextExtent( tmp
, &x
, &y
, &d
);
572 return wxSize(x
,y
+d
);
575 bool wxDataViewDateRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewListModel
*model
, unsigned int col
, unsigned int row
)
578 model
->GetValue( variant
, col
, row
);
579 wxDateTime value
= variant
.GetDateTime();
581 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
582 GetOwner()->GetOwner()->GetParent(), &value
, model
, col
, row
);
583 wxPoint pos
= wxGetMousePosition();
586 popup
->Popup( popup
->m_cal
);
591 // ---------------------------------------------------------
593 // ---------------------------------------------------------
595 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
597 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
, unsigned int model_column
,
598 int width
, int flags
) :
599 wxDataViewColumnBase( title
, cell
, model_column
, width
, flags
)
606 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
, unsigned int model_column
,
607 int width
, int flags
) :
608 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, flags
)
615 void wxDataViewColumn::SetAlignment( wxAlignment
WXUNUSED(align
) )
620 void wxDataViewColumn::SetSortable( bool WXUNUSED(sortable
) )
625 bool wxDataViewColumn::GetSortable()
631 void wxDataViewColumn::SetSortOrder( bool WXUNUSED(ascending
) )
636 bool wxDataViewColumn::IsSortOrderAscending()
643 wxDataViewColumn::~wxDataViewColumn()
647 void wxDataViewColumn::SetTitle( const wxString
&title
)
649 wxDataViewColumnBase::SetTitle( title
);
653 void wxDataViewColumn::SetBitmap( const wxBitmap
&bitmap
)
655 wxDataViewColumnBase::SetBitmap( bitmap
);
659 int wxDataViewColumn::GetWidth()
664 //-----------------------------------------------------------------------------
665 // wxDataViewHeaderWindow
666 //-----------------------------------------------------------------------------
668 IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindow
, wxWindow
)
670 BEGIN_EVENT_TABLE(wxDataViewHeaderWindow
,wxWindow
)
671 EVT_PAINT (wxDataViewHeaderWindow::OnPaint
)
672 EVT_MOUSE_EVENTS (wxDataViewHeaderWindow::OnMouse
)
673 EVT_SET_FOCUS (wxDataViewHeaderWindow::OnSetFocus
)
676 wxDataViewHeaderWindow::wxDataViewHeaderWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
677 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
678 wxWindow( parent
, id
, pos
, size
, 0, name
)
682 m_resizeCursor
= new wxCursor( wxCURSOR_SIZEWE
);
684 wxVisualAttributes attr
= wxPanel::GetClassDefaultAttributes();
685 SetOwnForegroundColour( attr
.colFg
);
686 SetOwnBackgroundColour( attr
.colBg
);
688 SetOwnFont( attr
.font
);
691 wxDataViewHeaderWindow::~wxDataViewHeaderWindow()
693 delete m_resizeCursor
;
696 void wxDataViewHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
699 GetClientSize( &w
, &h
);
701 wxPaintDC
dc( this );
704 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
707 m_owner
->GetViewStart( &x
, NULL
);
709 // account for the horz scrollbar offset
710 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
712 dc
.SetFont( GetFont() );
714 unsigned int cols
= GetOwner()->GetNumberOfColumns();
717 for (i
= 0; i
< cols
; i
++)
719 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
720 int width
= col
->GetWidth();
725 wxRendererNative::Get().DrawHeaderButton
729 wxRect(xpos
, 0, cw
, ch
-1),
730 m_parent
->IsEnabled() ? 0
731 : (int)wxCONTROL_DISABLED
734 dc
.DrawText( col
->GetTitle(), xpos
+3, 3 );
740 void wxDataViewHeaderWindow::OnMouse( wxMouseEvent
&WXUNUSED(event
) )
744 void wxDataViewHeaderWindow::OnSetFocus( wxFocusEvent
&event
)
746 GetParent()->SetFocus();
750 //-----------------------------------------------------------------------------
751 // wxDataViewRenameTimer
752 //-----------------------------------------------------------------------------
754 wxDataViewRenameTimer::wxDataViewRenameTimer( wxDataViewMainWindow
*owner
)
759 void wxDataViewRenameTimer::Notify()
761 m_owner
->OnRenameTimer();
764 //-----------------------------------------------------------------------------
765 // wxDataViewTextCtrlWrapper: wraps a wxTextCtrl for inline editing
766 //-----------------------------------------------------------------------------
768 BEGIN_EVENT_TABLE(wxDataViewTextCtrlWrapper
, wxEvtHandler
)
769 EVT_CHAR (wxDataViewTextCtrlWrapper::OnChar
)
770 EVT_KEY_UP (wxDataViewTextCtrlWrapper::OnKeyUp
)
771 EVT_KILL_FOCUS (wxDataViewTextCtrlWrapper::OnKillFocus
)
774 wxDataViewTextCtrlWrapper::wxDataViewTextCtrlWrapper(
775 wxDataViewMainWindow
*owner
,
777 wxDataViewListModel
*model
,
778 unsigned int col
, unsigned int row
,
788 m_aboutToFinish
= false;
791 model
->GetValue( value
, col
, row
);
792 m_startValue
= value
.GetString();
794 m_owner
->GetOwner()->CalcScrolledPosition(
795 rectLabel
.x
, rectLabel
.y
, &rectLabel
.x
, &rectLabel
.y
);
797 m_text
->Create( owner
, wxID_ANY
, m_startValue
,
798 wxPoint(rectLabel
.x
-2,rectLabel
.y
-2),
799 wxSize(rectLabel
.width
+7,rectLabel
.height
+4) );
802 m_text
->PushEventHandler(this);
805 void wxDataViewTextCtrlWrapper::AcceptChangesAndFinish()
807 m_aboutToFinish
= true;
809 // Notify the owner about the changes
812 // Even if vetoed, close the control (consistent with MSW)
816 void wxDataViewTextCtrlWrapper::OnChar( wxKeyEvent
&event
)
818 switch ( event
.m_keyCode
)
821 AcceptChangesAndFinish();
825 // m_owner->OnRenameCancelled( m_itemEdited );
834 void wxDataViewTextCtrlWrapper::OnKeyUp( wxKeyEvent
&event
)
842 // auto-grow the textctrl
843 wxSize parentSize
= m_owner
->GetSize();
844 wxPoint myPos
= m_text
->GetPosition();
845 wxSize mySize
= m_text
->GetSize();
847 m_text
->GetTextExtent(m_text
->GetValue() + _T("MM"), &sx
, &sy
);
848 if (myPos
.x
+ sx
> parentSize
.x
)
849 sx
= parentSize
.x
- myPos
.x
;
852 m_text
->SetSize(sx
, wxDefaultCoord
);
857 void wxDataViewTextCtrlWrapper::OnKillFocus( wxFocusEvent
&event
)
859 if ( !m_finished
&& !m_aboutToFinish
)
862 //if ( !AcceptChanges() )
863 // m_owner->OnRenameCancelled( m_itemEdited );
868 // We must let the native text control handle focus
872 bool wxDataViewTextCtrlWrapper::AcceptChanges()
874 const wxString value
= m_text
->GetValue();
876 if ( value
== m_startValue
)
877 // nothing changed, always accept
880 // if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
881 // vetoed by the user
884 // accepted, do rename the item
887 m_model
->SetValue( variant
, m_col
, m_row
);
888 m_model
->ValueChanged( m_col
, m_row
);
893 void wxDataViewTextCtrlWrapper::Finish()
899 m_text
->RemoveEventHandler(this);
900 m_owner
->FinishEditing(m_text
);
903 wxPendingDelete
.Append( this );
907 //-----------------------------------------------------------------------------
908 // wxDataViewMainWindow
909 //-----------------------------------------------------------------------------
911 int LINKAGEMODE
wxDataViewSelectionCmp( unsigned int row1
, unsigned int row2
)
913 if (row1
> row2
) return 1;
914 if (row1
== row2
) return 0;
919 IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow
, wxWindow
)
921 BEGIN_EVENT_TABLE(wxDataViewMainWindow
,wxWindow
)
922 EVT_PAINT (wxDataViewMainWindow::OnPaint
)
923 EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse
)
924 EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus
)
925 EVT_KILL_FOCUS (wxDataViewMainWindow::OnKillFocus
)
926 EVT_CHAR (wxDataViewMainWindow::OnChar
)
929 wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
930 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
931 wxWindow( parent
, id
, pos
, size
, wxWANTS_CHARS
, name
),
932 m_selection( wxDataViewSelectionCmp
)
937 m_lastOnSame
= false;
938 m_renameTimer
= new wxDataViewRenameTimer( this );
939 m_textctrlWrapper
= NULL
;
941 // TODO: user better initial values/nothing selected
945 // TODO: we need to calculate this smartly
949 m_dragStart
= wxPoint(0,0);
950 m_lineLastClicked
= (unsigned int) -1;
951 m_lineBeforeLastClicked
= (unsigned int) -1;
952 m_lineSelectSingleOnUp
= (unsigned int) -1;
956 SetBackgroundColour( *wxWHITE
);
961 wxDataViewMainWindow::~wxDataViewMainWindow()
963 delete m_renameTimer
;
966 void wxDataViewMainWindow::OnRenameTimer()
968 // We have to call this here because changes may just have
969 // been made and no screen update taken place.
975 unsigned int cols
= GetOwner()->GetNumberOfColumns();
977 for (i
= 0; i
< cols
; i
++)
979 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
980 if (c
== m_currentCol
)
982 xpos
+= c
->GetWidth();
984 wxRect
labelRect( xpos
, m_currentRow
* m_lineHeight
, m_currentCol
->GetWidth(), m_lineHeight
);
986 wxClassInfo
*textControlClass
= CLASSINFO(wxTextCtrl
);
988 wxTextCtrl
* const text
= (wxTextCtrl
*)textControlClass
->CreateObject();
989 m_textctrlWrapper
= new wxDataViewTextCtrlWrapper(this, text
, GetOwner()->GetModel(),
990 m_currentCol
->GetModelColumn(), m_currentRow
, labelRect
);
993 void wxDataViewMainWindow::FinishEditing( wxTextCtrl
*text
)
996 m_textctrlWrapper
= NULL
;
998 // SetFocusIgnoringChildren();
1001 bool wxDataViewMainWindow::RowAppended()
1006 bool wxDataViewMainWindow::RowPrepended()
1011 bool wxDataViewMainWindow::RowInserted( unsigned int WXUNUSED(before
) )
1016 bool wxDataViewMainWindow::RowDeleted( unsigned int WXUNUSED(row
) )
1021 bool wxDataViewMainWindow::RowChanged( unsigned int WXUNUSED(row
) )
1026 bool wxDataViewMainWindow::ValueChanged( unsigned int WXUNUSED(col
), unsigned int row
)
1028 wxRect
rect( 0, row
*m_lineHeight
, 10000, m_lineHeight
);
1029 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1030 Refresh( true, &rect
);
1035 bool wxDataViewMainWindow::RowsReordered( unsigned int *WXUNUSED(new_order
) )
1042 bool wxDataViewMainWindow::Cleared()
1047 void wxDataViewMainWindow::UpdateDisplay()
1052 void wxDataViewMainWindow::OnInternalIdle()
1054 wxWindow::OnInternalIdle();
1058 RecalculateDisplay();
1063 void wxDataViewMainWindow::RecalculateDisplay()
1065 wxDataViewListModel
*model
= GetOwner()->GetModel();
1073 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1075 for (i
= 0; i
< cols
; i
++)
1077 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
1078 width
+= col
->GetWidth();
1081 int height
= model
->GetNumberOfRows() * m_lineHeight
;
1083 SetVirtualSize( width
, height
);
1084 GetOwner()->SetScrollRate( 10, m_lineHeight
);
1089 void wxDataViewMainWindow::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
1091 wxWindow::ScrollWindow( dx
, dy
, rect
);
1092 GetOwner()->m_headerArea
->ScrollWindow( dx
, 0 );
1095 void wxDataViewMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1097 wxPaintDC
dc( this );
1099 GetOwner()->PrepareDC( dc
);
1101 dc
.SetFont( GetFont() );
1103 wxRect update
= GetUpdateRegion().GetBox();
1104 m_owner
->CalcUnscrolledPosition( update
.x
, update
.y
, &update
.x
, &update
.y
);
1106 wxDataViewListModel
*model
= GetOwner()->GetModel();
1108 unsigned int item_start
= wxMax( 0, (update
.y
/ m_lineHeight
) );
1109 unsigned int item_count
= wxMin( (int)(((update
.y
+ update
.height
) / m_lineHeight
) - item_start
+ 1),
1110 (int)(model
->GetNumberOfRows()-item_start
) );
1115 for (item
= item_start
; item
< item_start
+item_count
; item
++)
1117 if (m_selection
.Index( item
) != wxNOT_FOUND
)
1119 int flags
= wxCONTROL_SELECTED
;
1120 if (item
== m_currentRow
)
1121 flags
|= wxCONTROL_CURRENT
;
1123 flags
|= wxCONTROL_FOCUSED
;
1124 wxRect
rect( 0, item
*m_lineHeight
+1, GetEndOfLastCol(), m_lineHeight
-2 );
1125 wxRendererNative::Get().DrawItemSelectionRect
1135 if (item
== m_currentRow
)
1137 int flags
= wxCONTROL_CURRENT
;
1139 flags
|= wxCONTROL_FOCUSED
; // should have no effect
1140 wxRect
rect( 0, item
*m_lineHeight
+1, GetEndOfLastCol(), m_lineHeight
-2 );
1141 wxRendererNative::Get().DrawItemSelectionRect
1155 cell_rect
.height
= m_lineHeight
;
1156 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1158 for (i
= 0; i
< cols
; i
++)
1160 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
1161 wxDataViewRenderer
*cell
= col
->GetRenderer();
1162 cell_rect
.width
= col
->GetWidth();
1164 for (item
= item_start
; item
< item_start
+item_count
; item
++)
1166 cell_rect
.y
= item
*m_lineHeight
;
1168 model
->GetValue( value
, col
->GetModelColumn(), item
);
1169 cell
->SetValue( value
);
1170 wxSize size
= cell
->GetSize();
1171 // cannot be bigger than allocated space
1172 size
.x
= wxMin( size
.x
, cell_rect
.width
);
1173 size
.y
= wxMin( size
.y
, cell_rect
.height
);
1174 // TODO: check for left/right/centre alignment here
1177 item_rect
.x
= cell_rect
.x
+ (cell_rect
.width
/ 2) - (size
.x
/ 2);
1178 item_rect
.y
= cell_rect
.y
+ (cell_rect
.height
/ 2) - (size
.y
/ 2);
1180 item_rect
.width
= size
.x
;
1181 item_rect
.height
= size
.y
;
1182 cell
->Render( item_rect
, &dc
, 0 );
1185 cell_rect
.x
+= cell_rect
.width
;
1189 int wxDataViewMainWindow::GetCountPerPage()
1191 wxSize size
= GetClientSize();
1192 return size
.y
/ m_lineHeight
;
1195 int wxDataViewMainWindow::GetEndOfLastCol()
1199 for (i
= 0; i
< GetOwner()->GetNumberOfColumns(); i
++)
1201 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1202 width
+= c
->GetWidth();
1207 unsigned int wxDataViewMainWindow::GetFirstVisibleRow()
1211 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
1213 return y
/ m_lineHeight
;
1216 unsigned int wxDataViewMainWindow::GetLastVisibleRow()
1218 wxSize client_size
= GetClientSize();
1219 m_owner
->CalcUnscrolledPosition( client_size
.x
, client_size
.y
, &client_size
.x
, &client_size
.y
);
1221 return wxMin( GetRowCount()-1, ((unsigned)client_size
.y
/m_lineHeight
)+1 );
1224 unsigned int wxDataViewMainWindow::GetRowCount()
1226 return GetOwner()->GetModel()->GetNumberOfRows();
1229 void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row
)
1236 void wxDataViewMainWindow::SelectAllRows( bool on
)
1243 m_selection
.Clear();
1244 for (unsigned int i
= 0; i
< GetRowCount(); i
++)
1245 m_selection
.Add( i
);
1250 unsigned int first_visible
= GetFirstVisibleRow();
1251 unsigned int last_visible
= GetLastVisibleRow();
1253 for (i
= 0; i
< m_selection
.GetCount(); i
++)
1255 unsigned int row
= m_selection
[i
];
1256 if ((row
>= first_visible
) && (row
<= last_visible
))
1259 m_selection
.Clear();
1263 void wxDataViewMainWindow::SelectRow( unsigned int row
, bool on
)
1265 if (m_selection
.Index( row
) == wxNOT_FOUND
)
1269 m_selection
.Add( row
);
1277 m_selection
.Remove( row
);
1283 void wxDataViewMainWindow::SelectRows( unsigned int from
, unsigned int to
, bool on
)
1287 unsigned int tmp
= from
;
1293 for (i
= from
; i
<= to
; i
++)
1295 if (m_selection
.Index( i
) == wxNOT_FOUND
)
1298 m_selection
.Add( i
);
1303 m_selection
.Remove( i
);
1306 RefreshRows( from
, to
);
1309 void wxDataViewMainWindow::ReverseRowSelection( unsigned int row
)
1311 if (m_selection
.Index( row
) == wxNOT_FOUND
)
1312 m_selection
.Add( row
);
1314 m_selection
.Remove( row
);
1318 bool wxDataViewMainWindow::IsRowSelected( unsigned int row
)
1320 return (m_selection
.Index( row
) != wxNOT_FOUND
);
1323 void wxDataViewMainWindow::RefreshRow( unsigned int row
)
1325 wxRect
rect( 0, row
*m_lineHeight
, GetEndOfLastCol(), m_lineHeight
);
1326 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1328 wxSize client_size
= GetClientSize();
1329 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1330 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1331 if (intersect_rect
.width
> 0)
1332 Refresh( true, &intersect_rect
);
1335 void wxDataViewMainWindow::RefreshRows( unsigned int from
, unsigned int to
)
1339 unsigned int tmp
= to
;
1344 wxRect
rect( 0, from
*m_lineHeight
, GetEndOfLastCol(), (to
-from
+1) * m_lineHeight
);
1345 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1347 wxSize client_size
= GetClientSize();
1348 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1349 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1350 if (intersect_rect
.width
> 0)
1351 Refresh( true, &intersect_rect
);
1354 void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow
)
1356 unsigned int count
= GetRowCount();
1357 if (firstRow
> count
)
1360 wxRect
rect( 0, firstRow
*m_lineHeight
, GetEndOfLastCol(), count
* m_lineHeight
);
1361 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
1363 wxSize client_size
= GetClientSize();
1364 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
1365 wxRect intersect_rect
= client_rect
.Intersect( rect
);
1366 if (intersect_rect
.width
> 0)
1367 Refresh( true, &intersect_rect
);
1370 void wxDataViewMainWindow::OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
)
1372 wxCHECK_RET( newCurrent
< GetRowCount(),
1373 _T("invalid item index in OnArrowChar()") );
1375 // if there is no selection, we cannot move it anywhere
1376 if (!HasCurrentRow())
1379 unsigned int oldCurrent
= m_currentRow
;
1381 // in single selection we just ignore Shift as we can't select several
1383 if ( event
.ShiftDown() && !IsSingleSel() )
1385 RefreshRow( oldCurrent
);
1387 ChangeCurrentRow( newCurrent
);
1389 // select all the items between the old and the new one
1390 if ( oldCurrent
> newCurrent
)
1392 newCurrent
= oldCurrent
;
1393 oldCurrent
= m_currentRow
;
1396 SelectRows( oldCurrent
, newCurrent
, true );
1400 RefreshRow( oldCurrent
);
1402 // all previously selected items are unselected unless ctrl is held
1403 if ( !event
.ControlDown() )
1404 SelectAllRows(false);
1406 ChangeCurrentRow( newCurrent
);
1408 if ( !event
.ControlDown() )
1409 SelectRow( m_currentRow
, true );
1411 RefreshRow( m_currentRow
);
1417 void wxDataViewMainWindow::OnChar( wxKeyEvent
&event
)
1419 if (event
.GetKeyCode() == WXK_TAB
)
1421 wxNavigationKeyEvent nevent
;
1422 nevent
.SetWindowChange( event
.ControlDown() );
1423 nevent
.SetDirection( !event
.ShiftDown() );
1424 nevent
.SetEventObject( GetParent()->GetParent() );
1425 nevent
.SetCurrentFocus( m_parent
);
1426 if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent
))
1430 // no item -> nothing to do
1431 if (!HasCurrentRow())
1437 // don't use m_linesPerPage directly as it might not be computed yet
1438 const int pageSize
= GetCountPerPage();
1439 wxCHECK_RET( pageSize
, _T("should have non zero page size") );
1441 switch ( event
.GetKeyCode() )
1444 if ( m_currentRow
> 0 )
1445 OnArrowChar( m_currentRow
- 1, event
);
1449 if ( m_currentRow
< GetRowCount() - 1 )
1450 OnArrowChar( m_currentRow
+ 1, event
);
1455 OnArrowChar( GetRowCount() - 1, event
);
1460 OnArrowChar( 0, event
);
1465 int steps
= pageSize
- 1;
1466 int index
= m_currentRow
- steps
;
1470 OnArrowChar( index
, event
);
1476 int steps
= pageSize
- 1;
1477 unsigned int index
= m_currentRow
+ steps
;
1478 unsigned int count
= GetRowCount();
1479 if ( index
>= count
)
1482 OnArrowChar( index
, event
);
1491 void wxDataViewMainWindow::OnMouse( wxMouseEvent
&event
)
1493 if (event
.GetEventType() == wxEVT_MOUSEWHEEL
)
1495 // let the base handle mouse wheel events.
1500 int x
= event
.GetX();
1501 int y
= event
.GetY();
1502 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
1504 wxDataViewColumn
*col
= NULL
;
1507 unsigned int cols
= GetOwner()->GetNumberOfColumns();
1509 for (i
= 0; i
< cols
; i
++)
1511 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1512 if (x
< xpos
+ c
->GetWidth())
1517 xpos
+= c
->GetWidth();
1521 wxDataViewRenderer
*cell
= col
->GetRenderer();
1523 unsigned int current
= y
/ m_lineHeight
;
1525 if ((current
> GetRowCount()) || (x
> GetEndOfLastCol()))
1527 // Unselect all if below the last row ?
1531 wxDataViewListModel
*model
= GetOwner()->GetModel();
1533 if (event
.Dragging())
1535 if (m_dragCount
== 0)
1537 // we have to report the raw, physical coords as we want to be
1538 // able to call HitTest(event.m_pointDrag) from the user code to
1539 // get the item being dragged
1540 m_dragStart
= event
.GetPosition();
1545 if (m_dragCount
!= 3)
1548 if (event
.LeftIsDown())
1550 // Notify cell about drag
1559 bool forceClick
= false;
1561 if (event
.ButtonDClick())
1563 m_renameTimer
->Stop();
1564 m_lastOnSame
= false;
1567 if (event
.LeftDClick())
1569 if ( current
== m_lineLastClicked
)
1571 if (cell
->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE
)
1574 model
->GetValue( value
, col
->GetModelColumn(), current
);
1575 cell
->SetValue( value
);
1576 wxRect
cell_rect( xpos
, current
* m_lineHeight
, col
->GetWidth(), m_lineHeight
);
1577 cell
->Activate( cell_rect
, model
, col
->GetModelColumn(), current
);
1583 // The first click was on another item, so don't interpret this as
1584 // a double click, but as a simple click instead
1591 if (m_lineSelectSingleOnUp
!= (unsigned int)-1)
1593 // select single line
1594 SelectAllRows( false );
1595 SelectRow( m_lineSelectSingleOnUp
, true );
1600 if ((col
== m_currentCol
) && (current
== m_currentRow
) &&
1601 (cell
->GetMode() == wxDATAVIEW_CELL_EDITABLE
) )
1603 m_renameTimer
->Start( 100, true );
1607 m_lastOnSame
= false;
1608 m_lineSelectSingleOnUp
= (unsigned int)-1;
1612 // This is necessary, because after a DnD operation in
1613 // from and to ourself, the up event is swallowed by the
1614 // DnD code. So on next non-up event (which means here and
1615 // now) m_lineSelectSingleOnUp should be reset.
1616 m_lineSelectSingleOnUp
= (unsigned int)-1;
1619 if (event
.RightDown())
1621 m_lineBeforeLastClicked
= m_lineLastClicked
;
1622 m_lineLastClicked
= current
;
1624 // If the item is already selected, do not update the selection.
1625 // Multi-selections should not be cleared if a selected item is clicked.
1626 if (!IsRowSelected(current
))
1628 SelectAllRows(false);
1629 ChangeCurrentRow(current
);
1630 SelectRow(m_currentRow
,true);
1633 // notify cell about right click
1636 // Allow generation of context menu event
1639 else if (event
.MiddleDown())
1641 // notify cell about middle click
1644 if (event
.LeftDown() || forceClick
)
1650 m_lineBeforeLastClicked
= m_lineLastClicked
;
1651 m_lineLastClicked
= current
;
1653 unsigned int oldCurrentRow
= m_currentRow
;
1654 bool oldWasSelected
= IsRowSelected(m_currentRow
);
1656 bool cmdModifierDown
= event
.CmdDown();
1657 if ( IsSingleSel() || !(cmdModifierDown
|| event
.ShiftDown()) )
1659 if ( IsSingleSel() || !IsRowSelected(current
) )
1661 SelectAllRows( false );
1663 ChangeCurrentRow(current
);
1665 SelectRow(m_currentRow
,true);
1667 else // multi sel & current is highlighted & no mod keys
1669 m_lineSelectSingleOnUp
= current
;
1670 ChangeCurrentRow(current
); // change focus
1673 else // multi sel & either ctrl or shift is down
1675 if (cmdModifierDown
)
1677 ChangeCurrentRow(current
);
1679 ReverseRowSelection(m_currentRow
);
1681 else if (event
.ShiftDown())
1683 ChangeCurrentRow(current
);
1685 unsigned int lineFrom
= oldCurrentRow
,
1688 if ( lineTo
< lineFrom
)
1691 lineFrom
= m_currentRow
;
1694 SelectRows(lineFrom
, lineTo
, true);
1696 else // !ctrl, !shift
1698 // test in the enclosing if should make it impossible
1699 wxFAIL_MSG( _T("how did we get here?") );
1703 if (m_currentRow
!= oldCurrentRow
)
1704 RefreshRow( oldCurrentRow
);
1706 wxDataViewColumn
*oldCurrentCol
= m_currentCol
;
1708 // Update selection here...
1711 m_lastOnSame
= !forceClick
&& ((col
== oldCurrentCol
) && (current
== oldCurrentRow
)) && oldWasSelected
;
1715 void wxDataViewMainWindow::OnSetFocus( wxFocusEvent
&event
)
1719 if (HasCurrentRow())
1725 void wxDataViewMainWindow::OnKillFocus( wxFocusEvent
&event
)
1729 if (HasCurrentRow())
1735 //-----------------------------------------------------------------------------
1737 //-----------------------------------------------------------------------------
1739 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
1741 BEGIN_EVENT_TABLE(wxDataViewCtrl
, wxDataViewCtrlBase
)
1742 EVT_SIZE(wxDataViewCtrl::OnSize
)
1745 wxDataViewCtrl::~wxDataViewCtrl()
1748 GetModel()->RemoveNotifier( m_notifier
);
1751 void wxDataViewCtrl::Init()
1756 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
1757 const wxPoint
& pos
, const wxSize
& size
,
1758 long style
, const wxValidator
& validator
)
1760 if (!wxControl::Create( parent
, id
, pos
, size
, style
| wxScrolledWindowStyle
|wxSUNKEN_BORDER
, validator
))
1766 MacSetClipChildren( true ) ;
1769 m_clientArea
= new wxDataViewMainWindow( this, wxID_ANY
);
1771 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
, wxDefaultPosition
, wxSize(wxDefaultCoord
,22) );
1773 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
, wxDefaultPosition
, wxSize(wxDefaultCoord
,25) );
1776 SetTargetWindow( m_clientArea
);
1778 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
1779 sizer
->Add( m_headerArea
, 0, wxGROW
);
1780 sizer
->Add( m_clientArea
, 1, wxGROW
);
1787 WXLRESULT
wxDataViewCtrl::MSWWindowProc(WXUINT nMsg
,
1791 WXLRESULT rc
= wxDataViewCtrlBase::MSWWindowProc(nMsg
, wParam
, lParam
);
1794 // we need to process arrows ourselves for scrolling
1795 if ( nMsg
== WM_GETDLGCODE
)
1797 rc
|= DLGC_WANTARROWS
;
1805 void wxDataViewCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1807 // We need to override OnSize so that our scrolled
1808 // window a) does call Layout() to use sizers for
1809 // positioning the controls but b) does not query
1810 // the sizer for their size and use that for setting
1811 // the scrollable area as set that ourselves by
1812 // calling SetScrollbar() further down.
1819 bool wxDataViewCtrl::AssociateModel( wxDataViewListModel
*model
)
1821 if (!wxDataViewCtrlBase::AssociateModel( model
))
1824 m_notifier
= new wxGenericDataViewListModelNotifier( m_clientArea
);
1826 model
->AddNotifier( m_notifier
);
1828 m_clientArea
->UpdateDisplay();
1833 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
1835 if (!wxDataViewCtrlBase::AppendColumn(col
))
1838 m_clientArea
->UpdateDisplay();
1843 void wxDataViewCtrl::SetSelection( int WXUNUSED(row
) )
1848 void wxDataViewCtrl::SetSelectionRange( unsigned int WXUNUSED(from
), unsigned int WXUNUSED(to
) )
1853 void wxDataViewCtrl::SetSelections( const wxArrayInt
& WXUNUSED(aSelections
) )
1858 void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row
) )
1863 bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row
) ) const
1870 int wxDataViewCtrl::GetSelection() const
1877 int wxDataViewCtrl::GetSelections(wxArrayInt
& WXUNUSED(aSelections
) ) const
1885 // !wxUSE_GENERICDATAVIEWCTRL
1888 // wxUSE_DATAVIEWCTRL