#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) |
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:
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.
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.
|
inline |
Create a delegate providing the array of menu items to delegate to, and also the number of items
itemArray | the array of menu item pointers |
items | the number of items in the array |
void MenuItemDelegate::setReadOnly | ( | bool | readOnly | ) |
Set the read only flag for all items in the delegate
readOnly | the new read only state. |
void MenuItemDelegate::setLocalOnly | ( | bool | localOnly | ) |
Set the local only flag for all items in the delegate
localOnly | if the value is local only. |
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.
visible | the new visibility. |
void MenuItemDelegate::setChangedAndRemoteSend | ( | ) |
Set all delegate items as changed and ready to send remotely
void MenuItemDelegate::setChangedOnly | ( | ) |
Set all delegate items as changed without marking for remote transmission
bool MenuItemDelegate::isReadOnly | ( | AnyOrAll | mode | ) |
Check if either ANY or ALL of the values are read only depending on the mode chosen.
mode | either ANY or ALL |
bool MenuItemDelegate::isLocalOnly | ( | AnyOrAll | mode | ) |
Check if either ANY or ALL of the values are local only depending on the mode chosen.
mode | either ANY or ALL |
bool MenuItemDelegate::isVisible | ( | AnyOrAll | mode | ) |
Check if either ANY or ALL of the values are visible depending on the mode chosen.
mode | either ANY or ALL |
bool MenuItemDelegate::isChanged | ( | AnyOrAll | mode | ) |
Check if either ANY or ALL of the values are changed depending on the mode chosen.
mode | either ANY or ALL |
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.
itemDelegateFn | the function that is called for each menu item |
modeAny | ANY or ALL |