tbx  0.7.6
Public Types | Public Member Functions | List of all members
tbx::ScrollList Class Reference

Scrolling list of items with an optional sprite. More...

#include <scrolllist.h>

Inheritance diagram for tbx::ScrollList:
tbx::Gadget tbx::Component

Public Types

enum  { TOOLBOX_CLASS = 0x401a }
 

Public Member Functions

 ScrollList ()
 Construct an uninitialised ScrollList range.
 
 ~ScrollList ()
 Destroy a scroll list gadget. More...
 
 ScrollList (const ScrollList &other)
 Construct a scroll list from another scroll list. More...
 
 ScrollList (const Gadget &other)
 Construct a scroll list from another gadget. More...
 
 ScrollList (const Component &other)
 Construct a scroll list from a gadget. More...
 
ScrollListoperator= (const ScrollList &other)
 Assign a scroll list to refer to the same underlying toolbox gadget as another.
 
ScrollListoperator= (const Gadget &other)
 Assign a scroll list to refer to the same underlying toolbox gadget as an existing Gadget. More...
 
ScrollListoperator= (const Component &other)
 Assign a scroll list to refer to the same underlying toolbox component as an existing Gadget. More...
 
bool operator== (const Gadget &other) const
 Check if this scroll list refers to the same underlying toolbox gadget as another gadget. More...
 
bool operator!= (const Gadget &other) const
 Check if this scroll list refers to the same underlying toolbox gadget as another gadget. More...
 
int state () const
 Get the state.
 
void state (int value)
 Set the state. More...
 
bool allow_multiple_selections () const
 Get Allow multiple selections.
 
void allow_multiple_selections (bool value)
 Set allow multiple selections. More...
 
void add_item (const std::string &text, int index=-1)
 Add a text item to the scroll list. More...
 
void add_item (const std::string &text, const WimpSprite &sprite, int index=-1)
 Add an item with a sprite from the WIMP sprite pool. More...
 
void add_item (const std::string &text, const UserSprite &sprite, int index=-1)
 Add an item with a use sprite. More...
 
void delete_item (int index)
 Delete an item. More...
 
void delete_items (int start, int end)
 Delete a range of items. More...
 
void clear ()
 Delete all the items.
 
void select_unique_item (int index)
 Select an item, clearing any other selection. More...
 
void select_item (int index)
 Add the specified item to the selection. More...
 
void deselect_item (int index)
 Remove an item from the selection. More...
 
int first_selected () const
 Return the first selected item. More...
 
int next_selected (int from) const
 Return the next selected item id. More...
 
void make_visible (int index)
 Ensure an item is visible in the scrolllist. More...
 
void item_text (int index, const std::string &text)
 Update the text of an item. More...
 
std::string item_text (int index) const
 Get the text for an item. More...
 
int count_items () const
 Get the number of items in the scroll list. More...
 
void font (const std::string &name, int width, int height)
 Set the font used for the scroll list items. More...
 
void system_font (int width, int height)
 Set the scroll list to use the system font to display the text. More...
 
void set_colour (WimpColour foreground, WimpColour background)
 Set the colours of the scroll list using WIMP colours. More...
 
void set_colour (Colour foreground, Colour background)
 Set the colours of the scroll list using RGB colours. More...
 
void get_colour (Colour &foreground, Colour &background) const
 Get the colours used in the scrolllist. More...
 
void add_selection_listener (ScrollListSelectionListener *listener)
 Add listener for when the selected items changes. More...
 
void remove_selection_listener (ScrollListSelectionListener *listener)
 Remove listener for when the selected items changes. More...
 
- Public Member Functions inherited from tbx::Gadget
 Gadget ()
 Construct an uninitialised gadget. More...
 
 Gadget (const Gadget &other)
 Construct a gadget as a copy of another gadget object. More...
 
 Gadget (const Component &other)
 Construct a gadget as a copy of another component object. More...
 
Window window ()
 Get the window that contains this gadget.
 
Window window () const
 Get the window that contains this gadget.
 
