]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented and tested EXPANDED etc events for wxGTK and in the sample
authorRobert Roebling <robert@roebling.de>
Sun, 19 Aug 2007 21:20:24 +0000 (21:20 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 19 Aug 2007 21:20:24 +0000 (21:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48204 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dataview/dataview.cpp
src/gtk/dataview.cpp

index 937efdc8f3abdcbaeacda68a56134baa738bc04f..1f0708a56a84fdae868e9132198cab76569b9dfd 100644 (file)
@@ -423,7 +423,13 @@ public:
     void OnValueChanged( wxDataViewEvent &event );
     void OnItemAdded( wxDataViewEvent &event );
     void OnItemDeleted( wxDataViewEvent &event );
+    
     void OnActivated( wxDataViewEvent &event );
+    void OnExpanding( wxDataViewEvent &event );
+    void OnExpanded( wxDataViewEvent &event );
+    void OnCollapsing( wxDataViewEvent &event );
+    void OnCollapsed( wxDataViewEvent &event );
+    
     void OnHeaderClick( wxDataViewEvent &event );
     void OnHeaderRightClick( wxDataViewEvent &event );
     void OnSorted( wxDataViewEvent &event );
@@ -499,14 +505,22 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_BUTTON( ID_PREPEND_LIST, MyFrame::OnPrependList )
     EVT_BUTTON( ID_DELETE_LIST, MyFrame::OnDeleteList )
     EVT_BUTTON( ID_GOTO, MyFrame::OnGoto)
+    
     EVT_DATAVIEW_MODEL_ITEM_ADDED( ID_MUSIC_CTRL, MyFrame::OnItemAdded )
     EVT_DATAVIEW_MODEL_ITEM_DELETED( ID_MUSIC_CTRL, MyFrame::OnItemDeleted )
     EVT_DATAVIEW_MODEL_VALUE_CHANGED( ID_MUSIC_CTRL, MyFrame::OnValueChanged )
     EVT_DATAVIEW_MODEL_ITEM_CHANGED( ID_MUSIC_CTRL, MyFrame::OnValueChanged )
+    
     EVT_DATAVIEW_ITEM_ACTIVATED(ID_MUSIC_CTRL, MyFrame::OnActivated )
+    EVT_DATAVIEW_ITEM_EXPANDING(ID_MUSIC_CTRL, MyFrame::OnExpanding)
+    EVT_DATAVIEW_ITEM_EXPANDED(ID_MUSIC_CTRL, MyFrame::OnExpanded)
+    EVT_DATAVIEW_ITEM_COLLAPSING(ID_MUSIC_CTRL, MyFrame::OnCollapsing)
+    EVT_DATAVIEW_ITEM_COLLAPSED(ID_MUSIC_CTRL, MyFrame::OnCollapsed)
+    
     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_RIGHT_UP(MyFrame::OnRightClick)
 END_EVENT_TABLE()
 
@@ -655,6 +669,38 @@ void MyFrame::OnActivated( wxDataViewEvent &event )
     wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, Item Id: %d;  Column: %d", event.GetItem().GetID(), event.GetColumn());
 }
 
+void MyFrame::OnExpanding( wxDataViewEvent &event )
+{
+    if (!m_log)
+        return;
+        
+    wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, Item Id: %d", event.GetItem().GetID() );
+}
+
+void MyFrame::OnExpanded( wxDataViewEvent &event )
+{
+    if (!m_log)
+        return;
+        
+    wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, Item Id: %d", event.GetItem().GetID() );
+}
+
+void MyFrame::OnCollapsing( wxDataViewEvent &event )
+{
+    if (!m_log)
+        return;
+        
+    wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, Item Id: %d", event.GetItem().GetID() );
+}
+
+void MyFrame::OnCollapsed( wxDataViewEvent &event )
+{
+    if (!m_log)
+        return;
+        
+    wxLogMessage("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, Item Id: %d", event.GetItem().GetID() );
+}
+
 void MyFrame::OnHeaderClick( wxDataViewEvent &event )
 {
     if(!m_log)
@@ -689,7 +735,8 @@ void MyFrame::OnRightClick( wxMouseEvent &event )
 
 void MyFrame::OnGoto( wxCommandEvent &event)
 {
-    m_listCtrl->EnsureVisible(50);
+    wxDataViewItem item = m_list_model->GetItem( 50 );
+    m_listCtrl->EnsureVisible(item);
 }
 
 void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
index 173f65e9bc43405625e53812f6ca901dfccc1086..dd8038be46b23da2804121ec789145d74950861c 100644 (file)
@@ -2733,8 +2733,60 @@ wxdataview_row_activated_callback( GtkTreeView* treeview, GtkTreePath *path,
     dv->GetEventHandler()->ProcessEvent( event );
 }
 
+static gboolean
+wxdataview_test_expand_row_callback( GtkTreeView* treeview, GtkTreeIter* iter,
+                                     GtkTreePath *path, wxDataViewCtrl *dv )
+{
+    wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, dv->GetId() );
+
+    wxDataViewItem item( (void*) iter->user_data );;
+    event.SetItem( item );
+    event.SetModel( dv->GetModel() );
+    dv->GetEventHandler()->ProcessEvent( event );
+  
+    return !event.IsAllowed();
+}
+
+static void
+wxdataview_row_expanded_callback( GtkTreeView* treeview, GtkTreeIter* iter,
+                                  GtkTreePath *path, wxDataViewCtrl *dv )
+{
+    wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, dv->GetId() );
+
+    wxDataViewItem item( (void*) iter->user_data );;
+    event.SetItem( item );
+    event.SetModel( dv->GetModel() );
+    dv->GetEventHandler()->ProcessEvent( event );
+}
+
+static gboolean
+wxdataview_test_collapse_row_callback( GtkTreeView* treeview, GtkTreeIter* iter,
+                                       GtkTreePath *path, wxDataViewCtrl *dv )
+{
+    wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, dv->GetId() );
+
+    wxDataViewItem item( (void*) iter->user_data );;
+    event.SetItem( item );
+    event.SetModel( dv->GetModel() );
+    dv->GetEventHandler()->ProcessEvent( event );
+    
+    return !event.IsAllowed();
+}
+
+static void
+wxdataview_row_collapsed_callback( GtkTreeView* treeview, GtkTreeIter* iter,
+                                   GtkTreePath *path, wxDataViewCtrl *dv )
+{
+    wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, dv->GetId() );
+
+    wxDataViewItem item( (void*) iter->user_data );;
+    event.SetItem( item );
+    event.SetModel( dv->GetModel() );
+    dv->GetEventHandler()->ProcessEvent( event );
+}
+
 //-----------------------------------------------------------------------------
-// wxDataViewCtrl
+    // wxDataViewCtrl
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
@@ -2867,9 +2919,21 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
 
     GtkEnableSelectionEvents();
 
-    g_signal_connect_after (m_treeview, "row_activated",
+    g_signal_connect_after (m_treeview, "row-activated",
                             G_CALLBACK (wxdataview_row_activated_callback), this);
 
+    g_signal_connect (m_treeview, "test-collapse-row",
+                            G_CALLBACK (wxdataview_test_collapse_row_callback), this);
+
+    g_signal_connect_after (m_treeview, "row-collapsed",
+                            G_CALLBACK (wxdataview_row_collapsed_callback), this);
+
+    g_signal_connect (m_treeview, "test-expand-row",
+                            G_CALLBACK (wxdataview_test_expand_row_callback), this);
+                            
+    g_signal_connect_after (m_treeview, "row-expanded",
+                            G_CALLBACK (wxdataview_row_expanded_callback), this);
+
     return true;
 }
 
@@ -2939,6 +3003,40 @@ wxDataViewItem wxDataViewCtrl::GetSelection()
     return wxDataViewItem(0);
 }
 
+int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
+{
+    return 0;
+}
+
+void wxDataViewCtrl::SetSelections( const wxDataViewItemArray & sel )
+{
+}
+
+void wxDataViewCtrl::Select( const wxDataViewItem & item )
+{
+}
+
+void wxDataViewCtrl::Unselect( const wxDataViewItem & item )
+{
+}
+
+bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
+{
+    return false;
+}
+
+void wxDataViewCtrl::SelectAll()
+{
+}
+
+void wxDataViewCtrl::UnselectAll()
+{
+}
+
+void wxDataViewCtrl::EnsureVisible( const wxDataViewItem & item )
+{
+}
+
 void wxDataViewCtrl::DoSetExpanderColumn()
 {
 }