Page 1 of 1

about ListboxItem, Listbox, ItemListbox...

Posted: Wed Jan 09, 2008 13:51
by chendot
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!

Posted: Wed Jan 09, 2008 14:55
by Rackle
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.

Posted: Wed Jan 09, 2008 18:38
by CrazyEddie
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.

Posted: Thu Jan 10, 2008 08:18
by chendot
: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!