tbx  0.7.6
Classes | Public Types | Public Member Functions | Friends | List of all members
tbx::res::ResMenu Class Reference

Menu object template class. More...

#include <resmenu.h>

Inheritance diagram for tbx::res::ResMenu:
tbx::res::ResObject tbx::res::ResBase

Classes

class  const_iterator
 Constant iterator for menu items. More...
 
class  iterator
 Iterator for menu items. More...
 

Public Types

enum  { CLASS_ID = 0x828c0 }
 

Public Member Functions

 ResMenu (std::string name)
 Constructor and empty ResMenu. More...
 
 ResMenu (const ResMenu &other)
 Copy constructor. More...
 
 ResMenu (const ResObject &other)
 Construct from a ResObject. More...
 
ResMenuoperator= (const ResMenu &other)
 Assignment. More...
 
ResMenuoperator= (const ResObject &other)
 Assignment from ResObject. More...
 
unsigned int flags () const
 Get all flags as a word raw access. More...
 
void flags (unsigned int value)
 Set all flags as a word. More...
 
bool generate_about_to_be_shown () const
 Check if about to be shown event will be generated. More...
 
void generate_about_to_be_shown (bool generate)
 Set if about to be shown event will be generated. More...
 
bool generate_has_been_hidden () const
 Check if event will be generated when the menu has been removed from the screen. More...
 
void generate_has_been_hidden (bool generate)
 Set if event will be generated when the menu has been removed from the screen. More...
 
const char * title () const
 Get the iconbar icon title. More...
 
void title (const char *value, int max_length=-1)
 Set the title. More...
 
void title (const std::string &value, int max_length=-1)
 Set the title. More...
 
int max_title () const
 Get the maximum title length.
 
const char * help_message () const
 Get the menu help message. More...
 
void help_message (const char *value, int max_length=-1)
 Set the help message. More...
 
void help_message (const std::string &value, int max_length=-1)
 Set the help message. More...
 
int max_help_message () const
 Get the maximum help message length.
 
int about_to_be_shown_event () const
 Get the event to generate when the menu is shown. More...
 
void about_to_be_shown_event (int event_id)
 Set the event to generate when the menu is shown. More...
 
int has_been_hidden_event () const
 Get the event to generate when menu is hidden. More...
 
void has_been_hidden_event (int event_id)
 Set the event to generate when the menu is hidden. More...
 
int item_count () const
 Get the number of menu entries.
 
ResMenuItem item (ComponentId component_id) const
 Get a copy of item with given component id. More...
 
ResMenuItem item_at (int index) const
 Get a copy of item at given index. More...
 
ResMenuItem item_at_offset (int item_offset) const
 Get a copy of an item at the given offset in the body. More...
 
const_iterator begin () const
 Get constant iterator to first menu item. More...
 
const_iterator end () const
 Get constant iterator to end of menu items. More...
 
const_iterator cbegin () const
 Get constant iterator to first menu item. More...
 
const_iterator cend () const
 Get constant iterator to end of menu items. More...
 
const_iterator find (ComponentId component_id) const
 Find component with given id. More...
 
iterator begin ()
 Get iterator to first menu item. More...
 
iterator end ()
 Get iterator to end of menu items. More...
 
iterator find (ComponentId component_id)
 Find component with given id. More...
 
bool contains (ComponentId component_id) const
 Check if menu contains a menu item with the given id. More...
 
void add (const ResMenuItem &item)
 Adds the item to the end of the menu. More...
 
void replace (const ResMenuItem &item)
 Replace menu item with same component id as given item. More...
 
void erase (ComponentId component_id)
 Erase menu item with specific id. More...
 
iterator insert (iterator pos, const ResMenuItem &item)
 Insert item at given position. More...
 
iterator replace (iterator pos, const ResMenuItem &item)
 Replace the item at the given iterator position. More...
 
iterator erase (iterator pos)
 Delete the component at the given location. More...
 
- Public Member Functions inherited from tbx::res::ResObject
 ResObject (const ResObject &other)
 Copy constructor.
 
virtual ~ResObject ()
 Destructor.
 
ResObjectoperator= (const ResObject &other)
 Assignment.
 
bool save (std::ostream &file)
 Save a resource object to a stream. More...
 
const ResObjectHeaderobject_header () const
 Return a pointer to the header information for this object.
 
const char * name () const
 Return pointer to name of object.
 
void name (std::string name)
 Set the name of the object.
 
int class_id () const
 Return class id of object.
 
int object_version () const
 Return version number * 100.
 
void object_version (int new_version)
 Set version for object.
 
