tcMenu
Public Types | Public Member Functions | List of all members
tccore::MenuItemDelegate Class Reference

#include <MenuItemDelegate.h>

Public Types

enum  AnyOrAll { ANY , ALL }
 
typedef bool(* ItemDelegateFn) (MenuItem *item, bool internalFlag)
 

Public Member Functions

 MenuItemDelegate (MenuItem **itemArray, int items)
 
void setReadOnly (bool readOnly)
 
void setLocalOnly (bool localOnly)
 
void setVisible (bool visible)
 
void setChangedAndRemoteSend ()
 
void setChangedOnly ()
 
bool isReadOnly (AnyOrAll mode)
 
bool isLocalOnly (AnyOrAll mode)
 
bool isVisible (AnyOrAll mode)
 
bool isChanged (AnyOrAll mode)
 
bool onEachItem (ItemDelegateFn itemDelegateFn, AnyOrAll modeAny)
 

Detailed Description

This delegate allows menu item operations to take place on more than once item at once. You provide an array of menu item references in the constructor, and then calling the delegated methods applies that action to all menu items.

An example is:

MenuItem*[] items = { &item1, &item2 };
MenuItemDelegate delegate(items, 2);
delegate.setReadOnly(true); // makes item1 and item2 read only.
Definition: MenuItems.h:329
MenuItemDelegate(MenuItem **itemArray, int items)
Definition: MenuItemDelegate.h:51

Member Typedef Documentation

◆ ItemDelegateFn

typedef bool(* tccore::MenuItemDelegate::ItemDelegateFn) (MenuItem *item, bool internalFlag)

If you use the onEachItem method, this is the signature of the function that is provided.

Member Enumeration Documentation

◆ AnyOrAll

For cases where a boolean value is returned, you can check if any item or all items match. For example are any values read only, or are all values read only.

Constructor & Destructor Documentation

◆ MenuItemDelegate()

tccore::MenuItemDelegate::MenuItemDelegate ( MenuItem **  itemArray,
int  items 
)
inline

Create a delegate providing the array of menu items to delegate to, and also the number of items

Parameters
itemArraythe array of menu item pointers
itemsthe number of items in the array

Member Function Documentation

◆ setReadOnly()

void MenuItemDelegate::setReadOnly ( bool  readOnly)

Set the read only flag for all items in the delegate

Parameters
readOnlythe new read only state.

◆ setLocalOnly()

void MenuItemDelegate::setLocalOnly ( bool  localOnly)

Set the local only flag for all items in the delegate

Parameters
localOnlyif the value is local only.

◆ setVisible()

void MenuItemDelegate::setVisible ( bool  visible)

Set the visibility flag for all items in the delegate - dont forget you need to mark the menu structurally changed after changing this.

Parameters
visiblethe new visibility.

◆ setChangedAndRemoteSend()

void MenuItemDelegate::setChangedAndRemoteSend ( )

Set all delegate items as changed and ready to send remotely

◆ setChangedOnly()

void MenuItemDelegate::setChangedOnly ( )

Set all delegate items as changed without marking for remote transmission

◆ isReadOnly()

bool MenuItemDelegate::isReadOnly ( AnyOrAll  mode)

Check if either ANY or ALL of the values are read only depending on the mode chosen.

Parameters
modeeither ANY or ALL
Returns
true if matched otherwise false

◆ isLocalOnly()

bool MenuItemDelegate::isLocalOnly ( AnyOrAll  mode)

Check if either ANY or ALL of the values are local only depending on the mode chosen.

Parameters
modeeither ANY or ALL
Returns
true if matched otherwise false

◆ isVisible()

bool MenuItemDelegate::isVisible ( AnyOrAll  mode)

Check if either ANY or ALL of the values are visible depending on the mode chosen.

Parameters
modeeither ANY or ALL
Returns
true if matched otherwise false

◆ isChanged()

bool MenuItemDelegate::isChanged ( AnyOrAll  mode)

Check if either ANY or ALL of the values are changed depending on the mode chosen.

Parameters
modeeither ANY or ALL
Returns
true if matched otherwise false

◆ onEachItem()

bool MenuItemDelegate::onEachItem ( MenuItemDelegate::ItemDelegateFn  itemDelegateFn,
AnyOrAll  modeAny 
)

Iterates over each of the items calling the itemDelegateFn which takes two parameters, the current menu item as a pointer, and the mode. It will return the return value of the delegate function based on the mode - ANY or ALL.

Parameters
itemDelegateFnthe function that is called for each menu item
modeAnyANY or ALL
Returns
the result based on either ANY or ALL flag

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