]> git.saurik.com Git - wxWidgets.git/commitdiff
TreeCtrl:
authorRobert Roebling <robert@roebling.de>
Mon, 26 Jul 1999 18:32:59 +0000 (18:32 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 26 Jul 1999 18:32:59 +0000 (18:32 +0000)
    Size calculation for bold items
    Reduced height per item by 2 pixels

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3154 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/treectrl.cpp

index 70bb1c58b3814ee99a5ee62c152440d4636c20ed..cffc64230c80522a59db6a066d8a5f5eb57ebe6c 100644 (file)
@@ -1937,12 +1937,35 @@ void wxTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc )
 {
     long text_w = 0;
     long text_h = 0;
 {
     long text_w = 0;
     long text_h = 0;
-    // TODO : check for boldness. Here with suppose that font normal and bold
-    //        have the same height !
-    // TODO : bug here, text_w is sometime not the correct answer !!!
+    
+    wxFont fontOld;
+    wxFont fontNew;
+    if (item->IsBold())
+    {
+        fontOld = dc.GetFont();
+        if (fontOld.Ok())
+        {
+          // VZ: is there any better way to make a bold variant of old font?
+          fontNew = wxFont( fontOld.GetPointSize(),
+                            fontOld.GetFamily(),
+                            fontOld.GetStyle(),
+                            wxBOLD,
+                            fontOld.GetUnderlined());
+          dc.SetFont(fontNew);
+        }
+        else
+        {
+            wxFAIL_MSG(_T("wxDC::GetFont() failed!"));
+        }
+    }
+    
     dc.GetTextExtent( item->GetText(), &text_w, &text_h );
     dc.GetTextExtent( item->GetText(), &text_w, &text_h );
-    text_h+=4;
+    text_h+=2;
 
 
+    // restore normal font for bold items
+    if (fontOld.Ok())
+        dc.SetFont( fontOld);
+    
     int image_h = 0;
     int image_w = 0;
     if ((item->IsExpanded()) && (item->GetSelectedImage() != -1))
     int image_h = 0;
     int image_w = 0;
     if ((item->IsExpanded()) && (item->GetSelectedImage() != -1))