]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/dataview/dataview.cpp
Don't use GetThreadId() in wxMSW code.
[wxWidgets.git] / samples / dataview / dataview.cpp
index f3c8bb2074764a82dc907c1f4a0fd3b012011234..857992884d39d4e6060bf2c970d2b6ec82d3d720 100644 (file)
@@ -41,7 +41,7 @@
 // resources
 // ----------------------------------------------------------------------------
 
-#ifndef __WXMSW__
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
@@ -189,22 +189,18 @@ public:
         return true;
     }
 
-    virtual bool Activate( const 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(const wxPoint& cursor,
-                           const 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;
     }
 
@@ -684,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 );
@@ -845,6 +841,7 @@ void MyFrame::OnBeginDrag( wxDataViewEvent &event )
     wxTextDataObject *obj = new wxTextDataObject;
     obj->SetText( node->m_title );
     event.SetDataObject( obj );
+    event.SetDragFlags(wxDrag_AllowMove); // allows both copy and move
 }
 
 void MyFrame::OnDropPossible( wxDataViewEvent &event )
@@ -947,6 +944,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))
@@ -1163,7 +1171,7 @@ void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
     if (ctrl->IsContainer(selected)) {
         wxDataViewItem newitem = ctrl->AppendItem( selected, "Item", 0 );
         ctrl->Select(newitem);
-        ctrl->StartEditor(newitem, 0);
+        ctrl->EditItem(newitem, ctrl->GetColumn(0));
     }
 }