From 3e4f8ee25683fe9c7ec6e8272608124e332700ac Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 10 Oct 2005 22:29:39 +0000 Subject: [PATCH] removed hardcoded DoGetBestSize() implementation; added support for textOnly parameter in GetBoundingRect() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35883 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/treectlg.h | 2 -- src/generic/treectlg.cpp | 41 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/include/wx/generic/treectlg.h b/include/wx/generic/treectlg.h index f22b42917a..833cfd1cc7 100644 --- a/include/wx/generic/treectlg.h +++ b/include/wx/generic/treectlg.h @@ -223,8 +223,6 @@ public: void OnGetToolTip( wxTreeEvent &event ); void OnInternalIdle( ); - virtual wxSize DoGetBestSize() const; - virtual wxVisualAttributes GetDefaultAttributes() const { return GetClassDefaultAttributes(GetWindowVariant()); diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 87df794ad0..9284957c8e 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -57,6 +57,9 @@ static const int NO_IMAGE = -1; static const int PIXELS_PER_UNIT = 10; +// the margin between the item image and the item text +static const int MARGIN_BETWEEN_IMAGE_AND_TEXT = 4; + // ----------------------------------------------------------------------------- // private classes // ----------------------------------------------------------------------------- @@ -374,7 +377,7 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner, if ( m_owner->m_imageListNormal ) { m_owner->m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; } else { @@ -2178,7 +2181,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc) if ( m_imageListNormal ) { m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; } else { @@ -2868,7 +2871,7 @@ wxTreeItemId wxGenericTreeCtrl::DoHitTest(const wxPoint& point, int& flags) // get the bounding rectangle of the item (or of its label only) bool wxGenericTreeCtrl::GetBoundingRect(const wxTreeItemId& item, wxRect& rect, - bool WXUNUSED(textOnly)) const + bool textOnly) const { wxCHECK_MSG( item.IsOk(), false, _T("invalid item in wxGenericTreeCtrl::GetBoundingRect") ); @@ -2877,10 +2880,25 @@ bool wxGenericTreeCtrl::GetBoundingRect(const wxTreeItemId& item, int startX, startY; GetViewStart(& startX, & startY); - rect.x = i->GetX() - startX*PIXELS_PER_UNIT; + if ( textOnly ) + { + rect.x = i->GetX() - startX*PIXELS_PER_UNIT; + rect.width = i->GetWidth(); + + if ( m_imageListNormal ) + { + int image_w, image_h; + m_imageListNormal->GetSize( 0, image_w, image_h ); + rect.width += image_w + MARGIN_BETWEEN_IMAGE_AND_TEXT; + } + } + else // the entire line + { + rect.x = 0; + rect.width = GetClientSize().x; + } + rect.y = i->GetY() - startY*PIXELS_PER_UNIT; - rect.width = i->GetWidth(); - //rect.height = i->GetHeight(); rect.height = GetLineHeight(i); return true; @@ -3352,7 +3370,7 @@ void wxGenericTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc ) if ( m_imageListNormal ) { m_imageListNormal->GetSize( image, image_w, image_h ); - image_w += 4; + image_w += MARGIN_BETWEEN_IMAGE_AND_TEXT; } } @@ -3531,15 +3549,6 @@ void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event ) } -wxSize wxGenericTreeCtrl::DoGetBestSize() const -{ - // something is better than nothing... - // 100x80 is what the MSW version will get from the default - // wxControl::DoGetBestSize - return wxSize(100,80); -} - - // NOTE: If using the wxListBox visual attributes works everywhere then this can // be removed, as well as the #else case below. #define _USE_VISATTR 0 -- 2.45.2