From ce43f9e11513c676775051e7cde150e1ef168092 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Jan 2009 18:21:36 +0000 Subject: [PATCH] use GetBoundingRect() for the in place text control positioning instead of duplicating its code (see #9591) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectlg.cpp | 55 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 6005ae07d1..2e18569c11 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -429,45 +429,32 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner, m_owner = owner; m_aboutToFinish = false; - int w = m_itemEdited->GetWidth(), - h = m_itemEdited->GetHeight(); - - int x, y; - m_owner->CalcScrolledPosition(item->GetX(), item->GetY(), &x, &y); - - int image_h = 0, - image_w = 0; - - int image = item->GetCurrentImage(); - if ( image != NO_IMAGE ) - { - if ( m_owner->m_imageListNormal ) - { - m_owner->m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; - } - else - { - wxFAIL_MSG(_T("you must create an image list to use images!")); - } - } + wxRect rect; + m_owner->GetBoundingRect(m_itemEdited, rect, true); - // FIXME: what are all these hardcoded 4, 8 and 11s really? - x += image_w; - w -= image_w + 4; -#ifdef __WXMAC__ - wxSize bs = DoGetBestSize() ; + // corrects possition and size for better apperance +#ifdef __WXMSW__ + rect.x -= 5; + rect.width += 10; +#elif __WXGTK__ + rect.x -= 5; + rect.y -= 2; + rect.width += 8; + rect.height += 4; +#elif __WXMAC__ + wxSize bs = DoGetBestSize(); // edit control height - if ( h > bs.y - 8 ) - { - int diff = h - ( bs.y - 8 ) ; - h -= diff ; - y += diff / 2 ; - } + if ( rect.height > bs.y - 8 ) + int diff = rect.height - ( bs.y - 8 ); + rect.height -= diff; + rect.y += diff / 2; + } #endif (void)Create(m_owner, wxID_ANY, m_startValue, - wxPoint(x - 4, y - 4), wxSize(w + 11, h + 8)); + rect.GetPosition(), rect.GetSize()); + + SetSelection(-1, -1); } void wxTreeTextCtrl::EndEdit(bool discardChanges) -- 2.45.2