void WindowTree::onRenderItem( RenderContext & context, const RectInt & window, PointInt & pos, Item * pItem ) { WindowStyle * pStyle = windowStyle(); ASSERT( pStyle ); Font * pFont = windowStyle()->font(); ASSERT( pFont ); // get the depth of this item int depth = itemDepth( pItem ); // determine the X position based on it's depth pos.x = window.left + (depth * m_Indent); // get the size of the label text SizeInt labelSize( pFont->size( pItem->sLabel ) ); // determine the height of this item int height = (int)(labelSize.height + TREE_ITEM_BUFFER); RectInt itemRect( window.left, pos.y, window.right, pos.y + height ); // check if this item is highlighted or not if ( m_CursorInWindow && itemRect.inRect( m_LastCursorPosition ) ) onHighlight( pItem ); PrimitiveMaterial::push( context.display(), WHITE, PrimitiveMaterial::ALPHA ); if ( pItem->dwFlags & BUTTON ) { bool expanded = (pItem->dwFlags & EXPANDED) != 0; Color backColor( expanded ? pStyle->backColor() * TREE_SHADE_COLOR : pStyle->backColor() ); Color shadeColor( expanded ? pStyle->borderColor() * TREE_LIGHT_COLOR : pStyle->borderColor() * TREE_SHADE_COLOR ); Color lightColor( expanded ? pStyle->borderColor() * TREE_SHADE_COLOR : pStyle->borderColor() * TREE_LIGHT_COLOR ); // render the button pushBackground( context, itemRect, backColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER ); pushBorder( context, itemRect, lightColor, shadeColor, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER ); // draw glow around this object if the mouse is currently over this button if ( m_pCursorOver == pItem ) pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, TREE_BUTTON_STYLE, TREE_BUTTON_BORDER ); // place the label in the center of the button PointInt labelPos( itemRect.center() - PointInt( labelSize.width / 2, labelSize.height / 2 ) ); // draw the label Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor ); } else { if ( m_pSelected == pItem ) pushBackground( context, itemRect, pStyle->highColor(), 0, 0 ); if ( m_pCursorOver == pItem ) pushGlow( context, itemRect, TREE_GLOW_SIZE, TREE_GLOW_INNER, TREE_GLOW_OUTER, 0, 0 ); PointInt labelPos( pos.x, (int)(pos.y + (TREE_ITEM_BUFFER / 2)) ); // render the label text` Font::push( context.display(), pFont, labelPos, pItem->sLabel, pItem->cColor ); } // move y down pos.y += (int)(height + WINDOW_TREE_SPACING); }