]> git.saurik.com Git - wxWidgets.git/commitdiff
removed hardcoded DoGetBestSize() implementation; added support for textOnly paramete...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 10 Oct 2005 22:29:39 +0000 (22:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 10 Oct 2005 22:29:39 +0000 (22:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35883 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/treectlg.h
src/generic/treectlg.cpp

index f22b42917a8d4bce04e356e3eaa91440cb22afbf..833cfd1cc7396f95dbed1118885e2dc606583777 100644 (file)
@@ -223,8 +223,6 @@ public:
     void OnGetToolTip( wxTreeEvent &event );
     void OnInternalIdle( );
 
-    virtual wxSize DoGetBestSize() const;
-
     virtual wxVisualAttributes GetDefaultAttributes() const
     {
         return GetClassDefaultAttributes(GetWindowVariant());
index 87df794ad039653b350c5ef7b11be0a1897702b2..9284957c8e4b5e39b8f891b0dda95de4297f2078 100644 (file)
@@ -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