* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36305 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2004-2010, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef KERNEL_BOOT_MENU_H
|
#ifndef KERNEL_BOOT_MENU_H
|
||||||
@@ -15,6 +15,7 @@ class MenuItem;
|
|||||||
|
|
||||||
typedef bool (*menu_item_hook)(Menu *, MenuItem *);
|
typedef bool (*menu_item_hook)(Menu *, MenuItem *);
|
||||||
|
|
||||||
|
|
||||||
enum menu_item_type {
|
enum menu_item_type {
|
||||||
MENU_ITEM_STANDARD = 1,
|
MENU_ITEM_STANDARD = 1,
|
||||||
MENU_ITEM_MARKABLE,
|
MENU_ITEM_MARKABLE,
|
||||||
@@ -23,53 +24,59 @@ enum menu_item_type {
|
|||||||
MENU_ITEM_SEPARATOR,
|
MENU_ITEM_SEPARATOR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MenuItem : public DoublyLinkedListLinkImpl<MenuItem> {
|
class MenuItem : public DoublyLinkedListLinkImpl<MenuItem> {
|
||||||
public:
|
public:
|
||||||
MenuItem(const char *label = NULL, Menu *subMenu = NULL);
|
MenuItem(const char* label = NULL,
|
||||||
~MenuItem();
|
Menu* subMenu = NULL);
|
||||||
|
~MenuItem();
|
||||||
|
|
||||||
void SetTarget(menu_item_hook target);
|
void SetTarget(menu_item_hook target);
|
||||||
menu_item_hook Target() const { return fTarget; }
|
menu_item_hook Target() const { return fTarget; }
|
||||||
|
|
||||||
void SetMarked(bool marked);
|
void SetMarked(bool marked);
|
||||||
bool IsMarked() const { return fIsMarked; }
|
bool IsMarked() const { return fIsMarked; }
|
||||||
|
|
||||||
void Select(bool selected);
|
void Select(bool selected);
|
||||||
bool IsSelected() const { return fIsSelected; }
|
bool IsSelected() const { return fIsSelected; }
|
||||||
|
|
||||||
void SetEnabled(bool enabled);
|
void SetEnabled(bool enabled);
|
||||||
bool IsEnabled() const { return fIsEnabled; }
|
bool IsEnabled() const { return fIsEnabled; }
|
||||||
|
|
||||||
void SetType(menu_item_type type);
|
void SetType(menu_item_type type);
|
||||||
menu_item_type Type() const { return fType; }
|
menu_item_type Type() const { return fType; }
|
||||||
|
|
||||||
void SetData(const void *data);
|
void SetData(const void* data);
|
||||||
const void *Data() const { return fData; }
|
const void* Data() const { return fData; }
|
||||||
|
|
||||||
void SetHelpText(const char *text);
|
void SetHelpText(const char* text);
|
||||||
const char *HelpText() const { return fHelpText; }
|
const char* HelpText() const { return fHelpText; }
|
||||||
|
|
||||||
const char *Label() const { return fLabel; }
|
const char* Label() const { return fLabel; }
|
||||||
Menu *Submenu() const { return fSubMenu; }
|
Menu* Submenu() const { return fSubMenu; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Menu;
|
friend class Menu;
|
||||||
void SetMenu(Menu *menu);
|
void SetMenu(Menu* menu);
|
||||||
|
|
||||||
const char *fLabel;
|
private:
|
||||||
menu_item_hook fTarget;
|
const char* fLabel;
|
||||||
bool fIsMarked;
|
menu_item_hook fTarget;
|
||||||
bool fIsSelected;
|
bool fIsMarked;
|
||||||
bool fIsEnabled;
|
bool fIsSelected;
|
||||||
menu_item_type fType;
|
bool fIsEnabled;
|
||||||
Menu *fMenu, *fSubMenu;
|
menu_item_type fType;
|
||||||
const void *fData;
|
Menu* fMenu;
|
||||||
const char *fHelpText;
|
Menu* fSubMenu;
|
||||||
|
const void* fData;
|
||||||
|
const char* fHelpText;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef DoublyLinkedList<MenuItem> MenuItemList;
|
typedef DoublyLinkedList<MenuItem> MenuItemList;
|
||||||
typedef MenuItemList::Iterator MenuItemIterator;
|
typedef MenuItemList::Iterator MenuItemIterator;
|
||||||
|
|
||||||
|
|
||||||
enum menu_type {
|
enum menu_type {
|
||||||
MAIN_MENU = 1,
|
MAIN_MENU = 1,
|
||||||
SAFE_MODE_MENU,
|
SAFE_MODE_MENU,
|
||||||
@@ -77,53 +84,59 @@ enum menu_type {
|
|||||||
CHOICE_MENU,
|
CHOICE_MENU,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Menu {
|
class Menu {
|
||||||
public:
|
public:
|
||||||
Menu(menu_type type, const char *title = NULL);
|
Menu(menu_type type, const char* title = NULL);
|
||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
menu_type Type() const { return fType; }
|
menu_type Type() const { return fType; }
|
||||||
|
|
||||||
void Hide() { fIsHidden = true; }
|
void Hide() { fIsHidden = true; }
|
||||||
void Show() { fIsHidden = false; }
|
void Show() { fIsHidden = false; }
|
||||||
bool IsHidden() const { return fIsHidden; }
|
bool IsHidden() const { return fIsHidden; }
|
||||||
|
|
||||||
MenuItemIterator ItemIterator() { return fItems.GetIterator(); }
|
MenuItemIterator ItemIterator() { return fItems.GetIterator(); }
|
||||||
MenuItem *ItemAt(int32 index);
|
MenuItem* ItemAt(int32 index);
|
||||||
int32 IndexOf(MenuItem *item);
|
int32 IndexOf(MenuItem* item);
|
||||||
int32 CountItems() const;
|
int32 CountItems() const;
|
||||||
|
|
||||||
MenuItem *FindItem(const char *label);
|
MenuItem* FindItem(const char* label);
|
||||||
MenuItem *FindMarked();
|
MenuItem* FindMarked();
|
||||||
MenuItem *FindSelected(int32 *_index = NULL);
|
MenuItem* FindSelected(int32* _index = NULL);
|
||||||
|
|
||||||
void AddItem(MenuItem *item);
|
void AddItem(MenuItem* item);
|
||||||
status_t AddSeparatorItem();
|
status_t AddSeparatorItem();
|
||||||
|
|
||||||
MenuItem *RemoveItemAt(int32 index);
|
MenuItem* RemoveItemAt(int32 index);
|
||||||
void RemoveItem(MenuItem *item);
|
void RemoveItem(MenuItem* item);
|
||||||
|
|
||||||
MenuItem *Superitem() const { return fSuperItem; }
|
MenuItem* Superitem() const { return fSuperItem; }
|
||||||
Menu *Supermenu() const { return fSuperItem ? fSuperItem->fMenu : NULL; }
|
Menu* Supermenu() const
|
||||||
|
{ return fSuperItem
|
||||||
|
? fSuperItem->fMenu : NULL; }
|
||||||
|
|
||||||
const char *Title() const { return fTitle; }
|
const char* Title() const { return fTitle; }
|
||||||
|
|
||||||
void SetChoiceText(const char *text) { fChoiceText = text; }
|
void SetChoiceText(const char* text)
|
||||||
const char *ChoiceText() const { return fChoiceText; }
|
{ fChoiceText = text; }
|
||||||
|
const char* ChoiceText() const { return fChoiceText; }
|
||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class MenuItem;
|
friend class MenuItem;
|
||||||
void Draw(MenuItem *item);
|
void Draw(MenuItem* item);
|
||||||
|
|
||||||
const char *fTitle;
|
private:
|
||||||
const char *fChoiceText;
|
const char* fTitle;
|
||||||
int32 fCount;
|
const char* fChoiceText;
|
||||||
bool fIsHidden;
|
int32 fCount;
|
||||||
MenuItemList fItems;
|
bool fIsHidden;
|
||||||
menu_type fType;
|
MenuItemList fItems;
|
||||||
MenuItem *fSuperItem;
|
menu_type fType;
|
||||||
|
MenuItem* fSuperItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* KERNEL_BOOT_MENU_H */
|
#endif /* KERNEL_BOOT_MENU_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user