Page 1 of 1

WindowsLook: Fonts not visible in listbox

Posted: Mon Oct 16, 2006 20:47
by punnie
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.

Posted: Tue Oct 17, 2006 08:31
by CrazyEddie
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.

Posted: Tue Oct 17, 2006 09:11
by punnie
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:

Posted: Tue Oct 17, 2006 09:15
by scriptkid
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?

Posted: Tue Oct 17, 2006 10:30
by CrazyEddie
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.

Posted: Tue Oct 17, 2006 13:49
by Pompei2
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 ;)