X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7549148b56fd7138bb1573bd0174943b33f3bb0c..51146826fc0a0a949d88f23fb9d83fc1f1ada14e:/src/msw/treectrl.cpp?ds=sidebyside diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index d7df087c94..f7e310659d 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -618,7 +618,9 @@ void wxTreeCtrl::Init() { m_textCtrl = NULL; m_hasAnyAttr = false; +#if wxUSE_DRAGIMAGE m_dragImage = NULL; +#endif m_pVirtualRoot = NULL; // initialize the global array of events now as it can't be done statically @@ -932,7 +934,7 @@ void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) { if ( item == m_idEdited ) { - ::SetWindowText(hwndEdit, text); + ::SetWindowText(hwndEdit, text.wx_str()); } } } @@ -1352,7 +1354,15 @@ wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); wxASSERT_MSG( IsVisible(item), wxT("The item you call GetNextVisible() for must be visible itself!")); - return wxTreeItemId(TreeView_GetNextVisible(GetHwnd(), HITEM(item))); + wxTreeItemId next(TreeView_GetNextVisible(GetHwnd(), HITEM(item))); + if ( next.IsOk() && !IsVisible(next) ) + { + // Win32 considers that any non-collapsed item is visible while we want + // to return only really visible items + next.Unset(); + } + + return next; } wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const @@ -1360,7 +1370,15 @@ wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); wxASSERT_MSG( IsVisible(item), wxT("The item you call GetPrevVisible() for must be visible itself!")); - return wxTreeItemId(TreeView_GetPrevVisible(GetHwnd(), HITEM(item))); + wxTreeItemId prev(TreeView_GetPrevVisible(GetHwnd(), HITEM(item))); + if ( prev.IsOk() && !IsVisible(prev) ) + { + // just as above, Win32 function will happily return the previous item + // in the tree for the first visible item too + prev.Unset(); + } + + return prev; } // ---------------------------------------------------------------------------- @@ -1900,8 +1918,10 @@ bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg) return wxTreeCtrlBase::MSWShouldPreProcessMessage(msg); } -bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id) +bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id_) { + const int id = (signed short)id_; + if ( cmd == EN_UPDATE ) { wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, id); @@ -2136,6 +2156,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara } #endif // __WXWINCE__ +#if wxUSE_DRAGIMAGE if ( m_dragImage ) { m_dragImage->Move(wxPoint(x, y)); @@ -2148,6 +2169,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara m_dragImage->Show(); } } +#endif // wxUSE_DRAGIMAGE break; case WM_LBUTTONUP: @@ -2173,6 +2195,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // fall through case WM_RBUTTONUP: +#if wxUSE_DRAGIMAGE if ( m_dragImage ) { m_dragImage->EndDrag(); @@ -2189,6 +2212,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara // are selected simultaneously which is quite weird TreeView_SelectDropTarget(GetHwnd(), 0); } +#endif // wxUSE_DRAGIMAGE break; } } @@ -2329,6 +2353,24 @@ wxTreeCtrl::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) if ( wParam == VK_SPACE || wParam == VK_RETURN ) return 0; } +#if wxUSE_DRAGIMAGE + else if ( nMsg == WM_KEYDOWN ) + { + if ( wParam == VK_ESCAPE ) + { + if ( m_dragImage ) + { + m_dragImage->EndDrag(); + delete m_dragImage; + m_dragImage = NULL; + + // 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); + } + } + } +#endif // wxUSE_DRAGIMAGE return wxControl::MSWDefWindowProc(nMsg, wParam, lParam); } @@ -2717,6 +2759,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case TVN_BEGINDRAG: case TVN_BEGINRDRAG: +#if wxUSE_DRAGIMAGE if ( event.IsAllowed() ) { // normally this is impossible because the m_dragImage is @@ -2727,6 +2770,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) m_dragImage->BeginDrag(wxPoint(0,0), this); m_dragImage->Show(); } +#endif // wxUSE_DRAGIMAGE break; case TVN_DELETEITEM: