+void wxTreeCtrl::CalculateSize( wxGenericTreeItem *item, wxDC &dc )
+{
+ 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 !!!
+ dc.GetTextExtent( item->GetText(), &text_w, &text_h );
+ text_h+=4;
+
+ int image_h = 0;
+ int image_w = 0;
+ if ((item->IsExpanded()) && (item->GetSelectedImage() != -1))
+ {
+ m_imageListNormal->GetSize( item->GetSelectedImage(), image_w, image_h );
+ image_w += 4;
+ }
+ else if (item->GetImage() != -1)
+ {
+ m_imageListNormal->GetSize( item->GetImage(), image_w, image_h );
+ image_w += 4;
+ }
+
+ int total_h = (image_h > text_h) ? image_h : text_h;
+
+ if (total_h<40) total_h+=4; // at least 4 pixels
+ else total_h+=total_h/10; // otherwise 10% extra spacing