2004-06-21 19:51:59 +04:00
|
|
|
/*
|
|
|
|
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
2004-06-22 04:28:28 +04:00
|
|
|
** Distributed under the terms of the Haiku License.
|
2004-06-21 19:51:59 +04:00
|
|
|
*/
|
|
|
|
#ifndef KERNEL_BOOT_MENU_H
|
|
|
|
#define KERNEL_BOOT_MENU_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
|
|
|
|
|
|
|
|
class Menu;
|
|
|
|
class MenuItem;
|
|
|
|
|
|
|
|
typedef bool (*menu_item_hook)(Menu *, MenuItem *);
|
|
|
|
|
|
|
|
enum menu_item_type {
|
|
|
|
MENU_ITEM_STANDARD = 1,
|
|
|
|
MENU_ITEM_MARKABLE,
|
|
|
|
MENU_ITEM_TITLE,
|
2004-06-22 04:28:28 +04:00
|
|
|
MENU_ITEM_NO_CHOICE,
|
2004-06-21 19:51:59 +04:00
|
|
|
MENU_ITEM_SEPARATOR,
|
|
|
|
};
|
|
|
|
|
|
|
|
class MenuItem {
|
|
|
|
public:
|
|
|
|
MenuItem(const char *label = NULL, Menu *subMenu = NULL);
|
|
|
|
~MenuItem();
|
|
|
|
|
|
|
|
void SetTarget(menu_item_hook target);
|
2004-06-22 05:16:43 +04:00
|
|
|
menu_item_hook Target() const { return fTarget; }
|
2004-06-21 19:51:59 +04:00
|
|
|
|
|
|
|
void SetMarked(bool marked);
|
|
|
|
bool IsMarked() const { return fIsMarked; }
|
|
|
|
|
|
|
|
void Select(bool selected);
|
|
|
|
bool IsSelected() const { return fIsSelected; }
|
|
|
|
|
|
|
|
void SetType(menu_item_type type);
|
|
|
|
menu_item_type Type() const { return fType; }
|
|
|
|
|
2004-06-22 01:50:31 +04:00
|
|
|
void SetData(void *data);
|
|
|
|
void *Data() const { return fData; }
|
|
|
|
|
2004-06-21 19:51:59 +04:00
|
|
|
const char *Label() const { return fLabel; }
|
|
|
|
Menu *Submenu() const { return fSubMenu; }
|
|
|
|
|
|
|
|
DoublyLinked::Link fLink;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Menu;
|
|
|
|
void SetMenu(Menu *menu);
|
|
|
|
|
|
|
|
const char *fLabel;
|
|
|
|
menu_item_hook fTarget;
|
|
|
|
bool fIsMarked;
|
|
|
|
bool fIsSelected;
|
|
|
|
menu_item_type fType;
|
|
|
|
Menu *fMenu, *fSubMenu;
|
2004-06-22 01:50:31 +04:00
|
|
|
void *fData;
|
2004-06-21 19:51:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef DoublyLinked::List<MenuItem> MenuItemList;
|
|
|
|
typedef DoublyLinked::Iterator<MenuItem> MenuItemIterator;
|
|
|
|
|
|
|
|
enum menu_type {
|
|
|
|
MAIN_MENU = 1,
|
|
|
|
SAFE_MODE_MENU,
|
|
|
|
STANDARD_MENU,
|
|
|
|
CHOICE_MENU,
|
|
|
|
};
|
|
|
|
|
|
|
|
class Menu {
|
|
|
|
public:
|
|
|
|
Menu(menu_type type, const char *title = NULL);
|
|
|
|
~Menu();
|
|
|
|
|
|
|
|
menu_type Type() const { return fType; }
|
|
|
|
|
|
|
|
void Hide() { fIsHidden = true; }
|
|
|
|
void Show() { fIsHidden = false; }
|
|
|
|
bool IsHidden() const { return fIsHidden; }
|
|
|
|
|
|
|
|
MenuItemIterator ItemIterator() { return fItems.Iterator(); }
|
|
|
|
MenuItem *ItemAt(int32 index);
|
|
|
|
int32 IndexOf(MenuItem *item);
|
|
|
|
int32 CountItems() const;
|
|
|
|
|
|
|
|
MenuItem *FindMarked();
|
|
|
|
MenuItem *FindSelected(int32 *_index = NULL);
|
|
|
|
|
|
|
|
void AddItem(MenuItem *item);
|
|
|
|
status_t AddSeparatorItem();
|
|
|
|
|
|
|
|
MenuItem *RemoveItemAt(int32 index);
|
|
|
|
void RemoveItem(MenuItem *item);
|
|
|
|
|
|
|
|
const char *Title() const { return fTitle; }
|
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class MenuItem;
|
|
|
|
void Draw(MenuItem *item);
|
|
|
|
|
|
|
|
const char *fTitle;
|
|
|
|
int32 fCount;
|
|
|
|
bool fIsHidden;
|
|
|
|
MenuItemList fItems;
|
|
|
|
menu_type fType;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* KERNEL_BOOT_MENU_H */
|