WindowsLook: Fonts not visible in listbox

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

punnie
Just popping in
Just popping in
Posts: 3
Joined: Wed Apr 19, 2006 09:08

WindowsLook: Fonts not visible in listbox

Postby punnie » Mon Oct 16, 2006 20:47

Hi all,

having browsed through the forum I realised the default font colour for listbox is white. However by using WindowsLook I am unable view any item in the listbox as the background is white as well. Is there anyway whereby I can change the font colour to perhaps black so that the items in the listbox is visible?

Thanks in advance.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Oct 17, 2006 08:31

Hi,

Have a look at ListboxTextItem::setTextColours.

The general advice here is not to use the generic ListboxTextItem class, but to sub-class it and provide your own specialised version which sets the text colour(s) and selection brush.

HTH

CE.

punnie
Just popping in
Just popping in
Posts: 3
Joined: Wed Apr 19, 2006 09:08

Postby punnie » Tue Oct 17, 2006 09:11

Thanks CE. You are a saviour

It works perfectly :lol: I was using ListboxItem instead of ListboxTextItem which explains why I couldn't setTextColours :oops:

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Tue Oct 17, 2006 09:15

Eddie beat me :-)

(Since i was already preparing an answer, i'll post it anyway). The ListboxItem gets mapped in your scheme files to a Falagard/EntryItem, which has no properties. So you have to code such changes. As a sample i have added one line to the listboxitem of Sampe_Demo7.h to create red items:

Code: Select all

// Sample sub-class for ListboxTextItem that auto-sets the selection brush
// image.  This saves doing it manually every time in the code.
class MyListItem : public CEGUI::ListboxTextItem
{
public:
    MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
    {
        setSelectionBrushImage("WindowsLook", "MultiListSelectionBrush");
        setTextColours(0xFFFF0000, 0xFFFF0000, 0xFFFF0000, 0xFFFF0000);
    }
};


Please note that this item gets also used in combo boxes and multi-column lists.

Maybe the PropertyDefinition parts in the looknfeel are obsoleted for the ListboxItem... Eddie?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Oct 17, 2006 10:30

Well, there's another confusing point there, since from 0.5.0 we have two different approaches to Listbox widgets.

The old way, and which is to be considered deprecated once 0.5.0 final is out, is using the base widget class Listbox along with ListboxItem and ListboxTextItem classes for items which are created in code via the new operator.

Whereas the new and improved method is to use the ItemListbox system which makes use of EntryItem - this is better because it makes it possible to produce 'base' items which are skinned and also allows specification of list items in a Layout file. This is where, for example, "WindowsLook/ListboxItem" gets used, and in these cases the PropertyDefinitions will work as expected :)

Confused? I know I am :lol:

CE.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Tue Oct 17, 2006 13:49

hey this sounds cool, being able to add items in the layout file ! but really a bit confusing :) I think when 0.5.0 comes out, it would be nice to have a little sample on this ;)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 16 guests