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();
360 for(int i
= 0; i
< len
; i
++)
362 for(int i
= 0; i
< len
; i
++)
366 len
= lvs
.GetCount();
369 for(int i
= 0; i
< len
; i
++)
375 wxDataViewTreeNode
* parent
;
376 wxDataViewTreeNodes nodes
;
377 wxDataViewTreeLeaves leaves
;
384 //Below is the compare stuff
385 //For the generic implements, both the leaf nodes and the nodes are sorted for fast search when needed
386 static wxDataViewModel
* g_model
;
388 int LINKAGEMODE
wxGenericTreeModelNodeCmp( wxDataViewTreeNode
* node1
, wxDataViewTreeNode
* node2
)
390 return g_model
->Compare( node1
->GetItem(), node2
->GetItem() );
393 int LINKAGEMODE
wxGenericTreeModelItemCmp( void * id1
, void * id2
)
395 return g_model
->Compare( id1
, id2
);
400 //-----------------------------------------------------------------------------
401 // wxDataViewMainWindow
402 //-----------------------------------------------------------------------------
404 WX_DEFINE_SORTED_USER_EXPORTED_ARRAY_SIZE_T(unsigned int, wxDataViewSelection
,
406 WX_DECLARE_LIST(wxDataViewItem
, ItemList
);
407 WX_DEFINE_LIST(ItemList
);
409 class wxDataViewMainWindow
: public wxWindow
412 wxDataViewMainWindow( wxDataViewCtrl
*parent
,
414 const wxPoint
&pos
= wxDefaultPosition
,
415 const wxSize
&size
= wxDefaultSize
,
416 const wxString
&name
= wxT("wxdataviewctrlmainwindow") );
417 virtual ~wxDataViewMainWindow();
419 // notifications from wxDataViewModel
420 bool ItemAdded( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
421 bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
);
422 bool ItemChanged( const wxDataViewItem
&item
);
423 bool ValueChanged( const wxDataViewItem
&item
, unsigned int col
);
426 { g_model
= GetOwner()->GetModel(); m_root
->Resort(); UpdateDisplay(); }
428 void SetOwner( wxDataViewCtrl
* owner
) { m_owner
= owner
; }
429 wxDataViewCtrl
*GetOwner() { return m_owner
; }
430 const wxDataViewCtrl
*GetOwner() const { return m_owner
; }
432 void OnPaint( wxPaintEvent
&event
);
433 void OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
);
434 void OnChar( wxKeyEvent
&event
);
435 void OnMouse( wxMouseEvent
&event
);
436 void OnSetFocus( wxFocusEvent
&event
);
437 void OnKillFocus( wxFocusEvent
&event
);
439 void UpdateDisplay();
440 void RecalculateDisplay();
441 void OnInternalIdle();
443 void OnRenameTimer();
445 void ScrollWindow( int dx
, int dy
, const wxRect
*rect
= NULL
);
447 bool HasCurrentRow() { return m_currentRow
!= (unsigned int)-1; }
448 void ChangeCurrentRow( unsigned int row
);
450 bool IsSingleSel() const { return !GetParent()->HasFlag(wxDV_MULTIPLE
); }
451 bool IsEmpty() { return GetRowCount() == 0; }
453 int GetCountPerPage() const;
454 int GetEndOfLastCol() const;
455 unsigned int GetFirstVisibleRow() const;
456 //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
457 unsigned int GetLastVisibleRow();
458 unsigned int GetRowCount() ;
460 wxDataViewItem
GetSelection();
462 void Select( const wxArrayInt
& aSelections
);
463 void SelectAllRows( bool on
);
464 void SelectRow( unsigned int row
, bool on
);
465 void SelectRows( unsigned int from
, unsigned int to
, bool on
);
466 void ReverseRowSelection( unsigned int row
);
467 bool IsRowSelected( unsigned int row
);
469 void RefreshRow( unsigned int row
);
470 void RefreshRows( unsigned int from
, unsigned int to
);
471 void RefreshRowsAfter( unsigned int firstRow
);
473 // returns the colour to be used for drawing the rules
474 wxColour
GetRuleColour() const
476 return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT
);
479 //void EnsureVisible( unsigned int row );
480 wxRect
GetLineRect( unsigned int row
) const;
482 //Some useful functions for row and item mapping
483 wxDataViewItem
GetItemByRow( unsigned int row
);
484 unsigned int GetRowByItem( const wxDataViewItem
& item
);
486 //Methods for building the mapping tree
487 void BuildTree( wxDataViewModel
* model
);
490 wxDataViewTreeNode
* GetTreeNodeByRow( unsigned int row
);
491 //We did not need this temporarily
492 //wxDataViewTreeNode * GetTreeNodeByItem( const wxDataViewItem & item );
494 int RecalculateCount() ;
496 void OnExpanding( unsigned int row
);
497 void OnCollapsing( unsigned int row
);
499 wxDataViewTreeNode
* FindNode( const wxDataViewItem
& item
);
502 wxDataViewCtrl
*m_owner
;
506 wxDataViewColumn
*m_currentCol
;
507 unsigned int m_currentRow
;
508 wxDataViewSelection m_selection
;
510 wxDataViewRenameTimer
*m_renameTimer
;
518 // for double click logic
519 unsigned int m_lineLastClicked
,
520 m_lineBeforeLastClicked
,
521 m_lineSelectSingleOnUp
;
523 // the pen used to draw horiz/vertical rules
526 // the pen used to draw the expander and the lines
529 //This is the tree structure of the model
530 wxDataViewTreeNode
* m_root
;
533 DECLARE_DYNAMIC_CLASS(wxDataViewMainWindow
)
534 DECLARE_EVENT_TABLE()
537 // ---------------------------------------------------------
538 // wxGenericDataViewModelNotifier
539 // ---------------------------------------------------------
541 class wxGenericDataViewModelNotifier
: public wxDataViewModelNotifier
544 wxGenericDataViewModelNotifier( wxDataViewMainWindow
*mainWindow
)
545 { m_mainWindow
= mainWindow
; }
547 virtual bool ItemAdded( const wxDataViewItem
& parent
, const wxDataViewItem
& item
)
548 { return m_mainWindow
->ItemAdded( parent
, item
); }
549 virtual bool ItemDeleted( const wxDataViewItem
&parent
, const wxDataViewItem
&item
)
550 { return m_mainWindow
->ItemDeleted( parent
, item
); }
551 virtual bool ItemChanged( const wxDataViewItem
& item
)
552 { return m_mainWindow
->ItemChanged(item
); }
553 virtual bool ValueChanged( const wxDataViewItem
& item
, unsigned int col
)
554 { return m_mainWindow
->ValueChanged( item
, col
); }
555 virtual bool Cleared()
556 { return m_mainWindow
->Cleared(); }
557 virtual void Resort()
558 { return m_mainWindow
->Resort(); }
560 wxDataViewMainWindow
*m_mainWindow
;
563 // ---------------------------------------------------------
564 // wxDataViewRenderer
565 // ---------------------------------------------------------
567 IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer
, wxDataViewRendererBase
)
569 wxDataViewRenderer::wxDataViewRenderer( const wxString
&varianttype
,
570 wxDataViewCellMode mode
,
572 wxDataViewRendererBase( varianttype
, mode
, align
)
579 wxDataViewRenderer::~wxDataViewRenderer()
585 wxDC
*wxDataViewRenderer::GetDC()
589 if (GetOwner() == NULL
)
591 if (GetOwner()->GetOwner() == NULL
)
593 m_dc
= new wxClientDC( GetOwner()->GetOwner() );
599 // ---------------------------------------------------------
600 // wxDataViewCustomRenderer
601 // ---------------------------------------------------------
603 IMPLEMENT_ABSTRACT_CLASS(wxDataViewCustomRenderer
, wxDataViewRenderer
)
605 wxDataViewCustomRenderer::wxDataViewCustomRenderer( const wxString
&varianttype
,
606 wxDataViewCellMode mode
, int align
) :
607 wxDataViewRenderer( varianttype
, mode
, align
)
611 // ---------------------------------------------------------
612 // wxDataViewTextRenderer
613 // ---------------------------------------------------------
615 IMPLEMENT_CLASS(wxDataViewTextRenderer
, wxDataViewCustomRenderer
)
617 wxDataViewTextRenderer::wxDataViewTextRenderer( const wxString
&varianttype
,
618 wxDataViewCellMode mode
, int align
) :
619 wxDataViewCustomRenderer( varianttype
, mode
, align
)
623 bool wxDataViewTextRenderer::SetValue( const wxVariant
&value
)
625 m_text
= value
.GetString();
630 bool wxDataViewTextRenderer::GetValue( wxVariant
& WXUNUSED(value
) ) const
635 bool wxDataViewTextRenderer::HasEditorCtrl()
640 wxControl
* wxDataViewTextRenderer::CreateEditorCtrl( wxWindow
*parent
,
641 wxRect labelRect
, const wxVariant
&value
)
643 return new wxTextCtrl( parent
, wxID_ANY
, value
,
644 wxPoint(labelRect
.x
,labelRect
.y
),
645 wxSize(labelRect
.width
,labelRect
.height
) );
648 bool wxDataViewTextRenderer::GetValueFromEditorCtrl( wxControl
*editor
, wxVariant
&value
)
650 wxTextCtrl
*text
= (wxTextCtrl
*) editor
;
651 value
= text
->GetValue();
655 bool wxDataViewTextRenderer::Render( wxRect cell
, wxDC
*dc
, int state
)
657 wxDataViewCtrl
*view
= GetOwner()->GetOwner();
658 wxColour col
= (state
& wxDATAVIEW_CELL_SELECTED
) ?
659 wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT
) :
660 view
->GetForegroundColour();
662 dc
->SetTextForeground(col
);
663 dc
->DrawText( m_text
, cell
.x
, cell
.y
);
668 wxSize
wxDataViewTextRenderer::GetSize() const
670 const wxDataViewCtrl
*view
= GetView();
674 view
->GetTextExtent( m_text
, &x
, &y
);
675 return wxSize( x
, y
);
677 return wxSize(80,20);
680 // ---------------------------------------------------------
681 // wxDataViewBitmapRenderer
682 // ---------------------------------------------------------
684 IMPLEMENT_CLASS(wxDataViewBitmapRenderer
, wxDataViewCustomRenderer
)
686 wxDataViewBitmapRenderer::wxDataViewBitmapRenderer( const wxString
&varianttype
,
687 wxDataViewCellMode mode
, int align
) :
688 wxDataViewCustomRenderer( varianttype
, mode
, align
)
692 bool wxDataViewBitmapRenderer::SetValue( const wxVariant
&value
)
694 if (value
.GetType() == wxT("wxBitmap"))
696 if (value
.GetType() == wxT("wxIcon"))
702 bool wxDataViewBitmapRenderer::GetValue( wxVariant
& WXUNUSED(value
) ) const
707 bool wxDataViewBitmapRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
710 dc
->DrawBitmap( m_bitmap
, cell
.x
, cell
.y
);
711 else if (m_icon
.Ok())
712 dc
->DrawIcon( m_icon
, cell
.x
, cell
.y
);
717 wxSize
wxDataViewBitmapRenderer::GetSize() const
720 return wxSize( m_bitmap
.GetWidth(), m_bitmap
.GetHeight() );
721 else if (m_icon
.Ok())
722 return wxSize( m_icon
.GetWidth(), m_icon
.GetHeight() );
724 return wxSize(16,16);
727 // ---------------------------------------------------------
728 // wxDataViewToggleRenderer
729 // ---------------------------------------------------------
731 IMPLEMENT_ABSTRACT_CLASS(wxDataViewToggleRenderer
, wxDataViewCustomRenderer
)
733 wxDataViewToggleRenderer::wxDataViewToggleRenderer( const wxString
&varianttype
,
734 wxDataViewCellMode mode
, int align
) :
735 wxDataViewCustomRenderer( varianttype
, mode
, align
)
740 bool wxDataViewToggleRenderer::SetValue( const wxVariant
&value
)
742 m_toggle
= value
.GetBool();
747 bool wxDataViewToggleRenderer::GetValue( wxVariant
&WXUNUSED(value
) ) const
752 bool wxDataViewToggleRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
754 // User wxRenderer here
757 rect
.x
= cell
.x
+ cell
.width
/2 - 10;
759 rect
.y
= cell
.y
+ cell
.height
/2 - 10;
764 flags
|= wxCONTROL_CHECKED
;
765 if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE
)
766 flags
|= wxCONTROL_DISABLED
;
768 wxRendererNative::Get().DrawCheckBox(
769 GetOwner()->GetOwner(),
777 bool wxDataViewToggleRenderer::Activate( wxRect
WXUNUSED(cell
),
778 wxDataViewModel
*model
,
779 const wxDataViewItem
& item
, unsigned int col
)
781 bool value
= !m_toggle
;
782 wxVariant variant
= value
;
783 model
->SetValue( variant
, item
, col
);
784 model
->ValueChanged( item
, col
);
788 wxSize
wxDataViewToggleRenderer::GetSize() const
790 return wxSize(20,20);
793 // ---------------------------------------------------------
794 // wxDataViewProgressRenderer
795 // ---------------------------------------------------------
797 IMPLEMENT_ABSTRACT_CLASS(wxDataViewProgressRenderer
, wxDataViewCustomRenderer
)
799 wxDataViewProgressRenderer::wxDataViewProgressRenderer( const wxString
&label
,
800 const wxString
&varianttype
, wxDataViewCellMode mode
, int align
) :
801 wxDataViewCustomRenderer( varianttype
, mode
, align
)
807 wxDataViewProgressRenderer::~wxDataViewProgressRenderer()
811 bool wxDataViewProgressRenderer::SetValue( const wxVariant
&value
)
813 m_value
= (long) value
;
815 if (m_value
< 0) m_value
= 0;
816 if (m_value
> 100) m_value
= 100;
821 bool wxDataViewProgressRenderer::GetValue( wxVariant
&value
) const
823 value
= (long) m_value
;
827 bool wxDataViewProgressRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
829 double pct
= (double)m_value
/ 100.0;
831 bar
.width
= (int)(cell
.width
* pct
);
832 dc
->SetPen( *wxTRANSPARENT_PEN
);
833 dc
->SetBrush( *wxBLUE_BRUSH
);
834 dc
->DrawRectangle( bar
);
836 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
837 dc
->SetPen( *wxBLACK_PEN
);
838 dc
->DrawRectangle( cell
);
843 wxSize
wxDataViewProgressRenderer::GetSize() const
845 return wxSize(40,12);
848 // ---------------------------------------------------------
849 // wxDataViewDateRenderer
850 // ---------------------------------------------------------
852 #define wxUSE_DATE_RENDERER_POPUP (wxUSE_CALENDARCTRL && wxUSE_POPUPWIN)
854 #if wxUSE_DATE_RENDERER_POPUP
856 class wxDataViewDateRendererPopupTransient
: public wxPopupTransientWindow
859 wxDataViewDateRendererPopupTransient( wxWindow
* parent
, wxDateTime
*value
,
860 wxDataViewModel
*model
, const wxDataViewItem
& item
, unsigned int col
) :
861 wxPopupTransientWindow( parent
, wxBORDER_SIMPLE
),
866 m_cal
= new wxCalendarCtrl( this, wxID_ANY
, *value
);
867 wxBoxSizer
*sizer
= new wxBoxSizer( wxHORIZONTAL
);
868 sizer
->Add( m_cal
, 1, wxGROW
);
873 void OnCalendar( wxCalendarEvent
&event
);
875 wxCalendarCtrl
*m_cal
;
876 wxDataViewModel
*m_model
;
878 const wxDataViewItem
& m_item
;
881 virtual void OnDismiss()
886 DECLARE_EVENT_TABLE()
889 BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient
,wxPopupTransientWindow
)
890 EVT_CALENDAR( wxID_ANY
, wxDataViewDateRendererPopupTransient::OnCalendar
)
893 void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent
&event
)
895 wxDateTime date
= event
.GetDate();
896 wxVariant value
= date
;
897 m_model
->SetValue( value
, m_item
, m_col
);
898 m_model
->ValueChanged( m_item
, m_col
);
902 #endif // wxUSE_DATE_RENDERER_POPUP
904 IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer
, wxDataViewCustomRenderer
)
906 wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString
&varianttype
,
907 wxDataViewCellMode mode
, int align
) :
908 wxDataViewCustomRenderer( varianttype
, mode
, align
)
912 bool wxDataViewDateRenderer::SetValue( const wxVariant
&value
)
914 m_date
= value
.GetDateTime();
919 bool wxDataViewDateRenderer::GetValue( wxVariant
&value
) const
925 bool wxDataViewDateRenderer::Render( wxRect cell
, wxDC
*dc
, int WXUNUSED(state
) )
927 dc
->SetFont( GetOwner()->GetOwner()->GetFont() );
928 wxString tmp
= m_date
.FormatDate();
929 dc
->DrawText( tmp
, cell
.x
, cell
.y
);
934 wxSize
wxDataViewDateRenderer::GetSize() const
936 const wxDataViewCtrl
* view
= GetView();
937 wxString tmp
= m_date
.FormatDate();
939 view
->GetTextExtent( tmp
, &x
, &y
, &d
);
940 return wxSize(x
,y
+d
);
943 bool wxDataViewDateRenderer::Activate( wxRect
WXUNUSED(cell
), wxDataViewModel
*model
,
944 const wxDataViewItem
& item
, unsigned int col
)
947 model
->GetValue( variant
, item
, col
);
948 wxDateTime value
= variant
.GetDateTime();
950 #if wxUSE_DATE_RENDERER_POPUP
951 wxDataViewDateRendererPopupTransient
*popup
= new wxDataViewDateRendererPopupTransient(
952 GetOwner()->GetOwner()->GetParent(), &value
, model
, item
, col
);
953 wxPoint pos
= wxGetMousePosition();
956 popup
->Popup( popup
->m_cal
);
957 #else // !wxUSE_DATE_RENDERER_POPUP
958 wxMessageBox(value
.Format());
959 #endif // wxUSE_DATE_RENDERER_POPUP/!wxUSE_DATE_RENDERER_POPUP
963 // ---------------------------------------------------------
965 // ---------------------------------------------------------
967 IMPLEMENT_ABSTRACT_CLASS(wxDataViewColumn
, wxDataViewColumnBase
)
969 wxDataViewColumn::wxDataViewColumn( const wxString
&title
, wxDataViewRenderer
*cell
,
970 unsigned int model_column
,
971 int width
, wxAlignment align
, int flags
) :
972 wxDataViewColumnBase( title
, cell
, model_column
, width
, align
, flags
)
978 Init(width
< 0 ? wxDVC_DEFAULT_WIDTH
: width
);
981 wxDataViewColumn::wxDataViewColumn( const wxBitmap
&bitmap
, wxDataViewRenderer
*cell
,
982 unsigned int model_column
,
983 int width
, wxAlignment align
, int flags
) :
984 wxDataViewColumnBase( bitmap
, cell
, model_column
, width
, align
, flags
)
989 Init(width
< 0 ? wxDVC_TOGGLE_DEFAULT_WIDTH
: width
);
992 wxDataViewColumn::~wxDataViewColumn()
996 void wxDataViewColumn::Init( int width
)
999 m_minWidth
= wxDVC_DEFAULT_MINWIDTH
;
1003 void wxDataViewColumn::SetResizeable( bool resizeable
)
1006 m_flags
|= wxDATAVIEW_COL_RESIZABLE
;
1008 m_flags
&= ~wxDATAVIEW_COL_RESIZABLE
;
1011 void wxDataViewColumn::SetHidden( bool hidden
)
1014 m_flags
|= wxDATAVIEW_COL_HIDDEN
;
1016 m_flags
&= ~wxDATAVIEW_COL_HIDDEN
;
1018 // tell our owner to e.g. update its scrollbars:
1020 GetOwner()->OnColumnChange();
1023 void wxDataViewColumn::SetSortable( bool sortable
)
1026 m_flags
|= wxDATAVIEW_COL_SORTABLE
;
1028 m_flags
&= ~wxDATAVIEW_COL_SORTABLE
;
1030 // Update header button
1032 GetOwner()->OnColumnChange();
1035 void wxDataViewColumn::SetSortOrder( bool ascending
)
1037 m_ascending
= ascending
;
1039 // Update header button
1041 GetOwner()->OnColumnChange();
1044 bool wxDataViewColumn::IsSortOrderAscending() const
1049 void wxDataViewColumn::SetInternalWidth( int width
)
1053 // the scrollbars of the wxDataViewCtrl needs to be recalculated!
1054 if (m_owner
&& m_owner
->m_clientArea
)
1055 m_owner
->m_clientArea
->RecalculateDisplay();
1058 void wxDataViewColumn::SetWidth( int width
)
1060 m_owner
->m_headerArea
->UpdateDisplay();
1062 SetInternalWidth(width
);
1066 //-----------------------------------------------------------------------------
1067 // wxDataViewHeaderWindowBase
1068 //-----------------------------------------------------------------------------
1070 void wxDataViewHeaderWindowBase::SendEvent(wxEventType type
, unsigned int n
)
1072 wxWindow
*parent
= GetParent();
1073 wxDataViewEvent
le(type
, parent
->GetId());
1075 le
.SetEventObject(parent
);
1077 le
.SetDataViewColumn(GetColumn(n
));
1078 le
.SetModel(GetOwner()->GetModel());
1080 // for events created by wxDataViewHeaderWindow the
1081 // row / value fields are not valid
1083 parent
->GetEventHandler()->ProcessEvent(le
);
1086 #if defined(__WXMSW__) && USE_NATIVE_HEADER_WINDOW
1088 // implemented in msw/listctrl.cpp:
1089 int WXDLLIMPEXP_CORE
wxMSWGetColumnClicked(NMHDR
*nmhdr
, POINT
*ptClick
);
1091 IMPLEMENT_ABSTRACT_CLASS(wxDataViewHeaderWindowMSW
, wxWindow
)
1093 bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl
*parent
, wxWindowID id
,
1094 const wxPoint
&pos
, const wxSize
&size
,
1095 const wxString
&name
)
1099 if ( !CreateControl(parent
, id
, pos
, size
, 0, wxDefaultValidator
, name
) )
1102 int x
= pos
.x
== wxDefaultCoord
? 0 : pos
.x
,
1103 y
= pos
.y
== wxDefaultCoord
? 0 : pos
.y
,
1104 w
= size
.x
== wxDefaultCoord
? 1 : size
.x
,
1105 h
= size
.y
== wxDefaultCoord
? 22 : size
.y
;
1107 // create the native WC_HEADER window:
1108 WXHWND hwndParent
= (HWND
)parent
->GetHandle();
1109 WXDWORD msStyle
= WS_CHILD
| HDS_BUTTONS
| HDS_HORZ
| HDS_HOTTRACK
| HDS_FULLDRAG
;
1110 m_hWnd
= CreateWindowEx(0,
1121 wxLogLastError(_T("CreateWindowEx"));
1125 // we need to subclass the m_hWnd to force wxWindow::HandleNotify
1126 // to call wxDataViewHeaderWindow::MSWOnNotify
1127 SubclassWin(m_hWnd
);
1129 // the following is required to get the default win's font for
1130 // header windows and must be done befor sending the HDM_LAYOUT msg
1137 // Retrieve the bounding rectangle of the parent window's
1138 // client area, and then request size and position values
1139 // from the header control.
1140 ::GetClientRect((HWND
)hwndParent
, &rcParent
);
1142 hdl
.prc
= &rcParent
;
1144 if (!SendMessage((HWND
)m_hWnd
, HDM_LAYOUT
, 0, (LPARAM
) &hdl
))
1146 wxLogLastError(_T("SendMessage"));
1150 // Set the size, position, and visibility of the header control.
1151 SetWindowPos((HWND
)m_hWnd
,
1155 wp
.flags
| SWP_SHOWWINDOW
);
1157 // set our size hints: wxDataViewCtrl will put this wxWindow inside
1158 // a wxBoxSizer and in order to avoid super-big header windows,
1159 // we need to set our height as fixed
1160 SetMinSize(wxSize(-1, wp
.cy
));
1161 SetMaxSize(wxSize(-1, wp
.cy
));
1166 wxDataViewHeaderWindowMSW::~wxDataViewHeaderWindow()
1171 void wxDataViewHeaderWindowMSW::UpdateDisplay()
1173 // remove old columns
1174 for (int j
=0, max
=Header_GetItemCount((HWND
)m_hWnd
); j
< max
; j
++)
1175 Header_DeleteItem((HWND
)m_hWnd
, 0);
1177 // add the updated array of columns to the header control
1178 unsigned int cols
= GetOwner()->GetColumnCount();
1179 unsigned int added
= 0;
1180 wxDataViewModel
* model
= GetOwner()->GetModel();
1181 for (unsigned int i
= 0; i
< cols
; i
++)
1183 wxDataViewColumn
*col
= GetColumn( i
);
1184 if (col
->IsHidden())
1185 continue; // don't add it!
1188 hdi
.mask
= HDI_TEXT
| HDI_FORMAT
| HDI_WIDTH
;
1189 hdi
.pszText
= (wxChar
*) col
->GetTitle().wx_str();
1190 hdi
.cxy
= col
->GetWidth();
1191 hdi
.cchTextMax
= sizeof(hdi
.pszText
)/sizeof(hdi
.pszText
[0]);
1192 hdi
.fmt
= HDF_LEFT
| HDF_STRING
;
1194 // lParam is reserved for application's use:
1195 // we store there the column index to use it later in MSWOnNotify
1196 // (since columns may have been hidden)
1197 hdi
.lParam
= (LPARAM
)i
;
1199 // the native wxMSW implementation of the header window
1200 // draws the column separator COLUMN_WIDTH_OFFSET pixels
1201 // on the right: to correct this effect we make the column
1202 // exactly COLUMN_WIDTH_OFFSET wider (for the first column):
1204 hdi
.cxy
+= COLUMN_WIDTH_OFFSET
;
1206 switch (col
->GetAlignment())
1209 hdi
.fmt
|= HDF_LEFT
;
1211 case wxALIGN_CENTER
:
1212 case wxALIGN_CENTER_HORIZONTAL
:
1213 hdi
.fmt
|= HDF_CENTER
;
1216 hdi
.fmt
|= HDF_RIGHT
;
1220 // such alignment is not allowed for the column header!
1224 SendMessage((HWND
)m_hWnd
, HDM_INSERTITEM
,
1225 (WPARAM
)added
, (LPARAM
)&hdi
);
1230 unsigned int wxDataViewHeaderWindowMSW::GetColumnIdxFromHeader(NMHEADER
*nmHDR
)
1234 // NOTE: we don't just return nmHDR->iItem because when there are
1235 // hidden columns, nmHDR->iItem may be different from
1236 // nmHDR->pitem->lParam
1238 if (nmHDR
->pitem
&& nmHDR
->pitem
->mask
& HDI_LPARAM
)
1240 idx
= (unsigned int)nmHDR
->pitem
->lParam
;
1245 item
.mask
= HDI_LPARAM
;
1246 Header_GetItem((HWND
)m_hWnd
, nmHDR
->iItem
, &item
);
1248 return (unsigned int)item
.lParam
;
1251 bool wxDataViewHeaderWindowMSW::MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
1253 NMHDR
*nmhdr
= (NMHDR
*)lParam
;
1255 // is it a message from the header?
1256 if ( nmhdr
->hwndFrom
!= (HWND
)m_hWnd
)
1257 return wxWindow::MSWOnNotify(idCtrl
, lParam
, result
);
1259 NMHEADER
*nmHDR
= (NMHEADER
*)nmhdr
;
1260 switch ( nmhdr
->code
)
1262 case HDN_BEGINTRACK
:
1263 // user has started to resize a column:
1264 // do we need to veto it?
1265 if (!GetColumn(nmHDR
->iItem
)->IsResizeable())
1273 // user has started to reorder a column
1276 case HDN_ITEMCHANGING
:
1277 if (nmHDR
->pitem
!= NULL
&&
1278 (nmHDR
->pitem
->mask
& HDI_WIDTH
) != 0)
1280 int minWidth
= GetColumnFromHeader(nmHDR
)->GetMinWidth();
1281 if (nmHDR
->pitem
->cxy
< minWidth
)
1283 // do not allow the user to resize this column under
1284 // its minimal width:
1290 case HDN_ITEMCHANGED
: // user is resizing a column
1291 case HDN_ENDTRACK
: // user has finished resizing a column
1292 case HDN_ENDDRAG
: // user has finished reordering a column
1294 // update the width of the modified column:
1295 if (nmHDR
->pitem
!= NULL
&&
1296 (nmHDR
->pitem
->mask
& HDI_WIDTH
) != 0)
1298 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1299 unsigned int w
= nmHDR
->pitem
->cxy
;
1300 wxDataViewColumn
*col
= GetColumn(idx
);
1302 // see UpdateDisplay() for more info about COLUMN_WIDTH_OFFSET
1303 if (idx
== 0 && w
> COLUMN_WIDTH_OFFSET
)
1304 w
-= COLUMN_WIDTH_OFFSET
;
1306 if (w
>= (unsigned)col
->GetMinWidth())
1307 col
->SetInternalWidth(w
);
1313 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1314 wxDataViewModel
* model
= GetOwner()->GetModel();
1316 if(nmHDR
->iButton
== 0)
1318 wxDataViewColumn
*col
= GetColumn(idx
);
1319 if(col
->IsSortable())
1321 if(model
&& model
->GetSortingColumn() == idx
)
1323 bool order
= col
->IsSortOrderAscending();
1324 col
->SetSortOrder(!order
);
1325 model
->SetSortOrderAscending(!order
);
1329 model
->SetSortingColumn(idx
);
1330 model
->SetSortOrderAscending(true);
1338 wxEventType evt
= nmHDR
->iButton
== 0 ?
1339 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
:
1340 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
1341 SendEvent(evt
, idx
);
1347 // NOTE: for some reason (i.e. for a bug in Windows)
1348 // the HDN_ITEMCLICK notification is not sent on
1349 // right clicks, so we need to handle NM_RCLICK
1352 int column
= wxMSWGetColumnClicked(nmhdr
, &ptClick
);
1353 if (column
!= wxNOT_FOUND
)
1356 item
.mask
= HDI_LPARAM
;
1357 Header_GetItem((HWND
)m_hWnd
, column
, &item
);
1359 // 'idx' may be different from 'column' if there are
1360 // hidden columns...
1361 unsigned int idx
= (unsigned int)item
.lParam
;
1362 SendEvent(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
,
1368 case HDN_GETDISPINFOW
:
1369 // see wxListCtrl::MSWOnNotify for more info!
1372 case HDN_ITEMDBLCLICK
:
1374 unsigned int idx
= GetColumnIdxFromHeader(nmHDR
);
1375 int w
= GetOwner()->GetBestColumnWidth(idx
);
1377 // update the native control:
1379 ZeroMemory(&hd
, sizeof(hd
));
1380 hd
.mask
= HDI_WIDTH
;
1382 Header_SetItem(GetHwnd(),
1383 nmHDR
->iItem
, // NOTE: we don't want 'idx' here!
1386 // update the wxDataViewColumn class:
1387 GetColumn(idx
)->SetInternalWidth(w
);
1392 return wxWindow::MSWOnNotify(idCtrl
, lParam
, result
);
1398 void wxDataViewHeaderWindowMSW::ScrollWindow(int WXUNUSED(dx
), int WXUNUSED(dy
),
1399 const wxRect
*WXUNUSED(rect
))
1401 wxSize ourSz
= GetClientSize();
1402 wxSize ownerSz
= m_owner
->GetClientSize();
1404 // where should the (logical) origin of this window be placed?
1406 m_owner
->CalcUnscrolledPosition(0, 0, &x1
, &y1
);
1408 // put this window on top of our parent and
1409 SetWindowPos((HWND
)m_hWnd
, HWND_TOP
, -x1
, 0,
1410 ownerSz
.GetWidth() + x1
, ourSz
.GetHeight(),
1414 void wxDataViewHeaderWindowMSW::DoSetSize(int WXUNUSED(x
), int WXUNUSED(y
),
1415 int WXUNUSED(w
), int WXUNUSED(h
),
1418 // the wxDataViewCtrl's internal wxBoxSizer will call this function when
1419 // the wxDataViewCtrl window gets resized: the following dummy call
1420 // to ScrollWindow() is required in order to get this header window
1421 // correctly repainted when it's (horizontally) scrolled:
1426 #else // !defined(__WXMSW__)
1428 IMPLEMENT_ABSTRACT_CLASS(wxGenericDataViewHeaderWindow
, wxWindow
)
1429 BEGIN_EVENT_TABLE(wxGenericDataViewHeaderWindow
, wxWindow
)
1430 EVT_PAINT (wxGenericDataViewHeaderWindow::OnPaint
)
1431 EVT_MOUSE_EVENTS (wxGenericDataViewHeaderWindow::OnMouse
)
1432 EVT_SET_FOCUS (wxGenericDataViewHeaderWindow::OnSetFocus
)
1435 bool wxGenericDataViewHeaderWindow::Create(wxDataViewCtrl
*parent
, wxWindowID id
,
1436 const wxPoint
&pos
, const wxSize
&size
,
1437 const wxString
&name
)
1441 if (!wxDataViewHeaderWindowBase::Create(parent
, id
, pos
, size
, name
))
1444 wxVisualAttributes attr
= wxPanel::GetClassDefaultAttributes();
1445 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
1446 SetOwnForegroundColour( attr
.colFg
);
1447 SetOwnBackgroundColour( attr
.colBg
);
1449 SetOwnFont( attr
.font
);
1451 // set our size hints: wxDataViewCtrl will put this wxWindow inside
1452 // a wxBoxSizer and in order to avoid super-big header windows,
1453 // we need to set our height as fixed
1454 SetMinSize(wxSize(-1, HEADER_WINDOW_HEIGHT
));
1455 SetMaxSize(wxSize(-1, HEADER_WINDOW_HEIGHT
));
1460 void wxGenericDataViewHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1463 GetClientSize( &w
, &h
);
1465 wxAutoBufferedPaintDC
dc( this );
1467 dc
.SetBackground(GetBackgroundColour());
1471 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
1474 m_owner
->GetViewStart( &x
, NULL
);
1476 // account for the horz scrollbar offset
1477 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
1479 dc
.SetFont( GetFont() );
1481 unsigned int cols
= GetOwner()->GetColumnCount();
1484 for (i
= 0; i
< cols
; i
++)
1486 wxDataViewColumn
*col
= GetColumn( i
);
1487 if (col
->IsHidden())
1488 continue; // skip it!
1490 int cw
= col
->GetWidth();
1493 wxHeaderSortIconType sortArrow
= wxHDR_SORT_ICON_NONE
;
1494 if (col
->IsSortable())
1496 if (col
->IsSortOrderAscending())
1497 sortArrow
= wxHDR_SORT_ICON_UP
;
1499 sortArrow
= wxHDR_SORT_ICON_DOWN
;
1502 wxRendererNative::Get().DrawHeaderButton
1506 wxRect(xpos
, 0, cw
, ch
-1),
1507 m_parent
->IsEnabled() ? 0
1508 : (int)wxCONTROL_DISABLED
,
1512 // align as required the column title:
1514 wxSize titleSz
= dc
.GetTextExtent(col
->GetTitle());
1515 switch (col
->GetAlignment())
1518 x
+= HEADER_HORIZ_BORDER
;
1520 case wxALIGN_CENTER
:
1521 case wxALIGN_CENTER_HORIZONTAL
:
1522 x
+= (cw
- titleSz
.GetWidth() - 2 * HEADER_HORIZ_BORDER
)/2;
1525 x
+= cw
- titleSz
.GetWidth() - HEADER_HORIZ_BORDER
;
1529 // always center the title vertically:
1530 int y
= wxMax((ch
- titleSz
.GetHeight()) / 2, HEADER_VERT_BORDER
);
1532 dc
.SetClippingRegion( xpos
+HEADER_HORIZ_BORDER
,
1534 wxMax(cw
- 2 * HEADER_HORIZ_BORDER
, 1), // width
1535 wxMax(ch
- 2 * HEADER_VERT_BORDER
, 1)); // height
1536 dc
.DrawText( col
->GetTitle(), x
, y
);
1537 dc
.DestroyClippingRegion();
1543 void wxGenericDataViewHeaderWindow::OnSetFocus( wxFocusEvent
&event
)
1545 GetParent()->SetFocus();
1549 void wxGenericDataViewHeaderWindow::OnMouse( wxMouseEvent
&event
)
1551 // we want to work with logical coords
1553 m_owner
->CalcUnscrolledPosition(event
.GetX(), 0, &x
, NULL
);
1554 int y
= event
.GetY();
1558 // we don't draw the line beyond our window,
1559 // but we allow dragging it there
1561 GetClientSize( &w
, NULL
);
1562 m_owner
->CalcUnscrolledPosition(w
, 0, &w
, NULL
);
1565 // erase the line if it was drawn
1569 if (event
.ButtonUp())
1571 m_isDragging
= false;
1577 GetColumn(m_column
)->SetWidth(m_currentX
- m_minX
);
1580 GetOwner()->Refresh();
1584 m_currentX
= wxMax(m_minX
+ 7, x
);
1586 // draw in the new location
1587 if (m_currentX
< w
) DrawCurrent();
1591 else // not dragging
1594 m_column
= wxNOT_FOUND
;
1596 bool hit_border
= false;
1598 // end of the current column
1601 // find the column where this event occured
1602 int countCol
= m_owner
->GetColumnCount();
1603 for (int column
= 0; column
< countCol
; column
++)
1605 wxDataViewColumn
*p
= GetColumn(column
);
1608 continue; // skip if not shown
1610 xpos
+= p
->GetWidth();
1612 if ((abs(x
-xpos
) < 3) && (y
< 22))
1620 // inside the column
1627 if (m_column
== wxNOT_FOUND
)
1630 bool resizeable
= GetColumn(m_column
)->IsResizeable();
1631 if (event
.LeftDClick() && resizeable
)
1633 GetColumn(m_column
)->SetWidth(GetOwner()->GetBestColumnWidth(m_column
));
1636 else if (event
.LeftDown() || event
.RightUp())
1638 if (hit_border
&& event
.LeftDown() && resizeable
)
1640 m_isDragging
= true;
1645 else // click on a column
1647 wxEventType evt
= event
.LeftDown() ?
1648 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK
:
1649 wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK
;
1650 SendEvent(evt
, m_column
);
1653 else if (event
.Moving())
1655 if (hit_border
&& resizeable
)
1656 m_currentCursor
= m_resizeCursor
;
1658 m_currentCursor
= wxSTANDARD_CURSOR
;
1660 SetCursor(*m_currentCursor
);
1665 void wxGenericDataViewHeaderWindow::DrawCurrent()
1667 int x1
= m_currentX
;
1669 ClientToScreen (&x1
, &y1
);
1671 int x2
= m_currentX
-1;
1673 ++x2
; // but why ????
1676 m_owner
->GetClientSize( NULL
, &y2
);
1677 m_owner
->ClientToScreen( &x2
, &y2
);
1680 dc
.SetLogicalFunction(wxINVERT
);
1681 dc
.SetPen(m_penCurrent
);
1682 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1684 dc
.DrawLine(x1
, y1
, x2
, y2
);
1687 void wxGenericDataViewHeaderWindow::AdjustDC(wxDC
& dc
)
1691 m_owner
->GetScrollPixelsPerUnit( &xpix
, NULL
);
1692 m_owner
->GetViewStart( &x
, NULL
);
1694 // shift the DC origin to match the position of the main window horizontal
1695 // scrollbar: this allows us to always use logical coords
1696 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
1699 #endif // defined(__WXMSW__)
1701 //-----------------------------------------------------------------------------
1702 // wxDataViewRenameTimer
1703 //-----------------------------------------------------------------------------
1705 wxDataViewRenameTimer::wxDataViewRenameTimer( wxDataViewMainWindow
*owner
)
1710 void wxDataViewRenameTimer::Notify()
1712 m_owner
->OnRenameTimer();
1715 //-----------------------------------------------------------------------------
1716 // wxDataViewMainWindow
1717 //-----------------------------------------------------------------------------
1719 //The tree building helper, declared firstly
1720 void BuildTreeHelper( wxDataViewModel
* model
, wxDataViewItem
& item
, wxDataViewTreeNode
* node
);
1722 int LINKAGEMODE
wxDataViewSelectionCmp( unsigned int row1
, unsigned int row2
)
1724 if (row1
> row2
) return 1;
1725 if (row1
== row2
) return 0;
1730 IMPLEMENT_ABSTRACT_CLASS(wxDataViewMainWindow
, wxWindow
)
1732 BEGIN_EVENT_TABLE(wxDataViewMainWindow
,wxWindow
)
1733 EVT_PAINT (wxDataViewMainWindow::OnPaint
)
1734 EVT_MOUSE_EVENTS (wxDataViewMainWindow::OnMouse
)
1735 EVT_SET_FOCUS (wxDataViewMainWindow::OnSetFocus
)
1736 EVT_KILL_FOCUS (wxDataViewMainWindow::OnKillFocus
)
1737 EVT_CHAR (wxDataViewMainWindow::OnChar
)
1740 wxDataViewMainWindow::wxDataViewMainWindow( wxDataViewCtrl
*parent
, wxWindowID id
,
1741 const wxPoint
&pos
, const wxSize
&size
, const wxString
&name
) :
1742 wxWindow( parent
, id
, pos
, size
, wxWANTS_CHARS
, name
),
1743 m_selection( wxDataViewSelectionCmp
)
1748 m_lastOnSame
= false;
1749 m_renameTimer
= new wxDataViewRenameTimer( this );
1751 // TODO: user better initial values/nothing selected
1752 m_currentCol
= NULL
;
1755 // TODO: we need to calculate this smartly
1762 wxASSERT(m_lineHeight
> 2*PADDING_TOPBOTTOM
);
1765 m_dragStart
= wxPoint(0,0);
1766 m_lineLastClicked
= (unsigned int) -1;
1767 m_lineBeforeLastClicked
= (unsigned int) -1;
1768 m_lineSelectSingleOnUp
= (unsigned int) -1;
1772 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
1773 SetBackgroundColour( *wxWHITE
);
1775 m_penRule
= wxPen(GetRuleColour(), 1, wxSOLID
);
1777 //Here I compose a pen can draw black lines, maybe there are something system colour to use
1778 m_penExpander
= wxPen( wxColour(0,0,0), 1, wxSOLID
);
1779 //Some new added code to deal with the tree structure
1780 m_root
= new wxDataViewTreeNode( NULL
);
1781 m_root
->SetHasChildren(true);
1783 //Make m_count = -1 will cause the class recaculate the real displaying number of rows.
1788 wxDataViewMainWindow::~wxDataViewMainWindow()
1791 delete m_renameTimer
;
1794 void wxDataViewMainWindow::OnRenameTimer()
1796 // We have to call this here because changes may just have
1797 // been made and no screen update taken place.
1802 unsigned int cols
= GetOwner()->GetColumnCount();
1804 for (i
= 0; i
< cols
; i
++)
1806 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
1808 continue; // skip it!
1810 if (c
== m_currentCol
)
1812 xpos
+= c
->GetWidth();
1814 wxRect
labelRect( xpos
, m_currentRow
* m_lineHeight
,
1815 m_currentCol
->GetWidth(), m_lineHeight
);
1817 GetOwner()->CalcScrolledPosition( labelRect
.x
, labelRect
.y
,
1818 &labelRect
.x
, &labelRect
.y
);
1820 wxDataViewItem item
= GetItemByRow( m_currentRow
);
1821 m_currentCol
->GetRenderer()->StartEditing( item
, labelRect
);
1824 //------------------------------------------------------------------
1825 // Helper class for do operation on the tree node
1826 //------------------------------------------------------------------
1833 //The return value control how the tree-walker tranverse the tree
1834 // 0: Job done, stop tranverse and return
1835 // 1: Ignore the current node's subtree and continue
1836 // 2: Job not done, continue
1837 enum { OK
= 0 , IGR
= 1, CONT
= 2 };
1838 virtual int operator() ( wxDataViewTreeNode
* node
) = 0 ;
1839 virtual int operator() ( void * n
) = 0;
1843 class ItemAddJob
: public DoJob
1846 ItemAddJob( const wxDataViewItem
& parent
, const wxDataViewItem
& item
, int * count
)
1847 { this->parent
= parent
; this->item
= item
; m_count
= count
; }
1848 virtual ~ItemAddJob(){};
1850 virtual int operator() ( wxDataViewTreeNode
* node
)
1852 if( node
->GetItem() == parent
)
1854 node
->SetHasChildren( true );
1855 wxDataViewTreeNode
* newnode
= new wxDataViewTreeNode( node
);
1856 newnode
->SetItem(item
);
1857 node
->AppendChild( newnode
);
1866 wxDataViewItem parent
, item
;
1870 bool Walker( wxDataViewTreeNode
* node
, DoJob
& func
)
1872 if( node
==NULL
|| !node
->HasChildren())
1875 wxDataViewTreeNodes nodes
= node
->GetNodes();
1876 wxDataViewTreeLeaves leaves
= node
->GetChildren();
1878 int len_nodes
= nodes
.GetCount();
1879 int len
= leaves
.GetCount();
1880 int i
= 0, nodes_i
= 0;
1881 for( ; i
< len
; i
++ )
1883 void * n
= leaves
[i
];
1884 if( nodes_i
< len_nodes
&& n
== nodes
[nodes_i
]->GetItem().GetID() )
1886 wxDataViewTreeNode
* nd
= nodes
[nodes_i
];
1889 switch( func( nd
) )
1900 if( Walker( nd
, func
) )
1919 bool wxDataViewMainWindow::ItemAdded(const wxDataViewItem
& parent
, const wxDataViewItem
& item
)
1921 g_model
= GetOwner()->GetModel();
1923 wxDataViewTreeNode
* node
;
1924 node
= FindNode(parent
);
1929 node
->SetHasChildren( true );
1931 if( g_model
->IsContainer( item
) )
1933 wxDataViewTreeNode
* newnode
= new wxDataViewTreeNode( node
);
1934 newnode
->SetItem(item
);
1935 node
->AddNode( newnode
);
1938 node
->AddLeaf( item
.GetID() );
1940 node
->ChangeSubTreeCount(1);
1948 class ItemDeleteJob
: public DoJob
1951 ItemDeleteJob( const wxDataViewItem
& item
, int * count
) { m_item
= item
; m_count
= count
; }
1952 virtual ~ItemDeleteJob(){}
1953 virtual int operator() ( wxDataViewTreeNode
* node
)
1955 if( node
->GetItem() == m_item
)
1957 node
->GetParent()->GetChildren().Remove( node
);
1967 wxDataViewItem m_item
;
1971 void DestroyTreeHelper( wxDataViewTreeNode
* node
);
1973 bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem
& parent
,
1974 const wxDataViewItem
& item
)
1976 g_model
= GetOwner()->GetModel();
1978 wxDataViewTreeNode
* node
;
1979 node
= FindNode(parent
);
1981 if( node
== NULL
|| node
->GetChildren().Index( item
.GetID() ) == wxNOT_FOUND
)
1987 node
->GetChildren().Remove( item
.GetID() );
1988 if( GetOwner()->GetModel()->IsContainer( item
) )
1990 wxDataViewTreeNode
* n
;
1991 wxDataViewTreeNodes nodes
= node
->GetNodes();
1992 int len
= nodes
.GetCount();
1993 for( int i
= 0 ; i
< len
; i
++)
1995 if( nodes
[i
]->GetItem() == item
)
2001 node
->GetNodes().Remove( n
);
2002 sub
-= n
->GetSubTreeCount();
2003 DestroyTreeHelper(n
);
2006 if( node
->GetChildrenNumber() == 0)
2007 node
->SetHasChildren( false );
2009 //Make the row number invalid and get a new valid one when user call GetRowCount
2011 node
->ChangeSubTreeCount(sub
);
2012 //Change the current row to the last row if the current exceed the max row number
2013 if( m_currentRow
> GetRowCount() )
2014 m_currentRow
= m_count
- 1;
2020 bool wxDataViewMainWindow::ItemChanged(const wxDataViewItem
& item
)
2022 g_model
= GetOwner()->GetModel();
2024 unsigned int row
= GetRowByItem(item
);
2029 bool wxDataViewMainWindow::ValueChanged( const wxDataViewItem
& item
, unsigned int WXUNUSED(col
) )
2031 // NOTE: to be valid, we cannot use e.g. INT_MAX - 1
2032 /*#define MAX_VIRTUAL_WIDTH 100000
2034 wxRect rect( 0, row*m_lineHeight, MAX_VIRTUAL_WIDTH, m_lineHeight );
2035 m_owner->CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
2036 Refresh( true, &rect );
2040 g_model
= GetOwner()->GetModel();
2042 unsigned int row
= GetRowByItem(item
);
2047 bool wxDataViewMainWindow::Cleared()
2049 g_model
= GetOwner()->GetModel();
2056 void wxDataViewMainWindow::UpdateDisplay()
2061 void wxDataViewMainWindow::OnInternalIdle()
2063 wxWindow::OnInternalIdle();
2067 RecalculateDisplay();
2072 void wxDataViewMainWindow::RecalculateDisplay()
2074 wxDataViewModel
*model
= GetOwner()->GetModel();
2081 int width
= GetEndOfLastCol();
2082 int height
= GetRowCount() * m_lineHeight
;
2084 SetVirtualSize( width
, height
);
2085 GetOwner()->SetScrollRate( 10, m_lineHeight
);
2090 void wxDataViewMainWindow::ScrollWindow( int dx
, int dy
, const wxRect
*rect
)
2092 wxWindow::ScrollWindow( dx
, dy
, rect
);
2094 if (GetOwner()->m_headerArea
)
2095 GetOwner()->m_headerArea
->ScrollWindow( dx
, 0 );
2098 void wxDataViewMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
2100 wxDataViewModel
*model
= GetOwner()->GetModel();
2101 wxAutoBufferedPaintDC
dc( this );
2104 dc
.SetBackground(GetBackgroundColour());
2106 GetOwner()->PrepareDC( dc
);
2107 dc
.SetFont( GetFont() );
2109 wxRect update
= GetUpdateRegion().GetBox();
2110 m_owner
->CalcUnscrolledPosition( update
.x
, update
.y
, &update
.x
, &update
.y
);
2112 // compute which items needs to be redrawn
2113 unsigned int item_start
= wxMax( 0, (update
.y
/ m_lineHeight
) );
2114 unsigned int item_count
=
2115 wxMin( (int)(((update
.y
+ update
.height
) / m_lineHeight
) - item_start
+ 1),
2116 (int)(GetRowCount( )- item_start
) );
2117 unsigned int item_last
= item_start
+ item_count
;
2119 // compute which columns needs to be redrawn
2120 unsigned int cols
= GetOwner()->GetColumnCount();
2121 unsigned int col_start
= 0;
2122 unsigned int x_start
= 0;
2123 for (x_start
= 0; col_start
< cols
; col_start
++)
2125 wxDataViewColumn
*col
= GetOwner()->GetColumn(col_start
);
2126 if (col
->IsHidden())
2127 continue; // skip it!
2129 unsigned int w
= col
->GetWidth();
2130 if (x_start
+w
>= (unsigned int)update
.x
)
2136 unsigned int col_last
= col_start
;
2137 unsigned int x_last
= x_start
;
2138 for (; col_last
< cols
; col_last
++)
2140 wxDataViewColumn
*col
= GetOwner()->GetColumn(col_last
);
2141 if (col
->IsHidden())
2142 continue; // skip it!
2144 if (x_last
> (unsigned int)update
.GetRight())
2147 x_last
+= col
->GetWidth();
2150 // Draw horizontal rules if required
2151 if ( m_owner
->HasFlag(wxDV_HORIZ_RULES
) )
2153 dc
.SetPen(m_penRule
);
2154 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2156 for (unsigned int i
= item_start
; i
<= item_last
+1; i
++)
2158 int y
= i
* m_lineHeight
;
2159 dc
.DrawLine(x_start
, y
, x_last
, y
);
2163 // Draw vertical rules if required
2164 if ( m_owner
->HasFlag(wxDV_VERT_RULES
) )
2166 dc
.SetPen(m_penRule
);
2167 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
2170 for (unsigned int i
= col_start
; i
< col_last
; i
++)
2172 wxDataViewColumn
*col
= GetOwner()->GetColumn(i
);
2173 if (col
->IsHidden())
2174 continue; // skip it
2176 dc
.DrawLine(x
, item_start
* m_lineHeight
,
2177 x
, item_last
* m_lineHeight
);
2179 x
+= col
->GetWidth();
2182 // Draw last vertical rule
2183 dc
.DrawLine(x
, item_start
* m_lineHeight
,
2184 x
, item_last
* m_lineHeight
);
2187 // redraw the background for the items which are selected/current
2188 for (unsigned int item
= item_start
; item
< item_last
; item
++)
2190 bool selected
= m_selection
.Index( item
) != wxNOT_FOUND
;
2191 if (selected
|| item
== m_currentRow
)
2193 int flags
= selected
? (int)wxCONTROL_SELECTED
: 0;
2194 if (item
== m_currentRow
)
2195 flags
|= wxCONTROL_CURRENT
;
2197 flags
|= wxCONTROL_FOCUSED
;
2199 wxRect
rect( x_start
, item
*m_lineHeight
, x_last
, m_lineHeight
);
2200 wxRendererNative::Get().DrawItemSelectionRect
2210 // redraw all cells for all rows which must be repainted and for all columns
2212 cell_rect
.x
= x_start
;
2213 cell_rect
.height
= m_lineHeight
; // -1 is for the horizontal rules
2214 for (unsigned int i
= col_start
; i
< col_last
; i
++)
2216 wxDataViewColumn
*col
= GetOwner()->GetColumn( i
);
2217 wxDataViewRenderer
*cell
= col
->GetRenderer();
2218 cell_rect
.width
= col
->GetWidth();
2220 if (col
->IsHidden())
2221 continue; // skipt it!
2223 for (unsigned int item
= item_start
; item
< item_last
; item
++)
2225 // get the cell value and set it into the renderer
2227 wxDataViewTreeNode
* node
= GetTreeNodeByRow(item
);
2233 wxDataViewItem dataitem
= node
->GetItem();
2234 model
->GetValue( value
, dataitem
, col
->GetModelColumn());
2235 cell
->SetValue( value
);
2237 // update the y offset
2238 cell_rect
.y
= item
* m_lineHeight
;
2240 //Draw the expander here.
2241 int indent
= node
->GetIndentLevel();
2242 if( col
->GetModelColumn() == GetOwner()->GetExpanderColumn() )
2244 //Calculate the indent first
2245 indent
= cell_rect
.x
+ GetOwner()->GetIndent() * indent
;
2247 int expander_width
= m_lineHeight
- 2*EXPANDER_MARGIN
;
2248 // change the cell_rect.x to the appropriate pos
2249 int expander_x
= indent
+ EXPANDER_MARGIN
, expander_y
= cell_rect
.y
+ EXPANDER_MARGIN
;
2250 indent
= indent
+ m_lineHeight
; //try to use the m_lineHeight as the expander space
2251 dc
.SetPen( m_penExpander
);
2252 dc
.SetBrush( wxNullBrush
);
2253 if( node
->HasChildren() )
2255 //dc.DrawRoundedRectangle( expander_x,expander_y,expander_width,expander_width, 1.0);
2256 //dc.DrawLine( expander_x + 2 , expander_y + expander_width/2, expander_x + expander_width - 2, expander_y + expander_width/2 );
2257 wxRect
rect( expander_x
, expander_y
, expander_width
, expander_width
);
2258 if( node
->IsOpen() )
2259 wxRendererNative::Get().DrawTreeItemButton( this, dc
, rect
, wxCONTROL_EXPANDED
);
2261 wxRendererNative::Get().DrawTreeItemButton( this, dc
, rect
);
2265 // I am wandering whether we should draw dot lines between tree nodes
2267 //Yes, if the node does not have any child, it must be a leaf which mean that it is a temporarily created by GetTreeNodeByRow
2270 //force the expander column to left-center align
2271 cell
->SetAlignment( wxALIGN_CENTER_VERTICAL
);
2275 // cannot be bigger than allocated space
2276 wxSize size
= cell
->GetSize();
2277 // Because of the tree structure indent, here we should minus the width of the cell for drawing
2278 size
.x
= wxMin( size
.x
+ 2*PADDING_RIGHTLEFT
, cell_rect
.width
- indent
);
2279 size
.y
= wxMin( size
.y
+ 2*PADDING_TOPBOTTOM
, cell_rect
.height
);
2281 wxRect
item_rect(cell_rect
.GetTopLeft(), size
);
2282 int align
= cell
->GetAlignment();
2284 // horizontal alignment:
2285 item_rect
.x
= cell_rect
.x
;
2286 if (align
& wxALIGN_CENTER_HORIZONTAL
)
2287 item_rect
.x
= cell_rect
.x
+ (cell_rect
.width
/ 2) - (size
.x
/ 2);
2288 else if (align
& wxALIGN_RIGHT
)
2289 item_rect
.x
= cell_rect
.x
+ cell_rect
.width
- size
.x
;
2290 //else: wxALIGN_LEFT is the default
2292 // vertical alignment:
2293 item_rect
.y
= cell_rect
.y
;
2294 if (align
& wxALIGN_CENTER_VERTICAL
)
2295 item_rect
.y
= cell_rect
.y
+ (cell_rect
.height
/ 2) - (size
.y
/ 2);
2296 else if (align
& wxALIGN_BOTTOM
)
2297 item_rect
.y
= cell_rect
.y
+ cell_rect
.height
- size
.y
;
2298 //else: wxALIGN_TOP is the default
2301 item_rect
.x
+= PADDING_RIGHTLEFT
;
2302 item_rect
.y
+= PADDING_TOPBOTTOM
;
2303 item_rect
.width
= size
.x
- 2 * PADDING_RIGHTLEFT
;
2304 item_rect
.height
= size
.y
- 2 * PADDING_TOPBOTTOM
;
2306 //Here we add the tree indent
2307 item_rect
.x
+= indent
;
2310 if (m_selection
.Index(item
) != wxNOT_FOUND
)
2311 state
|= wxDATAVIEW_CELL_SELECTED
;
2313 // TODO: it would be much more efficient to create a clipping
2314 // region for the entire column being rendered (in the OnPaint
2315 // of wxDataViewMainWindow) instead of a single clip region for
2316 // each cell. However it would mean that each renderer should
2317 // respect the given wxRect's top & bottom coords, eventually
2318 // violating only the left & right coords - however the user can
2319 // make its own renderer and thus we cannot be sure of that.
2320 dc
.SetClippingRegion( item_rect
);
2321 cell
->Render( item_rect
, &dc
, state
);
2322 dc
.DestroyClippingRegion();
2325 cell_rect
.x
+= cell_rect
.width
;
2329 int wxDataViewMainWindow::GetCountPerPage() const
2331 wxSize size
= GetClientSize();
2332 return size
.y
/ m_lineHeight
;
2335 int wxDataViewMainWindow::GetEndOfLastCol() const
2339 for (i
= 0; i
< GetOwner()->GetColumnCount(); i
++)
2341 const wxDataViewColumn
*c
=
2342 wx_const_cast(wxDataViewCtrl
*, GetOwner())->GetColumn( i
);
2345 width
+= c
->GetWidth();
2350 unsigned int wxDataViewMainWindow::GetFirstVisibleRow() const
2354 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
2356 return y
/ m_lineHeight
;
2359 unsigned int wxDataViewMainWindow::GetLastVisibleRow()
2361 wxSize client_size
= GetClientSize();
2362 m_owner
->CalcUnscrolledPosition( client_size
.x
, client_size
.y
,
2363 &client_size
.x
, &client_size
.y
);
2365 return wxMin( GetRowCount()-1, ((unsigned)client_size
.y
/m_lineHeight
)+1 );
2368 unsigned int wxDataViewMainWindow::GetRowCount()
2370 if ( m_count
== -1 )
2372 m_count
= RecalculateCount();
2374 GetVirtualSize( &width
, &height
);
2375 height
= m_count
* m_lineHeight
;
2377 SetVirtualSize( width
, height
);
2382 void wxDataViewMainWindow::ChangeCurrentRow( unsigned int row
)
2389 void wxDataViewMainWindow::SelectAllRows( bool on
)
2396 m_selection
.Clear();
2397 for (unsigned int i
= 0; i
< GetRowCount(); i
++)
2398 m_selection
.Add( i
);
2403 unsigned int first_visible
= GetFirstVisibleRow();
2404 unsigned int last_visible
= GetLastVisibleRow();
2406 for (i
= 0; i
< m_selection
.GetCount(); i
++)
2408 unsigned int row
= m_selection
[i
];
2409 if ((row
>= first_visible
) && (row
<= last_visible
))
2412 m_selection
.Clear();
2416 void wxDataViewMainWindow::SelectRow( unsigned int row
, bool on
)
2418 if (m_selection
.Index( row
) == wxNOT_FOUND
)
2422 m_selection
.Add( row
);
2430 m_selection
.Remove( row
);
2436 void wxDataViewMainWindow::SelectRows( unsigned int from
, unsigned int to
, bool on
)
2440 unsigned int tmp
= from
;
2446 for (i
= from
; i
<= to
; i
++)
2448 if (m_selection
.Index( i
) == wxNOT_FOUND
)
2451 m_selection
.Add( i
);
2456 m_selection
.Remove( i
);
2459 RefreshRows( from
, to
);
2462 void wxDataViewMainWindow::Select( const wxArrayInt
& aSelections
)
2464 for (size_t i
=0; i
< aSelections
.GetCount(); i
++)
2466 int n
= aSelections
[i
];
2468 m_selection
.Add( n
);
2473 void wxDataViewMainWindow::ReverseRowSelection( unsigned int row
)
2475 if (m_selection
.Index( row
) == wxNOT_FOUND
)
2476 m_selection
.Add( row
);
2478 m_selection
.Remove( row
);
2482 bool wxDataViewMainWindow::IsRowSelected( unsigned int row
)
2484 return (m_selection
.Index( row
) != wxNOT_FOUND
);
2487 void wxDataViewMainWindow::RefreshRow( unsigned int row
)
2489 wxRect
rect( 0, row
*m_lineHeight
, GetEndOfLastCol(), m_lineHeight
);
2490 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2492 wxSize client_size
= GetClientSize();
2493 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2494 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2495 if (intersect_rect
.width
> 0)
2496 Refresh( true, &intersect_rect
);
2499 void wxDataViewMainWindow::RefreshRows( unsigned int from
, unsigned int to
)
2503 unsigned int tmp
= to
;
2508 wxRect
rect( 0, from
*m_lineHeight
, GetEndOfLastCol(), (to
-from
+1) * m_lineHeight
);
2509 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2511 wxSize client_size
= GetClientSize();
2512 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2513 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2514 if (intersect_rect
.width
> 0)
2515 Refresh( true, &intersect_rect
);
2518 void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow
)
2520 unsigned int count
= GetRowCount();
2521 if (firstRow
> count
)
2524 wxRect
rect( 0, firstRow
*m_lineHeight
, GetEndOfLastCol(), count
* m_lineHeight
);
2525 m_owner
->CalcScrolledPosition( rect
.x
, rect
.y
, &rect
.x
, &rect
.y
);
2527 wxSize client_size
= GetClientSize();
2528 wxRect
client_rect( 0, 0, client_size
.x
, client_size
.y
);
2529 wxRect intersect_rect
= client_rect
.Intersect( rect
);
2530 if (intersect_rect
.width
> 0)
2531 Refresh( true, &intersect_rect
);
2534 void wxDataViewMainWindow::OnArrowChar(unsigned int newCurrent
, const wxKeyEvent
& event
)
2536 wxCHECK_RET( newCurrent
< GetRowCount(),
2537 _T("invalid item index in OnArrowChar()") );
2539 // if there is no selection, we cannot move it anywhere
2540 if (!HasCurrentRow())
2543 unsigned int oldCurrent
= m_currentRow
;
2545 // in single selection we just ignore Shift as we can't select several
2547 if ( event
.ShiftDown() && !IsSingleSel() )
2549 RefreshRow( oldCurrent
);
2551 ChangeCurrentRow( newCurrent
);
2553 // select all the items between the old and the new one
2554 if ( oldCurrent
> newCurrent
)
2556 newCurrent
= oldCurrent
;
2557 oldCurrent
= m_currentRow
;
2560 SelectRows( oldCurrent
, newCurrent
, true );
2564 RefreshRow( oldCurrent
);
2566 // all previously selected items are unselected unless ctrl is held
2567 if ( !event
.ControlDown() )
2568 SelectAllRows(false);
2570 ChangeCurrentRow( newCurrent
);
2572 if ( !event
.ControlDown() )
2573 SelectRow( m_currentRow
, true );
2575 RefreshRow( m_currentRow
);
2578 //EnsureVisible( m_currentRow );
2581 wxRect
wxDataViewMainWindow::GetLineRect( unsigned int row
) const
2585 rect
.y
= m_lineHeight
* row
;
2586 rect
.width
= GetEndOfLastCol();
2587 rect
.height
= m_lineHeight
;
2592 class RowToItemJob
: public DoJob
2595 RowToItemJob( unsigned int row
, int current
) { this->row
= row
; this->current
= current
;}
2596 virtual ~RowToItemJob(){};
2598 virtual int operator() ( wxDataViewTreeNode
* node
)
2601 if( current
== static_cast<int>(row
))
2603 ret
= node
->GetItem() ;
2607 if( node
->GetSubTreeCount() + current
< static_cast<int>(row
) )
2609 current
+= node
->GetSubTreeCount();
2616 virtual int operator() ( void * n
)
2619 if( current
== static_cast<int>(row
))
2621 ret
= wxDataViewItem( n
) ;
2626 wxDataViewItem
GetResult(){ return ret
; }
2633 wxDataViewItem
wxDataViewMainWindow::GetItemByRow(unsigned int row
)
2635 RowToItemJob
job( row
, -1 );
2636 Walker( m_root
, job
);
2637 return job
.GetResult();
2640 class RowToTreeNodeJob
: public DoJob
2643 RowToTreeNodeJob( unsigned int row
, int current
, wxDataViewTreeNode
* node
)
2646 this->current
= current
;
2650 virtual ~RowToTreeNodeJob(){};
2652 virtual int operator() ( wxDataViewTreeNode
* node
)
2655 if( current
== static_cast<int>(row
))
2661 if( node
->GetSubTreeCount() + current
< static_cast<int>(row
) )
2663 current
+= node
->GetSubTreeCount();
2674 virtual int operator() ( void * n
)
2677 if( current
== static_cast<int>(row
))
2679 ret
= new wxDataViewTreeNode( parent
) ;
2680 ret
->SetItem( wxDataViewItem( n
));
2681 ret
->SetHasChildren(false);
2687 wxDataViewTreeNode
* GetResult(){ return ret
; }
2691 wxDataViewTreeNode
* ret
;
2692 wxDataViewTreeNode
* parent
;
2696 wxDataViewTreeNode
* wxDataViewMainWindow::GetTreeNodeByRow(unsigned int row
)
2698 RowToTreeNodeJob
job( row
, -1, m_root
);
2699 Walker( m_root
, job
);
2700 return job
.GetResult();
2704 class CountJob
: public DoJob
2707 CountJob(){ count
= 0 ; }
2708 virtual ~CountJob(){};
2710 virtual int operator () ( wxDataViewTreeNode
* node
)
2713 if ( node
->IsOpen())
2719 unsigned int GetResult()
2728 void wxDataViewMainWindow::OnExpanding( unsigned int row
)
2730 wxDataViewTreeNode
* node
= GetTreeNodeByRow(row
);
2733 if( node
->HasChildren())
2734 if( !node
->IsOpen())
2737 //Here I build the children of current node
2738 if( node
->GetChildrenNumber() == 0 )
2739 BuildTreeHelper(GetOwner()->GetModel(), node
->GetItem(), node
);
2745 SelectRow( row
, false );
2746 SelectRow( row
+ 1, true );
2747 ChangeCurrentRow( row
+ 1 );
2754 void wxDataViewMainWindow::OnCollapsing(unsigned int row
)
2756 wxDataViewTreeNode
* node
= GetTreeNodeByRow(row
);
2759 wxDataViewTreeNode
* nd
= node
;
2761 if( node
->HasChildren() && node
->IsOpen() )
2766 //RefreshRows(row,GetLastVisibleRow());
2770 node
= node
->GetParent();
2773 int parent
= GetRowByItem( node
->GetItem()) ;
2774 SelectRow( row
, false);
2775 SelectRow(parent
, true );
2776 ChangeCurrentRow( parent
);
2779 if( !nd
->HasChildren())
2784 wxDataViewTreeNode
* wxDataViewMainWindow::FindNode( const wxDataViewItem
& item
)
2786 wxDataViewModel
* model
= GetOwner()->GetModel();
2790 //Compose the a parent-chain of the finding item
2792 list
.DeleteContents( true );
2793 wxDataViewItem
it( item
);
2796 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2797 list
.Insert( pItem
);
2798 it
= model
->GetParent( it
);
2801 //Find the item along the parent-chain.
2802 //This algorithm is designed to speed up the node-finding method
2804 wxDataViewTreeNode
* node
= m_root
;
2805 for( ItemList::Node
* n
= list
.GetFirst(); n
; n
= n
->GetNext() )
2807 if( node
->HasChildren() )
2809 if( node
->GetChildrenNumber() == 0 )
2810 BuildTreeHelper(model
, node
->GetItem(), node
);
2812 int len
= node
->GetNodeNumber();
2813 wxDataViewTreeNodes nodes
= node
->GetNodes();
2815 for( ; j
< len
; j
++)
2817 if( nodes
[j
]->GetItem() == *(n
->GetData()))
2823 // Whenever we can't find the node in any level, return NULL to indicate the item can't be found
2836 int wxDataViewMainWindow::RecalculateCount()
2838 return m_root
->GetSubTreeCount();
2841 class ItemToRowJob
: public DoJob
2844 ItemToRowJob(const wxDataViewItem
& item
, ItemList::Node
* node
)
2845 { this->item
= item
; ret
= 0 ; nd
= node
; }
2846 virtual ~ItemToRowJob(){};
2848 virtual int operator() ( wxDataViewTreeNode
* node
)
2851 if( node
->GetItem() == item
)
2856 if( nd
&& node
->GetItem() == *(nd
->GetData()))
2863 ret
+= node
->GetSubTreeCount();
2869 virtual int operator() ( void * n
)
2872 if( n
== item
.GetID() )
2876 //the row number is begin from zero
2877 int GetResult(){ return ret
-1 ; }
2879 ItemList::Node
* nd
;
2880 wxDataViewItem item
;
2885 unsigned int wxDataViewMainWindow::GetRowByItem(const wxDataViewItem
& item
)
2887 wxDataViewModel
* model
= GetOwner()->GetModel();
2891 //Compose the a parent-chain of the finding item
2893 list
.DeleteContents( true );
2894 wxDataViewItem
it( item
);
2897 wxDataViewItem
* pItem
= new wxDataViewItem( it
);
2898 list
.Insert( pItem
);
2899 it
= model
->GetParent( it
);
2902 ItemToRowJob
job( item
, list
.GetFirst() );
2903 Walker(m_root
, job
);
2904 return job
.GetResult();
2907 void BuildTreeHelper( wxDataViewModel
* model
, wxDataViewItem
& item
, wxDataViewTreeNode
* node
)
2909 if( !model
->IsContainer( item
) )
2912 wxDataViewItem i
= model
->GetFirstChild( item
);
2917 if( model
->IsContainer( i
) )
2919 wxDataViewTreeNode
* n
= new wxDataViewTreeNode( node
);
2921 n
->SetHasChildren( true ) ;
2926 node
->AddLeaf( i
.GetID() );
2928 i
= model
->GetNextSibling( i
);
2930 node
->SetSubTreeCount( num
);
2931 wxDataViewTreeNode
* n
= node
->GetParent();
2933 n
->ChangeSubTreeCount(num
);
2937 void wxDataViewMainWindow::BuildTree(wxDataViewModel
* model
)
2939 //First we define a invalid item to fetch the top-level elements
2940 wxDataViewItem item
;
2941 g_model
= GetOwner()->GetModel();
2942 BuildTreeHelper( model
, item
, m_root
);
2946 void DestroyTreeHelper( wxDataViewTreeNode
* node
)
2948 if( node
->GetNodeNumber() != 0 )
2950 int len
= node
->GetNodeNumber();
2952 wxDataViewTreeNodes nodes
= node
->GetNodes();
2953 for( ; i
< len
; i
++ )
2955 DestroyTreeHelper(nodes
[i
]);
2961 void wxDataViewMainWindow::DestroyTree()
2963 DestroyTreeHelper(m_root
);
2964 m_root
->SetSubTreeCount(0);
2968 void wxDataViewMainWindow::OnChar( wxKeyEvent
&event
)
2970 if (event
.GetKeyCode() == WXK_TAB
)
2972 wxNavigationKeyEvent nevent
;
2973 nevent
.SetWindowChange( event
.ControlDown() );
2974 nevent
.SetDirection( !event
.ShiftDown() );
2975 nevent
.SetEventObject( GetParent()->GetParent() );
2976 nevent
.SetCurrentFocus( m_parent
);
2977 if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent
))
2981 // no item -> nothing to do
2982 if (!HasCurrentRow())
2988 // don't use m_linesPerPage directly as it might not be computed yet
2989 const int pageSize
= GetCountPerPage();
2990 wxCHECK_RET( pageSize
, _T("should have non zero page size") );
2992 switch ( event
.GetKeyCode() )
2995 if ( m_currentRow
> 0 )
2996 OnArrowChar( m_currentRow
- 1, event
);
3000 if ( m_currentRow
< GetRowCount() - 1 )
3001 OnArrowChar( m_currentRow
+ 1, event
);
3003 //Add the process for tree expanding/collapsing
3005 OnCollapsing(m_currentRow
);
3008 OnExpanding( m_currentRow
);
3012 OnArrowChar( GetRowCount() - 1, event
);
3017 OnArrowChar( 0, event
);
3022 int steps
= pageSize
- 1;
3023 int index
= m_currentRow
- steps
;
3027 OnArrowChar( index
, event
);
3033 int steps
= pageSize
- 1;
3034 unsigned int index
= m_currentRow
+ steps
;
3035 unsigned int count
= GetRowCount();
3036 if ( index
>= count
)
3039 OnArrowChar( index
, event
);
3048 void wxDataViewMainWindow::OnMouse( wxMouseEvent
&event
)
3050 if (event
.GetEventType() == wxEVT_MOUSEWHEEL
)
3052 // let the base handle mouse wheel events.
3057 int x
= event
.GetX();
3058 int y
= event
.GetY();
3059 m_owner
->CalcUnscrolledPosition( x
, y
, &x
, &y
);
3061 wxDataViewColumn
*col
= NULL
;
3064 unsigned int cols
= GetOwner()->GetColumnCount();
3066 for (i
= 0; i
< cols
; i
++)
3068 wxDataViewColumn
*c
= GetOwner()->GetColumn( i
);
3070 continue; // skip it!
3072 if (x
< xpos
+ c
->GetWidth())
3077 xpos
+= c
->GetWidth();
3081 wxDataViewRenderer
*cell
= col
->GetRenderer();
3083 unsigned int current
= y
/ m_lineHeight
;
3085 if ((current
> GetRowCount()) || (x
> GetEndOfLastCol()))
3087 // Unselect all if below the last row ?
3091 wxDataViewModel
*model
= GetOwner()->GetModel();
3093 if (event
.Dragging())
3095 if (m_dragCount
== 0)
3097 // we have to report the raw, physical coords as we want to be
3098 // able to call HitTest(event.m_pointDrag) from the user code to
3099 // get the item being dragged
3100 m_dragStart
= event
.GetPosition();
3105 if (m_dragCount
!= 3)
3108 if (event
.LeftIsDown())
3110 // Notify cell about drag
3119 bool forceClick
= false;
3121 if (event
.ButtonDClick())
3123 m_renameTimer
->Stop();
3124 m_lastOnSame
= false;
3127 if (event
.LeftDClick())
3129 if ( current
== m_lineLastClicked
)
3131 if (cell
->GetMode() == wxDATAVIEW_CELL_ACTIVATABLE
)
3133 wxDataViewItem item
= GetItemByRow(current
);
3135 model
->GetValue( value
, item
, col
->GetModelColumn() );
3136 cell
->SetValue( value
);
3137 wxRect
cell_rect( xpos
, current
* m_lineHeight
,
3138 col
->GetWidth(), m_lineHeight
);
3139 cell
->Activate( cell_rect
, model
, item
, col
->GetModelColumn() );
3145 // The first click was on another item, so don't interpret this as
3146 // a double click, but as a simple click instead
3153 if (m_lineSelectSingleOnUp
!= (unsigned int)-1)
3155 // select single line
3156 SelectAllRows( false );
3157 SelectRow( m_lineSelectSingleOnUp
, true );
3160 //Process the event of user clicking the expander
3161 bool expander
= false;
3162 wxDataViewTreeNode
* node
= GetTreeNodeByRow(current
);
3163 if( node
!=NULL
&& node
->HasChildren() )
3165 int indent
= node
->GetIndentLevel();
3166 indent
= GetOwner()->GetIndent()*indent
;
3167 wxRect
rect( xpos
+ indent
+ EXPANDER_MARGIN
, current
* m_lineHeight
+ EXPANDER_MARGIN
, m_lineHeight
-2*EXPANDER_MARGIN
,m_lineHeight
-2*EXPANDER_MARGIN
);
3168 if( rect
.Contains( x
, y
) )
3171 if( node
->IsOpen() )
3172 OnCollapsing(current
);
3174 OnExpanding( current
);
3178 //If the user click the expander, we do not do editing even if the column with expander are editable
3179 if (m_lastOnSame
&& !expander
)
3181 if ((col
== m_currentCol
) && (current
== m_currentRow
) &&
3182 (cell
->GetMode() == wxDATAVIEW_CELL_EDITABLE
) )
3184 m_renameTimer
->Start( 100, true );
3188 m_lastOnSame
= false;
3189 m_lineSelectSingleOnUp
= (unsigned int)-1;
3193 // This is necessary, because after a DnD operation in
3194 // from and to ourself, the up event is swallowed by the
3195 // DnD code. So on next non-up event (which means here and
3196 // now) m_lineSelectSingleOnUp should be reset.
3197 m_lineSelectSingleOnUp
= (unsigned int)-1;
3200 if (event
.RightDown())
3202 m_lineBeforeLastClicked
= m_lineLastClicked
;
3203 m_lineLastClicked
= current
;
3205 // If the item is already selected, do not update the selection.
3206 // Multi-selections should not be cleared if a selected item is clicked.
3207 if (!IsRowSelected(current
))
3209 SelectAllRows(false);
3210 ChangeCurrentRow(current
);
3211 SelectRow(m_currentRow
,true);
3214 // notify cell about right click
3217 // Allow generation of context menu event
3220 else if (event
.MiddleDown())
3222 // notify cell about middle click
3225 if (event
.LeftDown() || forceClick
)
3231 m_lineBeforeLastClicked
= m_lineLastClicked
;
3232 m_lineLastClicked
= current
;
3234 unsigned int oldCurrentRow
= m_currentRow
;
3235 bool oldWasSelected
= IsRowSelected(m_currentRow
);
3237 bool cmdModifierDown
= event
.CmdDown();
3238 if ( IsSingleSel() || !(cmdModifierDown
|| event
.ShiftDown()) )
3240 if ( IsSingleSel() || !IsRowSelected(current
) )
3242 SelectAllRows( false );
3244 ChangeCurrentRow(current
);
3246 SelectRow(m_currentRow
,true);
3248 else // multi sel & current is highlighted & no mod keys
3250 m_lineSelectSingleOnUp
= current
;
3251 ChangeCurrentRow(current
); // change focus
3254 else // multi sel & either ctrl or shift is down
3256 if (cmdModifierDown
)
3258 ChangeCurrentRow(current
);
3260 ReverseRowSelection(m_currentRow
);
3262 else if (event
.ShiftDown())
3264 ChangeCurrentRow(current
);
3266 unsigned int lineFrom
= oldCurrentRow
,
3269 if ( lineTo
< lineFrom
)
3272 lineFrom
= m_currentRow
;
3275 SelectRows(lineFrom
, lineTo
, true);
3277 else // !ctrl, !shift
3279 // test in the enclosing if should make it impossible
3280 wxFAIL_MSG( _T("how did we get here?") );
3284 if (m_currentRow
!= oldCurrentRow
)
3285 RefreshRow( oldCurrentRow
);
3287 wxDataViewColumn
*oldCurrentCol
= m_currentCol
;
3289 // Update selection here...
3292 m_lastOnSame
= !forceClick
&& ((col
== oldCurrentCol
) &&
3293 (current
== oldCurrentRow
)) && oldWasSelected
;
3297 void wxDataViewMainWindow::OnSetFocus( wxFocusEvent
&event
)
3301 if (HasCurrentRow())
3307 void wxDataViewMainWindow::OnKillFocus( wxFocusEvent
&event
)
3311 if (HasCurrentRow())
3317 wxDataViewItem
wxDataViewMainWindow::GetSelection()
3319 if( m_selection
.GetCount() != 1 )
3320 return wxDataViewItem();
3322 return GetItemByRow( m_selection
.Item(0));
3325 //-----------------------------------------------------------------------------
3327 //-----------------------------------------------------------------------------
3329 IMPLEMENT_DYNAMIC_CLASS(wxDataViewCtrl
, wxDataViewCtrlBase
)
3331 BEGIN_EVENT_TABLE(wxDataViewCtrl
, wxDataViewCtrlBase
)
3332 EVT_SIZE(wxDataViewCtrl::OnSize
)
3335 wxDataViewCtrl::~wxDataViewCtrl()
3338 GetModel()->RemoveNotifier( m_notifier
);
3341 void wxDataViewCtrl::Init()
3346 bool wxDataViewCtrl::Create(wxWindow
*parent
, wxWindowID id
,
3347 const wxPoint
& pos
, const wxSize
& size
,
3348 long style
, const wxValidator
& validator
)
3350 if (!wxControl::Create( parent
, id
, pos
, size
,
3351 style
| wxScrolledWindowStyle
|wxSUNKEN_BORDER
, validator
))
3357 MacSetClipChildren( true ) ;
3360 m_clientArea
= new wxDataViewMainWindow( this, wxID_ANY
);
3362 if (HasFlag(wxDV_NO_HEADER
))
3363 m_headerArea
= NULL
;
3365 m_headerArea
= new wxDataViewHeaderWindow( this, wxID_ANY
);
3367 SetTargetWindow( m_clientArea
);
3369 wxBoxSizer
*sizer
= new wxBoxSizer( wxVERTICAL
);
3371 sizer
->Add( m_headerArea
, 0, wxGROW
);
3372 sizer
->Add( m_clientArea
, 1, wxGROW
);
3379 WXLRESULT
wxDataViewCtrl::MSWWindowProc(WXUINT nMsg
,
3383 WXLRESULT rc
= wxDataViewCtrlBase::MSWWindowProc(nMsg
, wParam
, lParam
);
3386 // we need to process arrows ourselves for scrolling
3387 if ( nMsg
== WM_GETDLGCODE
)
3389 rc
|= DLGC_WANTARROWS
;
3397 void wxDataViewCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
3399 // We need to override OnSize so that our scrolled
3400 // window a) does call Layout() to use sizers for
3401 // positioning the controls but b) does not query
3402 // the sizer for their size and use that for setting
3403 // the scrollable area as set that ourselves by
3404 // calling SetScrollbar() further down.
3411 bool wxDataViewCtrl::AssociateModel( wxDataViewModel
*model
)
3413 if (!wxDataViewCtrlBase::AssociateModel( model
))
3416 m_notifier
= new wxGenericDataViewModelNotifier( m_clientArea
);
3418 model
->AddNotifier( m_notifier
);
3420 m_clientArea
->BuildTree(model
);
3422 m_clientArea
->UpdateDisplay();
3427 bool wxDataViewCtrl::AppendColumn( wxDataViewColumn
*col
)
3429 if (!wxDataViewCtrlBase::AppendColumn(col
))
3436 void wxDataViewCtrl::OnColumnChange()
3439 m_headerArea
->UpdateDisplay();
3441 m_clientArea
->UpdateDisplay();
3444 void wxDataViewCtrl::DoSetExpanderColumn()
3446 m_clientArea
->UpdateDisplay();
3449 void wxDataViewCtrl::DoSetIndent()
3451 m_clientArea
->UpdateDisplay();
3454 wxDataViewItem
wxDataViewCtrl::GetSelection()
3456 return m_clientArea
->GetSelection();
3459 /********************************************************************
3460 void wxDataViewCtrl::SetSelection( int row )
3462 m_clientArea->SelectRow(row, true);
3465 void wxDataViewCtrl::SetSelectionRange( unsigned int from, unsigned int to )
3467 m_clientArea->SelectRows(from, to, true);
3470 void wxDataViewCtrl::SetSelections( const wxArrayInt& aSelections )
3472 m_clientArea->Select(aSelections);
3475 void wxDataViewCtrl::Unselect( unsigned int WXUNUSED(row) )
3480 bool wxDataViewCtrl::IsSelected( unsigned int WXUNUSED(row) ) const
3487 int wxDataViewCtrl::GetSelection() const
3494 int wxDataViewCtrl::GetSelections(wxArrayInt& WXUNUSED(aSelections) ) const
3500 *********************************************************************/
3502 // !wxUSE_GENERICDATAVIEWCTRL
3505 // wxUSE_DATAVIEWCTRL