tbx
0.7.6
|
Menu object template class. More...
#include <resmenu.h>
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... | |
ResMenu & | operator= (const ResMenu &other) |
Assignment. More... | |
ResMenu & | operator= (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... | |
![]() | |
ResObject (const ResObject &other) | |
Copy constructor. | |
virtual | ~ResObject () |
Destructor. | |
ResObject & | operator= (const ResObject &other) |
Assignment. | |
bool | save (std::ostream &file) |
Save a resource object to a stream. More... | |
const ResObjectHeader * | object_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... | |
![]() | |
ResBase (const ResBase &other) | |
Copy constructor. More... | |
virtual | ~ResBase () |
Destructor. | |
ResBase & | operator= (const ResBase &other) |
Assignment. More... | |
Friends | |
class | const_iterator |
class | iterator |
Additional Inherited Members | |
![]() | |
static ResObject * | load (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. | |
![]() | |
ResObject (std::string name, int class_id, int version, int object_size) | |
Protected constructor for creating a subclass. | |
ResObjectHeader * | object_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... | |
![]() | |
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... | |
![]() | |
ResImpl * | _impl |
Internal Resource implementation. | |
Menu object template class.
|
inline |
Constructor and empty ResMenu.
name | template name of the object |
|
inline |
Copy constructor.
other | object to create copy of |
|
inline |
Construct from a ResObject.
other | object to create copy of |
|
inline |
Get the event to generate when the menu is shown.
@returns event ID or -1 for the default.
|
inline |
Set the event to generate when the menu is shown.
@param event_id event ID or -1 for the default.
void tbx::res::ResMenu::add | ( | const ResMenuItem & | item | ) |
Adds the item to the end of the menu.
item | - menu item to add |
std::invalid_argument | if the menu item component id is already in the menu |
ResMenu::iterator tbx::res::ResMenu::begin | ( | ) |
Get iterator to first menu item.
ResMenu::const_iterator tbx::res::ResMenu::begin | ( | ) | const |
Get constant iterator to first menu item.
ResMenu::const_iterator tbx::res::ResMenu::cbegin | ( | ) | const |
Get constant iterator to first menu item.
ResMenu::const_iterator tbx::res::ResMenu::cend | ( | ) | const |
Get constant iterator to end of menu items.
bool tbx::res::ResMenu::contains | ( | ComponentId | component_id | ) | const |
Check if menu contains a menu item with the given id.
component_id | component ID to check |
ResMenu::iterator tbx::res::ResMenu::end | ( | ) |
Get iterator to end of menu items.
ResMenu::const_iterator tbx::res::ResMenu::end | ( | ) | const |
Get constant iterator to end of menu items.
void tbx::res::ResMenu::erase | ( | ComponentId | component_id | ) |
Erase menu item with specific id.
component_id | component id |
ResMenuItemNotFound | if id is not in the menu |
ResMenu::iterator tbx::res::ResMenu::erase | ( | iterator | pos | ) |
Delete the component at the given location.
pos | location of item to delete |
ResMenu::iterator tbx::res::ResMenu::find | ( | ComponentId | component_id | ) |
Find component with given id.
component_id | id of component to find |
ResMenu::const_iterator tbx::res::ResMenu::find | ( | ComponentId | component_id | ) | const |
Find component with given id.
component_id | id of component to find |
|
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
|
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
value | new flags value |
|
inline |
Check if about to be shown event will be generated.
|
inline |
Set if about to be shown event will be generated.
generate | set to true if the about to be shown event should be generated |
|
inline |
Check if event will be generated when the menu has been removed from the screen.
|
inline |
Set if event will be generated when the menu has been removed from the screen.
generate | set to true if an event should be generated when the menu is hidden |
|
inline |
Get the event to generate when menu is hidden.
@returns event ID or -1 for the default.
|
inline |
Set the event to generate when the menu is hidden.
@param event_id event ID or -1 for the default.
|
inline |
Get the menu help message.
|
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.
|
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.
ResMenu::iterator tbx::res::ResMenu::insert | ( | iterator | pos, |
const ResMenuItem & | item | ||
) |
Insert item at given position.
pos | location to insert the item before |
item | menu item to insert |
ResMenuItemExists | if the menu already contains an item with the same component id |
ResMenuItem tbx::res::ResMenu::item | ( | ComponentId | component_id | ) | const |
Get a copy of item with given component id.
component_id | to find |
ResMenuItemNotFound | if component can't be found |
ResMenuItem tbx::res::ResMenu::item_at | ( | int | index | ) | const |
Get a copy of item at given index.
index | zero based item index. |
std::range_error | if index is not valid |
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.
item_offset | offset of menu |
Assignment.
other | object to create copy of |
Assignment from ResObject.
other | object to create copy of |
void tbx::res::ResMenu::replace | ( | const ResMenuItem & | item | ) |
Replace menu item with same component id as given item.
item | Menu item resource to replace |
ResMenuItemNotFound | if there is no existing item with the same component ID |
ResMenu::iterator tbx::res::ResMenu::replace | ( | iterator | pos, |
const ResMenuItem & | item | ||
) |
Replace the item at the given iterator position.
pos | position of item to replace |
item | menu item to replace it with |
ResMenuItemExists | if the menu already contains an item with the same component ID unless it is the component being replaced. |
|
inline |
Get the iconbar icon title.
|
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.
|
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.