Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

UListbox Class Reference

List gadget. More...

#include <ugadgets.hpp>

List of all members.

Public Member Functions

 UListbox (const UArgs &a=UArgs::none)
virtual const UStylegetStyle (UContext *) const
UChoicechoice () const
UListboxaddItem (UStr *)
UListboxaddItems (const std::vector< UStr * > &str_list)
UListboxaddItems (const UArgs &item_prefix, const std::vector< UStr * > &str_list)
 UStr strings are *NOT* duplicated and should not be destroyed.
UListboxaddItem (const char *)
UListboxaddItems (const char *string_list[])
UListboxaddItems (const UArgs &item_prefix, const char *string_list[])
 char* strings are duplicated and can be destroyed.

Static Public Member Functions

static const UStylemakeStyle ()

Static Public Attributes

static UStylestyle = null

Protected Member Functions

virtual void mouseCB (UEvent &)

Protected Attributes

uptr< class UChoicepchoice
uptr< UCall > callbacks

Friends

UListboxulistbox (const UArgs &a=UArgs::none)


Detailed Description

List gadget.

Vertical (or horizontal) list of selectable gadgets.

A listbox gadget can contain any brick but only ARMable gadgets (UItem, UButton, UCheckbox...) will be *selectable*. Use UItem children to obtain the usual appearance of a list gadget. Strings that are directly added to the listbox are visible but cant be seletecd.

Listbox children (for instance selectable UItem children) can contain an arbitrary combination of text, images, gadgets...

Geometry:

Default Properties:

Selection management:

Exemple:

    XXX* obj = ...;
    UListbox& list = ulistbox
    (
      ulabel("title")         // can't be selected
      + uitem("first item")
      + uitem("second item")
      + uitem(UPix::right + "third" + " item" + ubutton(...))
        + UOn::action / ucall(obj, &XXX::foo)
        + UOn::select / ucall(obj, &XXX::foo)
     );

    list.add(uitem("4th item"));

    UGroup* item = list.choice().getItem());   // returns the selected item
    int index = list.choice().getIndex())      // returns the index of the selected item
 

Callbacks: as for other UBox subclasses generic callback conditions make it possible to specify callback methods and functions: see class UCond. For instance:

 void XXX::foo(UEvent& e) {
     // getSource() returns the listbox
     UListbox* list = e.getSource() ? dynamic_cast<UListbox*>(e.getSource()) : null;

    if (list) {
      UGroup* item = list->choice().getItem());   // returns the selected item
      int index = list->choice().getIndex())      // returns the index of the selected item
    }

    // getTarget() returns the selected item (same as list->choice().getItem())
    if (e.getTarget()) {
      // collates the text that is enclosed in the item and copies it to 's'
      UStr s = e.getTarget()->copyText();
    }
 }
 


The documentation for this class was generated from the following files:
Generated on Thu Mar 3 06:29:06 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.1