1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/datavgen.cpp
3 // Purpose: wxDataViewCtrl generic implementation
4 // Author: Robert Roebling
5 // Modified by: Francesco Montorsi, Guru Kathiresan, Otto Wyss
7 // Copyright: (c) 1998 Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_DATAVIEWCTRL
20 #include "wx/dataview.h"
22 #ifdef wxUSE_GENERICDATAVIEWCTRL
26 #include "wx/msw/private.h"
27 #include "wx/msw/wrapwin.h"
28 #include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
32 #include "wx/dcclient.h"
34 #include "wx/settings.h"
35 #include "wx/msgdlg.h"
36 #include "wx/dcscreen.h"
39 #include "wx/stockitem.h"
40 #include "wx/calctrl.h"
41 #include "wx/popupwin.h"
42 #include "wx/renderer.h"
43 #include "wx/dcbuffer.h"
46 #include "wx/listimpl.cpp"
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
54 static const int SCROLL_UNIT_X
= 15;
56 // the cell padding on the left/right
57 static const int PADDING_RIGHTLEFT
= 3;
59 // the cell padding on the top/bottom
60 static const int PADDING_TOPBOTTOM
= 1;
62 // the expander space margin
63 static const int EXPANDER_MARGIN
= 4;
65 //-----------------------------------------------------------------------------
66 // wxDataViewHeaderWindow
67 //-----------------------------------------------------------------------------
69 #define USE_NATIVE_HEADER_WINDOW 1
71 // NB: for some reason, this class must be dllexport'ed or we get warnings from
73 class WXDLLIMPEXP_ADV wxDataViewHeaderWindowBase
: public wxControl
76 wxDataViewHeaderWindowBase()
79 bool Create(wxDataViewCtrl
*parent
, wxWindowID id
,
80 const wxPoint
&pos
, const wxSize
&size
,
83 return wxWindow::Create(parent
, id
, pos
, size
, wxNO_BORDER
, name
);
86 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
87 wxDataViewCtrl
*GetOwner() { return m_owner
; }
89 // called on column addition/removal
90 virtual void UpdateDisplay() { /* by default, do nothing */ }
92 // returns the n-th column
93 virtual wxDataViewColumn
*GetColumn(unsigned int n
)
96 wxDataViewColumn
*ret
= m_owner
->GetColumn(n
);
103 wxDataViewCtrl
*m_owner
;
105 // sends an event generated from the n-th wxDataViewColumn
106 void SendEvent(wxEventType type
, unsigned int n
);
109 // on wxMSW the header window (only that part however) can be made native!
110 #if defined(__WXMSW__) && USE_NATIVE_HEADER_WINDOW
112 #define COLUMN_WIDTH_OFFSET 2
113 #define wxDataViewHeaderWindowMSW wxDataViewHeaderWindow
115 class wxDataViewHeaderWindowMSW
: public wxDataViewHeaderWindowBase
119 wxDataViewHeaderWindowMSW( wxDataViewCtrl
*parent
,
121 const wxPoint
&pos
= wxDefaultPosition
,
122 const wxSize
&size
= wxDefaultSize
,
123 const wxString
&name
= wxT("wxdataviewctrlheaderwindow") )
125 Create(parent
, id
, pos
, size
, name
);
128 bool Create(wxDataViewCtrl
*parent
, wxWindowID id
,
129 const wxPoint
&pos
, const wxSize
&size
,
130 const wxString
&name
);
132 ~wxDataViewHeaderWindowMSW();
134 // called when any column setting is changed and/or changed
136 virtual void UpdateDisplay();
138 // called when the main window gets scrolled
139 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
142 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
143 virtual void DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
);
145 unsigned int GetColumnIdxFromHeader(NMHEADER
*nmHDR
);
147 wxDataViewColumn
*GetColumnFromHeader(NMHEADER
*nmHDR
)
148 { return GetColumn(GetColumnIdxFromHeader(nmHDR
)); }
151 DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindowMSW
)
154 #else // !defined(__WXMSW__)
156 #define HEADER_WINDOW_HEIGHT 25
157 #define HEADER_HORIZ_BORDER 5
158 #define HEADER_VERT_BORDER 3
159 #define wxGenericDataViewHeaderWindow wxDataViewHeaderWindow
161 class wxGenericDataViewHeaderWindow
: public wxDataViewHeaderWindowBase
164 wxGenericDataViewHeaderWindow( wxDataViewCtrl
*parent
,
166 const wxPoint
&pos
= wxDefaultPosition
,
167 const wxSize
&size
= wxDefaultSize
,
168 const wxString
&name
= wxT("wxdataviewctrlheaderwindow") )
171 Create(parent
, id
, pos
, size
, name
);
174 bool Create(wxDataViewCtrl
*parent
, wxWindowID id
,
175 const wxPoint
&pos
, const wxSize
&size
,
176 const wxString
&name
);
178 ~wxGenericDataViewHeaderWindow()
180 delete m_resizeCursor
;
183 virtual void UpdateDisplay() { Refresh(); }
187 void OnPaint( wxPaintEvent
&event
);
188 void OnMouse( wxMouseEvent
&event
);
189 void OnSetFocus( wxFocusEvent
&event
);
194 // vars used for column resizing:
196 wxCursor
*m_resizeCursor
;
197 const wxCursor
*m_currentCursor
;
200 bool m_dirty
; // needs refresh?
201 int m_column
; // index of the column being resized
202 int m_currentX
; // divider line position in logical (unscrolled) coords
203 int m_minX
; // minimal position beyond which the divider line
204 // can't be dragged in logical coords
206 // the pen used to draw the current column width drag line
207 // when resizing the columsn
211 // internal utilities:
215 m_currentCursor
= (wxCursor
*) NULL
;
216 m_resizeCursor
= new wxCursor( wxCURSOR_SIZEWE
);
218 m_isDragging
= false;
221 m_column
= wxNOT_FOUND
;
225 wxColour col
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
);
226 m_penCurrent
= wxPen(col
, 1, wxSOLID
);
230 void AdjustDC(wxDC
& dc
);
233 DECLARE_DYNAMIC_CLASS(wxGenericDataViewHeaderWindow
)
234 DECLARE_EVENT_TABLE()
237 #endif // defined(__WXMSW__)
239 //-----------------------------------------------------------------------------
240 // wxDataViewRenameTimer
241 //-----------------------------------------------------------------------------
243 class wxDataViewRenameTimer
: public wxTimer
246 wxDataViewMainWindow
*m_owner
;
249 wxDataViewRenameTimer( wxDataViewMainWindow
*owner
);
253 //-----------------------------------------------------------------------------
254 // wxDataViewTreeNode
255 //-----------------------------------------------------------------------------
256 class wxDataViewTreeNode
;
257 WX_DEFINE_SORTED_ARRAY( wxDataViewTreeNode
*, wxDataViewTreeNodes
);
258 WX_DEFINE_SORTED_ARRAY( void* , wxDataViewTreeLeaves
);
260 int LINKAGEMODE
wxGenericTreeModelNodeCmp( wxDataViewTreeNode
* node1
, wxDataViewTreeNode
* node2
);
261 int LINKAGEMODE
wxGenericTreeModelItemCmp( void * id1
, void * id2
);
263 class wxDataViewTreeNode
266 wxDataViewTreeNode( wxDataViewTreeNode
* parent
)
267 :leaves( wxGenericTreeModelItemCmp
),
268 nodes(wxGenericTreeModelNodeCmp
)
269 { this->parent
= parent
;
277 //I don't know what I need to do in the destructure
278 ~wxDataViewTreeNode()
283 wxDataViewTreeNode
* GetParent() { return parent
; }
284 void SetParent( wxDataViewTreeNode
* parent
) { this->parent
= parent
; }
285 wxDataViewTreeNodes
& GetNodes() { return nodes
; }
286 wxDataViewTreeLeaves
& GetChildren() { return leaves
; }
288 void AddNode( wxDataViewTreeNode
* node
)
291 leaves
.Add( node
->GetItem().GetID() );
293 void AddLeaf( void * leaf
) { leaves
.Add( leaf
); }
295 wxDataViewItem
& GetItem() { return item
; }
296 void SetItem( const wxDataViewItem
& item
) { this->item
= item
; }
298 unsigned int GetChildrenNumber() { return leaves
.GetCount(); }
299 unsigned int GetNodeNumber() { return nodes
.GetCount(); }
303 wxDataViewTreeNode
* node
= this;
304 while( node
->GetParent()->GetParent() != NULL
)
306 node
= node
->GetParent();
319 int len
= nodes
.GetCount();
321 for ( int i
= 0 ;i
< len
; i
++)
322 sum
+= nodes
[i
]->GetSubTreeCount();
324 sum
+= leaves
.GetCount();
327 ChangeSubTreeCount(-sum
);
333 ChangeSubTreeCount(sum
);
336 bool HasChildren() { return hasChildren
; }
337 void SetHasChildren( bool has
){ hasChildren
= has
; }
339 void SetSubTreeCount( int num
) { subTreeCount
= num
; }
340 int GetSubTreeCount() { return subTreeCount
; }
341 void ChangeSubTreeCount( int num
)
347 parent
->ChangeSubTreeCount(num
);
352 wxDataViewTreeNodes nds
= nodes
;
353 wxDataViewTreeLeaves lvs
= leaves
;
357 int len
= nds
.GetCount();
361 for(i
= 0; i
< len
; i
++)
363 for(i
= 0; i
< len
; i
++)
367 len
= lvs
.GetCount();
370 for(int i
= 0; i
< len
; i
++)
376 wxDataViewTreeNode
* parent
;
377 wxDataViewTreeNodes nodes
;
378 wxDataViewTreeLeaves leaves
;
385 //Below is the compare stuff
386 //For the generic implements, both the leaf nodes and the nodes are sorted for fast search when needed
387 static wxDataViewModel
* g_model
;
389 int LINKAGEMODE
wxGenericTreeModelNodeCmp( wxDataViewTreeNode
* node1
, wxDataViewTreeNode
* node2
)
391 return g_model
->Compare( node1
->GetItem(), node2
->GetItem() );
394 int LINKAGEMODE
wxGenericTreeModelItemCmp( void * id1
, void * id2
)
396 return g_model
->Compare( id1
, id2
);
401 //-----------------------------------------------------------------------------
402 // wxDataViewMainWindow
403 //-----------------------------------------------------------------------------
405 WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection
,
407 WX_DECLARE_LIST(wxDataViewItem
, ItemList
);
408 WX_DEFINE_LIST(ItemList
);
410 class wxDataViewMainWindow
: public wxWindow
413 wxDataViewMainWindow( wxDataViewCtrl
*parent
,
415 const wxPoint
&pos
= wxDefaultPosition
,
416 const wxSize
&size
= wxDefaultSize
,
417 const wxString
&name
= wxT("wxdataviewctrlmainwindow") );
418 virtual ~wxDataViewMainWindow();
420 // notifications from wxDataViewModel
421 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
422 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
423 bool ItemChanged( const wxDataViewItem
&item
);
424 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
427 { g_model
= GetOwner()->GetModel(); m_root
->Resort(); UpdateDisplay(); }
429 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
430 wxDataViewCtrl
*GetOwner() { return m_owner
; }
431 const wxDataViewCtrl
*GetOwner() const { return m_owner
; }
433 void OnPaint( wxPaintEvent
&event
);
434 void OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
);
435 void OnChar( wxKeyEvent
&event
);
436 void OnMouse( wxMouseEvent
&event
);
437 void OnSetFocus( wxFocusEvent
&event
);
438 void OnKillFocus( wxFocusEvent
&event
);
440 void UpdateDisplay();
441 void RecalculateDisplay();
442 void OnInternalIdle();
444 void OnRenameTimer();
446 void ScrollWindow( int dx
, int dy
, const wxRect
*rect
= NULL
);
448 bool HasCurrentRow() { return m_currentRow
!= (unsigned int)-1; }
449 void ChangeCurrentRow( unsigned int row
);
451 bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE
); }
452 bool IsEmpty() { return GetRowCount() == 0; }
454 int GetCountPerPage() const;
455 int GetEndOfLastCol() const;
456 unsigned int GetFirstVisibleRow() const;
457 //I change this method to un const because in the tree view, the displaying number of the tree are changing along with the expanding/collapsing of the tree nodes
458 unsigned int GetLastVisibleRow();
459 unsigned int GetRowCount() ;
461 wxDataViewItem
GetSelection();
463 void Select( const wxArrayInt
& aSelections
);
464 void SelectAllRows( bool on
);
465 void SelectRow( unsigned int row
, bool on
);
466 void SelectRows( unsigned int from
, unsigned int to
, bool on
);
467 void ReverseRowSelection( unsigned int row
);
468 bool IsRowSelected( unsigned int row
);
470 void RefreshRow( unsigned int row
);
471 void RefreshRows( unsigned int from
, unsigned int to
);
472 void RefreshRowsAfter( unsigned int firstRow
);
474 // returns the colour to be used for drawing the rules
475 wxColour
GetRuleColour() const
477 return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
);
480 //void EnsureVisible( unsigned int row );
481 wxRect
GetLineRect( unsigned int row
) const;
483 //Some useful functions for row and item mapping
484 wxDataViewItem
GetItemByRow( unsigned int row
);
485 unsigned int GetRowByItem( const wxDataViewItem
& item
);
487 //Methods for building the mapping tree
488 void BuildTree( wxDataViewModel
* model
);
491 wxDataViewTreeNode
* GetTreeNodeByRow( unsigned int row
);
492 //We did not need this temporarily
493 //wxDataViewTreeNode * GetTreeNodeByItem( const wxDataViewItem & item );
495 int RecalculateCount() ;
497 void OnExpanding( unsigned int row
);
498 void OnCollapsing( unsigned int row
);
500 wxDataViewTreeNode
* FindNode( const wxDataViewItem
& item
);
503 wxDataViewCtrl
*m_owner
;
507 wxDataViewColumn
*m_currentCol
;
508 unsigned int m_currentRow
;
509 wxDataViewSelection m_selection
;
511 wxDataViewRenameTimer
*m_renameTimer
;
519 // for double click logic
520 unsigned int m_lineLastClicked
,
521 m_lineBeforeLastClicked
,
522 m_lineSelectSingleOnUp
;
524 // the pen used to draw horiz/vertical rules
527 // the pen used to draw the expander and the lines
530 //This is the tree structure of the model
531 wxDataViewTreeNode
* m_root
;
534 DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow
)
535 DECLARE_EVENT_TABLE()
538 // ---------------------------------------------------------
539 // wxGenericDataViewModelNotifier
540 // ---------------------------------------------------------
542 class wxGenericDataViewModelNotifier
: public wxDataViewModelNotifier
545 wxGenericDataViewModelNotifier( wxDataViewMainWindow
*mainWindow
)
546 { m_mainWindow
= mainWindow
; }
548 virtual bool ItemAdded( const wxDataViewItem
& parent
, const wxDataViewItem
& item
)
549 { return m_mainWindow
->ItemAdded( parent
, item
); }
550 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
551 { return m_mainWindow
->ItemDeleted( parent
, item
); }
552 virtual bool ItemChanged( const wxDataViewItem
& item
)
553 { return m_mainWindow
->ItemChanged(item
); }
554 virtual bool ValueChanged( const wxDataViewItem
& item
, unsigned int col
)
555 { return m_mainWindow
->ValueChanged( item
, col
); }
556 virtual bool Cleared()
557 { return m_mainWindow
->Cleared(); }
558 virtual void Resort()
559 { m_mainWindow
->Resort(); }
561 wxDataViewMainWindow
*m_mainWindow
;
564 // ---------------------------------------------------------
565 // wxDataViewRenderer
566 // ---------------------------------------------------------
568 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
570 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
,
571 wxDataViewCellMode mode
,
573 wxDataViewRendererBase( varianttype
, mode
, align
)
580 wxDataViewRenderer::~wxDataViewRenderer()
586 wxDC
*wxDataViewRenderer::GetDC()
590 if (GetOwner() == NULL
)
592 if (GetOwner()->GetOwner() == NULL
)
594 m_dc
= new wxClientDC( GetOwner()->GetOwner() );
600 // ---------------------------------------------------------
601 // wxDataViewCustomRenderer
602 // ---------------------------------------------------------
604 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
606 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
607 wxDataViewCellMode mode
, int align
) :
608 wxDataViewRenderer( varianttype
, mode
, align
)
612 // ---------------------------------------------------------
613 // wxDataViewTextRenderer
614 // ---------------------------------------------------------
616 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewCustomRenderer
)
618 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
,
619 wxDataViewCellMode mode
, int align
) :
620 wxDataViewCustomRenderer( varianttype
, mode
, align
)
624 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
626 m_text
= value
.GetString();
631 bool wxDataViewTextRenderer::GetValue( wxVariant
& WXUNUSED(value
) ) const
636 bool wxDataViewTextRenderer::HasEditorCtrl()
641 wxControl
* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow
*parent
,
642 wxRect labelRect
, const wxVariant
&value
)
644 return new wxTextCtrl( parent
, wxID_ANY
, value
,
645 wxPoint(labelRect
.x
,labelRect
.y
),
646 wxSize(labelRect
.width
,labelRect
.height
) );
649 bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxControl
*editor
, wxVariant
&value
)
651 wxTextCtrl
*text
= (wxTextCtrl
*) editor
;
652 value
= text
->GetValue();
656 bool wxDataViewTextRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
658 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
659 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ?
660 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) :
661 view
->GetForegroundColour();
663 dc
->SetTextForeground(col
);
664 dc
->DrawText( m_text
, cell
.x
, cell
.y
);
669 wxSize
wxDataViewTextRenderer::GetSize() const
671 const wxDataViewCtrl
*view
= GetView();
675 view
->GetTextExtent( m_text
, &x
, &y
);
676 return wxSize( x
, y
);
678 return wxSize(80,20);
681 // ---------------------------------------------------------
682 // wxDataViewBitmapRenderer
683 // ---------------------------------------------------------
685 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewCustomRenderer
)
687 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
,
688 wxDataViewCellMode mode
, int align
) :
689 wxDataViewCustomRenderer( varianttype
, mode
, align
)
693 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
695 if (value
.GetType() == wxT("wxBitmap"))
697 if (value
.GetType() == wxT("wxIcon"))
703 bool wxDataViewBitmapRenderer::GetValue( wxVariant
& WXUNUSED(value
) ) const
708 bool wxDataViewBitmapRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
711 dc
->DrawBitmap( m_bitmap
, cell
.x
, cell
.y
);
712 else if (m_icon
.Ok())
713 dc
->DrawIcon( m_icon
, cell
.x
, cell
.y
);
718 wxSize
wxDataViewBitmapRenderer::GetSize() const
721 return wxSize( m_bitmap
.GetWidth(), m_bitmap
.GetHeight() );
722 else if (m_icon
.Ok())
723 return wxSize( m_icon
.GetWidth(), m_icon
.GetHeight() );
725 return wxSize(16,16);
728 // ---------------------------------------------------------
729 // wxDataViewToggleRenderer
730 // ---------------------------------------------------------
732 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
, wxDataViewCustomRenderer
)
734 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
735 wxDataViewCellMode mode
, int align
) :
736 wxDataViewCustomRenderer( varianttype
, mode
, align
)
741 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
743 m_toggle
= value
.GetBool();
748 bool wxDataViewToggleRenderer::GetValue( wxVariant
&WXUNUSED(value
) ) const
753 bool wxDataViewToggleRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
755 // User wxRenderer here
758 rect
.x
= cell
.x
+ cell
.width
/2 - 10;
760 rect
.y
= cell
.y
+ cell
.height
/2 - 10;
765 flags
|= wxCONTROL_CHECKED
;
766 if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE
)
767 flags
|= wxCONTROL_DISABLED
;
769 wxRendererNative::Get().DrawCheckBox(
770 GetOwner()->GetOwner(),
778 bool wxDataViewToggleRenderer::Activate( wxRect
WXUNUSED(cell
),
779 wxDataViewModel
*model
,
780 const wxDataViewItem
& item
, unsigned int col
)
782 bool value
= !m_toggle
;
783 wxVariant variant
= value
;
784 model
->SetValue( variant
, item
, col
);
785 model
->ValueChanged( item
, col
);
789 wxSize
wxDataViewToggleRenderer::GetSize() const
791 return wxSize(20,20);
794 // ---------------------------------------------------------
795 // wxDataViewProgressRenderer
796 // ---------------------------------------------------------
798 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
800 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
801 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
802 wxDataViewCustomRenderer( varianttype
, mode
, align
)
808 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
812 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
814 m_value
= (long) value
;
816 if (m_value
< 0) m_value
= 0;
817 if (m_value
> 100) m_value
= 100;
822 bool wxDataViewProgressRenderer::GetValue( wxVariant
&value
) const
824 value
= (long) m_value
;
828 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
830 double pct
= (double)m_value
/ 100.0;
832 bar
.width
= (int)(cell
.width
* pct
);
833 dc
->SetPen( *wxTRANSPARENT_PEN
);
834 dc
->SetBrush( *wxBLUE_BRUSH
);
835 dc
->DrawRectangle( bar
);
837 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
838 dc
->SetPen( *wxBLACK_PEN
);
839 dc
->DrawRectangle( cell
);
844 wxSize
wxDataViewProgressRenderer::GetSize() const
846 return wxSize(40,12);
849 // ---------------------------------------------------------
850 // wxDataViewDateRenderer
851 // ---------------------------------------------------------
853 #define wxUSE_DATE_RENDERER_POPUP (wxUSE_CALENDARCTRL && wxUSE_POPUPWIN)
855 #if wxUSE_DATE_RENDERER_POPUP
857 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
860 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
861 wxDataViewModel
*model
, const wxDataViewItem
& item
, unsigned int col
) :
862 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
),
867 m_cal
= new wxCalendarCtrl( this, wxID_ANY
, *value
);
868 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
869 sizer
->Add( m_cal
, 1, wxGROW
);
874 void OnCalendar( wxCalendarEvent
&event
);
876 wxCalendarCtrl
*m_cal
;
877 wxDataViewModel
*m_model
;
879 const wxDataViewItem
& m_item
;
882 virtual void OnDismiss()
887 DECLARE_EVENT_TABLE()
890 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
891 EVT_CALENDAR( wxID_ANY
, wxDataViewDateRendererPopupTransient::OnCalendar
)
894 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
896 wxDateTime date
= event
.GetDate();
897 wxVariant value
= date
;
898 m_model
->SetValue( value
, m_item
, m_col
);
899 m_model
->ValueChanged( m_item
, m_col
);
903 #endif // wxUSE_DATE_RENDERER_POPUP
905 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
907 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
908 wxDataViewCellMode mode
, int align
) :
909 wxDataViewCustomRenderer( varianttype
, mode
, align
)
913 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
915 m_date
= value
.GetDateTime();
920 bool wxDataViewDateRenderer::GetValue( wxVariant
&value
) const
926 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
928 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
929 wxString tmp
= m_date
.FormatDate();
930 dc
->DrawText( tmp
, cell
.x
, cell
.y
);
935 wxSize
wxDataViewDateRenderer::GetSize() const
937 const wxDataViewCtrl
* view
= GetView();
938 wxString tmp
= m_date
.FormatDate();
940 view
->GetTextExtent( tmp
, &x
, &y
, &d
);
941 return wxSize(x
,y
+d
);
944 bool wxDataViewDateRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewModel
*model
,
945 const wxDataViewItem
& item
, unsigned int col
)
948 model
->GetValue( variant
, item
, col
);
949 wxDateTime value
= variant
.GetDateTime();
951 #if wxUSE_DATE_RENDERER_POPUP
952 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
953 GetOwner()->GetOwner()->GetParent(), &value
, model
, item
, col
);
954 wxPoint pos
= wxGetMousePosition();
957 popup
->Popup( popup
->m_cal
);
958 #else // !wxUSE_DATE_RENDERER_POPUP
959 wxMessageBox(value
.Format());
960 #endif // wxUSE_DATE_RENDERER_POPUP/!wxUSE_DATE_RENDERER_POPUP
964 // ---------------------------------------------------------
966 // ---------------------------------------------------------
968 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
970 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
,
971 unsigned int model_column
,
972 int width
, wxAlignment align
, int flags
) :
973 wxDataViewColumnBase( title
, cell
, model_column
, width
, align
, flags
)
979 Init(width
< 0 ? wxDVC_DEFAULT_WIDTH
: width
);
982 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
,
983 unsigned int model_column
,
984 int width
, wxAlignment align
, int flags
) :
985 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, align
, flags
)
990 Init(width
< 0 ? wxDVC_TOGGLE_DEFAULT_WIDTH
: width
);
993 wxDataViewColumn::~wxDataViewColumn()
997 void wxDataViewColumn::Init( int width
)
1000 m_minWidth
= wxDVC_DEFAULT_MINWIDTH
;
1004 void wxDataViewColumn::SetResizeable( bool resizeable
)
1007 m_flags
|= wxDATAVIEW_COL_RESIZABLE
;
1009 m_flags
&= ~wxDATAVIEW_COL_RESIZABLE
;
1012 void wxDataViewColumn::SetHidden( bool hidden
)
1015 m_flags
|= wxDATAVIEW_COL_HIDDEN
;
1017 m_flags
&= ~wxDATAVIEW_COL_HIDDEN
;
1019 // tell our owner to e.g. update its scrollbars:
1021 GetOwner()->OnColumnChange();
1024 void wxDataViewColumn::SetSortable( bool sortable
)
1027 m_flags
|= wxDATAVIEW_COL_SORTABLE
;
1029 m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
1031 // Update header button
1033 GetOwner()->OnColumnChange();
1036 void wxDataViewColumn::SetSortOrder( bool ascending
)
1038 m_ascending
= ascending
;
1040 // Update header button
1042 GetOwner()->OnColumnChange();
1045 bool wxDataViewColumn::IsSortOrderAscending() const
1050 void wxDataViewColumn::SetInternalWidth( int width
)
1054 // the scrollbars of the wxDataViewCtrl needs to be recalculated!
1055 if (m_owner
&& m_owner
->m_clientArea
)
1056 m_owner
->m_clientArea
->RecalculateDisplay();
1059 void wxDataViewColumn::SetWidth( int width
)
1061 m_owner
->m_headerArea
->UpdateDisplay();
1063 SetInternalWidth(width
);
1067 //-----------------------------------------------------------------------------
1068 // wxDataViewHeaderWindowBase
1069 //-----------------------------------------------------------------------------
1071 void wxDataViewHeaderWindowBase::SendEvent(wxEventType type
, unsigned int n
)
1073 wxWindow
*parent
= GetParent();
1074 wxDataViewEvent
le(type
, parent
->GetId());
1076 le
.SetEventObject(parent
);
1078 le
.SetDataViewColumn(GetColumn(n
));
1079 le
.SetModel(GetOwner()->GetModel());
1081 // for events created by wxDataViewHeaderWindow the
1082 // row / value fields are not valid
1084 parent
->GetEventHandler()->ProcessEvent(le
);
1087 #if defined(__WXMSW__) && USE_NATIVE_HEADER_WINDOW
1089 // implemented in msw/listctrl.cpp:
1090 int WXDLLIMPEXP_CORE
wxMSWGetColumnClicked(NMHDR
*nmhdr
, POINT
*ptClick
);
1092 IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindowMSW
, wxWindow
)
1094 bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl
*parent
, wxWindowID id
,
1095 const wxPoint
&pos
, const wxSize
&size
,
1096 const wxString
&name
)
1100 if ( !CreateControl(parent
, id
, pos
, size
, 0, wxDefaultValidator
, name
) )
1103 int x
= pos
.x
== wxDefaultCoord
? 0 : pos
.x
,
1104 y
= pos
.y
== wxDefaultCoord
? 0 : pos
.y
,
1105 w
= size
.x
== wxDefaultCoord
? 1 : size
.x
,
1106 h
= size
.y
== wxDefaultCoord
? 22 : size
.y
;
1108 // create the native WC_HEADER window:
1109 WXHWND hwndParent
= (HWND
)parent
->GetHandle();
1110 WXDWORD msStyle
= WS_CHILD
| HDS_BUTTONS
| HDS_HORZ
| HDS_HOTTRACK
| HDS_FULLDRAG
;
1111 m_hWnd
= CreateWindowEx(0,
1122 wxLogLastError(_T("CreateWindowEx"));
1126 // we need to subclass the m_hWnd to force wxWindow::HandleNotify
1127 // to call wxDataViewHeaderWindow::MSWOnNotify
1128 SubclassWin(m_hWnd
);
1130 // the following is required to get the default win's font for
1131 // header windows and must be done befor sending the HDM_LAYOUT msg
1138 // Retrieve the bounding rectangle of the parent window's
1139 // client area, and then request size and position values
1140 // from the header control.
1141 ::GetClientRect((HWND
)hwndParent
, &rcParent
);
1143 hdl
.prc
= &rcParent
;
1145 if (!SendMessage((HWND
)m_hWnd
, HDM_LAYOUT
, 0, (LPARAM
) &hdl
))
1147 wxLogLastError(_T("SendMessage"));
1151 // Set the size, position, and visibility of the header control.
1152 SetWindowPos((HWND
)m_hWnd
,
1156 wp
.flags
| SWP_SHOWWINDOW
);
1158 // set our size hints: wxDataViewCtrl will put this wxWindow inside
1159 // a wxBoxSizer and in order to avoid super-big header windows,
1160 // we need to set our height as fixed
1161 SetMinSize(wxSize(-1, wp
.cy
));
1162 SetMaxSize(wxSize(-1, wp
.cy
));
1167 wxDataViewHeaderWindowMSW::~wxDataViewHeaderWindow()
1172 void wxDataViewHeaderWindowMSW::UpdateDisplay()
1174 // remove old columns
1175 for (int j
=0, max
=Header_GetItemCount((HWND
)m_hWnd
); j
< max
; j
++)
1176 Header_DeleteItem((HWND
)m_hWnd
, 0);
1178 // add the updated array of columns to the header control
1179 unsigned int cols
= GetOwner()->GetColumnCount();
1180 unsigned int added
= 0;
1181 wxDataViewModel
* model
= GetOwner()->GetModel();
1182 for (unsigned int i
= 0; i
< cols
; i
++)
1184 wxDataViewColumn
*col
= GetColumn( i
);
1185 if (col
->IsHidden())
1186 continue; // don't add it!
1189 hdi
.mask
= HDI_TEXT
| HDI_FORMAT
| HDI_WIDTH
;
1190 hdi
.pszText
= (wxChar
*) col
->GetTitle().wx_str();
1191 hdi
.cxy
= col
->GetWidth();
1192 hdi
.cchTextMax
= sizeof(hdi
.pszText
)/sizeof(hdi
.pszText
[0]);
1193 hdi
.fmt
= HDF_LEFT
| HDF_STRING
;
1195 // lParam is reserved for application's use:
1196 // we store there the column index to use it later in MSWOnNotify
1197 // (since columns may have been hidden)
1198 hdi
.lParam
= (LPARAM
)i
;
1200 // the native wxMSW implementation of the header window
1201 // draws the column separator COLUMN_WIDTH_OFFSET pixels
1202 // on the right: to correct this effect we make the column
1203 // exactly COLUMN_WIDTH_OFFSET wider (for the first column):
1205 hdi
.cxy
+= COLUMN_WIDTH_OFFSET
;
1207 switch (col
->GetAlignment())
1210 hdi
.fmt
|= HDF_LEFT
;
1212 case wxALIGN_CENTER
:
1213 case wxALIGN_CENTER_HORIZONTAL
:
1214 hdi
.fmt
|= HDF_CENTER
;
1217 hdi
.fmt
|= HDF_RIGHT
;
1221 // such alignment is not allowed for the column header!
1225 SendMessage((HWND
)m_hWnd
, HDM_INSERTITEM
,
1226 (WPARAM
)added
, (LPARAM
)&hdi
);
1231 unsigned int wxDataViewHeaderWindowMSW::GetColumnIdxFromHeader(NMHEADER
*nmHDR
)
1235 // NOTE: we don't just return nmHDR->iItem because when there are
1236 // hidden columns, nmHDR->iItem may be different from
1237 // nmHDR->pitem->lParam
1239 if (nmHDR
->pitem
&& nmHDR
->pitem
->mask
& HDI_LPARAM
)
1241 idx
= (unsigned int)nmHDR
->pitem
->lParam
;
1246 item
.mask
= HDI_LPARAM
;
1247 Header_GetItem((HWND
)m_hWnd
, nmHDR
->iItem
, &item
);
1249 return (unsigned int)item
.lParam
;
1252 bool wxDataViewHeaderWindowMSW::MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
1254 NMHDR
*nmhdr
= (NMHDR
*)lParam
;
1256 // is it a message from the header?
1257 if ( nmhdr
->hwndFrom
!= (HWND
)m_hWnd
)
1258 return wxWindow::MSWOnNotify(idCtrl
, lParam
, result
);
1260 NMHEADER
*nmHDR
= (NMHEADER
*)nmhdr
;
1261 switch ( nmhdr
->code
)
1263 case HDN_BEGINTRACK
:
1264 // user has started to resize a column:
1265 // do we need to veto it?
1266 if (!GetColumn(nmHDR
->iItem
)->IsResizeable())
1274 // user has started to reorder a column
1277 case HDN_ITEMCHANGING
:
1278 if (nmHDR
->pitem
!= NULL
&&
1279 (nmHDR
->pitem
->mask
& HDI_WIDTH
) != 0)
1281 int minWidth
= GetColumnFromHeader(nmHDR
)->GetMinWidth();
1282 if (nmHDR
->pitem
->cxy
< minWidth
)
1284 // do not allow the user to resize this column under
1285 // its minimal width:
1291 case HDN_ITEMCHANGED
: // user is resizing a column
1292 case HDN_ENDTRACK
: // user has finished resizing a column
1293 case HDN_ENDDRAG
: // user has finished reordering a column
1295 // update the width of the modified column:
1296 if (nmHDR
->pitem
!= NULL
&&
1297 (nmHDR
->pitem
->mask
& HDI_WIDTH
) != 0)
1299 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1300 unsigned int w
= nmHDR
->pitem
->cxy
;
1301 wxDataViewColumn
*col
= GetColumn(idx
);
1303 // see UpdateDisplay() for more info about COLUMN_WIDTH_OFFSET
1304 if (idx
== 0 && w
> COLUMN_WIDTH_OFFSET
)
1305 w
-= COLUMN_WIDTH_OFFSET
;
1307 if (w
>= (unsigned)col
->GetMinWidth())
1308 col
->SetInternalWidth(w
);
1314 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1315 wxDataViewModel
* model
= GetOwner()->GetModel();
1317 if(nmHDR
->iButton
== 0)
1319 wxDataViewColumn
*col
= GetColumn(idx
);
1320 if(col
->IsSortable())
1322 if(model
&& model
->GetSortingColumn() == idx
)
1324 bool order
= col
->IsSortOrderAscending();
1325 col
->SetSortOrder(!order
);
1326 model
->SetSortOrderAscending(!order
);
1330 model
->SetSortingColumn(idx
);
1331 model
->SetSortOrderAscending(true);
1339 wxEventType evt
= nmHDR
->iButton
== 0 ?
1340 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
:
1341 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
1342 SendEvent(evt
, idx
);
1348 // NOTE: for some reason (i.e. for a bug in Windows)
1349 // the HDN_ITEMCLICK notification is not sent on
1350 // right clicks, so we need to handle NM_RCLICK
1353 int column
= wxMSWGetColumnClicked(nmhdr
, &ptClick
);
1354 if (column
!= wxNOT_FOUND
)
1357 item
.mask
= HDI_LPARAM
;
1358 Header_GetItem((HWND
)m_hWnd
, column
, &item
);
1360 // 'idx' may be different from 'column' if there are
1361 // hidden columns...
1362 unsigned int idx
= (unsigned int)item
.lParam
;
1363 SendEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
,
1369 case HDN_GETDISPINFOW
:
1370 // see wxListCtrl::MSWOnNotify for more info!
1373 case HDN_ITEMDBLCLICK
:
1375 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1376 int w
= GetOwner()->GetBestColumnWidth(idx
);
1378 // update the native control:
1380 ZeroMemory(&hd
, sizeof(hd
));
1381 hd
.mask
= HDI_WIDTH
;
1383 Header_SetItem(GetHwnd(),
1384 nmHDR
->iItem
, // NOTE: we don't want 'idx' here!
1387 // update the wxDataViewColumn class:
1388 GetColumn(idx
)->SetInternalWidth(w
);
1393 return wxWindow::MSWOnNotify(idCtrl
, lParam
, result
);
1399 void wxDataViewHeaderWindowMSW::ScrollWindow(int WXUNUSED(dx
), int WXUNUSED(dy
),
1400 const wxRect
*WXUNUSED(rect
))
1402 wxSize ourSz
= GetClientSize();
1403 wxSize ownerSz
= m_owner
->GetClientSize();
1405 // where should the (logical) origin of this window be placed?
1407 m_owner
->CalcUnscrolledPosition(0, 0, &x1
, &y1
);
1409 // put this window on top of our parent and
1410 SetWindowPos((HWND
)m_hWnd
, HWND_TOP
, -x1
, 0,
1411 ownerSz
.GetWidth() + x1
, ourSz
.GetHeight(),
1415 void wxDataViewHeaderWindowMSW::DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
1416 int WXUNUSED(w
), int WXUNUSED(h
),
1419 // the wxDataViewCtrl's internal wxBoxSizer will call this function when
1420 // the wxDataViewCtrl window gets resized: the following dummy call
1421 // to ScrollWindow() is required in order to get this header window
1422 // correctly repainted when it's (horizontally) scrolled:
1427 #else // !defined(__WXMSW__)
1429 IMPLEMENT_ABSTRACT_CLASS(wxGenericDataViewHeaderWindow
, wxWindow
)
1430 BEGIN_EVENT_TABLE(wxGenericDataViewHeaderWindow
, wxWindow
)
1431 EVT_PAINT (wxGenericDataViewHeaderWindow::OnPaint
)
1432 EVT_MOUSE_EVENTS (wxGenericDataViewHeaderWindow::OnMouse
)
1433 EVT_SET_FOCUS (wxGenericDataViewHeaderWindow::OnSetFocus
)
1436 bool wxGenericDataViewHeaderWindow::Create(wxDataViewCtrl
*parent
, wxWindowID id
,
1437 const wxPoint
&pos
, const wxSize
&size
,
1438 const wxString
&name
)
1442 if (!wxDataViewHeaderWindowBase::Create(parent
, id
, pos
, size
, name
))
1445 wxVisualAttributes attr
= wxPanel::GetClassDefaultAttributes();
1446 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
1447 SetOwnForegroundColour( attr
.colFg
);
1448 SetOwnBackgroundColour( attr
.colBg
);
1450 SetOwnFont( attr
.font
);
1452 // set our size hints: wxDataViewCtrl will put this wxWindow inside
1453 // a wxBoxSizer and in order to avoid super-big header windows,
1454 // we need to set our height as fixed
1455 SetMinSize(wxSize(-1, HEADER_WINDOW_HEIGHT
));
1456 SetMaxSize(wxSize(-1, HEADER_WINDOW_HEIGHT
));
1461 void wxGenericDataViewHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1464 GetClientSize( &w
, &h
);
1466 wxAutoBufferedPaintDC
dc( this );
1468 dc
.SetBackground(GetBackgroundColour());
1472 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
1475 m_owner
->GetViewStart( &x
, NULL
);
1477 // account for the horz scrollbar offset
1478 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
1480 dc
.SetFont( GetFont() );
1482 unsigned int cols
= GetOwner()->GetColumnCount();
1485 for (i
= 0; i
< cols
; i
++)
1487 wxDataViewColumn
*col
= GetColumn( i
);
1488 if (col
->IsHidden())
1489 continue; // skip it!
1491 int cw
= col
->GetWidth();
1494 wxHeaderSortIconType sortArrow
= wxHDR_SORT_ICON_NONE
;
1495 if (col
->IsSortable())
1497 if (col
->IsSortOrderAscending())
1498 sortArrow
= wxHDR_SORT_ICON_UP
;
1500 sortArrow
= wxHDR_SORT_ICON_DOWN
;
1503 wxRendererNative::Get().DrawHeaderButton
1507 wxRect(xpos
, 0, cw
, ch
-1),
1508 m_parent
->IsEnabled() ? 0
1509 : (int)wxCONTROL_DISABLED
,
1513 // align as required the column title:
1515 wxSize titleSz
= dc
.GetTextExtent(col
->GetTitle());
1516 switch (col
->GetAlignment())
1519 x
+= HEADER_HORIZ_BORDER
;
1521 case wxALIGN_CENTER
:
1522 case wxALIGN_CENTER_HORIZONTAL
:
1523 x
+= (cw
- titleSz
.GetWidth() - 2 * HEADER_HORIZ_BORDER
)/2;
1526 x
+= cw
- titleSz
.GetWidth() - HEADER_HORIZ_BORDER
;
1530 // always center the title vertically:
1531 int y
= wxMax((ch
- titleSz
.GetHeight()) / 2, HEADER_VERT_BORDER
);
1533 dc
.SetClippingRegion( xpos
+HEADER_HORIZ_BORDER
,
1535 wxMax(cw
- 2 * HEADER_HORIZ_BORDER
, 1), // width
1536 wxMax(ch
- 2 * HEADER_VERT_BORDER
, 1)); // height
1537 dc
.DrawText( col
->GetTitle(), x
, y
);
1538 dc
.DestroyClippingRegion();
1544 void wxGenericDataViewHeaderWindow::OnSetFocus( wxFocusEvent
&event
)
1546 GetParent()->SetFocus();
1550 void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent
&event
)
1552 // we want to work with logical coords
1554 m_owner
->CalcUnscrolledPosition(event
.GetX(), 0, &x
, NULL
);
1555 int y
= event
.GetY();
1559 // we don't draw the line beyond our window,
1560 // but we allow dragging it there
1562 GetClientSize( &w
, NULL
);
1563 m_owner
->CalcUnscrolledPosition(w
, 0, &w
, NULL
);
1566 // erase the line if it was drawn
1570 if (event
.ButtonUp())
1572 m_isDragging
= false;
1578 GetColumn(m_column
)->SetWidth(m_currentX
- m_minX
);
1581 GetOwner()->Refresh();
1585 m_currentX
= wxMax(m_minX
+ 7, x
);
1587 // draw in the new location
1588 if (m_currentX
< w
) DrawCurrent();
1592 else // not dragging
1595 m_column
= wxNOT_FOUND
;
1597 bool hit_border
= false;
1599 // end of the current column
1602 // find the column where this event occured
1603 int countCol
= m_owner
->GetColumnCount();
1604 for (int column
= 0; column
< countCol
; column
++)
1606 wxDataViewColumn
*p
= GetColumn(column
);
1609 continue; // skip if not shown
1611 xpos
+= p
->GetWidth();
1613 if ((abs(x
-xpos
) < 3) && (y
< 22))
1621 // inside the column
1628 if (m_column
== wxNOT_FOUND
)
1631 bool resizeable
= GetColumn(m_column
)->IsResizeable();
1632 if (event
.LeftDClick() && resizeable
)
1634 GetColumn(m_column
)->SetWidth(GetOwner()->GetBestColumnWidth(m_column
));
1637 else if (event
.LeftDown() || event
.RightUp())
1639 if (hit_border
&& event
.LeftDown() && resizeable
)
1641 m_isDragging
= true;
1646 else // click on a column
1648 wxEventType evt
= event
.LeftDown() ?
1649 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
:
1650 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
1651 SendEvent(evt
, m_column
);
1654 else if (event
.Moving())
1656 if (hit_border
&& resizeable
)
1657 m_currentCursor
= m_resizeCursor
;
1659 m_currentCursor
= wxSTANDARD_CURSOR
;
1661 SetCursor(*m_currentCursor
);
1666 void wxGenericDataViewHeaderWindow::DrawCurrent()
1668 int x1
= m_currentX
;
1670 ClientToScreen (&x1
, &y1
);
1672 int x2
= m_currentX
-1;
1674 ++x2
; // but why ????
1677 m_owner
->GetClientSize( NULL
, &y2
);
1678 m_owner
->ClientToScreen( &x2
, &y2
);
1681 dc
.SetLogicalFunction(wxINVERT
);
1682 dc
.SetPen(m_penCurrent
);
1683 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1685 dc
.DrawLine(x1
, y1
, x2
, y2
);
1688 void wxGenericDataViewHeaderWindow::AdjustDC(wxDC
& dc
)
1692 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
1693 m_owner
->GetViewStart( &x
, NULL
);
1695 // shift the DC origin to match the position of the main window horizontal
1696 // scrollbar: this allows us to always use logical coords
1697 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
1700 #endif // defined(__WXMSW__)
1702 //-----------------------------------------------------------------------------
1703 // wxDataViewRenameTimer
1704 //-----------------------------------------------------------------------------
1706 wxDataViewRenameTimer::wxDataViewRenameTimer( wxDataViewMainWindow
*owner
)
1711 void wxDataViewRenameTimer::Notify()
1713 m_owner
->OnRenameTimer();
1716 //-----------------------------------------------------------------------------
1717 // wxDataViewMainWindow
1718 //-----------------------------------------------------------------------------
1720 //The tree building helper, declared firstly
1721 void BuildTreeHelper( wxDataViewModel
* model
, wxDataViewItem
& item
, wxDataViewTreeNode
* node
);
1723 int LINKAGEMODE
wxDataViewSelectionCmp( unsigned int row1
, unsigned int row2
)
1725 if (row1
> row2
) return 1;
1726 if (row1
== row2
) return 0;
1731 IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow
, wxWindow
)
1733 BEGIN_EVENT_TABLE(wxDataViewMainWindow
,wxWindow
)
1734 EVT_PAINT (wxDataViewMainWindow::OnPaint
)
1735 EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse
)
1736 EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus
)
1737 EVT_KILL_FOCUS (wxDataViewMainWindow::OnKillFocus
)
1738 EVT_CHAR (wxDataViewMainWindow::OnChar
)
1741 wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
1742 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
1743 wxWindow( parent
, id
, pos
, size
, wxWANTS_CHARS
, name
),
1744 m_selection( wxDataViewSelectionCmp
)
1749 m_lastOnSame
= false;
1750 m_renameTimer
= new wxDataViewRenameTimer( this );
1752 // TODO: user better initial values/nothing selected
1753 m_currentCol
= NULL
;
1756 // TODO: we need to calculate this smartly
1763 wxASSERT(m_lineHeight
> 2*PADDING_TOPBOTTOM
);
1766 m_dragStart
= wxPoint(0,0);
1767 m_lineLastClicked
= (unsigned int) -1;
1768 m_lineBeforeLastClicked
= (unsigned int) -1;
1769 m_lineSelectSingleOnUp
= (unsigned int) -1;
1773 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
1774 SetBackgroundColour( *wxWHITE
);
1776 m_penRule
= wxPen(GetRuleColour(), 1, wxSOLID
);
1778 //Here I compose a pen can draw black lines, maybe there are something system colour to use
1779 m_penExpander
= wxPen( wxColour(0,0,0), 1, wxSOLID
);
1780 //Some new added code to deal with the tree structure
1781 m_root
= new wxDataViewTreeNode( NULL
);
1782 m_root
->SetHasChildren(true);
1784 //Make m_count = -1 will cause the class recaculate the real displaying number of rows.
1789 wxDataViewMainWindow::~wxDataViewMainWindow()
1792 delete m_renameTimer
;
1795 void wxDataViewMainWindow::OnRenameTimer()
1797 // We have to call this here because changes may just have
1798 // been made and no screen update taken place.
1803 unsigned int cols
= GetOwner()->GetColumnCount();
1805 for (i
= 0; i
< cols
; i
++)
1807 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1809 continue; // skip it!
1811 if (c
== m_currentCol
)
1813 xpos
+= c
->GetWidth();
1815 wxRect
labelRect( xpos
, m_currentRow
* m_lineHeight
,
1816 m_currentCol
->GetWidth(), m_lineHeight
);
1818 GetOwner()->CalcScrolledPosition( labelRect
.x
, labelRect
.y
,
1819 &labelRect
.x
, &labelRect
.y
);
1821 wxDataViewItem item
= GetItemByRow( m_currentRow
);
1822 m_currentCol
->GetRenderer()->StartEditing( item
, labelRect
);
1825 //------------------------------------------------------------------
1826 // Helper class for do operation on the tree node
1827 //------------------------------------------------------------------
1834 //The return value control how the tree-walker tranverse the tree
1835 // 0: Job done, stop tranverse and return
1836 // 1: Ignore the current node's subtree and continue
1837 // 2: Job not done, continue
1838 enum { OK
= 0 , IGR
= 1, CONT
= 2 };
1839 virtual int operator() ( wxDataViewTreeNode
* node
) = 0 ;
1840 virtual int operator() ( void * n
) = 0;
1844 class ItemAddJob
: public DoJob
1847 ItemAddJob( const wxDataViewItem
& parent
, const wxDataViewItem
& item
, int * count
)
1848 { this->parent
= parent
; this->item
= item
; m_count
= count
; }
1849 virtual ~ItemAddJob(){};
1851 virtual int operator() ( wxDataViewTreeNode
* node
)
1853 if( node
->GetItem() == parent
)
1855 node
->SetHasChildren( true );
1856 wxDataViewTreeNode
* newnode
= new wxDataViewTreeNode( node
);
1857 newnode
->SetItem(item
);
1858 node
->AppendChild( newnode
);
1867 wxDataViewItem parent
, item
;
1871 bool Walker( wxDataViewTreeNode
* node
, DoJob
& func
)
1873 if( node
==NULL
|| !node
->HasChildren())
1876 wxDataViewTreeNodes nodes
= node
->GetNodes();
1877 wxDataViewTreeLeaves leaves
= node
->GetChildren();
1879 int len_nodes
= nodes
.GetCount();
1880 int len
= leaves
.GetCount();
1881 int i
= 0, nodes_i
= 0;
1882 for( ; i
< len
; i
++ )
1884 void * n
= leaves
[i
];
1885 if( nodes_i
< len_nodes
&& n
== nodes
[nodes_i
]->GetItem().GetID() )
1887 wxDataViewTreeNode
* nd
= nodes
[nodes_i
];
1890 switch( func( nd
) )
1901 if( Walker( nd
, func
) )
1920 bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem
& parent
, const wxDataViewItem
& item
)
1922 g_model
= GetOwner()->GetModel();
1924 wxDataViewTreeNode
* node
;
1925 node
= FindNode(parent
);
1930 node
->SetHasChildren( true );
1932 if( g_model
->IsContainer( item
) )
1934 wxDataViewTreeNode
* newnode
= new wxDataViewTreeNode( node
);
1935 newnode
->SetItem(item
);
1936 node
->AddNode( newnode
);
1939 node
->AddLeaf( item
.GetID() );
1941 node
->ChangeSubTreeCount(1);
1949 class ItemDeleteJob
: public DoJob
1952 ItemDeleteJob( const wxDataViewItem
& item
, int * count
) { m_item
= item
; m_count
= count
; }
1953 virtual ~ItemDeleteJob(){}
1954 virtual int operator() ( wxDataViewTreeNode
* node
)
1956 if( node
->GetItem() == m_item
)
1958 node
->GetParent()->GetChildren().Remove( node
);
1968 wxDataViewItem m_item
;
1972 void DestroyTreeHelper( wxDataViewTreeNode
* node
);
1974 bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem
& parent
,
1975 const wxDataViewItem
& item
)
1977 g_model
= GetOwner()->GetModel();
1979 wxDataViewTreeNode
* node
;
1980 node
= FindNode(parent
);
1982 if( node
== NULL
|| node
->GetChildren().Index( item
.GetID() ) == wxNOT_FOUND
)
1988 node
->GetChildren().Remove( item
.GetID() );
1989 if( GetOwner()->GetModel()->IsContainer( item
) )
1991 wxDataViewTreeNode
* n
= NULL
;
1992 wxDataViewTreeNodes nodes
= node
->GetNodes();
1993 int len
= nodes
.GetCount();
1994 for( int i
= 0 ; i
< len
; i
++)
1996 if( nodes
[i
]->GetItem() == item
)
2006 node
->GetNodes().Remove( n
);
2007 sub
-= n
->GetSubTreeCount();
2008 DestroyTreeHelper(n
);
2011 if( node
->GetChildrenNumber() == 0)
2012 node
->SetHasChildren( false );
2014 //Make the row number invalid and get a new valid one when user call GetRowCount
2016 node
->ChangeSubTreeCount(sub
);
2017 //Change the current row to the last row if the current exceed the max row number
2018 if( m_currentRow
> GetRowCount() )
2019 m_currentRow
= m_count
- 1;
2025 bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem
& item
)
2027 g_model
= GetOwner()->GetModel();
2029 unsigned int row
= GetRowByItem(item
);
2034 bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem
& item
, unsigned int WXUNUSED(col
) )
2036 // NOTE: to be valid, we cannot use e.g. INT_MAX - 1
2037 /*#define MAX_VIRTUAL_WIDTH 100000
2039 wxRect rect( 0, row*m_lineHeight, MAX_VIRTUAL_WIDTH, m_lineHeight );
2040 m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
2041 Refresh( true, &rect );
2045 g_model
= GetOwner()->GetModel();
2047 unsigned int row
= GetRowByItem(item
);
2052 bool wxDataViewMainWindow::Cleared()
2054 g_model
= GetOwner()->GetModel();
2061 void wxDataViewMainWindow::UpdateDisplay()
2066 void wxDataViewMainWindow::OnInternalIdle()
2068 wxWindow::OnInternalIdle();
2072 RecalculateDisplay();
2077 void wxDataViewMainWindow::RecalculateDisplay()
2079 wxDataViewModel
*model
= GetOwner()->GetModel();
2086 int width
= GetEndOfLastCol();
2087 int height
= GetRowCount() * m_lineHeight
;
2089 SetVirtualSize( width
, height
);
2090 GetOwner()->SetScrollRate( 10, m_lineHeight
);
2095 void wxDataViewMainWindow::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
2097 wxWindow::ScrollWindow( dx
, dy
, rect
);
2099 if (GetOwner()->m_headerArea
)
2100 GetOwner()->m_headerArea
->ScrollWindow( dx
, 0 );
2103 void wxDataViewMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
2105 wxDataViewModel
*model
= GetOwner()->GetModel();
2106 wxAutoBufferedPaintDC
dc( this );
2109 dc
.SetBackground(GetBackgroundColour());
2111 GetOwner()->PrepareDC( dc
);
2112 dc
.SetFont( GetFont() );
2114 wxRect update
= GetUpdateRegion().GetBox();
2115 m_owner
->CalcUnscrolledPosition( update
.x
, update
.y
, &update
.x
, &update
.y
);
2117 // compute which items needs to be redrawn
2118 unsigned int item_start
= wxMax( 0, (update
.y
/ m_lineHeight
) );
2119 unsigned int item_count
=
2120 wxMin( (int)(((update
.y
+ update
.height
) / m_lineHeight
) - item_start
+ 1),
2121 (int)(GetRowCount( )- item_start
) );
2122 unsigned int item_last
= item_start
+ item_count
;
2124 // compute which columns needs to be redrawn
2125 unsigned int cols
= GetOwner()->GetColumnCount();
2126 unsigned int col_start
= 0;
2127 unsigned int x_start
= 0;
2128 for (x_start
= 0; col_start
< cols
; col_start
++)
2130 wxDataViewColumn
*col
= GetOwner()->GetColumn(col_start
);
2131 if (col
->IsHidden())
2132 continue; // skip it!
2134 unsigned int w
= col
->GetWidth();
2135 if (x_start
+w
>= (unsigned int)update
.x
)
2141 unsigned int col_last
= col_start
;
2142 unsigned int x_last
= x_start
;
2143 for (; col_last
< cols
; col_last
++)
2145 wxDataViewColumn
*col
= GetOwner()->GetColumn(col_last
);
2146 if (col
->IsHidden())
2147 continue; // skip it!
2149 if (x_last
> (unsigned int)update
.GetRight())
2152 x_last
+= col
->GetWidth();
2155 // Draw horizontal rules if required
2156 if ( m_owner
->HasFlag(wxDV_HORIZ_RULES
) )
2158 dc
.SetPen(m_penRule
);
2159 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2161 for (unsigned int i
= item_start
; i
<= item_last
+1; i
++)
2163 int y
= i
* m_lineHeight
;
2164 dc
.DrawLine(x_start
, y
, x_last
, y
);
2168 // Draw vertical rules if required
2169 if ( m_owner
->HasFlag(wxDV_VERT_RULES
) )
2171 dc
.SetPen(m_penRule
);
2172 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2175 for (unsigned int i
= col_start
; i
< col_last
; i
++)
2177 wxDataViewColumn
*col
= GetOwner()->GetColumn(i
);
2178 if (col
->IsHidden())
2179 continue; // skip it
2181 dc
.DrawLine(x
, item_start
* m_lineHeight
,
2182 x
, item_last
* m_lineHeight
);
2184 x
+= col
->GetWidth();
2187 // Draw last vertical rule
2188 dc
.DrawLine(x
, item_start
* m_lineHeight
,
2189 x
, item_last
* m_lineHeight
);
2192 // redraw the background for the items which are selected/current
2193 for (unsigned int item
= item_start
; item
< item_last
; item
++)
2195 bool selected
= m_selection
.Index( item
) != wxNOT_FOUND
;
2196 if (selected
|| item
== m_currentRow
)
2198 int flags
= selected
? (int)wxCONTROL_SELECTED
: 0;
2199 if (item
== m_currentRow
)
2200 flags
|= wxCONTROL_CURRENT
;
2202 flags
|= wxCONTROL_FOCUSED
;
2204 wxRect
rect( x_start
, item
*m_lineHeight
, x_last
, m_lineHeight
);
2205 wxRendererNative::Get().DrawItemSelectionRect
2215 // redraw all cells for all rows which must be repainted and for all columns
2217 cell_rect
.x
= x_start
;
2218 cell_rect
.height
= m_lineHeight
; // -1 is for the horizontal rules
2219 for (unsigned int i
= col_start
; i
< col_last
; i
++)
2221 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
2222 wxDataViewRenderer
*cell
= col
->GetRenderer();
2223 cell_rect
.width
= col
->GetWidth();
2225 if (col
->IsHidden())
2226 continue; // skipt it!
2228 for (unsigned int item
= item_start
; item
< item_last
; item
++)
2230 // get the cell value and set it into the renderer
2232 wxDataViewTreeNode
* node
= GetTreeNodeByRow(item
);
2238 wxDataViewItem dataitem
= node
->GetItem();
2239 model
->GetValue( value
, dataitem
, col
->GetModelColumn());
2240 cell
->SetValue( value
);
2242 // update the y offset
2243 cell_rect
.y
= item
* m_lineHeight
;
2245 //Draw the expander here.
2246 int indent
= node
->GetIndentLevel();
2247 if( col
->GetModelColumn() == GetOwner()->GetExpanderColumn() )
2249 //Calculate the indent first
2250 indent
= cell_rect
.x
+ GetOwner()->GetIndent() * indent
;
2252 int expander_width
= m_lineHeight
- 2*EXPANDER_MARGIN
;
2253 // change the cell_rect.x to the appropriate pos
2254 int expander_x
= indent
+ EXPANDER_MARGIN
, expander_y
= cell_rect
.y
+ EXPANDER_MARGIN
;
2255 indent
= indent
+ m_lineHeight
; //try to use the m_lineHeight as the expander space
2256 dc
.SetPen( m_penExpander
);
2257 dc
.SetBrush( wxNullBrush
);
2258 if( node
->HasChildren() )
2260 //dc.DrawRoundedRectangle( expander_x,expander_y,expander_width,expander_width, 1.0);
2261 //dc.DrawLine( expander_x + 2 , expander_y + expander_width/2, expander_x + expander_width - 2, expander_y + expander_width/2 );
2262 wxRect
rect( expander_x
, expander_y
, expander_width
, expander_width
);
2263 if( node
->IsOpen() )
2264 wxRendererNative::Get().DrawTreeItemButton( this, dc
, rect
, wxCONTROL_EXPANDED
);
2266 wxRendererNative::Get().DrawTreeItemButton( this, dc
, rect
);
2270 // I am wandering whether we should draw dot lines between tree nodes
2272 //Yes, if the node does not have any child, it must be a leaf which mean that it is a temporarily created by GetTreeNodeByRow
2275 //force the expander column to left-center align
2276 cell
->SetAlignment( wxALIGN_CENTER_VERTICAL
);
2280 // cannot be bigger than allocated space
2281 wxSize size
= cell
->GetSize();
2282 // Because of the tree structure indent, here we should minus the width of the cell for drawing
2283 size
.x
= wxMin( size
.x
+ 2*PADDING_RIGHTLEFT
, cell_rect
.width
- indent
);
2284 size
.y
= wxMin( size
.y
+ 2*PADDING_TOPBOTTOM
, cell_rect
.height
);
2286 wxRect
item_rect(cell_rect
.GetTopLeft(), size
);
2287 int align
= cell
->GetAlignment();
2289 // horizontal alignment:
2290 item_rect
.x
= cell_rect
.x
;
2291 if (align
& wxALIGN_CENTER_HORIZONTAL
)
2292 item_rect
.x
= cell_rect
.x
+ (cell_rect
.width
/ 2) - (size
.x
/ 2);
2293 else if (align
& wxALIGN_RIGHT
)
2294 item_rect
.x
= cell_rect
.x
+ cell_rect
.width
- size
.x
;
2295 //else: wxALIGN_LEFT is the default
2297 // vertical alignment:
2298 item_rect
.y
= cell_rect
.y
;
2299 if (align
& wxALIGN_CENTER_VERTICAL
)
2300 item_rect
.y
= cell_rect
.y
+ (cell_rect
.height
/ 2) - (size
.y
/ 2);
2301 else if (align
& wxALIGN_BOTTOM
)
2302 item_rect
.y
= cell_rect
.y
+ cell_rect
.height
- size
.y
;
2303 //else: wxALIGN_TOP is the default
2306 item_rect
.x
+= PADDING_RIGHTLEFT
;
2307 item_rect
.y
+= PADDING_TOPBOTTOM
;
2308 item_rect
.width
= size
.x
- 2 * PADDING_RIGHTLEFT
;
2309 item_rect
.height
= size
.y
- 2 * PADDING_TOPBOTTOM
;
2311 //Here we add the tree indent
2312 item_rect
.x
+= indent
;
2315 if (m_selection
.Index(item
) != wxNOT_FOUND
)
2316 state
|= wxDATAVIEW_CELL_SELECTED
;
2318 // TODO: it would be much more efficient to create a clipping
2319 // region for the entire column being rendered (in the OnPaint
2320 // of wxDataViewMainWindow) instead of a single clip region for
2321 // each cell. However it would mean that each renderer should
2322 // respect the given wxRect's top & bottom coords, eventually
2323 // violating only the left & right coords - however the user can
2324 // make its own renderer and thus we cannot be sure of that.
2325 dc
.SetClippingRegion( item_rect
);
2326 cell
->Render( item_rect
, &dc
, state
);
2327 dc
.DestroyClippingRegion();
2330 cell_rect
.x
+= cell_rect
.width
;
2334 int wxDataViewMainWindow::GetCountPerPage() const
2336 wxSize size
= GetClientSize();
2337 return size
.y
/ m_lineHeight
;
2340 int wxDataViewMainWindow::GetEndOfLastCol() const
2344 for (i
= 0; i
< GetOwner()->GetColumnCount(); i
++)
2346 const wxDataViewColumn
*c
=
2347 wx_const_cast(wxDataViewCtrl
*, GetOwner())->GetColumn( i
);
2350 width
+= c
->GetWidth();
2355 unsigned int wxDataViewMainWindow::GetFirstVisibleRow() const
2359 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
2361 return y
/ m_lineHeight
;
2364 unsigned int wxDataViewMainWindow::GetLastVisibleRow()
2366 wxSize client_size
= GetClientSize();
2367 m_owner
->CalcUnscrolledPosition( client_size
.x
, client_size
.y
,
2368 &client_size
.x
, &client_size
.y
);
2370 return wxMin( GetRowCount()-1, ((unsigned)client_size
.y
/m_lineHeight
)+1 );
2373 unsigned int wxDataViewMainWindow::GetRowCount()
2375 if ( m_count
== -1 )
2377 m_count
= RecalculateCount();
2379 GetVirtualSize( &width
, &height
);
2380 height
= m_count
* m_lineHeight
;
2382 SetVirtualSize( width
, height
);
2387 void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row
)
2394 void wxDataViewMainWindow::SelectAllRows( bool on
)
2401 m_selection
.Clear();
2402 for (unsigned int i
= 0; i
< GetRowCount(); i
++)
2403 m_selection
.Add( i
);
2408 unsigned int first_visible
= GetFirstVisibleRow();
2409 unsigned int last_visible
= GetLastVisibleRow();
2411 for (i
= 0; i
< m_selection
.GetCount(); i
++)
2413 unsigned int row
= m_selection
[i
];
2414 if ((row
>= first_visible
) && (row
<= last_visible
))
2417 m_selection
.Clear();
2421 void wxDataViewMainWindow::SelectRow( unsigned int row
, bool on
)
2423 if (m_selection
.Index( row
) == wxNOT_FOUND
)
2427 m_selection
.Add( row
);
2435 m_selection
.Remove( row
);
2441 void wxDataViewMainWindow::SelectRows( unsigned int from
, unsigned int to
, bool on
)
2445 unsigned int tmp
= from
;
2451 for (i
= from
; i
<= to
; i
++)
2453 if (m_selection
.Index( i
) == wxNOT_FOUND
)
2456 m_selection
.Add( i
);
2461 m_selection
.Remove( i
);
2464 RefreshRows( from
, to
);
2467 void wxDataViewMainWindow::Select( const wxArrayInt
& aSelections
)
2469 for (size_t i
=0; i
< aSelections
.GetCount(); i
++)
2471 int n
= aSelections
[i
];
2473 m_selection
.Add( n
);
2478 void wxDataViewMainWindow::ReverseRowSelection( unsigned int row
)
2480 if (m_selection
.Index( row
) == wxNOT_FOUND
)
2481 m_selection
.Add( row
);
2483 m_selection
.Remove( row
);
2487 bool wxDataViewMainWindow::IsRowSelected( unsigned int row
)
2489 return (m_selection
.Index( row
) != wxNOT_FOUND
);
2492 void wxDataViewMainWindow::RefreshRow( unsigned int row
)
2494 wxRect
rect( 0, row
*m_lineHeight
, GetEndOfLastCol(), m_lineHeight
);
2495 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2497 wxSize client_size
= GetClientSize();
2498 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2499 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2500 if (intersect_rect
.width
> 0)
2501 Refresh( true, &intersect_rect
);
2504 void wxDataViewMainWindow::RefreshRows( unsigned int from
, unsigned int to
)
2508 unsigned int tmp
= to
;
2513 wxRect
rect( 0, from
*m_lineHeight
, GetEndOfLastCol(), (to
-from
+1) * m_lineHeight
);
2514 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2516 wxSize client_size
= GetClientSize();
2517 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2518 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2519 if (intersect_rect
.width
> 0)
2520 Refresh( true, &intersect_rect
);
2523 void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow
)
2525 unsigned int count
= GetRowCount();
2526 if (firstRow
> count
)
2529 wxRect
rect( 0, firstRow
*m_lineHeight
, GetEndOfLastCol(), count
* m_lineHeight
);
2530 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2532 wxSize client_size
= GetClientSize();
2533 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2534 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2535 if (intersect_rect
.width
> 0)
2536 Refresh( true, &intersect_rect
);
2539 void wxDataViewMainWindow::OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
)
2541 wxCHECK_RET( newCurrent
< GetRowCount(),
2542 _T("invalid item index in OnArrowChar()") );
2544 // if there is no selection, we cannot move it anywhere
2545 if (!HasCurrentRow())
2548 unsigned int oldCurrent
= m_currentRow
;
2550 // in single selection we just ignore Shift as we can't select several
2552 if ( event
.ShiftDown() && !IsSingleSel() )
2554 RefreshRow( oldCurrent
);
2556 ChangeCurrentRow( newCurrent
);
2558 // select all the items between the old and the new one
2559 if ( oldCurrent
> newCurrent
)
2561 newCurrent
= oldCurrent
;
2562 oldCurrent
= m_currentRow
;
2565 SelectRows( oldCurrent
, newCurrent
, true );
2569 RefreshRow( oldCurrent
);
2571 // all previously selected items are unselected unless ctrl is held
2572 if ( !event
.ControlDown() )
2573 SelectAllRows(false);
2575 ChangeCurrentRow( newCurrent
);
2577 if ( !event
.ControlDown() )
2578 SelectRow( m_currentRow
, true );
2580 RefreshRow( m_currentRow
);
2583 //EnsureVisible( m_currentRow );
2586 wxRect
wxDataViewMainWindow::GetLineRect( unsigned int row
) const
2590 rect
.y
= m_lineHeight
* row
;
2591 rect
.width
= GetEndOfLastCol();
2592 rect
.height
= m_lineHeight
;
2597 class RowToItemJob
: public DoJob
2600 RowToItemJob( unsigned int row
, int current
) { this->row
= row
; this->current
= current
;}
2601 virtual ~RowToItemJob(){};
2603 virtual int operator() ( wxDataViewTreeNode
* node
)
2606 if( current
== static_cast<int>(row
))
2608 ret
= node
->GetItem() ;
2612 if( node
->GetSubTreeCount() + current
< static_cast<int>(row
) )
2614 current
+= node
->GetSubTreeCount();
2621 virtual int operator() ( void * n
)
2624 if( current
== static_cast<int>(row
))
2626 ret
= wxDataViewItem( n
) ;
2631 wxDataViewItem
GetResult(){ return ret
; }
2638 wxDataViewItem
wxDataViewMainWindow::GetItemByRow(unsigned int row
)
2640 RowToItemJob
job( row
, -1 );
2641 Walker( m_root
, job
);
2642 return job
.GetResult();
2645 class RowToTreeNodeJob
: public DoJob
2648 RowToTreeNodeJob( unsigned int row
, int current
, wxDataViewTreeNode
* node
)
2651 this->current
= current
;
2655 virtual ~RowToTreeNodeJob(){};
2657 virtual int operator() ( wxDataViewTreeNode
* node
)
2660 if( current
== static_cast<int>(row
))
2666 if( node
->GetSubTreeCount() + current
< static_cast<int>(row
) )
2668 current
+= node
->GetSubTreeCount();
2679 virtual int operator() ( void * n
)
2682 if( current
== static_cast<int>(row
))
2684 ret
= new wxDataViewTreeNode( parent
) ;
2685 ret
->SetItem( wxDataViewItem( n
));
2686 ret
->SetHasChildren(false);
2692 wxDataViewTreeNode
* GetResult(){ return ret
; }
2696 wxDataViewTreeNode
* ret
;
2697 wxDataViewTreeNode
* parent
;
2701 wxDataViewTreeNode
* wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row
)
2703 RowToTreeNodeJob
job( row
, -1, m_root
);
2704 Walker( m_root
, job
);
2705 return job
.GetResult();
2709 class CountJob
: public DoJob
2712 CountJob(){ count
= 0 ; }
2713 virtual ~CountJob(){};
2715 virtual int operator () ( wxDataViewTreeNode
* node
)
2718 if ( node
->IsOpen())
2724 unsigned int GetResult()
2733 void wxDataViewMainWindow::OnExpanding( unsigned int row
)
2735 wxDataViewTreeNode
* node
= GetTreeNodeByRow(row
);
2738 if( node
->HasChildren())
2739 if( !node
->IsOpen())
2742 //Here I build the children of current node
2743 if( node
->GetChildrenNumber() == 0 )
2744 BuildTreeHelper(GetOwner()->GetModel(), node
->GetItem(), node
);
2750 SelectRow( row
, false );
2751 SelectRow( row
+ 1, true );
2752 ChangeCurrentRow( row
+ 1 );
2759 void wxDataViewMainWindow::OnCollapsing(unsigned int row
)
2761 wxDataViewTreeNode
* node
= GetTreeNodeByRow(row
);
2764 wxDataViewTreeNode
* nd
= node
;
2766 if( node
->HasChildren() && node
->IsOpen() )
2771 //RefreshRows(row,GetLastVisibleRow());
2775 node
= node
->GetParent();
2778 int parent
= GetRowByItem( node
->GetItem()) ;
2779 SelectRow( row
, false);
2780 SelectRow(parent
, true );
2781 ChangeCurrentRow( parent
);
2784 if( !nd
->HasChildren())
2789 wxDataViewTreeNode
* wxDataViewMainWindow::FindNode( const wxDataViewItem
& item
)
2791 wxDataViewModel
* model
= GetOwner()->GetModel();
2795 //Compose the a parent-chain of the finding item
2797 list
.DeleteContents( true );
2798 wxDataViewItem
it( item
);
2801 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2802 list
.Insert( pItem
);
2803 it
= model
->GetParent( it
);
2806 //Find the item along the parent-chain.
2807 //This algorithm is designed to speed up the node-finding method
2809 wxDataViewTreeNode
* node
= m_root
;
2810 for( ItemList::Node
* n
= list
.GetFirst(); n
; n
= n
->GetNext() )
2812 if( node
->HasChildren() )
2814 if( node
->GetChildrenNumber() == 0 )
2815 BuildTreeHelper(model
, node
->GetItem(), node
);
2817 int len
= node
->GetNodeNumber();
2818 wxDataViewTreeNodes nodes
= node
->GetNodes();
2820 for( ; j
< len
; j
++)
2822 if( nodes
[j
]->GetItem() == *(n
->GetData()))
2828 // Whenever we can't find the node in any level, return NULL to indicate the item can't be found
2841 int wxDataViewMainWindow::RecalculateCount()
2843 return m_root
->GetSubTreeCount();
2846 class ItemToRowJob
: public DoJob
2849 ItemToRowJob(const wxDataViewItem
& item
, ItemList::Node
* node
)
2850 { this->item
= item
; ret
= 0 ; nd
= node
; }
2851 virtual ~ItemToRowJob(){};
2853 virtual int operator() ( wxDataViewTreeNode
* node
)
2856 if( node
->GetItem() == item
)
2861 if( nd
&& node
->GetItem() == *(nd
->GetData()))
2868 ret
+= node
->GetSubTreeCount();
2874 virtual int operator() ( void * n
)
2877 if( n
== item
.GetID() )
2881 //the row number is begin from zero
2882 int GetResult(){ return ret
-1 ; }
2884 ItemList::Node
* nd
;
2885 wxDataViewItem item
;
2890 unsigned int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem
& item
)
2892 wxDataViewModel
* model
= GetOwner()->GetModel();
2896 //Compose the a parent-chain of the finding item
2898 list
.DeleteContents( true );
2899 wxDataViewItem
it( item
);
2902 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2903 list
.Insert( pItem
);
2904 it
= model
->GetParent( it
);
2907 ItemToRowJob
job( item
, list
.GetFirst() );
2908 Walker(m_root
, job
);
2909 return job
.GetResult();
2912 void BuildTreeHelper( wxDataViewModel
* model
, wxDataViewItem
& item
, wxDataViewTreeNode
* node
)
2914 if( !model
->IsContainer( item
) )
2917 wxDataViewItem i
= model
->GetFirstChild( item
);
2922 if( model
->IsContainer( i
) )
2924 wxDataViewTreeNode
* n
= new wxDataViewTreeNode( node
);
2926 n
->SetHasChildren( true ) ;
2931 node
->AddLeaf( i
.GetID() );
2933 i
= model
->GetNextSibling( i
);
2935 node
->SetSubTreeCount( num
);
2936 wxDataViewTreeNode
* n
= node
->GetParent();
2938 n
->ChangeSubTreeCount(num
);
2942 void wxDataViewMainWindow::BuildTree(wxDataViewModel
* model
)
2944 //First we define a invalid item to fetch the top-level elements
2945 wxDataViewItem item
;
2946 g_model
= GetOwner()->GetModel();
2947 BuildTreeHelper( model
, item
, m_root
);
2951 void DestroyTreeHelper( wxDataViewTreeNode
* node
)
2953 if( node
->GetNodeNumber() != 0 )
2955 int len
= node
->GetNodeNumber();
2957 wxDataViewTreeNodes nodes
= node
->GetNodes();
2958 for( ; i
< len
; i
++ )
2960 DestroyTreeHelper(nodes
[i
]);
2966 void wxDataViewMainWindow::DestroyTree()
2968 DestroyTreeHelper(m_root
);
2969 m_root
->SetSubTreeCount(0);
2973 void wxDataViewMainWindow::OnChar( wxKeyEvent
&event
)
2975 if (event
.GetKeyCode() == WXK_TAB
)
2977 wxNavigationKeyEvent nevent
;
2978 nevent
.SetWindowChange( event
.ControlDown() );
2979 nevent
.SetDirection( !event
.ShiftDown() );
2980 nevent
.SetEventObject( GetParent()->GetParent() );
2981 nevent
.SetCurrentFocus( m_parent
);
2982 if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent
))
2986 // no item -> nothing to do
2987 if (!HasCurrentRow())
2993 // don't use m_linesPerPage directly as it might not be computed yet
2994 const int pageSize
= GetCountPerPage();
2995 wxCHECK_RET( pageSize
, _T("should have non zero page size") );
2997 switch ( event
.GetKeyCode() )
3000 if ( m_currentRow
> 0 )
3001 OnArrowChar( m_currentRow
- 1, event
);
3005 if ( m_currentRow
< GetRowCount() - 1 )
3006 OnArrowChar( m_currentRow
+ 1, event
);
3008 //Add the process for tree expanding/collapsing
3010 OnCollapsing(m_currentRow
);
3013 OnExpanding( m_currentRow
);
3017 OnArrowChar( GetRowCount() - 1, event
);
3022 OnArrowChar( 0, event
);
3027 int steps
= pageSize
- 1;
3028 int index
= m_currentRow
- steps
;
3032 OnArrowChar( index
, event
);
3038 int steps
= pageSize
- 1;
3039 unsigned int index
= m_currentRow
+ steps
;
3040 unsigned int count
= GetRowCount();
3041 if ( index
>= count
)
3044 OnArrowChar( index
, event
);
3053 void wxDataViewMainWindow::OnMouse( wxMouseEvent
&event
)
3055 if (event
.GetEventType() == wxEVT_MOUSEWHEEL
)
3057 // let the base handle mouse wheel events.
3062 int x
= event
.GetX();
3063 int y
= event
.GetY();
3064 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
3066 wxDataViewColumn
*col
= NULL
;
3069 unsigned int cols
= GetOwner()->GetColumnCount();
3071 for (i
= 0; i
< cols
; i
++)
3073 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
3075 continue; // skip it!
3077 if (x
< xpos
+ c
->GetWidth())
3082 xpos
+= c
->GetWidth();
3086 wxDataViewRenderer
*cell
= col
->GetRenderer();
3088 unsigned int current
= y
/ m_lineHeight
;
3090 if ((current
> GetRowCount()) || (x
> GetEndOfLastCol()))
3092 // Unselect all if below the last row ?
3096 wxDataViewModel
*model
= GetOwner()->GetModel();
3098 if (event
.Dragging())
3100 if (m_dragCount
== 0)
3102 // we have to report the raw, physical coords as we want to be
3103 // able to call HitTest(event.m_pointDrag) from the user code to
3104 // get the item being dragged
3105 m_dragStart
= event
.GetPosition();
3110 if (m_dragCount
!= 3)
3113 if (event
.LeftIsDown())
3115 // Notify cell about drag
3124 bool forceClick
= false;
3126 if (event
.ButtonDClick())
3128 m_renameTimer
->Stop();
3129 m_lastOnSame
= false;
3132 if (event
.LeftDClick())
3134 if ( current
== m_lineLastClicked
)
3136 if (cell
->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE
)
3138 wxDataViewItem item
= GetItemByRow(current
);
3140 model
->GetValue( value
, item
, col
->GetModelColumn() );
3141 cell
->SetValue( value
);
3142 wxRect
cell_rect( xpos
, current
* m_lineHeight
,
3143 col
->GetWidth(), m_lineHeight
);
3144 cell
->Activate( cell_rect
, model
, item
, col
->GetModelColumn() );
3150 // The first click was on another item, so don't interpret this as
3151 // a double click, but as a simple click instead
3158 if (m_lineSelectSingleOnUp
!= (unsigned int)-1)
3160 // select single line
3161 SelectAllRows( false );
3162 SelectRow( m_lineSelectSingleOnUp
, true );
3165 //Process the event of user clicking the expander
3166 bool expander
= false;
3167 wxDataViewTreeNode
* node
= GetTreeNodeByRow(current
);
3168 if( node
!=NULL
&& node
->HasChildren() )
3170 int indent
= node
->GetIndentLevel();
3171 indent
= GetOwner()->GetIndent()*indent
;
3172 wxRect
rect( xpos
+ indent
+ EXPANDER_MARGIN
, current
* m_lineHeight
+ EXPANDER_MARGIN
, m_lineHeight
-2*EXPANDER_MARGIN
,m_lineHeight
-2*EXPANDER_MARGIN
);
3173 if( rect
.Contains( x
, y
) )
3176 if( node
->IsOpen() )
3177 OnCollapsing(current
);
3179 OnExpanding( current
);
3183 //If the user click the expander, we do not do editing even if the column with expander are editable
3184 if (m_lastOnSame
&& !expander
)
3186 if ((col
== m_currentCol
) && (current
== m_currentRow
) &&
3187 (cell
->GetMode() == wxDATAVIEW_CELL_EDITABLE
) )
3189 m_renameTimer
->Start( 100, true );
3193 m_lastOnSame
= false;
3194 m_lineSelectSingleOnUp
= (unsigned int)-1;
3198 // This is necessary, because after a DnD operation in
3199 // from and to ourself, the up event is swallowed by the
3200 // DnD code. So on next non-up event (which means here and
3201 // now) m_lineSelectSingleOnUp should be reset.
3202 m_lineSelectSingleOnUp
= (unsigned int)-1;
3205 if (event
.RightDown())
3207 m_lineBeforeLastClicked
= m_lineLastClicked
;
3208 m_lineLastClicked
= current
;
3210 // If the item is already selected, do not update the selection.
3211 // Multi-selections should not be cleared if a selected item is clicked.
3212 if (!IsRowSelected(current
))
3214 SelectAllRows(false);
3215 ChangeCurrentRow(current
);
3216 SelectRow(m_currentRow
,true);
3219 // notify cell about right click
3222 // Allow generation of context menu event
3225 else if (event
.MiddleDown())
3227 // notify cell about middle click
3230 if (event
.LeftDown() || forceClick
)
3236 m_lineBeforeLastClicked
= m_lineLastClicked
;
3237 m_lineLastClicked
= current
;
3239 unsigned int oldCurrentRow
= m_currentRow
;
3240 bool oldWasSelected
= IsRowSelected(m_currentRow
);
3242 bool cmdModifierDown
= event
.CmdDown();
3243 if ( IsSingleSel() || !(cmdModifierDown
|| event
.ShiftDown()) )
3245 if ( IsSingleSel() || !IsRowSelected(current
) )
3247 SelectAllRows( false );
3249 ChangeCurrentRow(current
);
3251 SelectRow(m_currentRow
,true);
3253 else // multi sel & current is highlighted & no mod keys
3255 m_lineSelectSingleOnUp
= current
;
3256 ChangeCurrentRow(current
); // change focus
3259 else // multi sel & either ctrl or shift is down
3261 if (cmdModifierDown
)
3263 ChangeCurrentRow(current
);
3265 ReverseRowSelection(m_currentRow
);
3267 else if (event
.ShiftDown())
3269 ChangeCurrentRow(current
);
3271 unsigned int lineFrom
= oldCurrentRow
,
3274 if ( lineTo
< lineFrom
)
3277 lineFrom
= m_currentRow
;
3280 SelectRows(lineFrom
, lineTo
, true);
3282 else // !ctrl, !shift
3284 // test in the enclosing if should make it impossible
3285 wxFAIL_MSG( _T("how did we get here?") );
3289 if (m_currentRow
!= oldCurrentRow
)
3290 RefreshRow( oldCurrentRow
);
3292 wxDataViewColumn
*oldCurrentCol
= m_currentCol
;
3294 // Update selection here...
3297 m_lastOnSame
= !forceClick
&& ((col
== oldCurrentCol
) &&
3298 (current
== oldCurrentRow
)) && oldWasSelected
;
3302 void wxDataViewMainWindow::OnSetFocus( wxFocusEvent
&event
)
3306 if (HasCurrentRow())
3312 void wxDataViewMainWindow::OnKillFocus( wxFocusEvent
&event
)
3316 if (HasCurrentRow())
3322 wxDataViewItem
wxDataViewMainWindow::GetSelection()
3324 if( m_selection
.GetCount() != 1 )
3325 return wxDataViewItem();
3327 return GetItemByRow( m_selection
.Item(0));
3330 //-----------------------------------------------------------------------------
3332 //-----------------------------------------------------------------------------
3334 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
3336 BEGIN_EVENT_TABLE(wxDataViewCtrl
, wxDataViewCtrlBase
)
3337 EVT_SIZE(wxDataViewCtrl::OnSize
)
3340 wxDataViewCtrl::~wxDataViewCtrl()
3343 GetModel()->RemoveNotifier( m_notifier
);
3346 void wxDataViewCtrl::Init()
3351 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
3352 const wxPoint
& pos
, const wxSize
& size
,
3353 long style
, const wxValidator
& validator
)
3355 if (!wxControl::Create( parent
, id
, pos
, size
,
3356 style
| wxScrolledWindowStyle
|wxSUNKEN_BORDER
, validator
))
3362 MacSetClipChildren( true ) ;
3365 m_clientArea
= new wxDataViewMainWindow( this, wxID_ANY
);
3367 if (HasFlag(wxDV_NO_HEADER
))
3368 m_headerArea
= NULL
;
3370 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
);
3372 SetTargetWindow( m_clientArea
);
3374 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
3376 sizer
->Add( m_headerArea
, 0, wxGROW
);
3377 sizer
->Add( m_clientArea
, 1, wxGROW
);
3384 WXLRESULT
wxDataViewCtrl::MSWWindowProc(WXUINT nMsg
,
3388 WXLRESULT rc
= wxDataViewCtrlBase::MSWWindowProc(nMsg
, wParam
, lParam
);
3391 // we need to process arrows ourselves for scrolling
3392 if ( nMsg
== WM_GETDLGCODE
)
3394 rc
|= DLGC_WANTARROWS
;
3402 void wxDataViewCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
3404 // We need to override OnSize so that our scrolled
3405 // window a) does call Layout() to use sizers for
3406 // positioning the controls but b) does not query
3407 // the sizer for their size and use that for setting
3408 // the scrollable area as set that ourselves by
3409 // calling SetScrollbar() further down.
3416 bool wxDataViewCtrl::AssociateModel( wxDataViewModel
*model
)
3418 if (!wxDataViewCtrlBase::AssociateModel( model
))
3421 m_notifier
= new wxGenericDataViewModelNotifier( m_clientArea
);
3423 model
->AddNotifier( m_notifier
);
3425 m_clientArea
->BuildTree(model
);
3427 m_clientArea
->UpdateDisplay();
3432 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
3434 if (!wxDataViewCtrlBase::AppendColumn(col
))
3441 void wxDataViewCtrl::OnColumnChange()
3444 m_headerArea
->UpdateDisplay();
3446 m_clientArea
->UpdateDisplay();
3449 void wxDataViewCtrl::DoSetExpanderColumn()
3451 m_clientArea
->UpdateDisplay();
3454 void wxDataViewCtrl::DoSetIndent()
3456 m_clientArea
->UpdateDisplay();
3459 wxDataViewItem
wxDataViewCtrl::GetSelection()
3461 return m_clientArea
->GetSelection();
3464 /********************************************************************
3465 void wxDataViewCtrl::SetSelection( int row )
3467 m_clientArea->SelectRow(row, true);
3470 void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to )
3472 m_clientArea->SelectRows(from, to, true);
3475 void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections )
3477 m_clientArea->Select(aSelections);
3480 void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row) )
3485 bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row) ) const
3492 int wxDataViewCtrl::GetSelection() const
3499 int wxDataViewCtrl::GetSelections(wxArrayInt& WXUNUSED(aSelections) ) const
3505 *********************************************************************/
3507 // !wxUSE_GENERICDATAVIEWCTRL
3510 // wxUSE_DATAVIEWCTRL