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

UListbox Class Reference

List gadget. More...

#include <ugadgets.hpp>

Inheritance diagram for UListbox:

UBox UGroup List of all members.

Public Member Functions

 UListbox (const UArgs &a=UArgs::none)
virtual const UStylegetStyle (UContext *) const
 returns the contextual UStyle of this object
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 ()
 creates the Style of this object.

Static Public Attributes

static UStylestyle = null
 corresponding Ubit UStyle

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();
    }
 }
 


Member Function Documentation

virtual const UStyle& UListbox::getStyle UContext *   )  const [virtual]
 

returns the contextual UStyle of this object

This virtual function calls the makeStyle() static function that was redefined for this specific class

Reimplemented from UBox.

const UStyle & UListbox::makeStyle  )  [static]
 

creates the Style of this object.

This static function is redefined by each class that derives from UGroup. It is called by the virtual function UGroup::getStyle()

Reimplemented from UBox.


The documentation for this class was generated from the following files:
Generated on Thu May 19 11:39:25 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.2