]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectrl.cpp
wxGetUserHome() returns "const wxMB2WXbuf" for Unix in Unicode build.
[wxWidgets.git] / src / generic / treectrl.cpp
index 8c9e480741aa51428a60977d55f42af032443e0c..0322373916e171f95508746149223dbfaba9ef40 100644 (file)
@@ -287,6 +287,7 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest( const wxPoint& point,
   if ((point.y > m_y) && (point.y < m_y + m_height))
   {
     // FIXME why +5?
+    //  Because that is the size of the plus sign, RR
     if ((point.x > m_xCross-5) && (point.x < m_xCross+5) &&
         (point.y > m_yCross-5) && (point.y < m_yCross+5) &&
         (IsExpanded() || HasPlus()))
@@ -295,8 +296,10 @@ wxGenericTreeItem *wxGenericTreeItem::HitTest( const wxPoint& point,
       return this;
     }
 
+    /* TODO: we should do a query here like
+         m_imageListNormal->GetSize( item->GetImage(), image_w, image_h );  */
     int w = m_width;
-    if (m_image != -1) w += 20;
+    if (m_image != -1) w += 24;
 
     if ((point.x > m_x) && (point.x < m_x+w))
     {
@@ -1036,6 +1039,7 @@ void wxTreeCtrl::SetImageList(wxImageList *imageList)
    for(int i = 0; i < n ; i++)
    {
       m_imageListNormal->GetSize(i, width, height);
+      height += height/5;  //20% extra spacing
       if(height > m_lineHeight) m_lineHeight = height;
    }
 }
@@ -1110,13 +1114,16 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
     }
 
     int total_h = (image_h > text_h) ? image_h : text_h;
-    dc.DrawRectangle( item->GetX()-2, item->GetY()-2, image_w+text_w+4, total_h+4 );
+    if(m_lineHeight > total_h) total_h = m_lineHeight;
+    
+    dc.DrawRectangle( item->GetX()-2, item->GetY(), image_w+text_w+4, total_h );
 
     if ((item->IsExpanded()) && (item->GetSelectedImage() != -1))
     {
         dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, total_h );
         m_imageListNormal->Draw( item->GetSelectedImage(), dc,
-                                 item->GetX(), item->GetY()-1,
+                                 item->GetX(),
+                                 item->GetY() +((total_h > image_h)?((total_h-image_h)/2):0),
                                  wxIMAGELIST_DRAW_TRANSPARENT );
         dc.DestroyClippingRegion();
     }
@@ -1124,14 +1131,15 @@ void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
     {
         dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, total_h );
         m_imageListNormal->Draw( item->GetImage(), dc,
-                                 item->GetX(), item->GetY()-1,
+                                 item->GetX(),
+                                 item->GetY() +((total_h > image_h)?((total_h-image_h)/2):0),
                                  wxIMAGELIST_DRAW_TRANSPARENT );
         dc.DestroyClippingRegion();
     }
 
     dc.SetBackgroundMode(wxTRANSPARENT);
     dc.DrawText( item->GetText(), image_w + item->GetX(), item->GetY()
-                 + (total_h > text_h)? (total_h - text_h)/2 : 0);
+                 + ((total_h > text_h) ? (total_h - text_h)/2 : 0));
 
     // restore normal font for bold items
     if (fontOld.Ok())
@@ -1145,7 +1153,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxDC &dc, int level, int &
     int horizX = level*m_indent;
 
     item->SetX( horizX+33 );
-    item->SetY( y-m_lineHeight/3 );
+    item->SetY( y-m_lineHeight/2 );
     item->SetHeight( m_lineHeight );
 
     item->SetCross( horizX+15, y );
@@ -1439,8 +1447,13 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event )
 
 wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& WXUNUSED(flags))
 {
+    wxClientDC dc(this);
+    PrepareDC(dc);
+    long x = dc.DeviceToLogicalX( (long)point.x );
+    long y = dc.DeviceToLogicalY( (long)point.y );
+
     bool onButton = FALSE;
-    return m_anchor->HitTest( point, onButton );
+    return m_anchor->HitTest( wxPoint(x, y), onButton );
 }
 
 void wxTreeCtrl::OnMouse( wxMouseEvent &event )
@@ -1519,7 +1532,7 @@ void wxTreeCtrl::CalculateLevel( wxGenericTreeItem *item, wxDC &dc, int level, i
     int horizX = level*m_indent;
 
     item->SetX( horizX+33 );
-    item->SetY( y-m_lineHeight/3-2 );
+    item->SetY( y-m_lineHeight/2 );
     item->SetHeight( m_lineHeight );
 
     if ( !item->IsExpanded() )