unsigned int object_flags () const
 object flags - use methods below for named access to the bits of the flags
 
void object_flags (unsigned int flags)
 Set the object flags for this object. More...
 
bool create_on_load () const
 Get create on load flag. More...
 
void create_on_load (bool value)
 Set if the object should be automatically created when the Resource file is loaded. More...
 
bool show_on_create () const
 Get show on create flags. More...
 
void show_on_create (bool value)
 Set if the object to be automatically shown when it is created. More...
 
bool shared () const
 Get shared flag. More...
 
void shared (bool value)
 Set if the object is to be a shared object. More...
 
bool ancestor () const
 Get ancestor flags. More...
 
void ancestor (bool value)
 Set if the object should be an ancestor object. More...
 
void check_class_id (int class_id) const
 Check if this objects class id is as specified. More...
 
- Public Member Functions inherited from tbx::res::ResBase
 ResBase (const ResBase &other)
 Copy constructor. More...
 
virtual ~ResBase ()
 Destructor.
 
ResBaseoperator= (const ResBase &other)
 Assignment. More...
 

Friends

class const_iterator
 
class iterator
 

Additional Inherited Members

- Static Public Member Functions inherited from tbx::res::ResObject
static ResObjectload (std::istream &file)
 Load a resource object from a stream. More...
 
static OsSpriteAreaPtr client_sprite_pointer ()
 Get pointer to client sprite area. More...
 
static void client_sprite_pointer (OsSpriteAreaPtr ptr)
 Set Sprite area to use for new and loaded objects.
 
- Protected Member Functions inherited from tbx::res::ResObject
 ResObject (std::string name, int class_id, int version, int object_size)
 Protected constructor for creating a subclass.
 
ResObjectHeaderobject_header ()
 Return a pointer to the header information for this object.
 
void make_writeable ()
 Make object writeable, call before any change. More...
 
ResData * component_data (char *new_body, int offset, int size) const
 Extract a copy of a components data from this object. More...
 
void insert_component (int offset, const ResImpl *comp_impl)
 Insert a component in an object. More...
 
void replace_component (int offset, int old_size, const ResImpl *comp_impl)
 Replace a component. More...
 
void erase_component (int offset, int size)
 Erase a component of the given size. More...
 
- Protected Member Functions inherited from tbx::res::ResBase
 ResBase (ResImpl *impl)
 Create from internal resource implementation. More...
 
const char * string (int offset) const
 Return a string at the given offset. More...
 
void string (int offset, const char *value)
 Set a string at the given offset. More...
 
void string (int offset, std::string value)
 Set a string at the given offset. More...
 
void string_with_length (int offset, const char *value, int length=-1)
 Assign a string where the length is at offset+4. More...
 
void string_with_length (int offset, const std::string &value, int length=-1)
 Assign a string where the length is at offset+4. More...
 
const char * message (int offset) const
 Get the message string at the given offset. More...
 
void message (int offset, const char *value)
 Set a message at the given offset. More...
 
void message (int offset, std::string value)
 Set a message at the given offset. More...
 
void message_with_length (int offset, const char *value, int length=-1)
 Assign a message where the length is at offset+4. More...
 
void message_with_length (int offset, const std::string &value, int length=-1)
 Assign a message where the length is at offset+4. More...
 
int int_value (int offset) const
 Get an integer value. More...
 
void int_value (int offset, int value)
 Set a number at the specified offset. More...
 
unsigned int uint_value (int offset) const
 Get an unsigned integer value. More...
 
void uint_value (int offset, unsigned int value)
 Set an unsigned number at the specified offset. More...
 
unsigned char byte_value (int offset) const
 Get a byte value. More...
 
void byte_value (int offset, unsigned char value)
 Set an unsigned byte (8 bit value) at the specified offset. More...
 
unsigned short ushort_value (int offset) const
 Get a unsigned short value. More...
 
void ushort_value (int offset, unsigned short value)
 Set an unsigned short (16 bit value) at the specified offset. More...
 
bool flag (int offset, int mask) const
 Check if any of the bits in a mask are set. More...
 
void flag (int offset, int mask, bool on)
 Set/clear the bits in mask. More...
 
int flag_value (int offset, int mask) const
 Get the bits for the given mask. More...
 
void flag_value (int offset, int mask, int value)
 Set bits in given mask clearing others. More...
 
void init_string (int offset, const char *value)
 Initialise a string in a constructor helper. More...
 
void init_message (int offset, const char *value)
 Initialise a message in a constructor helper. More...
 
void init_sprite_area_ref (int offset)
 Initialise a sprite area reference. More...
 
