boot loader: Menu[Item] API improvements
* Make Menu and MenuItem polymorphic.
* MenuItem:
- Make SetMarked() virtual, so it can be overridden.
- Add SetSubmenu() and Supermenu().
- Delete the submenu in the destructor.
* Menu:
- Add Entered()/Exited() hooks. They frame the time the user navigates
the menu or any of its submenus. The hooks allow for subclasses
populating their item list dynamically.
- Add SortItems().
* Update boot loader menu copyright text to include 2013, now that it is
over soon. :-)
This commit is contained in:
@@ -30,12 +30,12 @@ class MenuItem : public DoublyLinkedListLinkImpl<MenuItem> {
|
||||
public:
|
||||
MenuItem(const char* label = NULL,
|
||||
Menu* subMenu = NULL);
|
||||
~MenuItem();
|
||||
virtual ~MenuItem();
|
||||
|
||||
void SetTarget(menu_item_hook target);
|
||||
menu_item_hook Target() const { return fTarget; }
|
||||
|
||||
void SetMarked(bool marked);
|
||||
virtual void SetMarked(bool marked);
|
||||
bool IsMarked() const { return fIsMarked; }
|
||||
|
||||
void Select(bool selected);
|
||||
@@ -57,7 +57,11 @@ public:
|
||||
char Shortcut() const { return fShortcut; }
|
||||
|
||||
const char* Label() const { return fLabel; }
|
||||
|
||||
Menu* Submenu() const { return fSubMenu; }
|
||||
void SetSubmenu(Menu* subMenu);
|
||||
|
||||
Menu* Supermenu() const { return fMenu; }
|
||||
|
||||
private:
|
||||
friend class Menu;
|
||||
@@ -93,10 +97,13 @@ enum menu_type {
|
||||
class Menu {
|
||||
public:
|
||||
Menu(menu_type type, const char* title = NULL);
|
||||
~Menu();
|
||||
virtual ~Menu();
|
||||
|
||||
menu_type Type() const { return fType; }
|
||||
|
||||
virtual void Entered();
|
||||
virtual void Exited();
|
||||
|
||||
void Hide() { fIsHidden = true; }
|
||||
void Show() { fIsHidden = false; }
|
||||
bool IsHidden() const { return fIsHidden; }
|
||||
@@ -131,6 +138,9 @@ public:
|
||||
shortcut_hook FindShortcut(char key) const;
|
||||
MenuItem* FindItemByShortcut(char key);
|
||||
|
||||
void SortItems(bool (*less)(const MenuItem*,
|
||||
const MenuItem*));
|
||||
|
||||
void Run();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user