Gadgetoperator= (const Gadget &other)
 Assign this gadget to refer to the same underlying toolbox gadget as another gadget.
 
Gadgetoperator= (const Component &other)
 Assign this gadget to refer to the same underlying toolbox gadget as the specified Component. More...
 
bool operator== (const Component &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Component. More...
 
bool operator!= (const Component &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Component. More...
 
bool operator== (const Gadget &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Gadget. More...
 
bool operator!= (const Gadget &other) const
 Check if this gadget refers to the same underlying toolbox component as the given Gadget. More...
 
void check_toolbox_class (int class_id) const
 Check the underlying gadget class for this object has the given class id. More...
 
int toolbox_class () const
 Get the toolbox class for a gadget. More...
 
int toolbox_class_and_size () const
 Get the toolbox class and size for a gadget. More...
 
unsigned int flags () const
 Return the gadget flags. More...
 
void set_flag (unsigned int set)
 Sets bits in the gadgets flags. More...
 
void clear_flag (unsigned int clear)
 Clear bits in the gadget flags. More...
 
void fade ()
 Fade the gadget.
 
void unfade ()
 Clear the gadgets fade state.
 
void fade (bool fade)
 Fade/unfade the gadget. More...
 
bool faded () const
 Check if the gadget is faded. More...
 
void focus ()
 Set input focus to the gadget. More...
 
std::vector< IconHandleicon_list ()
 Get list of icons used in this gadget. More...
 
BBox bounds () const
 Get the bounding box of the gadget.
 
void bounds (const BBox &bounds)
 Set the bounds of the gadget. More...
 
Point bottom_left () const
 Get the bottom left location of gadget. More...
 
Point top_left () const
 Get the top left location of gadget. More...
 
void move_to (const Point &pos)
 Move gadget (without resizing) More...
 
void move_to (int x, int y)
 Move gadget without resizing. More...
 
void move_by (int bx, int by)
 Move gadget relative to it's current position without resizing. More...
 
Size size () const
 Return the size of the gadget. More...
 
void size (const Size &sz)
 Set size of gadget without moving it. More...
 
void add_loader (Loader *loader, int file_type=-2)
 Add a file loader. More...
 
void remove_loader (Loader *loader, int file_type=-2)
 Remove a file loader. More...
 
- Public Member Functions inherited from tbx::Component
 Component ()
 Construct an uninitialised component. More...
 
 Component (Object obj, ComponentId id)
 Construct a component from an object and component id. More...
 
 Component (ObjectId handle, ComponentId id)
 Construct a component from an object handle and component id. More...
 
bool null () const
 Check if this component is in an uninitialised state. More...
 
Object object ()
 Return the object his component belongs to.
 
Object object () const
 Return the object his component belongs to.
 
ObjectId handle () const
 Return the object handle for his component.
 
ComponentId id () const
 Get the component ID of this component. More...
 
Componentoperator= (const Component &other)
 Assign the Component to refer to the same underlying toolbox component.
 
bool operator== (const Component &other) const
 Check if this component refers to the same underlying toolbox component. More...
 
bool operator!= (const Component &other) const
 Check if this component refers to the same underlying toolbox gadget. More...
 
 operator bool () const
 Operator to check if this component has been initialised. More...
 
void add_command (int command_id, Command *command)
 Add a command to this Component. More...
 
void remove_command (int command_id, Command *command)
 Remove a command from this component. More...
 
void add_user_event_listener (int event_id, UserEventListener *listener)
 Add a user event listener. More...
 
void remove_user_event_listener (int event_id, UserEventListener *listener)
 Remove a user event listener from this component. More...
 
void remove_all_listeners ()
 Remove all the listeners on this component. More...
 

Additional Inherited Members

- Protected Member Functions inherited from tbx::Component
void add_listener (int action, Listener *listener, RawToolboxEventHandler handler)
 Helper function to add listeners to this component. More...
 
void remove_listener (int action, Listener *listener)
 Helper function to remove listeners from this component.
 
void add_window_listener (int event_code, Listener *listener)
 Helper function to add a listener for a WIMP window event.
 
void remove_window_listener (int event_code, Listener *listener)
 Helper function to remove a listener for a WIMP window event.
 
int int_property (int property_id) const
 Get an integer property from the toolbox Component. More...
 
void int_property (int property_id, int value)
 Set an integer property from the toolbox object. More...
 
bool bool_property (int property_id) const
 Get a boolean property from the toolbox Component. More...
 
void bool_property (int property_id, bool value)
 Set a boolean property from the toolbox object. More...
 
std::string string_property (int property_id) const
 Get a string property from the toolbox object. More...
 
int string_property_length (int property_id) const
 Get a the length of a string property from the toolbox object. More...
 
void string_property (int property_id, const std::string &value)
 Set a string property in the toolbox object. More...
 
bool flag_property (int property_id, int flag) const
 Check if a particular flag is set in a property. More...
 
void flag_property (int property_id, int flag, bool value)
 Set a particular flag in a property. More...
 
- Protected Attributes inherited from tbx::Component
ObjectId _handle
 Underlying toolbox handle.
 
int _id
 Underlying toolbox component id.
 

Detailed Description

Scrolling list of items with an optional sprite.

Constructor & Destructor Documentation

◆ ~ScrollList()

tbx::ScrollList::~ScrollList ( )
inline

Destroy a scroll list gadget.

This does not delete the underlying toolbox gadget.

◆ ScrollList() [1/3]

tbx::ScrollList::ScrollList ( const ScrollList other)
inline

Construct a scroll list from another scroll list.

Both ScrollList will refer to the same underlying toolbox gadget.

◆ ScrollList() [2/3]

tbx::ScrollList::ScrollList ( const Gadget other)
inline

Construct a scroll list from another gadget.

The ScrollList and the Gadget will refer to the same underlying toolbox gadget.

Exceptions
GadgetClassErrorif the underlying toolbox gadget isn't a scroll list

◆ ScrollList() [3/3]

tbx::ScrollList::ScrollList ( const Component other)
inline

Construct a scroll list from a gadget.

The ScrollList and the Component will refer to the same underlying toolbox component.

Member Function Documentation

◆ add_item() [1/3]

void tbx::ScrollList::add_item ( const std::string &  text,
const UserSprite sprite,
int  index = -1 
)

Add an item with a use sprite.

Parameters
textText of item to add
spriteUserSprite to display with the item
indexlocation to insert or -1 (the default) for the end of the list

◆ add_item() [2/3]

void tbx::ScrollList::add_item ( const std::string &  text,
const WimpSprite sprite,
int  index = -1 
)

Add an item with a sprite from the WIMP sprite pool.

Parameters
textText of item to add
spriteWimpSprite to display with the item
indexlocation to insert or -1 (the default) for the end of the list

◆ add_item() [3/3]

void tbx::ScrollList::add_item ( const std::string &  text,
int  index = -1 
)

Add a text item to the scroll list.

Parameters
textText of item to add
indexlocation to insert or -1 (the default) for the end of the list

◆ add_selection_listener()

void tbx::ScrollList::add_selection_listener ( ScrollListSelectionListener listener)

Add listener for when the selected items changes.

The default Selection listener event must have been enabled in the resources for this scroll list for the event listener to be called.

Parameters
listenerlistener to add

◆ allow_multiple_selections()

void tbx::ScrollList::allow_multiple_selections ( bool  value)
inline

Set allow multiple selections.

Parameters
valuetrue to allow multiple selections

◆ count_items()

int tbx::ScrollList::count_items ( ) const

Get the number of items in the scroll list.

Returns
number of items in the scrolllist

◆ delete_item()

void tbx::ScrollList::delete_item ( int  index)

Delete an item.

Parameters
indexindex of item to remove from the scroll list

◆ delete_items()

void tbx::ScrollList::delete_items ( int  start,
int  end 
)

Delete a range of items.

Parameters
startfirst item to delete
endlast item to delete

◆ deselect_item()

void tbx::ScrollList::deselect_item ( int  index)

Remove an item from the selection.

Parameters
indexindex of item to remove from the selection

◆ first_selected()

int tbx::ScrollList::first_selected ( ) const

Return the first selected item.

Returns
first selected item id or -1 if none

◆ font()

void tbx::ScrollList::font ( const std::string &  name,
int  width,
int  height 
)

Set the font used for the scroll list items.

Parameters
nameThe name of the font
widthfont width in 16ths of a point
heightfont height in 16ths of a point

◆ get_colour()

void tbx::ScrollList::get_colour ( Colour foreground,
Colour background 
) const

Get the colours used in the scrolllist.

Parameters
foregroundupdated to foreground/text colour
backgroundupdated to background/text colour

◆ item_text() [1/2]

std::string tbx::ScrollList::item_text ( int  index) const

Get the text for an item.

Parameters
indexindex of item to retrieve text from
Returns
text for the item

◆ item_text() [2/2]

void tbx::ScrollList::item_text ( int  index,
const std::string &  text 
)

Update the text of an item.

Parameters
indexindex of item to update
textnew text

◆ make_visible()

void tbx::ScrollList::make_visible ( int  index)

Ensure an item is visible in the scrolllist.

Parameters
indexindex of item to make visible

◆ next_selected()

int tbx::ScrollList::next_selected ( int  from) const

Return the next selected item id.

Parameters
fromlocation to search for the selection from
Returns
next selected item id or -1

◆ operator!=()

bool tbx::ScrollList::operator!= ( const Gadget other) const
inline

Check if this scroll list refers to the same underlying toolbox gadget as another gadget.

Returns
true if they do not refer to the same underlying toolbox gadget.

◆ operator=() [1/2]

ScrollList& tbx::ScrollList::operator= ( const Component other)
inline

Assign a scroll list to refer to the same underlying toolbox component as an existing Gadget.

Exceptions
ObjectClassErrorif the component is not in a window.
GadgetClassErrorif the underlying toolbox gadget isn't a scroll list

◆ operator=() [2/2]

ScrollList& tbx::ScrollList::operator= ( const Gadget other)
inline

Assign a scroll list to refer to the same underlying toolbox gadget as an existing Gadget.

Exceptions
GadgetClassErrorif the underlying toolbox gadget isn't a scroll list

◆ operator==()

bool tbx::ScrollList::operator== ( const Gadget other) const
inline

Check if this scroll list refers to the same underlying toolbox gadget as another gadget.

Returns
true if they refer to the same underlying toolbox gadget.

◆ remove_selection_listener()

void tbx::ScrollList::remove_selection_listener ( ScrollListSelectionListener listener)

Remove listener for when the selected items changes.

Parameters
listenerlistener to remove

◆ select_item()

void tbx::ScrollList::select_item ( int  index)

Add the specified item to the selection.

Parameters
indexitem to add to the selection

◆ select_unique_item()

void tbx::ScrollList::select_unique_item ( int  index)

Select an item, clearing any other selection.

Parameters
indexnew item that will make up the selection

◆ set_colour() [1/2]

void tbx::ScrollList::set_colour ( Colour  foreground,
Colour  background 
)

Set the colours of the scroll list using RGB colours.

Parameters
foregroundforeground/text colour
backgroundbackground colour

◆ set_colour() [2/2]

void tbx::ScrollList::set_colour ( WimpColour  foreground,
WimpColour  background 
)

Set the colours of the scroll list using WIMP colours.

Parameters
foregroundforeground/text colour
backgroundbackground colour

◆ state()

void tbx::ScrollList::state ( int  value)
inline

Set the state.

Parameters
valuenew state

◆ system_font()

void tbx::ScrollList::system_font ( int  width,
int  height 
)

Set the scroll list to use the system font to display the text.

Parameters
widthfont width in 16ths of a point
heightfont height in 16ths of a point

The documentation for this class was generated from the following files: