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 // -------------------------------------
44 // -------------------------------------
47 Implement this data model
49 -------------------------------------------------------------
52 3: You are not alone Michael Jackson 1995
53 4: Take a bow Madonna 1994
55 6: Ninth Symphony Ludwig v. Beethoven 1824
56 7: German Requiem Johannes Brahms 1868
61 class MyMusicModelNode
;
62 WX_DEFINE_ARRAY_PTR( MyMusicModelNode
*, MyMusicModelNodes
);
64 class MyMusicModelNode
67 MyMusicModelNode( MyMusicModelNode
* parent
,
68 const wxString
&title
, const wxString
&artist
, int year
)
74 m_isContainer
= false;
77 MyMusicModelNode( MyMusicModelNode
* parent
,
78 const wxString
&branch
)
88 size_t count
= m_children
.GetCount();
90 for (i
= 0; i
< count
; i
++)
92 MyMusicModelNode
*child
= m_children
[i
];
97 bool IsContainer() { return m_isContainer
; }
99 MyMusicModelNode
* GetParent() { return m_parent
; }
100 MyMusicModelNodes
&GetChildren() { return m_children
; }
101 MyMusicModelNode
* GetNthChild( unsigned int n
) { return m_children
.Item( n
); }
102 void Insert( MyMusicModelNode
* child
, unsigned int n
) { m_children
.Insert( child
, n
); }
103 void Append( MyMusicModelNode
* child
) { m_children
.Add( child
); }
104 unsigned int GetChildCount() { return m_children
.GetCount(); }
112 MyMusicModelNode
*m_parent
;
113 MyMusicModelNodes m_children
;
118 class MyMusicModel
: public wxDataViewModel
126 m_root
= new MyMusicModelNode( NULL
, "My Music" );
127 m_pop
= new MyMusicModelNode( m_root
, "Pop music" );
128 m_root
->Append( m_pop
);
129 m_pop
->Append( new MyMusicModelNode( m_pop
,
130 "You are not alone", "Michael Jackson", 1995 ) );
131 m_pop
->Append( new MyMusicModelNode( m_pop
,
132 "Take a bow", "Madonna", 1994 ) );
133 m_classical
= new MyMusicModelNode( m_root
, "Classical music" );
134 m_root
->Append( m_classical
);
135 m_classical
->Append( new MyMusicModelNode( m_classical
,
136 "Ninth symphony", "Ludwig van Beethoven", 1824 ) );
137 m_classical
->Append( new MyMusicModelNode( m_classical
,
138 "German Requiem", "Johannes Brahms", 1868 ) );
139 m_classicalMusicIsKnownToControl
= false;
142 // helper method for wxLog
144 wxString
GetTitle( const wxDataViewItem
&item
)
146 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
148 return wxEmptyString
;
150 return node
->m_title
;
153 // helper methods to change the model
155 void AddToClassical( const wxString
&title
, const wxString
&artist
, int year
)
158 MyMusicModelNode
*child_node
=
159 new MyMusicModelNode( m_classical
, title
, artist
, year
);
161 m_classical
->Append( child_node
);
163 if (m_classicalMusicIsKnownToControl
)
166 wxDataViewItem
child( (void*) child_node
);
167 wxDataViewItem
parent( (void*) m_classical
);
168 ItemAdded( parent
, child
);
172 void Delete( const wxDataViewItem
&item
)
174 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
175 wxDataViewItem
parent( node
->GetParent() );
177 node
->GetParent()->GetChildren().Remove( node
);
181 ItemDeleted( parent
, item
);
184 // override sorting to always sort branches ascendingly
186 int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
187 unsigned int column
, bool ascending
)
189 if (IsContainer(item1
) && IsContainer(item2
))
191 wxVariant value1
,value2
;
192 GetValue( value1
, item1
, 0 );
193 GetValue( value2
, item2
, 0 );
195 wxString str1
= value1
.GetString();
196 wxString str2
= value2
.GetString();
197 int res
= str1
.Cmp( str2
);
200 // items must be different
201 unsigned long litem1
= (unsigned long) item1
.GetID();
202 unsigned long litem2
= (unsigned long) item2
.GetID();
204 return litem1
-litem2
;
207 return wxDataViewModel::Compare( item1
, item2
, column
, ascending
);
210 // implementation of base class virtuals to define model
212 virtual unsigned int GetColumnCount() const
217 virtual wxString
GetColumnType( unsigned int col
) const
225 virtual void GetValue( wxVariant
&variant
,
226 const wxDataViewItem
&item
, unsigned int col
) const
228 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
231 case 0: variant
= node
->m_title
; break;
232 case 1: variant
= node
->m_artist
; break;
233 case 2: variant
= (long) node
->m_year
; break;
236 wxLogError( "MyMusicModel::GetValue: wrong column" );
238 // provoke a crash when mouse button down
239 wxMouseState state
= wxGetMouseState();
240 if (state
.ShiftDown())
249 virtual bool SetValue( const wxVariant
&variant
,
250 const wxDataViewItem
&item
, unsigned int col
)
252 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
255 case 0: node
->m_title
= variant
.GetString(); return true;
256 case 1: node
->m_artist
= variant
.GetString(); return true;
257 case 2: node
->m_year
= variant
.GetLong(); return true;
258 default: wxLogError( "MyMusicModel::SetValue: wrong column" );
263 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const
265 // the invisble root node has no parent
267 return wxDataViewItem(0);
269 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
271 // "MyMusic" also has no parent
273 return wxDataViewItem(0);
275 return wxDataViewItem( (void*) node
->GetParent() );
278 virtual bool IsContainer( const wxDataViewItem
&item
) const
280 // the invisble root node can have children (in
281 // our model always "MyMusic")
285 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
286 return node
->IsContainer();
289 virtual unsigned int GetChildren( const wxDataViewItem
&parent
, wxDataViewItemArray
&array
) const
291 MyMusicModelNode
*node
= (MyMusicModelNode
*) parent
.GetID();
294 array
.Add( wxDataViewItem( (void*) m_root
) );
298 if (node
== m_classical
)
300 MyMusicModel
*model
= (MyMusicModel
*)(const MyMusicModel
*) this;
301 model
->m_classicalMusicIsKnownToControl
= true;
304 if (node
->GetChildCount() == 0)
309 unsigned int count
= node
->GetChildren().GetCount();
311 for (pos
= 0; pos
< count
; pos
++)
313 MyMusicModelNode
*child
= node
->GetChildren().Item( pos
);
314 array
.Add( wxDataViewItem( (void*) child
) );
320 MyMusicModelNode
* m_root
;
321 MyMusicModelNode
* m_pop
;
322 MyMusicModelNode
* m_classical
;
323 bool m_classicalMusicIsKnownToControl
;
326 class MyListModel
: public wxDataViewIndexListModel
330 wxDataViewIndexListModel( 100 )
333 for (i
= 0; i
< 100; i
++)
336 str
.Printf( "row number %d", i
);
340 m_icon
= wxIcon( null_xpm
);
343 // helper methods to change the model
345 void Prepend( const wxString
&text
)
347 m_array
.Insert( text
, 0 );
351 void DeleteItem( const wxDataViewItem
&item
)
353 unsigned int row
= GetRow( item
);
354 m_array
.RemoveAt( row
);
358 // implementation of base class virtuals to define model
360 virtual unsigned int GetColumnCount() const
365 virtual wxString
GetColumnType( unsigned int col
) const
368 return "wxDataViewIconText";
373 virtual unsigned int GetRowCount()
375 return m_array
.GetCount();
378 virtual void GetValue( wxVariant
&variant
,
379 unsigned int row
, unsigned int col
) const
383 variant
= m_array
[ row
];
387 wxDataViewIconText
data( "test", m_icon
);
399 virtual bool GetAttr( unsigned int row
, unsigned int col
, wxDataViewItemAttr
&attr
)
405 attr
.SetColour( *wxBLUE
);
407 attr
.SetItalic( true );
412 virtual bool SetValue( const wxVariant
&variant
,
413 unsigned int row
, unsigned int col
)
417 m_array
[row
] = variant
.GetString();
424 wxArrayString m_array
;
428 // -------------------------------------
430 // -------------------------------------
432 class MyApp
: public wxApp
439 // -------------------------------------
441 // -------------------------------------
443 class MyFrame
: public wxFrame
446 MyFrame(wxFrame
*frame
, const wxString
&title
, int x
, int y
, int w
, int h
);
449 void OnQuit(wxCommandEvent
& event
);
450 void OnAbout(wxCommandEvent
& event
);
452 void OnTestTreeCtrl(wxCommandEvent
& event
);
454 void OnAddMozart(wxCommandEvent
& event
);
455 void OnDeleteMusic(wxCommandEvent
& event
);
456 void OnDeleteYear(wxCommandEvent
& event
);
458 void OnPrependList(wxCommandEvent
& event
);
459 void OnDeleteList(wxCommandEvent
& event
);
461 void OnValueChanged( wxDataViewEvent
&event
);
463 void OnActivated( wxDataViewEvent
&event
);
464 void OnExpanding( wxDataViewEvent
&event
);
465 void OnExpanded( wxDataViewEvent
&event
);
466 void OnCollapsing( wxDataViewEvent
&event
);
467 void OnCollapsed( wxDataViewEvent
&event
);
468 void OnSelectionChanged( wxDataViewEvent
&event
);
470 void OnEditingStarted( wxDataViewEvent
&event
);
471 void OnEditingDone( wxDataViewEvent
&event
);
473 void OnHeaderClick( wxDataViewEvent
&event
);
474 void OnHeaderRightClick( wxDataViewEvent
&event
);
475 void OnSorted( wxDataViewEvent
&event
);
477 void OnRightClick( wxMouseEvent
&event
);
478 void OnGoto( wxCommandEvent
&event
);
481 wxDataViewCtrl
* m_musicCtrl
;
482 wxObjectDataPtr
<MyMusicModel
> m_music_model
;
484 wxDataViewCtrl
* m_listCtrl
;
485 wxObjectDataPtr
<MyListModel
> m_list_model
;
487 wxDataViewColumn
* m_col
;
493 DECLARE_EVENT_TABLE()
496 // -------------------------------------
498 // -------------------------------------
502 bool MyApp::OnInit(void)
504 if ( !wxApp::OnInit() )
507 // build the first frame
509 new MyFrame(NULL
, wxT("wxDataViewCtrl feature test"), 40, 40, 800, 440);
522 // -------------------------------------
524 // -------------------------------------
529 ID_ABOUT
= wxID_ABOUT
,
532 ID_TEST_TREECTRL
= 40,
537 ID_DELETE_MUSIC
= 101,
538 ID_DELETE_YEAR
= 102,
540 ID_PREPEND_LIST
= 200,
541 ID_DELETE_LIST
= 201,
545 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
546 EVT_MENU( ID_ABOUT
, MyFrame::OnAbout
)
547 EVT_MENU( ID_TEST_TREECTRL
, MyFrame::OnTestTreeCtrl
)
548 EVT_MENU( ID_EXIT
, MyFrame::OnQuit
)
549 EVT_BUTTON( ID_ADD_MOZART
, MyFrame::OnAddMozart
)
550 EVT_BUTTON( ID_DELETE_MUSIC
, MyFrame::OnDeleteMusic
)
551 EVT_BUTTON( ID_DELETE_YEAR
, MyFrame::OnDeleteYear
)
552 EVT_BUTTON( ID_PREPEND_LIST
, MyFrame::OnPrependList
)
553 EVT_BUTTON( ID_DELETE_LIST
, MyFrame::OnDeleteList
)
554 EVT_BUTTON( ID_GOTO
, MyFrame::OnGoto
)
556 EVT_DATAVIEW_ITEM_VALUE_CHANGED( ID_MUSIC_CTRL
, MyFrame::OnValueChanged
)
558 EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL
, MyFrame::OnActivated
)
559 EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL
, MyFrame::OnExpanding
)
560 EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL
, MyFrame::OnExpanded
)
561 EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL
, MyFrame::OnCollapsing
)
562 EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL
, MyFrame::OnCollapsed
)
563 EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL
, MyFrame::OnSelectionChanged
)
565 EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL
, MyFrame::OnEditingStarted
)
566 EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL
, MyFrame::OnEditingDone
)
568 EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL
, MyFrame::OnHeaderClick
)
569 EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL
, MyFrame::OnHeaderRightClick
)
570 EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL
, MyFrame::OnSorted
)
572 EVT_RIGHT_UP(MyFrame::OnRightClick
)
575 MyFrame::MyFrame(wxFrame
*frame
, const wxString
&title
, int x
, int y
, int w
, int h
):
576 wxFrame(frame
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(w
, h
))
581 SetIcon(wxICON(sample
));
585 wxMenu
*file_menu
= new wxMenu
;
586 file_menu
->Append(ID_ABOUT
, "&About");
587 file_menu
->AppendSeparator();
588 file_menu
->Append(ID_TEST_TREECTRL
, "Test &Treectrl");
589 file_menu
->AppendSeparator();
590 file_menu
->Append(ID_EXIT
, "E&xit");
592 wxMenuBar
*menu_bar
= new wxMenuBar
;
593 menu_bar
->Append(file_menu
, "&File");
595 SetMenuBar(menu_bar
);
598 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
600 wxBoxSizer
*data_sizer
= new wxBoxSizer( wxHORIZONTAL
);
604 m_musicCtrl
= new wxDataViewCtrl( this, ID_MUSIC_CTRL
, wxDefaultPosition
,
605 wxDefaultSize
, wxDV_MULTIPLE
);
607 m_music_model
= new MyMusicModel
;
608 m_musicCtrl
->AssociateModel( m_music_model
.get() );
610 /* wxDataViewColumn *col = */ m_musicCtrl
->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT
, 200,
611 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
613 // Call this and sorting is enabled
614 // immediatly upon start up.
615 col
->SetSortOrder( true );
618 m_musicCtrl
->AppendTextColumn( "Artist", 1, wxDATAVIEW_CELL_EDITABLE
, 150,
619 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
621 wxDataViewSpinRenderer
*sr
= new wxDataViewSpinRenderer( 0, 2010 );
622 wxDataViewColumn
*column
= new wxDataViewColumn( "year", sr
, 2, -1, wxALIGN_CENTRE
, wxDATAVIEW_COL_SORTABLE
);
623 m_musicCtrl
->AppendColumn( column
);
625 data_sizer
->Add( m_musicCtrl
, 3, wxGROW
);
631 m_listCtrl
= new wxDataViewCtrl( this, wxID_ANY
, wxDefaultPosition
,
632 wxDefaultSize
, wxDV_MULTIPLE
);
634 m_list_model
= new MyListModel
;
635 m_listCtrl
->AssociateModel( m_list_model
.get() );
637 m_listCtrl
->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE
, 120 );
638 m_listCtrl
->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT
, 60 );
640 wxDataViewTextRendererAttr
*ra
= new wxDataViewTextRendererAttr
;
641 column
= new wxDataViewColumn( "attributes", ra
, 2 );
642 m_listCtrl
->AppendColumn( column
);
644 data_sizer
->Add( m_listCtrl
, 2, wxGROW
);
648 main_sizer
->Add( data_sizer
, 2, wxGROW
);
650 wxBoxSizer
*button_sizer
= new wxBoxSizer( wxHORIZONTAL
);
652 button_sizer
->Add( new wxButton( this, ID_ADD_MOZART
, "Add Mozart"), 0, wxALL
, 10 );
653 button_sizer
->Add( new wxButton( this, ID_DELETE_MUSIC
, "Delete selected"), 0, wxALL
, 10 );
654 button_sizer
->Add( new wxButton( this, ID_DELETE_YEAR
, "Delete \"Year\" column"), 0, wxALL
, 10 );
655 button_sizer
->Add( 10, 10, 1 );
656 button_sizer
->Add( new wxButton( this, ID_PREPEND_LIST
, "Prepend"), 0, wxALL
, 10 );
657 button_sizer
->Add( new wxButton( this, ID_DELETE_LIST
, "Delete selected"), 0, wxALL
, 10 );
658 button_sizer
->Add( new wxButton( this, ID_GOTO
, "Goto 50"), 0, wxALL
, 10 );
660 main_sizer
->Add( button_sizer
, 0, wxGROW
, 0 );
662 m_log
= new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
663 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_log
));
664 wxLogMessage("This is the log window");
666 main_sizer
->Add( m_log
, 1, wxGROW
);
668 SetSizer( main_sizer
);
671 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
678 static const char *small1_xpm
[] = {
679 /* columns rows colors chars-per-pixel */
706 void MyFrame::OnTestTreeCtrl(wxCommandEvent
& WXUNUSED(event
) )
708 wxDialog
dialog( this, -1, "Test wxDataViewTreeStore" );
710 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
712 wxDataViewCtrl
*treectrl
= new wxDataViewCtrl( &dialog
, -1,
713 wxDefaultPosition
, wxSize(300,200), wxDV_NO_HEADER
);
715 wxDataViewTreeStore
*store
= new wxDataViewTreeStore
;
716 wxDataViewItem parent
= store
->AppendContainer( wxDataViewItem(0), "Root 1", wxIcon(small1_xpm
) );
717 wxDataViewItem child
= store
->AppendItem( parent
, "Child 1", wxIcon(small1_xpm
) );
718 child
= store
->AppendItem( parent
, "Child 2", wxIcon(small1_xpm
) );
719 child
= store
->AppendItem( parent
, "Child 3", wxIcon(small1_xpm
) );
720 treectrl
->AssociateModel( store
);
723 treectrl
->AppendIconTextColumn( "no label", 0, wxDATAVIEW_CELL_INERT
, 200 );
725 main_sizer
->Add( treectrl
, 1, wxGROW
);
728 wxSizer
*button_sizer
= dialog
.CreateButtonSizer( wxOK
);
730 main_sizer
->Add( button_sizer
, 0, wxGROW
|wxALL
, 10 );
732 dialog
.SetSizer( main_sizer
);
733 main_sizer
->Fit( &dialog
);
738 void MyFrame::OnAddMozart(wxCommandEvent
& WXUNUSED(event
) )
740 m_music_model
->AddToClassical( "Kleine Nachtmusik", "Wolfgang Mozart", 1787 );
743 void MyFrame::OnDeleteMusic(wxCommandEvent
& WXUNUSED(event
) )
745 wxDataViewItemArray items
;
746 int len
= m_musicCtrl
->GetSelections( items
);
747 for( int i
= 0; i
< len
; i
++ )
749 m_music_model
->Delete( items
[i
] );
752 void MyFrame::OnDeleteYear( wxCommandEvent
& WXUNUSED(event
) )
754 m_musicCtrl
->DeleteColumn( m_musicCtrl
->GetColumn( 2 ) );
755 FindWindow( ID_DELETE_YEAR
)->Disable();
758 void MyFrame::OnPrependList( wxCommandEvent
& WXUNUSED(event
) )
760 m_list_model
->Prepend( "Test" );
763 void MyFrame::OnDeleteList( wxCommandEvent
& WXUNUSED(event
) )
765 wxDataViewItemArray items
;
766 int len
= m_listCtrl
->GetSelections( items
);
767 for( int i
= 0; i
< len
; i
++ )
769 m_list_model
->DeleteItem( items
[i
] );
772 void MyFrame::OnValueChanged( wxDataViewEvent
&event
)
777 wxLogMessage( "EVT_DATAVIEW_ITEM_VALUE_CHANGED, Item Id: %d; Column: %d", event
.GetItem().GetID(), event
.GetColumn() );
780 void MyFrame::OnActivated( wxDataViewEvent
&event
)
785 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
786 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title
);
789 void MyFrame::OnSelectionChanged( wxDataViewEvent
&event
)
794 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
798 wxLogMessage("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, First selected Item: %s", title
);
801 void MyFrame::OnExpanding( wxDataViewEvent
&event
)
806 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
807 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item: %s", title
);
811 void MyFrame::OnEditingStarted( wxDataViewEvent
&event
)
816 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
817 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, Item: %s", title
);
820 void MyFrame::OnEditingDone( wxDataViewEvent
&event
)
825 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
826 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, Item: %s", title
);
829 void MyFrame::OnExpanded( wxDataViewEvent
&event
)
834 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
835 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item: %s", title
);
838 void MyFrame::OnCollapsing( wxDataViewEvent
&event
)
843 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
844 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item: %s", title
);
847 void MyFrame::OnCollapsed( wxDataViewEvent
&event
)
852 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
853 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title
);
856 void MyFrame::OnHeaderClick( wxDataViewEvent
&event
)
861 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
863 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos
);
866 void MyFrame::OnHeaderRightClick( wxDataViewEvent
&event
)
871 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
873 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos
);
876 void MyFrame::OnSorted( wxDataViewEvent
&event
)
881 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
883 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, Column position: %d", pos
);
886 void MyFrame::OnRightClick( wxMouseEvent
&event
)
891 wxLogMessage("wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d", event
.GetX(), event
.GetY());
894 void MyFrame::OnGoto(wxCommandEvent
& WXUNUSED(event
))
896 wxDataViewItem item
= m_list_model
->GetItem( 50 );
897 m_listCtrl
->EnsureVisible(item
,m_col
);
900 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
902 wxAboutDialogInfo info
;
903 info
.SetName(_("DataView sample"));
904 info
.SetDescription(_("This sample demonstrates the dataview control handling"));
905 info
.SetCopyright(_T("(C) 2007 Robert Roebling"));