Page 1 of 1

(Horizontal) TextAlignment in Listboxes

Posted: Sun Dec 26, 2004 20:12
by Emmeran
Hi there,
I made some changes in my CE-Code to provide horizontal text alignment in Listboxes. It works perfectly for me.
@CE: maybe you want to merge this into your project

The changes:
In CEGUIListboxTextItem.h I added this public members to ListboxTextItem class:

Code: Select all

   enum HorzFormatting
   {
      LeftAligned,         
      RightAligned,      
      HorzCentred,      
      WordWrapLeftAligned,
      WordWrapRightAligned,
      WordWrapCentred,   
   };

   HorzFormatting   d_horzFormatting;
   void   setHorizontalFormatting(HorzFormatting h_fmt) { d_horzFormatting = h_fmt; }


I added the parameters z and absarea to the draw member of ListboxItem and ListboxTextItem:

Code: Select all

virtual   void   draw(const Vector3& position, float alpha, const Rect& clipper, const Rect& absarea, float z) const;



and made some changes in CEGUIListboxTextItem.cpp, in the function draw:

Code: Select all

if (fnt != NULL)
{
   Rect area = absarea;
   area.setPosition(Point(position.d_x, position.d_y));
   fnt->drawText(d_itemText, area, z - 0.001, clipper, (CEGUI::TextFormatting)d_horzFormatting, getModulateAlphaColourRect(d_textCols, alpha));
}


That's all

Greetings,
Emmeran

(Horizontal) TextAlignment in Listboxes

Posted: Wed Dec 29, 2004 10:19
by CrazyEddie
The ListboxTextItem is really just a simple example, though is probably too simple for may peoples needs ;)

It was always my intention that people needing more functionality should use their own sub-class. Your extenstions are pretty generic though, so I'll see if I can get them added in shortly.

Thanks,

CE.