void init_object_ref (int offset)
 Initialise an object reference. More...
 
- Protected Attributes inherited from tbx::res::ResBase
ResImpl * _impl
 Internal Resource implementation.
 

Detailed Description

Menu object template class.

Constructor & Destructor Documentation

◆ ResMenu() [1/3]

tbx::res::ResMenu::ResMenu ( std::string  name)
inline

Constructor and empty ResMenu.

Parameters
nametemplate name of the object

◆ ResMenu() [2/3]

tbx::res::ResMenu::ResMenu ( const ResMenu other)
inline

Copy constructor.

Parameters
otherobject to create copy of

◆ ResMenu() [3/3]

tbx::res::ResMenu::ResMenu ( const ResObject other)
inline

Construct from a ResObject.

Parameters
otherobject to create copy of

Member Function Documentation

◆ about_to_be_shown_event() [1/2]

int tbx::res::ResMenu::about_to_be_shown_event ( ) const
inline

Get the event to generate when the menu is shown.

@returns event ID or -1 for the default.

◆ about_to_be_shown_event() [2/2]

void tbx::res::ResMenu::about_to_be_shown_event ( int  event_id)
inline

Set the event to generate when the menu is shown.

@param event_id event ID or -1 for the default.

◆ add()

void tbx::res::ResMenu::add ( const ResMenuItem item)

Adds the item to the end of the menu.

Parameters
item- menu item to add
Exceptions
std::invalid_argumentif the menu item component id is already in the menu

◆ begin() [1/2]

ResMenu::iterator tbx::res::ResMenu::begin ( )

Get iterator to first menu item.

Returns
iterator to first menu item or end() if no menu items

◆ begin() [2/2]

ResMenu::const_iterator tbx::res::ResMenu::begin ( ) const

Get constant iterator to first menu item.

Returns
constant iterator to first menu item or end() if no menu items

◆ cbegin()

ResMenu::const_iterator tbx::res::ResMenu::cbegin ( ) const

Get constant iterator to first menu item.

Returns
constant iterator to first menu item or end() if no menu items

◆ cend()

ResMenu::const_iterator tbx::res::ResMenu::cend ( ) const

Get constant iterator to end of menu items.

Returns
constant iterator to then item after the last menu item

◆ contains()

bool tbx::res::ResMenu::contains ( ComponentId  component_id) const

Check if menu contains a menu item with the given id.

Parameters
component_idcomponent ID to check
Returns
true if the menu contains the component ID

◆ end() [1/2]

ResMenu::iterator tbx::res::ResMenu::end ( )

Get iterator to end of menu items.

Returns
iterator to then item after the last menu item

◆ end() [2/2]

ResMenu::const_iterator tbx::res::ResMenu::end ( ) const

Get constant iterator to end of menu items.

Returns
constant iterator to then item after the last menu item

◆ erase() [1/2]

void tbx::res::ResMenu::erase ( ComponentId  component_id)

Erase menu item with specific id.

Parameters
component_idcomponent id
Exceptions
ResMenuItemNotFoundif id is not in the menu

◆ erase() [2/2]

ResMenu::iterator tbx::res::ResMenu::erase ( iterator  pos)

Delete the component at the given location.

Parameters
poslocation of item to delete
Returns
iterator to next item in menu

◆ find() [1/2]

ResMenu::iterator tbx::res::ResMenu::find ( ComponentId  component_id)

Find component with given id.

Parameters
component_idid of component to find
Returns
iterator to component or end()

◆ find() [2/2]

ResMenu::const_iterator tbx::res::ResMenu::find ( ComponentId  component_id) const

Find component with given id.

Parameters
component_idid of component to find
Returns
constant iterator to component or end()

◆ flags() [1/2]

unsigned int tbx::res::ResMenu::flags ( ) const
inline

Get all flags as a word raw access.

Not normally used as there are named methods that allow access to the individual items in the flags

◆ flags() [2/2]

void tbx::res::ResMenu::flags ( unsigned int  value)
inline

Set all flags as a word.

Not normally used as there are named methods that allow access to the individual items in the flags

Parameters
valuenew flags value

◆ generate_about_to_be_shown() [1/2]

bool tbx::res::ResMenu::generate_about_to_be_shown ( ) const
inline

Check if about to be shown event will be generated.

Returns
true if the about to be shown event will be generated

◆ generate_about_to_be_shown() [2/2]

void tbx::res::ResMenu::generate_about_to_be_shown ( bool  generate)
inline

Set if about to be shown event will be generated.

Parameters
generateset to true if the about to be shown event should be generated

