+void wxTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
+{
+ // render bold items in bold
+ wxFont *fontOld = (wxFont *)NULL,
+ *fontNew = (wxFont *)NULL;
+ if ( item->IsBold() )
+ {
+ fontOld = dc.GetFont();
+ if ( fontOld )
+ {
+ // @@ is there any better way to make a bold variant of old font?
+ fontNew = new wxFont(fontOld->GetPointSize(),
+ fontOld->GetFamily(),
+ fontOld->GetStyle(),
+ wxBOLD,
+ fontOld->GetUnderlined());
+ dc.SetFont(fontNew);
+ }
+ else
+ {
+ wxFAIL_MSG("wxDC::GetFont() failed!");
+ }
+ }
+
+ long text_w = 0;
+ long text_h = 0;
+ dc.GetTextExtent( item->GetText(), &text_w, &text_h );
+
+ int image_h = 0;
+ int image_w = 0;
+ if (item->GetImage() != -1)
+ {
+ m_imageListNormal->GetSize( item->GetImage(), image_w, image_h );
+ image_w += 4;
+ }
+
+ dc.DrawRectangle( item->GetX()-2, item->GetY()-2, image_w+text_w+4, text_h+4 );
+
+ if (item->GetImage() != -1)
+ {
+ dc.SetClippingRegion( item->GetX(), item->GetY(), image_w-2, text_h );
+ m_imageListNormal->Draw( item->GetImage(), dc,
+ item->GetX(), item->GetY()-1,
+ wxIMAGELIST_DRAW_TRANSPARENT );
+ dc.DestroyClippingRegion();
+ }
+
+ dc.DrawText( item->GetText(), image_w + item->GetX(), item->GetY() );
+
+ // restore normal font for bold items
+ if ( fontOld )
+ {
+ dc.SetFont(fontOld);
+ delete fontNew;
+ }
+}
+