1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDataViewCtrl wxWidgets sample
4 // Author: Robert Roebling
5 // Modified by: Francesco Montorsi, Bo Yang
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/datetime.h"
24 #include "wx/splitter.h"
25 #include "wx/aboutdlg.h"
26 #include "wx/choicdlg.h"
27 #include "wx/numdlg.h"
28 #include "wx/dataview.h"
29 #include "wx/spinctrl.h"
32 #include "../sample.xpm"
38 #define DEFAULT_ALIGN wxALIGN_LEFT
39 #define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
42 // -------------------------------------
43 // MySpinCtrlInPlaceRenderer
44 // -------------------------------------
46 class MySpinCtrlInPlaceRenderer
: public wxDataViewCustomRenderer
49 MySpinCtrlInPlaceRenderer() :
50 wxDataViewCustomRenderer( wxT("long"), wxDATAVIEW_CELL_EDITABLE
) { }
53 virtual bool HasEditorCtrl()
57 virtual wxControl
* CreateEditorCtrl( wxWindow
*parent
, wxRect labelRect
, const wxVariant
&value
)
60 return new wxSpinCtrl( parent
, wxID_ANY
, wxEmptyString
,
61 labelRect
.GetTopLeft(), labelRect
.GetSize(), -0, -1, 2010, l
);
63 virtual bool GetValueFromEditorCtrl( wxControl
* editor
, wxVariant
&value
)
65 wxSpinCtrl
*sc
= (wxSpinCtrl
*) editor
;
66 long l
= sc
->GetValue();
71 bool Render( wxRect rect
, wxDC
*dc
, int WXUNUSED(state
) )
74 str
.Printf( wxT("%d"), (int) m_data
);
75 dc
->SetTextForeground( *wxBLACK
);
76 dc
->DrawText( str
, rect
.x
, rect
.y
);
79 wxSize
GetSize() const
83 bool SetValue( const wxVariant
&value
)
85 m_data
= value
.GetLong();
88 bool GetValue( wxVariant
&value
) const
100 // -------------------------------------
102 // -------------------------------------
105 Implement this data model
107 -------------------------------------------------------------
110 3: You are not alone Michael Jackson 1995
111 4: Take a bow Madonna 1994
113 6: Ninth Symphony Ludwig v. Beethoven 1824
114 7: German Requiem Johannes Brahms 1868
119 class MyMusicModelNode
;
120 WX_DEFINE_ARRAY_PTR( MyMusicModelNode
*, MyMusicModelNodes
);
122 class MyMusicModelNode
125 MyMusicModelNode( MyMusicModelNode
* parent
,
126 const wxString
&title
, const wxString
&artist
, int year
)
132 m_isContainer
= false;
135 MyMusicModelNode( MyMusicModelNode
* parent
,
136 const wxString
&branch
)
141 m_isContainer
= true;
146 size_t count
= m_children
.GetCount();
148 for (i
= 0; i
< count
; i
++)
150 MyMusicModelNode
*child
= m_children
[i
];
155 bool IsContainer() { return m_isContainer
; }
157 MyMusicModelNode
* GetParent() { return m_parent
; }
158 MyMusicModelNodes
&GetChildren() { return m_children
; }
159 MyMusicModelNode
* GetNthChild( unsigned int n
) { return m_children
.Item( n
); }
160 void Insert( MyMusicModelNode
* child
, unsigned int n
) { m_children
.Insert( child
, n
); }
161 void Append( MyMusicModelNode
* child
) { m_children
.Add( child
); }
162 unsigned int GetChildCount() { return m_children
.GetCount(); }
170 MyMusicModelNode
*m_parent
;
171 MyMusicModelNodes m_children
;
176 class MyMusicModel
: public wxDataViewModel
184 m_root
= new MyMusicModelNode( NULL
, "My Music" );
185 m_pop
= new MyMusicModelNode( m_root
, "Pop music" );
186 m_root
->Append( m_pop
);
187 m_pop
->Append( new MyMusicModelNode( m_pop
,
188 "You are not alone", "Michael Jackson", 1995 ) );
189 m_pop
->Append( new MyMusicModelNode( m_pop
,
190 "Take a bow", "Madonna", 1994 ) );
191 m_classical
= new MyMusicModelNode( m_root
, "Classical music" );
192 m_root
->Append( m_classical
);
193 m_classical
->Append( new MyMusicModelNode( m_classical
,
194 "Ninth symphony", "Ludwig van Beethoven", 1824 ) );
195 m_classical
->Append( new MyMusicModelNode( m_classical
,
196 "German Requiem", "Johannes Brahms", 1868 ) );
197 m_classicalMusicIsKnownToControl
= false;
200 // helper method for wxLog
202 wxString
GetTitle( const wxDataViewItem
&item
)
204 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
206 return wxEmptyString
;
208 return node
->m_title
;
211 // helper methods to change the model
213 void AddToClassical( const wxString
&title
, const wxString
&artist
, int year
)
216 MyMusicModelNode
*child_node
=
217 new MyMusicModelNode( m_classical
, title
, artist
, year
);
219 m_classical
->Append( child_node
);
221 if (m_classicalMusicIsKnownToControl
)
224 wxDataViewItem
child( (void*) child_node
);
225 wxDataViewItem
parent( (void*) m_classical
);
226 ItemAdded( parent
, child
);
230 void Delete( const wxDataViewItem
&item
)
232 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
233 wxDataViewItem
parent( node
->GetParent() );
235 node
->GetParent()->GetChildren().Remove( node
);
239 ItemDeleted( parent
, item
);
242 // override sorting to always sort branches ascendingly
244 int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
245 unsigned int column
, bool ascending
)
247 if (IsContainer(item1
) && IsContainer(item2
))
249 wxVariant value1
,value2
;
250 GetValue( value1
, item1
, 0 );
251 GetValue( value2
, item2
, 0 );
253 wxString str1
= value1
.GetString();
254 wxString str2
= value2
.GetString();
255 int res
= str1
.Cmp( str2
);
258 // items must be different
259 unsigned long litem1
= (unsigned long) item1
.GetID();
260 unsigned long litem2
= (unsigned long) item2
.GetID();
262 return litem1
-litem2
;
265 return wxDataViewModel::Compare( item1
, item2
, column
, ascending
);
268 // implementation of base class virtuals to define model
270 virtual unsigned int GetColumnCount() const
275 virtual wxString
GetColumnType( unsigned int col
) const
283 virtual void GetValue( wxVariant
&variant
,
284 const wxDataViewItem
&item
, unsigned int col
) const
286 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
289 case 0: variant
= node
->m_title
; break;
290 case 1: variant
= node
->m_artist
; break;
291 case 2: variant
= (long) node
->m_year
; break;
294 wxLogError( "MyMusicModel::GetValue: wrong column" );
296 // provoke a crash when mouse button down
297 wxMouseState state
= wxGetMouseState();
298 if (state
.ShiftDown())
307 virtual bool SetValue( const wxVariant
&variant
,
308 const wxDataViewItem
&item
, unsigned int col
)
310 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
313 case 0: node
->m_title
= variant
.GetString(); return true;
314 case 1: node
->m_artist
= variant
.GetString(); return true;
315 case 2: node
->m_year
= variant
.GetLong(); return true;
316 default: wxLogError( "MyMusicModel::SetValue: wrong column" );
321 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const
323 // the invisble root node has no parent
325 return wxDataViewItem(0);
327 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
329 // "MyMusic" also has no parent
331 return wxDataViewItem(0);
333 return wxDataViewItem( (void*) node
->GetParent() );
336 virtual bool IsContainer( const wxDataViewItem
&item
) const
338 // the invisble root node can have children (in
339 // our model always "MyMusic")
343 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
344 return node
->IsContainer();
347 virtual unsigned int GetChildren( const wxDataViewItem
&parent
, wxDataViewItemArray
&array
) const
349 MyMusicModelNode
*node
= (MyMusicModelNode
*) parent
.GetID();
352 array
.Add( wxDataViewItem( (void*) m_root
) );
356 if (node
== m_classical
)
358 MyMusicModel
*model
= (MyMusicModel
*)(const MyMusicModel
*) this;
359 model
->m_classicalMusicIsKnownToControl
= true;
362 if (node
->GetChildCount() == 0)
367 unsigned int count
= node
->GetChildren().GetCount();
369 for (pos
= 0; pos
< count
; pos
++)
371 MyMusicModelNode
*child
= node
->GetChildren().Item( pos
);
372 array
.Add( wxDataViewItem( (void*) child
) );
378 MyMusicModelNode
* m_root
;
379 MyMusicModelNode
* m_pop
;
380 MyMusicModelNode
* m_classical
;
381 bool m_classicalMusicIsKnownToControl
;
384 class MyListModel
: public wxDataViewIndexListModel
388 wxDataViewIndexListModel( 100 )
391 for (i
= 0; i
< 100; i
++)
394 str
.Printf( "row number %d", i
);
398 m_icon
= wxIcon( null_xpm
);
401 // helper methods to change the model
403 void Prepend( const wxString
&text
)
405 m_array
.Insert( text
, 0 );
409 void DeleteItem( const wxDataViewItem
&item
)
411 unsigned int row
= GetRow( item
);
412 m_array
.RemoveAt( row
);
416 // implementation of base class virtuals to define model
418 virtual unsigned int GetColumnCount() const
423 virtual wxString
GetColumnType( unsigned int col
) const
426 return "wxDataViewIconText";
431 virtual unsigned int GetRowCount()
433 return m_array
.GetCount();
436 virtual void GetValue( wxVariant
&variant
,
437 unsigned int row
, unsigned int col
) const
441 variant
= m_array
[ row
];
445 wxDataViewIconText
data( "test", m_icon
);
451 str
.Printf( "row %d col %d", row
, col
);
456 virtual bool SetValue( const wxVariant
&variant
,
457 unsigned int row
, unsigned int col
)
461 m_array
[row
] = variant
.GetString();
468 wxArrayString m_array
;
472 // -------------------------------------
474 // -------------------------------------
476 class MyApp
: public wxApp
483 // -------------------------------------
485 // -------------------------------------
487 class MyFrame
: public wxFrame
490 MyFrame(wxFrame
*frame
, wxChar
*title
, int x
, int y
, int w
, int h
);
493 void OnQuit(wxCommandEvent
& event
);
494 void OnAbout(wxCommandEvent
& event
);
496 void OnAddMozart(wxCommandEvent
& event
);
497 void OnDeleteMusic(wxCommandEvent
& event
);
499 void OnPrependList(wxCommandEvent
& event
);
500 void OnDeleteList(wxCommandEvent
& event
);
502 void OnValueChanged( wxDataViewEvent
&event
);
503 void OnItemAdded( wxDataViewEvent
&event
);
504 void OnItemDeleted( wxDataViewEvent
&event
);
506 void OnActivated( wxDataViewEvent
&event
);
507 void OnExpanding( wxDataViewEvent
&event
);
508 void OnExpanded( wxDataViewEvent
&event
);
509 void OnCollapsing( wxDataViewEvent
&event
);
510 void OnCollapsed( wxDataViewEvent
&event
);
511 void OnSelectionChanged( wxDataViewEvent
&event
);
513 void OnEditingStarted( wxDataViewEvent
&event
);
514 void OnEditingDone( wxDataViewEvent
&event
);
516 void OnHeaderClick( wxDataViewEvent
&event
);
517 void OnHeaderRightClick( wxDataViewEvent
&event
);
518 void OnSorted( wxDataViewEvent
&event
);
520 void OnRightClick( wxMouseEvent
&event
);
521 void OnGoto( wxCommandEvent
&event
);
524 wxDataViewCtrl
* m_musicCtrl
;
525 wxObjectDataPtr
<MyMusicModel
> m_music_model
;
527 wxDataViewCtrl
* m_listCtrl
;
528 wxObjectDataPtr
<MyListModel
> m_list_model
;
530 wxDataViewColumn
* m_col
;
536 DECLARE_EVENT_TABLE()
539 // -------------------------------------
541 // -------------------------------------
545 bool MyApp::OnInit(void)
547 if ( !wxApp::OnInit() )
550 // build the first frame
552 new MyFrame(NULL
, wxT("wxDataViewCtrl feature test"), 40, 40, 800, 440);
565 // -------------------------------------
567 // -------------------------------------
572 ID_ABOUT
= wxID_ABOUT
,
578 ID_DELETE_MUSIC
= 101,
580 ID_PREPEND_LIST
= 200,
581 ID_DELETE_LIST
= 201,
585 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
586 EVT_MENU( ID_ABOUT
, MyFrame::OnAbout
)
587 EVT_MENU( ID_EXIT
, MyFrame::OnQuit
)
588 EVT_BUTTON( ID_ADD_MOZART
, MyFrame::OnAddMozart
)
589 EVT_BUTTON( ID_DELETE_MUSIC
, MyFrame::OnDeleteMusic
)
590 EVT_BUTTON( ID_PREPEND_LIST
, MyFrame::OnPrependList
)
591 EVT_BUTTON( ID_DELETE_LIST
, MyFrame::OnDeleteList
)
592 EVT_BUTTON( ID_GOTO
, MyFrame::OnGoto
)
594 EVT_DATAVIEW_MODEL_ITEM_ADDED( ID_MUSIC_CTRL
, MyFrame::OnItemAdded
)
595 EVT_DATAVIEW_MODEL_ITEM_DELETED( ID_MUSIC_CTRL
, MyFrame::OnItemDeleted
)
596 EVT_DATAVIEW_MODEL_VALUE_CHANGED( ID_MUSIC_CTRL
, MyFrame::OnValueChanged
)
597 EVT_DATAVIEW_MODEL_ITEM_CHANGED( ID_MUSIC_CTRL
, MyFrame::OnValueChanged
)
599 EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL
, MyFrame::OnActivated
)
600 EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL
, MyFrame::OnExpanding
)
601 EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL
, MyFrame::OnExpanded
)
602 EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL
, MyFrame::OnCollapsing
)
603 EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL
, MyFrame::OnCollapsed
)
604 EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL
, MyFrame::OnSelectionChanged
)
606 EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL
, MyFrame::OnEditingStarted
)
607 EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL
, MyFrame::OnEditingDone
)
609 EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL
, MyFrame::OnHeaderClick
)
610 EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL
, MyFrame::OnHeaderRightClick
)
611 EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL
, MyFrame::OnSorted
)
613 EVT_RIGHT_UP(MyFrame::OnRightClick
)
616 MyFrame::MyFrame(wxFrame
*frame
, wxChar
*title
, int x
, int y
, int w
, int h
):
617 wxFrame(frame
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(w
, h
))
622 SetIcon(wxICON(sample
));
626 wxMenu
*file_menu
= new wxMenu
;
627 file_menu
->Append(ID_ABOUT
, "&About");
628 file_menu
->AppendSeparator();
629 file_menu
->Append(ID_EXIT
, "E&xit");
631 wxMenuBar
*menu_bar
= new wxMenuBar
;
632 menu_bar
->Append(file_menu
, "&File");
634 SetMenuBar(menu_bar
);
637 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
639 wxBoxSizer
*data_sizer
= new wxBoxSizer( wxHORIZONTAL
);
643 m_musicCtrl
= new wxDataViewCtrl( this, ID_MUSIC_CTRL
, wxDefaultPosition
,
644 wxDefaultSize
, wxDV_MULTIPLE
);
646 m_music_model
= new MyMusicModel
;
647 m_musicCtrl
->AssociateModel( m_music_model
.get() );
649 wxDataViewColumn
*col
= m_musicCtrl
->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT
, 200,
650 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
652 // Call this and sorting is enabled
653 // immediatly upon start up.
654 col
->SetSortOrder( true );
657 m_musicCtrl
->AppendTextColumn( "Artist", 1, wxDATAVIEW_CELL_EDITABLE
, 150,
658 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
660 MySpinCtrlInPlaceRenderer
*sr
= new MySpinCtrlInPlaceRenderer
;
661 wxDataViewColumn
*column
= new wxDataViewColumn( "year", sr
, 2, -1, wxALIGN_CENTRE
, wxDATAVIEW_COL_SORTABLE
);
662 m_musicCtrl
->AppendColumn( column
);
664 data_sizer
->Add( m_musicCtrl
, 3, wxGROW
);
670 m_listCtrl
= new wxDataViewCtrl( this, wxID_ANY
, wxDefaultPosition
,
671 wxDefaultSize
, wxDV_MULTIPLE
);
673 m_list_model
= new MyListModel
;
674 m_listCtrl
->AssociateModel( m_list_model
.get() );
676 m_listCtrl
->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE
, 120 );
677 m_listCtrl
->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT
, 60 );
678 m_listCtrl
->AppendTextColumn( "index", 2, wxDATAVIEW_CELL_INERT
, 120 );
680 data_sizer
->Add( m_listCtrl
, 2, wxGROW
);
684 main_sizer
->Add( data_sizer
, 2, wxGROW
);
686 wxBoxSizer
*button_sizer
= new wxBoxSizer( wxHORIZONTAL
);
688 button_sizer
->Add( new wxButton( this, ID_ADD_MOZART
, "Add Mozart"), 0, wxALL
, 10 );
689 button_sizer
->Add( new wxButton( this, ID_DELETE_MUSIC
, "Delete selected"), 0, wxALL
, 10 );
690 button_sizer
->Add( 10, 10, 1 );
691 button_sizer
->Add( new wxButton( this, ID_PREPEND_LIST
, "Prepend"), 0, wxALL
, 10 );
692 button_sizer
->Add( new wxButton( this, ID_DELETE_LIST
, "Delete selected"), 0, wxALL
, 10 );
693 button_sizer
->Add( new wxButton( this, ID_GOTO
, "Goto 50"), 0, wxALL
, 10 );
695 main_sizer
->Add( button_sizer
, 0, wxGROW
, 0 );
697 m_log
= new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
698 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_log
));
699 wxLogMessage("This is the log window");
701 main_sizer
->Add( m_log
, 1, wxGROW
);
703 SetSizer( main_sizer
);
706 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
711 void MyFrame::OnAddMozart(wxCommandEvent
& WXUNUSED(event
) )
713 m_music_model
->AddToClassical( "Kleine Nachtmusik", "Wolfgang Mozart", 1787 );
716 void MyFrame::OnDeleteMusic(wxCommandEvent
& WXUNUSED(event
) )
718 wxDataViewItemArray items
;
719 int len
= m_musicCtrl
->GetSelections( items
);
720 for( int i
= 0; i
< len
; i
++ )
722 m_music_model
->Delete( items
[i
] );
725 void MyFrame::OnPrependList( wxCommandEvent
& WXUNUSED(event
) )
727 m_list_model
->Prepend( "Test" );
730 void MyFrame::OnDeleteList( wxCommandEvent
& WXUNUSED(event
) )
732 wxDataViewItemArray items
;
733 int len
= m_listCtrl
->GetSelections( items
);
734 for( int i
= 0; i
< len
; i
++ )
736 m_list_model
->DeleteItem( items
[i
] );
739 void MyFrame::OnItemAdded( wxDataViewEvent
&event
)
744 wxLogMessage("wxEVT_COMMAND_DATAVIEW_MODEL_ITEM_ADDED, Item Id: %d",event
.GetItem().GetID());
747 void MyFrame::OnItemDeleted( wxDataViewEvent
&event
)
752 wxLogMessage( "EVT_DATAVIEW_MODEL_ITEM_DELETED, Item Id: %d", event
.GetItem().GetID() );
755 void MyFrame::OnValueChanged( wxDataViewEvent
&event
)
760 wxLogMessage( "EVT_DATAVIEW_MODEL_VALUE_CHANGED, Item Id: %d; Column: %d", event
.GetItem().GetID(), event
.GetColumn() );
763 void MyFrame::OnActivated( wxDataViewEvent
&event
)
768 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
769 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title
);
772 void MyFrame::OnSelectionChanged( wxDataViewEvent
&event
)
777 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
781 wxLogMessage("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, First selected Item: %s", title
);
784 void MyFrame::OnExpanding( wxDataViewEvent
&event
)
789 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
790 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item: %s", title
);
794 void MyFrame::OnEditingStarted( wxDataViewEvent
&event
)
799 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
800 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, Item: %s", title
);
803 void MyFrame::OnEditingDone( wxDataViewEvent
&event
)
808 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
809 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, Item: %s", title
);
812 void MyFrame::OnExpanded( wxDataViewEvent
&event
)
817 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
818 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item: %s", title
);
821 void MyFrame::OnCollapsing( wxDataViewEvent
&event
)
826 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
827 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item: %s", title
);
830 void MyFrame::OnCollapsed( wxDataViewEvent
&event
)
835 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
836 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title
);
839 void MyFrame::OnHeaderClick( wxDataViewEvent
&event
)
844 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
846 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos
);
849 void MyFrame::OnHeaderRightClick( wxDataViewEvent
&event
)
854 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
856 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos
);
859 void MyFrame::OnSorted( wxDataViewEvent
&event
)
864 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
866 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, Column position: %d", pos
);
869 void MyFrame::OnRightClick( wxMouseEvent
&event
)
874 wxLogMessage("wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d", event
.GetX(), event
.GetY());
877 void MyFrame::OnGoto( wxCommandEvent
&event
)
879 wxDataViewItem item
= m_list_model
->GetItem( 50 );
880 m_listCtrl
->EnsureVisible(item
,m_col
);
883 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
885 wxAboutDialogInfo info
;
886 info
.SetName(_("DataView sample"));
887 info
.SetDescription(_("This sample demonstrates the dataview control handling"));
888 info
.SetCopyright(_T("(C) 2007 Robert Roebling"));