◆ generate_has_been_hidden() [1/2]

bool tbx::res::ResMenu::generate_has_been_hidden ( ) const
inline

Check if event will be generated when the menu has been removed from the screen.

Returns
true if an event is generated when the menu is hidden

◆ generate_has_been_hidden() [2/2]

void tbx::res::ResMenu::generate_has_been_hidden ( bool  generate)
inline

Set if event will be generated when the menu has been removed from the screen.

Parameters
generateset to true if an event should be generated when the menu is hidden

◆ has_been_hidden_event() [1/2]

int tbx::res::ResMenu::has_been_hidden_event ( ) const
inline

Get the event to generate when menu is hidden.

@returns event ID or -1 for the default.

◆ has_been_hidden_event() [2/2]

void tbx::res::ResMenu::has_been_hidden_event ( int  event_id)
inline

Set the event to generate when the menu is hidden.

@param event_id event ID or -1 for the default.

◆ help_message() [1/3]

const char* tbx::res::ResMenu::help_message ( ) const
inline

Get the menu help message.

Returns
pointer to zero terminated help message or 0 for none

◆ help_message() [2/3]

void tbx::res::ResMenu::help_message ( const char *  value,
int  max_length = -1 
)
inline

Set the help message.

@param value pointer to zero terminated help message or 0 for none
@param max_length maximum length for help message or -1 to use current value.
                  This is always adjusted to allow for the full length of the help message.

◆ help_message() [3/3]

void tbx::res::ResMenu::help_message ( const std::string &  value,
int  max_length = -1 
)
inline

Set the help message.

@param value help message
@param max_length maximum length for help message or -1 to use current value.
                  This is always adjusted to allow for the full length of the help message.

◆ insert()

ResMenu::iterator tbx::res::ResMenu::insert ( iterator  pos,
const ResMenuItem item 
)

Insert item at given position.

Parameters
poslocation to insert the item before
itemmenu item to insert
Exceptions
ResMenuItemExistsif the menu already contains an item with the same component id

◆ item()

ResMenuItem tbx::res::ResMenu::item ( ComponentId  component_id) const

Get a copy of item with given component id.

Parameters
component_idto find
Exceptions
ResMenuItemNotFoundif component can't be found

◆ item_at()

ResMenuItem tbx::res::ResMenu::item_at ( int  index) const

Get a copy of item at given index.

Parameters
indexzero based item index.
Returns
Copy of menu item at the given index
Exceptions
std::range_errorif index is not valid

◆ item_at_offset()

ResMenuItem tbx::res::ResMenu::item_at_offset ( int  item_offset) const

Get a copy of an item at the given offset in the body.

There is no checking on the offset given so you must ensure it is correct before using this function.

Parameters
item_offsetoffset of menu
Returns
menu item

◆ operator=() [1/2]

ResMenu& tbx::res::ResMenu::operator= ( const ResMenu other)
inline

Assignment.

Parameters
otherobject to create copy of

◆ operator=() [2/2]

ResMenu& tbx::res::ResMenu::operator= ( const ResObject other)
inline

Assignment from ResObject.

Parameters
otherobject to create copy of

◆ replace() [1/2]

void tbx::res::ResMenu::replace ( const ResMenuItem item)

Replace menu item with same component id as given item.

Parameters
itemMenu item resource to replace
Exceptions
ResMenuItemNotFoundif there is no existing item with the same component ID

◆ replace() [2/2]

ResMenu::iterator tbx::res::ResMenu::replace ( iterator  pos,
const ResMenuItem item 
)

Replace the item at the given iterator position.

Parameters
posposition of item to replace
itemmenu item to replace it with
Exceptions
ResMenuItemExistsif the menu already contains an item with the same component ID unless it is the component being replaced.

◆ title() [1/3]

const char* tbx::res::ResMenu::title ( ) const
inline

Get the iconbar icon title.

Returns
pointer to zero terminated title or "" for no title bar or 0 for no title.

◆ title() [2/3]

void tbx::res::ResMenu::title ( const char *  value,
int  max_length = -1 
)
inline

Set the title.

@param value menu title (0 means no title, an empty string means no titlebar)
@param max_length maximum length for title or -1 to use current value.
                  This is always adjusted to allow for the full length of the title.

◆ title() [3/3]

void tbx::res::ResMenu::title ( const std::string &  value,
int  max_length = -1 
)
inline

Set the title.

@param value menu title (an empty string means no titlebar)
@param max_length maximum length for title or -1 to use current value.
                  This is always adjusted to allow for the full length of the title.

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