5ea23bb0a3
"booted_from_image" in the kernel_args' boot_disk structure. Also, added fields "cd" and "user_selected". A CHOICE_MENU menu can now have a choice text - this is automatically updated as entries in the menu get selected. The boot volume menu now has the initial choice text "CD-ROM or hard drive" in case the boot loader was loaded from an image. The "Rescan volumes" item is no longer selected by default (only if there was no boot volume found) - but it's still functionless anyway. The TAR fs will now appear as "Boot from CD-ROM" in the boot volume menu. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14388 a95241bf-73f2-0310-859d-f6bbb57e9c96
130 lines
2.9 KiB
C++
130 lines
2.9 KiB
C++
/*
|
|
* Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#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,
|
|
MENU_ITEM_NO_CHOICE,
|
|
MENU_ITEM_SEPARATOR,
|
|
};
|
|
|
|
class MenuItem : public DoublyLinkedListLinkImpl<MenuItem> {
|
|
public:
|
|
MenuItem(const char *label = NULL, Menu *subMenu = NULL);
|
|
~MenuItem();
|
|
|
|
void SetTarget(menu_item_hook target);
|
|
menu_item_hook Target() const { return fTarget; }
|
|
|
|
void SetMarked(bool marked);
|
|
bool IsMarked() const { return fIsMarked; }
|
|
|
|
void Select(bool selected);
|
|
bool IsSelected() const { return fIsSelected; }
|
|
|
|
void SetEnabled(bool enabled);
|
|
bool IsEnabled() const { return fIsEnabled; }
|
|
|
|
void SetType(menu_item_type type);
|
|
menu_item_type Type() const { return fType; }
|
|
|
|
void SetData(const void *data);
|
|
const void *Data() const { return fData; }
|
|
|
|
void SetHelpText(const char *text);
|
|
const char *HelpText() const { return fHelpText; }
|
|
|
|
const char *Label() const { return fLabel; }
|
|
Menu *Submenu() const { return fSubMenu; }
|
|
|
|
private:
|
|
friend class Menu;
|
|
void SetMenu(Menu *menu);
|
|
|
|
const char *fLabel;
|
|
menu_item_hook fTarget;
|
|
bool fIsMarked;
|
|
bool fIsSelected;
|
|
bool fIsEnabled;
|
|
menu_item_type fType;
|
|
Menu *fMenu, *fSubMenu;
|
|
const void *fData;
|
|
const char *fHelpText;
|
|
};
|
|
|
|
typedef DoublyLinkedList<MenuItem> MenuItemList;
|
|
typedef MenuItemList::Iterator 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.GetIterator(); }
|
|
MenuItem *ItemAt(int32 index);
|
|
int32 IndexOf(MenuItem *item);
|
|
int32 CountItems() const;
|
|
|
|
MenuItem *FindItem(const char *label);
|
|
MenuItem *FindMarked();
|
|
MenuItem *FindSelected(int32 *_index = NULL);
|
|
|
|
void AddItem(MenuItem *item);
|
|
status_t AddSeparatorItem();
|
|
|
|
MenuItem *RemoveItemAt(int32 index);
|
|
void RemoveItem(MenuItem *item);
|
|
|
|
MenuItem *Superitem() const { return fSuperItem; }
|
|
Menu *Supermenu() const { return fSuperItem ? fSuperItem->fMenu : NULL; }
|
|
|
|
const char *Title() const { return fTitle; }
|
|
|
|
void SetChoiceText(const char *text) { fChoiceText = text; }
|
|
const char *ChoiceText() const { return fChoiceText; }
|
|
|
|
void Run();
|
|
|
|
private:
|
|
friend class MenuItem;
|
|
void Draw(MenuItem *item);
|
|
|
|
const char *fTitle;
|
|
const char *fChoiceText;
|
|
int32 fCount;
|
|
bool fIsHidden;
|
|
MenuItemList fItems;
|
|
menu_type fType;
|
|
MenuItem *fSuperItem;
|
|
};
|
|
|
|
#endif /* KERNEL_BOOT_MENU_H */
|