+ if ( m_imageListButtons )
+ {
+ // draw the image button here
+ int image_h = 0,
+ image_w = 0;
+ int image = item->IsExpanded() ? wxTreeItemIcon_Expanded
+ : wxTreeItemIcon_Normal;
+ if ( item->IsSelected() )
+ image += wxTreeItemIcon_Selected - wxTreeItemIcon_Normal;
+
+ m_imageListButtons->GetSize(image, image_w, image_h);
+ int xx = x - image_w/2;
+ int yy = y_mid - image_h/2;
+
+ wxDCClipper clip(dc, xx, yy, image_w, image_h);
+ m_imageListButtons->Draw(image, dc, xx, yy,
+ wxIMAGELIST_DRAW_TRANSPARENT);
+ }
+ else // no custom buttons
+ {
+ static const int wImage = 9;
+ static const int hImage = 9;
+
+ int flag = 0;
+ if (item->IsExpanded())
+ flag |= wxCONTROL_EXPANDED;
+ if (item == m_underMouse)
+ flag |= wxCONTROL_CURRENT;
+
+ wxRendererNative::Get().DrawTreeItemButton
+ (
+ this,
+ dc,
+ wxRect(x - wImage/2,
+ y_mid - hImage/2,
+ wImage, hImage),
+ flag
+ );
+ }
+ }
+ }
+
+ if (item->IsExpanded())
+ {
+ wxArrayGenericTreeItems& children = item->GetChildren();
+ int count = children.Count();
+ if (count > 0)
+ {
+ int n = 0, oldY;
+ ++level;
+ do {
+ oldY = y;
+ PaintLevel(children[n], dc, level, y);
+ } while (++n < count);
+
+ if (!HasFlag(wxTR_NO_LINES) && count > 0)
+ {
+ // draw line down to last child
+ oldY += GetLineHeight(children[n-1])>>1;
+ if (HasButtons()) y_mid += 5;
+
+ // Only draw the portion of the line that is visible, in case it is huge
+ wxCoord xOrigin=0, yOrigin=0, width, height;
+ dc.GetDeviceOrigin(&xOrigin, &yOrigin);
+ yOrigin = abs(yOrigin);
+ GetClientSize(&width, &height);
+
+ // Move end points to the begining/end of the view?
+ if (y_mid < yOrigin)
+ y_mid = yOrigin;
+ if (oldY > yOrigin + height)
+ oldY = yOrigin + height;
+
+ // after the adjustments if y_mid is larger than oldY then the line
+ // isn't visible at all so don't draw anything
+ if (y_mid < oldY)
+ dc.DrawLine(x, y_mid, x, oldY);
+ }
+ }
+ }