]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dataview/dataview.cpp
Make sizing logic clearer, at the expense of a few duplicated lines.
[wxWidgets.git] / samples / dataview / dataview.cpp
index 8a191f93489c220ba928de449baec3e0919eefcf..c852284476cf10a2a06f7db71e3779ef9723dccf 100644 (file)
@@ -518,6 +518,8 @@ public:
     void OnHeaderRightClick( wxDataViewEvent &event );
     void OnSorted( wxDataViewEvent &event );
 
+    void OnContextMenu( wxDataViewEvent &event );
+
     void OnRightClick( wxMouseEvent &event );
     void OnGoto( wxCommandEvent &event);
 
@@ -609,6 +611,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_DATAVIEW_COLUMN_HEADER_CLICK(ID_MUSIC_CTRL, MyFrame::OnHeaderClick)
     EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(ID_MUSIC_CTRL, MyFrame::OnHeaderRightClick)
     EVT_DATAVIEW_COLUMN_SORTED(ID_MUSIC_CTRL, MyFrame::OnSorted)
+
+    EVT_DATAVIEW_ITEM_CONTEXT_MENU(ID_MUSIC_CTRL, MyFrame::OnContextMenu)
     
     EVT_RIGHT_UP(MyFrame::OnRightClick)
 END_EVENT_TABLE()
@@ -726,8 +730,11 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
     // wxDataViewTreeCtrl
 
     wxDataViewTreeCtrl *treectrl2 = new wxDataViewTreeCtrl( this, -1, wxDefaultPosition, wxSize(300,200) );
+    
     wxImageList *ilist = new wxImageList;
     ilist->Add( wxIcon(small1_xpm) );
+    treectrl2->SetImageList( ilist );
+    
     parent = treectrl2->AppendContainer( wxDataViewItem(0), "Root 1", 0 );
     child = treectrl2->AppendItem( parent, "Child 1", 0 );
     child = treectrl2->AppendItem( parent, "Child 2", 0 );
@@ -865,6 +872,15 @@ void MyFrame::OnCollapsed( wxDataViewEvent &event )
     wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item: %s", title );
 }
 
+void MyFrame::OnContextMenu( wxDataViewEvent &event )
+{
+    if (!m_log)
+        return;
+    
+    wxString title = m_music_model->GetTitle( event.GetItem() );
+    wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, Item: %s", title );
+}
+
 void MyFrame::OnHeaderClick( wxDataViewEvent &event )
 {
     if(!m_log)