#include <MenuIterator.h>
Public Member Functions | |
void | setPredicate (MenuItemPredicate *predicate) |
void | reset () |
MenuItem * | nextItem () |
MenuItem * | currentParent () |
This provides a way to non recursively iterate through the entire menu structure. Each call to nextItem() finds the next item that matches the predicate, traversing through submenus if needed. This has a limitation of traversing only up to MAX_MENU_DEPTH
levels of menus. Adjust this value in MenuIterator.h to support more menu levels.
|
inline |
Set the predicate that will be used on subsequent calls
predicate | a predicate that will filter returned results. |
void MenuItemIterator::reset | ( | ) |
Reset the state so that the next call to nextItem() returns the first
MenuItem * MenuItemIterator::nextItem | ( | ) |
Gets the next menu item in this iterators order, filtered by the current predicate. When the last item is passed this iterator returns NULL and then calls reset().
MenuItem * MenuItemIterator::currentParent | ( | ) |
Returns the parent of the item that will be returned by nextItem(), always call AFTER calling nextItem() as next item will possibly alter this value. Result will be NULL when there is no parent (root). The result when not null will be the nearest submenu.