Game Development Community

Question about GuiPopUpCtrl

by Jacob · in Torque Game Engine · 04/03/2005 (9:36 am) · 2 replies

I am hoping to be able to have my text centered in the cells of this control but haven't figured out how to go about it...I believe this is the code in GuiPopUpCtrl.cc that renders the text in a cell:

void GuiPopUpTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
   ColorI fontColor;
   mPopUpCtrl->getFontColor( fontColor, mList[cell.y].id, selected, mouseOver );

   dglSetBitmapModulation( fontColor );
   dglDrawText( mFont, Point2I( offset.x + 4, offset.y ), mList[cell.y].text );
}

...any ideas please? Thank you!

#1
04/03/2005 (2:20 pm)
Get the length of the string using the font (there's a getStringWidth or similar function), calculate the vertical center line of the cell, and subtract half the width from the center position?
#2
04/05/2005 (8:40 am)
Thanks, I'll give it a try.