about ListboxItem, Listbox, ItemListbox...

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

chendot
Just popping in
Just popping in
Posts: 10
Joined: Wed Jan 09, 2008 13:22

about ListboxItem, Listbox, ItemListbox...

Postby chendot » Wed Jan 09, 2008 13:51

Hi, I have two questions about the Listbox.
1) A ListboxTextItem often create like this:
ListboxTextItem* item = new ListboxTextItem("item1");
This is not a auto_ptr, so when the application shut down, does the ListboxTextItem object delete by itself? if not, where should it be deleted?

2) What is the different between ItemListbox and Listbox? Can I add a ListboxTextItem to ItemListbox? as the "addItem" method in the "ItemListbox" define like this "addItem(ItemEntry *item)", It cannot convert a ListboxTextItem* to ItemEntry*.

any help~
thanks!

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jan 09, 2008 14:55

Regarding point #2: CheckListboxItem is an example usage. Basically you can create a custom listbox item and add it to ItemListbox. Another example would be a merchant's inventory (sale and purchase) list where we can see an image of the object, its name as text on the upper right and price on the lower right:

Code: Select all

PPPPP  <Item name>
PPPPP  <Item description>
PPPPP  ----------------------
PPPPP  <Item price>

where P is an image/picture

You could also add a button to purchase/sell the item within the listbox item, a button to obtain additional information, etc.

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

Postby CrazyEddie » Wed Jan 09, 2008 18:38

Regarding point #1: The last parameter to the ListboxItem constructor is the boolean 'auto_delete'. If this is set to true (the default), the Listbox will automatically delete the item when the Listbox is destroyed; if this is set to false, the client code must destroy the item after it has been detached from the Listbox or after the Listbox has been destroyed.

Generally speaking, you're probably better off using the new ItemListbox approach (see Rackle's response above) since it's much more powerful.

CE.

chendot
Just popping in
Just popping in
Posts: 10
Joined: Wed Jan 09, 2008 13:22

Postby chendot » Thu Jan 10, 2008 08:18

:D I get it, I'll have a try to change my project from Listbox to ItemListbox. thanks CE and Rackle, you really give a great help!


Return to “Help”

Who is online

Users browsing this forum: No registered users and 24 guests