X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a4088e1c733e980d2f01b7da58545c804ac7e24..660296aa90ad5ecc98c585cc24567cee8130499a:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index c2e063711f..6bc4c2341c 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -683,7 +683,7 @@ bool wxTreeCtrl::Create(wxWindow *parent, #endif // Create the tree control. - if ( !MSWCreateControl(WC_TREEVIEW, wstyle) ) + if ( !MSWCreateControl(WC_TREEVIEW, wstyle, pos, size) ) return false; #if wxUSE_COMCTL32_SAFELY @@ -716,8 +716,8 @@ bool wxTreeCtrl::Create(wxWindow *parent, HDC hdcMem = CreateCompatibleDC(NULL); // create a mono bitmap of the standard size - int x = GetSystemMetrics(SM_CXMENUCHECK); - int y = GetSystemMetrics(SM_CYMENUCHECK); + int x = ::GetSystemMetrics(SM_CXMENUCHECK); + int y = ::GetSystemMetrics(SM_CYMENUCHECK); wxImageList imagelistCheckboxes(x, y, false, 2); HBITMAP hbmpCheck = CreateBitmap(x, y, // bitmap size 1, // # of color planes @@ -755,8 +755,6 @@ bool wxTreeCtrl::Create(wxWindow *parent, } #endif // 0 - SetSize(pos.x, pos.y, size.x, size.y); - wxSetCCUnicodeFormat(GetHwnd()); return true; @@ -904,7 +902,7 @@ bool wxTreeCtrl::SetBackgroundColour(const wxColour &colour) if ( !wxWindowBase::SetBackgroundColour(colour) ) return false; - SendMessage(GetHwnd(), TVM_SETBKCOLOR, 0, colour.GetPixel()); + ::SendMessage(GetHwnd(), TVM_SETBKCOLOR, 0, colour.GetPixel()); #endif return true; @@ -916,7 +914,7 @@ bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) if ( !wxWindowBase::SetForegroundColour(colour) ) return false; - SendMessage(GetHwnd(), TVM_SETTEXTCOLOR, 0, colour.GetPixel()); + ::SendMessage(GetHwnd(), TVM_SETTEXTCOLOR, 0, colour.GetPixel()); #endif return true; @@ -928,7 +926,7 @@ bool wxTreeCtrl::SetForegroundColour(const wxColour &colour) wxString wxTreeCtrl::GetItemText(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), wxT(""), wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), wxEmptyString, wxT("invalid tree item") ); wxChar buf[512]; // the size is arbitrary... @@ -1371,7 +1369,7 @@ void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font) bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); if ( item == wxTreeItemId(TVI_ROOT) ) { @@ -1402,7 +1400,7 @@ bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); wxTreeViewItem tvItem(item, TVIF_CHILDREN); DoGetItem(&tvItem); @@ -1412,7 +1410,7 @@ bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_EXPANDED); DoGetItem(&tvItem); @@ -1422,7 +1420,7 @@ bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_SELECTED); DoGetItem(&tvItem); @@ -1432,7 +1430,7 @@ bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_BOLD); DoGetItem(&tvItem); @@ -1499,8 +1497,14 @@ wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item), wxTreeItemIdValue& cookie) const { - wxTreeItemId item(TreeView_GetNextSibling(GetHwnd(), - HITEM(wxTreeItemId(cookie)))); + wxTreeItemId fromCookie(cookie); + + HTREEITEM hitem = HITEM(fromCookie); + + hitem = TreeView_GetNextSibling(GetHwnd(), hitem); + + wxTreeItemId item(hitem); + cookie = item.m_pItem; return item; @@ -1521,11 +1525,14 @@ wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item), long& cookie) const { - wxTreeItemId item(TreeView_GetNextSibling - ( - GetHwnd(), - HITEM(wxTreeItemId((void *)cookie) - ))); + wxTreeItemId fromCookie((void *)cookie); + + HTREEITEM hitem = HITEM(fromCookie); + + hitem = TreeView_GetNextSibling(GetHwnd(), hitem); + + wxTreeItemId item(hitem); + cookie = (long)item.m_pItem; return item; @@ -1590,7 +1597,7 @@ wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const bool wxTreeCtrl::IsItemChecked(const wxTreeItemId& item) const { - wxCHECK_MSG( item.IsOk(), FALSE, wxT("invalid tree item") ); + wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") ); // receive the desired information. wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_STATEIMAGEMASK); @@ -1648,7 +1655,7 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent, } UINT mask = 0; - if ( !text.IsEmpty() ) + if ( !text.empty() ) { mask |= TVIF_TEXT; tvIns.item.pszText = (wxChar *)text.c_str(); // cast is ok @@ -1712,6 +1719,26 @@ wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, image, selImage, NULL); } +wxImageList *wxTreeCtrl::GetImageList(int) const +{ + return GetImageList(); +} + +void wxTreeCtrl::SetImageList(wxImageList *imageList, int) +{ + SetImageList(imageList); +} + +int wxTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const +{ + return GetItemImage(item, wxTreeItemIcon_Selected); +} + +void wxTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image) +{ + SetItemImage(item, image, wxTreeItemIcon_Selected); +} + #endif // WXWIN_COMPATIBILITY_2_4 wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, @@ -1893,10 +1920,12 @@ void wxTreeCtrl::Toggle(const wxTreeItemId& item) } #if WXWIN_COMPATIBILITY_2_4 + void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action) { DoExpand(item, action); } + #endif void wxTreeCtrl::Unselect() @@ -2046,7 +2075,7 @@ wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, } // End label editing, optionally cancelling the edit -void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool discardChanges) +void wxTreeCtrl::DoEndEditLabel(bool discardChanges) { TreeView_EndEditLabelNow(GetHwnd(), discardChanges); @@ -2212,6 +2241,18 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara WXLRESULT rc = 0; bool isMultiple = (GetWindowStyle() & wxTR_MULTIPLE) != 0; +#ifdef WM_CONTEXTMENU + if ( nMsg == WM_CONTEXTMENU ) + { + wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() ); + event.m_item = GetSelection(); + event.SetEventObject( this ); + if ( GetEventHandler()->ProcessEvent(event) ) + return true; + //else: continue with generating wxEVT_CONTEXT_MENU in base class code + } +#endif // __SMARTPHONE__ + if ( (nMsg >= WM_MOUSEFIRST) && (nMsg <= WM_MOUSELAST) ) { // we only process mouse messages here and these parameters have the @@ -2469,6 +2510,24 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara processed = true; } } + else if ( nMsg == WM_COMMAND ) + { + // if we receive a EN_KILLFOCUS command from the in-place edit control + // used for label editing, make sure to end editing + WORD id, cmd; + WXHWND hwnd; + UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); + + if ( cmd == EN_KILLFOCUS ) + { + if ( m_textCtrl && m_textCtrl->GetHandle() == hwnd ) + { + DoEndEditLabel(); + + processed = true; + } + } + } if ( !processed ) rc = wxControl::MSWWindowProc(nMsg, wParam, lParam); @@ -2844,7 +2903,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxASSERT_MSG( !m_dragImage, _T("starting to drag once again?") ); m_dragImage = new wxDragImage(*this, event.m_item); - m_dragImage->BeginDrag(wxPoint(0, 0), this); + m_dragImage->BeginDrag(wxPoint(0,0), this); m_dragImage->Show(); } break; @@ -3032,5 +3091,14 @@ int wxTreeCtrl::GetState(const wxTreeItemId& node) return STATEIMAGEMASKTOINDEX(tvi.state); } +#if WXWIN_COMPATIBILITY_2_2 + +wxTreeItemId wxTreeCtrl::GetParent(const wxTreeItemId& item) const +{ + return GetItemParent( item ); +} + +#endif // WXWIN_COMPATIBILITY_2_2 + #endif // wxUSE_TREECTRL