]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dataview/dataview.cpp
remove 10.4 compatibility code
[wxWidgets.git] / samples / dataview / dataview.cpp
index 252cca4655a49d62ba0bc19f1f7f08f0e2e95027..2feca42856f1944d9aeb698c15ccf6f0e6fae282 100644 (file)
@@ -41,7 +41,7 @@
 // resources
 // ----------------------------------------------------------------------------
 
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
@@ -189,21 +189,18 @@ public:
         return true;
     }
 
-    virtual bool Activate( wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model),
-                           const wxDataViewItem &WXUNUSED(item),
-                           unsigned int WXUNUSED(col) )
+    virtual bool ActivateCell(const wxRect& WXUNUSED(cell),
+                              wxDataViewModel *WXUNUSED(model),
+                              const wxDataViewItem &WXUNUSED(item),
+                              unsigned int WXUNUSED(col),
+                              const wxMouseEvent *mouseEvent)
     {
-        wxLogMessage( "MyCustomRenderer Activate()" );
-        return false;
-    }
-
-    virtual bool LeftClick( wxPoint cursor, wxRect WXUNUSED(cell),
-                           wxDataViewModel *WXUNUSED(model),
-                           const wxDataViewItem &WXUNUSED(item),
-                           unsigned int WXUNUSED(col) )
-    {
-        wxLogMessage( "MyCustomRenderer LeftClick( %d, %d )", cursor.x, cursor.y );
+        wxString position;
+        if ( mouseEvent )
+            position = wxString::Format("via mouse at %d, %d", mouseEvent->m_x, mouseEvent->m_y);
+        else
+            position = "from keyboard";
+        wxLogMessage("MyCustomRenderer ActivateCell() %s", position);
         return false;
     }
 
@@ -242,7 +239,6 @@ bool MyApp::OnInit()
 
     MyFrame *frame =
         new MyFrame(NULL, "wxDataViewCtrl sample", 40, 40, 1000, 540);
-    SetTopWindow(frame);
 
     frame->Show(true);
     return true;
@@ -540,10 +536,10 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
             m_music_model = new MyMusicTreeModel;
             m_ctrl[0]->AssociateModel( m_music_model.get() );
 
-#if wxUSE_DRAG_AND_DROP
+#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
             m_ctrl[0]->EnableDragSource( wxDF_UNICODETEXT );
             m_ctrl[0]->EnableDropTarget( wxDF_UNICODETEXT );
-#endif // wxUSE_DRAG_AND_DROP
+#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
 
             // column 0 of the view control:
 
@@ -653,6 +649,10 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
                                         wxDefaultSize, style );
             m_ctrl[2] = lc;
 
+            MyListStoreDerivedModel* page2_model = new MyListStoreDerivedModel();
+            lc->AssociateModel(page2_model);
+            page2_model->DecRef();
+
             lc->AppendToggleColumn( "Toggle" );
             lc->AppendTextColumn( "Text" );
             lc->AppendProgressColumn( "Progress" );
@@ -680,7 +680,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
 
             wxImageList *ilist = new wxImageList( 16, 16 );
             ilist->Add( wxIcon(wx_small_xpm) );
-            tc->SetImageList( ilist );
+            tc->AssignImageList( ilist );
 
             wxDataViewItem parent =
                 tc->AppendContainer( wxDataViewItem(0), "The Root", 0 );
@@ -943,6 +943,17 @@ void MyFrame::OnShowCurrent(wxCommandEvent& WXUNUSED(event))
     {
         wxLogMessage("There is no current item.");
     }
+
+    wxDataViewColumn *col = m_ctrl[0]->GetCurrentColumn();
+    if ( col )
+    {
+        wxLogMessage("Current column: %d",
+                     m_ctrl[0]->GetColumnPosition(col));
+    }
+    else
+    {
+        wxLogMessage("There is no current column.");
+    }
 }
 
 void MyFrame::OnSetNinthCurrent(wxCommandEvent& WXUNUSED(event))
@@ -1156,8 +1167,11 @@ void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
 {
     wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
     wxDataViewItem selected = ctrl->GetSelection();
-    if (ctrl->IsContainer(selected))
-        ctrl->AppendItem( selected, "Item", 0 );
+    if (ctrl->IsContainer(selected)) {
+        wxDataViewItem newitem = ctrl->AppendItem( selected, "Item", 0 );
+        ctrl->Select(newitem);
+        ctrl->EditItem(newitem, ctrl->GetColumn(0));
+    }
 }
 
 void MyFrame::OnAddTreeContainerItem(wxCommandEvent& WXUNUSED(event))