]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
Removed old wxGLCanvas stuff; moved wxTreeLayout to wxWindows; corrected some doc...
[wxWidgets.git] / src / msw / treectrl.cpp
index 500d880e7cc31a6895015e99e66574bf29982410..39277963f373ea34cfd8bd84c1386a13b0a064f5 100644 (file)
     #define TV_FIRST                0x1100
 #endif
 
+#ifndef TVS_CHECKBOXES
+    #define TVS_CHECKBOXES          0x0100
+#endif
+
 // old headers might miss these messages (comctl32.dll 4.71+ only)
 #ifndef TVM_SETBKCOLOR
     #define TVM_SETBKCOLOR          (TV_FIRST + 29)
@@ -247,7 +251,8 @@ static HTREEITEM GetItemFromPoint(HWND hwndTV, int x, int y)
     tvht.pt.x = x;
     tvht.pt.y = y;
 
-    return TreeView_HitTest(hwndTV, &tvht);
+    // TreeView_HitTest() doesn't do the right cast in mingw32 headers
+    return (HTREEITEM)TreeView_HitTest(hwndTV, &tvht);
 }
 
 // ----------------------------------------------------------------------------
@@ -344,6 +349,7 @@ bool wxTreeCtrl::Create(wxWindow *parent,
     !defined( __BORLANDC__ ) && \
     !defined( __WATCOMC__ ) && \
     (!defined(__VISUALC__) || (__VISUALC__ > 1010))
+
     // we emulate the multiple selection tree controls by using checkboxes: set
     // up the image list we need for this if we do have multiple selections
     if ( m_windowStyle & wxTR_MULTIPLE )
@@ -1315,6 +1321,24 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId& item)
 
 wxTextCtrl* wxTreeCtrl::GetEditControl() const
 {
+    // normally, we could try to do something like this to return something
+    // even when the editing was started by the user and not by calling
+    // EditLabel() - but as nobody has asked for this so far and there might be
+    // problems in the code below, I leave it disabled for now (VZ)
+#if 0
+    if ( !m_textCtrl )
+    {
+        HWND hwndText = TreeView_GetEditControl(GetHwnd());
+        if ( hwndText )
+        {
+            m_textCtrl = new wxTextCtrl(this, -1);
+            m_textCtrl->Hide();
+            m_textCtrl->SetHWND((WXHWND)hwndText);
+        }
+        //else: not editing label right now
+    }
+#endif // 0
+
     return m_textCtrl;
 }
 
@@ -1334,6 +1358,8 @@ wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item,
 {
     wxASSERT( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)) );
 
+    DeleteTextCtrl();
+
     HWND hWnd = (HWND) TreeView_EditLabel(GetHwnd(), (HTREEITEM) (WXHTREEITEM) item);
 
     // this is not an error - the TVN_BEGINLABELEDIT handler might have
@@ -1343,8 +1369,6 @@ wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item,
         return NULL;
     }
 
-    DeleteTextCtrl();
-
     m_textCtrl = (wxTextCtrl *)textControlClass->CreateObject();
     m_textCtrl->SetHWND((WXHWND)hWnd);
     m_textCtrl->SubclassWin((WXHWND)hWnd);
@@ -1525,6 +1549,10 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
                     event.SetEventObject(this);
 
                     (void)GetEventHandler()->ProcessEvent(event);
+
+                    // if we don't do it, the tree seems to think that 2 items
+                    // are selected simultaneously which is quite weird
+                    TreeView_SelectDropTarget(GetHwnd(), 0);
                 }
                 break;
         }