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 static const char *small1_xpm
[] = {
39 /* columns rows colors chars-per-pixel */
68 #define DEFAULT_ALIGN wxALIGN_LEFT
69 #define DATAVIEW_DEFAULT_STYLE (wxDV_MULTIPLE|wxDV_HORIZ_RULES|wxDV_VERT_RULES)
72 // -------------------------------------
74 // -------------------------------------
77 Implement this data model
79 -------------------------------------------------------------
82 3: You are not alone Michael Jackson 1995
83 4: Take a bow Madonna 1994
85 6: Ninth Symphony Ludwig v. Beethoven 1824
86 7: German Requiem Johannes Brahms 1868
91 class MyMusicModelNode
;
92 WX_DEFINE_ARRAY_PTR( MyMusicModelNode
*, MyMusicModelNodes
);
94 class MyMusicModelNode
97 MyMusicModelNode( MyMusicModelNode
* parent
,
98 const wxString
&title
, const wxString
&artist
, int year
)
104 m_isContainer
= false;
107 MyMusicModelNode( MyMusicModelNode
* parent
,
108 const wxString
&branch
)
113 m_isContainer
= true;
118 size_t count
= m_children
.GetCount();
120 for (i
= 0; i
< count
; i
++)
122 MyMusicModelNode
*child
= m_children
[i
];
127 bool IsContainer() { return m_isContainer
; }
129 MyMusicModelNode
* GetParent() { return m_parent
; }
130 MyMusicModelNodes
&GetChildren() { return m_children
; }
131 MyMusicModelNode
* GetNthChild( unsigned int n
) { return m_children
.Item( n
); }
132 void Insert( MyMusicModelNode
* child
, unsigned int n
) { m_children
.Insert( child
, n
); }
133 void Append( MyMusicModelNode
* child
) { m_children
.Add( child
); }
134 unsigned int GetChildCount() { return m_children
.GetCount(); }
142 MyMusicModelNode
*m_parent
;
143 MyMusicModelNodes m_children
;
148 class MyMusicModel
: public wxDataViewModel
156 m_root
= new MyMusicModelNode( NULL
, "My Music" );
157 m_pop
= new MyMusicModelNode( m_root
, "Pop music" );
158 m_root
->Append( m_pop
);
159 m_pop
->Append( new MyMusicModelNode( m_pop
,
160 "You are not alone", "Michael Jackson", 1995 ) );
161 m_pop
->Append( new MyMusicModelNode( m_pop
,
162 "Take a bow", "Madonna", 1994 ) );
163 m_classical
= new MyMusicModelNode( m_root
, "Classical music" );
164 m_root
->Append( m_classical
);
165 m_classical
->Append( new MyMusicModelNode( m_classical
,
166 "Ninth symphony", "Ludwig van Beethoven", 1824 ) );
167 m_classical
->Append( new MyMusicModelNode( m_classical
,
168 "German Requiem", "Johannes Brahms", 1868 ) );
169 m_classicalMusicIsKnownToControl
= false;
172 // helper method for wxLog
174 wxString
GetTitle( const wxDataViewItem
&item
)
176 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
178 return wxEmptyString
;
180 return node
->m_title
;
183 // helper methods to change the model
185 void AddToClassical( const wxString
&title
, const wxString
&artist
, int year
)
188 MyMusicModelNode
*child_node
=
189 new MyMusicModelNode( m_classical
, title
, artist
, year
);
191 m_classical
->Append( child_node
);
193 if (m_classicalMusicIsKnownToControl
)
196 wxDataViewItem
child( (void*) child_node
);
197 wxDataViewItem
parent( (void*) m_classical
);
198 ItemAdded( parent
, child
);
202 void Delete( const wxDataViewItem
&item
)
204 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
205 wxDataViewItem
parent( node
->GetParent() );
207 node
->GetParent()->GetChildren().Remove( node
);
211 ItemDeleted( parent
, item
);
214 // override sorting to always sort branches ascendingly
216 int Compare( const wxDataViewItem
&item1
, const wxDataViewItem
&item2
,
217 unsigned int column
, bool ascending
)
219 if (IsContainer(item1
) && IsContainer(item2
))
221 wxVariant value1
,value2
;
222 GetValue( value1
, item1
, 0 );
223 GetValue( value2
, item2
, 0 );
225 wxString str1
= value1
.GetString();
226 wxString str2
= value2
.GetString();
227 int res
= str1
.Cmp( str2
);
230 // items must be different
231 unsigned long litem1
= (unsigned long) item1
.GetID();
232 unsigned long litem2
= (unsigned long) item2
.GetID();
234 return litem1
-litem2
;
237 return wxDataViewModel::Compare( item1
, item2
, column
, ascending
);
240 // implementation of base class virtuals to define model
242 virtual unsigned int GetColumnCount() const
247 virtual wxString
GetColumnType( unsigned int col
) const
255 virtual void GetValue( wxVariant
&variant
,
256 const wxDataViewItem
&item
, unsigned int col
) const
258 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
261 case 0: variant
= node
->m_title
; break;
262 case 1: variant
= node
->m_artist
; break;
263 case 2: variant
= (long) node
->m_year
; break;
266 wxLogError( "MyMusicModel::GetValue: wrong column" );
268 // provoke a crash when mouse button down
269 wxMouseState state
= wxGetMouseState();
270 if (state
.ShiftDown())
279 virtual bool SetValue( const wxVariant
&variant
,
280 const wxDataViewItem
&item
, unsigned int col
)
282 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
285 case 0: node
->m_title
= variant
.GetString(); return true;
286 case 1: node
->m_artist
= variant
.GetString(); return true;
287 case 2: node
->m_year
= variant
.GetLong(); return true;
288 default: wxLogError( "MyMusicModel::SetValue: wrong column" );
293 virtual wxDataViewItem
GetParent( const wxDataViewItem
&item
) const
295 // the invisble root node has no parent
297 return wxDataViewItem(0);
299 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
301 // "MyMusic" also has no parent
303 return wxDataViewItem(0);
305 return wxDataViewItem( (void*) node
->GetParent() );
308 virtual bool IsContainer( const wxDataViewItem
&item
) const
310 // the invisble root node can have children (in
311 // our model always "MyMusic")
315 MyMusicModelNode
*node
= (MyMusicModelNode
*) item
.GetID();
316 return node
->IsContainer();
319 virtual unsigned int GetChildren( const wxDataViewItem
&parent
, wxDataViewItemArray
&array
) const
321 MyMusicModelNode
*node
= (MyMusicModelNode
*) parent
.GetID();
324 array
.Add( wxDataViewItem( (void*) m_root
) );
328 if (node
== m_classical
)
330 MyMusicModel
*model
= (MyMusicModel
*)(const MyMusicModel
*) this;
331 model
->m_classicalMusicIsKnownToControl
= true;
334 if (node
->GetChildCount() == 0)
339 unsigned int count
= node
->GetChildren().GetCount();
341 for (pos
= 0; pos
< count
; pos
++)
343 MyMusicModelNode
*child
= node
->GetChildren().Item( pos
);
344 array
.Add( wxDataViewItem( (void*) child
) );
350 MyMusicModelNode
* m_root
;
351 MyMusicModelNode
* m_pop
;
352 MyMusicModelNode
* m_classical
;
353 bool m_classicalMusicIsKnownToControl
;
356 class MyListModel
: public wxDataViewIndexListModel
361 wxDataViewIndexListModel( 1000 )
363 wxDataViewIndexListModel( 100000 )
367 for (i
= 0; i
< 100; i
++)
370 str
.Printf( "row number %d", i
);
374 m_icon
= wxIcon( null_xpm
);
377 // helper methods to change the model
379 void Prepend( const wxString
&text
)
381 m_array
.Insert( text
, 0 );
385 void DeleteItem( const wxDataViewItem
&item
)
387 unsigned int row
= GetRow( item
);
388 m_array
.RemoveAt( row
);
392 // implementation of base class virtuals to define model
394 virtual unsigned int GetColumnCount() const
399 virtual wxString
GetColumnType( unsigned int col
) const
402 return "wxDataViewIconText";
407 virtual unsigned int GetRowCount()
409 return m_array
.GetCount();
412 virtual void GetValue( wxVariant
&variant
,
413 unsigned int row
, unsigned int col
) const
417 if (row
>= m_array
.GetCount())
420 str
.Printf( "row %d", row
);
425 variant
= m_array
[ row
];
430 wxDataViewIconText
data( "test", m_icon
);
442 virtual bool GetAttr( unsigned int row
, unsigned int col
, wxDataViewItemAttr
&attr
)
448 attr
.SetColour( *wxBLUE
);
450 attr
.SetItalic( true );
455 virtual bool SetValue( const wxVariant
&variant
,
456 unsigned int row
, unsigned int col
)
460 if (row
>= m_array
.GetCount())
463 m_array
[row
] = variant
.GetString();
470 wxArrayString m_array
;
474 // -------------------------------------
476 // -------------------------------------
478 class MyApp
: public wxApp
485 // -------------------------------------
487 // -------------------------------------
489 class MyFrame
: public wxFrame
492 MyFrame(wxFrame
*frame
, const wxString
&title
, int x
, int y
, int w
, int h
);
495 void OnQuit(wxCommandEvent
& event
);
496 void OnAbout(wxCommandEvent
& event
);
498 void OnAddMozart(wxCommandEvent
& event
);
499 void OnDeleteMusic(wxCommandEvent
& event
);
500 void OnDeleteYear(wxCommandEvent
& event
);
502 void OnPrependList(wxCommandEvent
& event
);
503 void OnDeleteList(wxCommandEvent
& event
);
505 void OnValueChanged( wxDataViewEvent
&event
);
507 void OnActivated( wxDataViewEvent
&event
);
508 void OnExpanding( wxDataViewEvent
&event
);
509 void OnExpanded( wxDataViewEvent
&event
);
510 void OnCollapsing( wxDataViewEvent
&event
);
511 void OnCollapsed( wxDataViewEvent
&event
);
512 void OnSelectionChanged( wxDataViewEvent
&event
);
514 void OnEditingStarted( wxDataViewEvent
&event
);
515 void OnEditingDone( wxDataViewEvent
&event
);
517 void OnHeaderClick( wxDataViewEvent
&event
);
518 void OnHeaderRightClick( wxDataViewEvent
&event
);
519 void OnSorted( wxDataViewEvent
&event
);
521 void OnContextMenu( wxDataViewEvent
&event
);
523 void OnRightClick( wxMouseEvent
&event
);
524 void OnGoto( wxCommandEvent
&event
);
527 wxDataViewCtrl
* m_musicCtrl
;
528 wxObjectDataPtr
<MyMusicModel
> m_music_model
;
530 wxDataViewCtrl
* m_listCtrl
;
531 wxObjectDataPtr
<MyListModel
> m_list_model
;
533 wxDataViewColumn
* m_col
;
539 DECLARE_EVENT_TABLE()
542 // -------------------------------------
544 // -------------------------------------
548 bool MyApp::OnInit(void)
550 if ( !wxApp::OnInit() )
553 // build the first frame
555 new MyFrame(NULL
, wxT("wxDataViewCtrl feature test"), 40, 40, 800, 440);
568 // -------------------------------------
570 // -------------------------------------
575 ID_ABOUT
= wxID_ABOUT
,
581 ID_DELETE_MUSIC
= 101,
582 ID_DELETE_YEAR
= 102,
584 ID_PREPEND_LIST
= 200,
585 ID_DELETE_LIST
= 201,
589 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
590 EVT_MENU( ID_ABOUT
, MyFrame::OnAbout
)
591 EVT_MENU( ID_EXIT
, MyFrame::OnQuit
)
592 EVT_BUTTON( ID_ADD_MOZART
, MyFrame::OnAddMozart
)
593 EVT_BUTTON( ID_DELETE_MUSIC
, MyFrame::OnDeleteMusic
)
594 EVT_BUTTON( ID_DELETE_YEAR
, MyFrame::OnDeleteYear
)
595 EVT_BUTTON( ID_PREPEND_LIST
, MyFrame::OnPrependList
)
596 EVT_BUTTON( ID_DELETE_LIST
, MyFrame::OnDeleteList
)
597 EVT_BUTTON( ID_GOTO
, MyFrame::OnGoto
)
599 EVT_DATAVIEW_ITEM_VALUE_CHANGED( ID_MUSIC_CTRL
, MyFrame::OnValueChanged
)
601 EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL
, MyFrame::OnActivated
)
602 EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL
, MyFrame::OnExpanding
)
603 EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL
, MyFrame::OnExpanded
)
604 EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL
, MyFrame::OnCollapsing
)
605 EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL
, MyFrame::OnCollapsed
)
606 EVT_DATAVIEW_SELECTION_CHANGED(ID_MUSIC_CTRL
, MyFrame::OnSelectionChanged
)
608 EVT_DATAVIEW_ITEM_EDITING_STARTED(ID_MUSIC_CTRL
, MyFrame::OnEditingStarted
)
609 EVT_DATAVIEW_ITEM_EDITING_DONE(ID_MUSIC_CTRL
, MyFrame::OnEditingDone
)
611 EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL
, MyFrame::OnHeaderClick
)
612 EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL
, MyFrame::OnHeaderRightClick
)
613 EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL
, MyFrame::OnSorted
)
615 EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL
, MyFrame::OnContextMenu
)
617 EVT_RIGHT_UP(MyFrame::OnRightClick
)
620 MyFrame::MyFrame(wxFrame
*frame
, const wxString
&title
, int x
, int y
, int w
, int h
):
621 wxFrame(frame
, wxID_ANY
, title
, wxPoint(x
, y
), wxSize(w
, h
))
626 SetIcon(wxICON(sample
));
630 wxMenu
*file_menu
= new wxMenu
;
631 file_menu
->Append(ID_ABOUT
, "&About");
632 file_menu
->AppendSeparator();
633 file_menu
->Append(ID_EXIT
, "E&xit");
635 wxMenuBar
*menu_bar
= new wxMenuBar
;
636 menu_bar
->Append(file_menu
, "&File");
638 SetMenuBar(menu_bar
);
641 wxBoxSizer
*main_sizer
= new wxBoxSizer( wxVERTICAL
);
643 wxBoxSizer
*data_sizer
= new wxBoxSizer( wxHORIZONTAL
);
647 m_musicCtrl
= new wxDataViewCtrl( this, ID_MUSIC_CTRL
, wxDefaultPosition
,
648 wxDefaultSize
, wxDV_MULTIPLE
);
650 m_music_model
= new MyMusicModel
;
651 m_musicCtrl
->AssociateModel( m_music_model
.get() );
653 /* wxDataViewColumn *col = */ m_musicCtrl
->AppendTextColumn( "Title", 0, wxDATAVIEW_CELL_INERT
, 200,
654 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
656 // Call this and sorting is enabled
657 // immediatly upon start up.
658 col
->SetSortOrder( true );
661 m_musicCtrl
->AppendTextColumn( "Artist", 1, wxDATAVIEW_CELL_EDITABLE
, 150,
662 DEFAULT_ALIGN
, wxDATAVIEW_COL_SORTABLE
);
664 wxDataViewSpinRenderer
*sr
= new wxDataViewSpinRenderer( 0, 2010 );
665 wxDataViewColumn
*column
= new wxDataViewColumn( "year", sr
, 2, -1, wxALIGN_CENTRE
, wxDATAVIEW_COL_SORTABLE
);
666 m_musicCtrl
->AppendColumn( column
);
668 data_sizer
->Add( m_musicCtrl
, 3, wxGROW
);
674 m_listCtrl
= new wxDataViewCtrl( this, wxID_ANY
, wxDefaultPosition
,
675 wxDefaultSize
, wxDV_MULTIPLE
);
677 m_list_model
= new MyListModel
;
678 m_listCtrl
->AssociateModel( m_list_model
.get() );
680 m_listCtrl
->AppendTextColumn( "editable string", 0, wxDATAVIEW_CELL_EDITABLE
, 120 );
681 m_listCtrl
->AppendIconTextColumn( "icon", 1, wxDATAVIEW_CELL_INERT
, 60 );
683 wxDataViewTextRendererAttr
*ra
= new wxDataViewTextRendererAttr
;
684 column
= new wxDataViewColumn( "attributes", ra
, 2 );
685 m_listCtrl
->AppendColumn( column
);
687 data_sizer
->Add( m_listCtrl
, 2, wxGROW
);
691 main_sizer
->Add( data_sizer
, 2, wxGROW
);
693 wxBoxSizer
*button_sizer
= new wxBoxSizer( wxHORIZONTAL
);
695 button_sizer
->Add( new wxButton( this, ID_ADD_MOZART
, "Add Mozart"), 0, wxALL
, 10 );
696 button_sizer
->Add( new wxButton( this, ID_DELETE_MUSIC
, "Delete selected"), 0, wxALL
, 10 );
697 button_sizer
->Add( new wxButton( this, ID_DELETE_YEAR
, "Delete \"Year\" column"), 0, wxALL
, 10 );
698 button_sizer
->Add( 10, 10, 1 );
699 button_sizer
->Add( new wxButton( this, ID_PREPEND_LIST
, "Prepend"), 0, wxALL
, 10 );
700 button_sizer
->Add( new wxButton( this, ID_DELETE_LIST
, "Delete selected"), 0, wxALL
, 10 );
701 button_sizer
->Add( new wxButton( this, ID_GOTO
, "Goto 50"), 0, wxALL
, 10 );
703 main_sizer
->Add( button_sizer
, 0, wxGROW
, 0 );
705 wxBoxSizer
*bottom_sizer
= new wxBoxSizer( wxHORIZONTAL
);
707 m_log
= new wxTextCtrl( this, -1, "", wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
708 m_logOld
= wxLog::SetActiveTarget(new wxLogTextCtrl(m_log
));
709 wxLogMessage("This is the log window");
711 bottom_sizer
->Add( m_log
, 1, wxGROW
);
713 // wxDataViewTreeStore
715 wxDataViewCtrl
*treectrl
= new wxDataViewCtrl( this, -1,
716 wxDefaultPosition
, wxSize(300,200), wxDV_NO_HEADER
);
718 wxDataViewTreeStore
*store
= new wxDataViewTreeStore
;
719 wxDataViewItem parent
= store
->AppendContainer( wxDataViewItem(0), "Root 1", wxIcon(small1_xpm
) );
720 wxDataViewItem child
= store
->AppendItem( parent
, "Child 1", wxIcon(small1_xpm
) );
721 child
= store
->AppendItem( parent
, "Child 2", wxIcon(small1_xpm
) );
722 child
= store
->AppendItem( parent
, "Child 3", wxIcon(small1_xpm
) );
723 treectrl
->AssociateModel( store
);
726 treectrl
->AppendIconTextColumn( "no label", 0, wxDATAVIEW_CELL_INERT
, 200 );
728 bottom_sizer
->Add( treectrl
);
730 // wxDataViewTreeCtrl
732 wxDataViewTreeCtrl
*treectrl2
= new wxDataViewTreeCtrl( this, -1, wxDefaultPosition
, wxSize(300,200) );
734 wxImageList
*ilist
= new wxImageList
;
735 ilist
->Add( wxIcon(small1_xpm
) );
736 treectrl2
->SetImageList( ilist
);
738 parent
= treectrl2
->AppendContainer( wxDataViewItem(0), "Root 1", 0 );
739 child
= treectrl2
->AppendItem( parent
, "Child 1", 0 );
740 child
= treectrl2
->AppendItem( parent
, "Child 2", 0 );
741 child
= treectrl2
->AppendItem( parent
, "Child 3", 0 );
743 bottom_sizer
->Add( treectrl2
);
747 main_sizer
->Add( bottom_sizer
, 0, wxGROW
);
749 SetSizer( main_sizer
);
752 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
) )
757 void MyFrame::OnAddMozart(wxCommandEvent
& WXUNUSED(event
) )
759 m_music_model
->AddToClassical( "Kleine Nachtmusik", "Wolfgang Mozart", 1787 );
762 void MyFrame::OnDeleteMusic(wxCommandEvent
& WXUNUSED(event
) )
764 wxDataViewItemArray items
;
765 int len
= m_musicCtrl
->GetSelections( items
);
766 for( int i
= 0; i
< len
; i
++ )
768 m_music_model
->Delete( items
[i
] );
771 void MyFrame::OnDeleteYear( wxCommandEvent
& WXUNUSED(event
) )
773 m_musicCtrl
->DeleteColumn( m_musicCtrl
->GetColumn( 2 ) );
774 FindWindow( ID_DELETE_YEAR
)->Disable();
777 void MyFrame::OnPrependList( wxCommandEvent
& WXUNUSED(event
) )
779 m_list_model
->Prepend( "Test" );
782 void MyFrame::OnDeleteList( wxCommandEvent
& WXUNUSED(event
) )
784 wxDataViewItemArray items
;
785 int len
= m_listCtrl
->GetSelections( items
);
786 for( int i
= 0; i
< len
; i
++ )
788 m_list_model
->DeleteItem( items
[i
] );
791 void MyFrame::OnValueChanged( wxDataViewEvent
&event
)
796 wxLogMessage( "EVT_DATAVIEW_ITEM_VALUE_CHANGED, Item Id: %d; Column: %d", event
.GetItem().GetID(), event
.GetColumn() );
799 void MyFrame::OnActivated( wxDataViewEvent
&event
)
804 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
805 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item: %s", title
);
808 void MyFrame::OnSelectionChanged( wxDataViewEvent
&event
)
813 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
817 wxLogMessage("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, First selected Item: %s", title
);
820 void MyFrame::OnExpanding( wxDataViewEvent
&event
)
825 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
826 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item: %s", title
);
830 void MyFrame::OnEditingStarted( wxDataViewEvent
&event
)
835 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
836 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, Item: %s", title
);
839 void MyFrame::OnEditingDone( wxDataViewEvent
&event
)
844 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
845 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, Item: %s", title
);
848 void MyFrame::OnExpanded( wxDataViewEvent
&event
)
853 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
854 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item: %s", title
);
857 void MyFrame::OnCollapsing( wxDataViewEvent
&event
)
862 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
863 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item: %s", title
);
866 void MyFrame::OnCollapsed( wxDataViewEvent
&event
)
871 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
872 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title
);
875 void MyFrame::OnContextMenu( wxDataViewEvent
&event
)
880 wxString title
= m_music_model
->GetTitle( event
.GetItem() );
881 wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, Item: %s", title
);
884 void MyFrame::OnHeaderClick( wxDataViewEvent
&event
)
889 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
891 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, Column position: %d", pos
);
894 void MyFrame::OnHeaderRightClick( wxDataViewEvent
&event
)
899 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
901 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, Column position: %d", pos
);
904 void MyFrame::OnSorted( wxDataViewEvent
&event
)
909 int pos
= m_musicCtrl
->GetColumnPosition( event
.GetDataViewColumn() );
911 wxLogMessage("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, Column position: %d", pos
);
914 void MyFrame::OnRightClick( wxMouseEvent
&event
)
919 wxLogMessage("wxEVT_MOUSE_RIGHT_UP, Click Point is X: %d, Y: %d", event
.GetX(), event
.GetY());
922 void MyFrame::OnGoto(wxCommandEvent
& WXUNUSED(event
))
924 wxDataViewItem item
= m_list_model
->GetItem( 50 );
925 m_listCtrl
->EnsureVisible(item
,m_col
);
928 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
) )
930 wxAboutDialogInfo info
;
931 info
.SetName(_("DataView sample"));
932 info
.SetDescription(_("This sample demonstrates the dataview control handling"));
933 info
.SetCopyright(_T("(C) 2007 Robert Roebling"));