diff --git a/headers/private/kernel/boot/menu.h b/headers/private/kernel/boot/menu.h new file mode 100644 index 0000000000..3bffc3e440 --- /dev/null +++ b/headers/private/kernel/boot/menu.h @@ -0,0 +1,108 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_MENU_H +#define KERNEL_BOOT_MENU_H + + +#include +#include + + +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_SEPARATOR, +}; + +class MenuItem { + public: + MenuItem(const char *label = NULL, Menu *subMenu = NULL); + ~MenuItem(); + + void SetTarget(menu_item_hook target); + + 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; } + + 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; +}; + +typedef DoublyLinked::List MenuItemList; +typedef DoublyLinked::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.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 */ diff --git a/headers/private/kernel/boot/platform.h b/headers/private/kernel/boot/platform.h index a1a927f973..121cc102e2 100644 --- a/headers/private/kernel/boot/platform.h +++ b/headers/private/kernel/boot/platform.h @@ -42,19 +42,29 @@ extern void platform_start_kernel(void); #ifdef __cplusplus } +// these functions have to be implemented in C++ + +/* device functions */ + class Node; namespace boot { class Partition; } -/* device functions */ - -// these functions have to be implemented in C++ extern status_t platform_get_boot_device(struct stage2_args *args, Node **_device); extern status_t platform_add_block_devices(struct stage2_args *args, NodeList *devicesList); extern status_t platform_get_boot_partition(struct stage2_args *args, Node *bootDevice, NodeList *partitions, boot::Partition **_partition); +/* menu functions */ + +class Menu; +class MenuItem; + +extern void platform_add_menus(Menu *menu); +extern void platform_update_menu_item(Menu *menu, MenuItem *item); +extern void platform_run_menu(Menu *menu); + #endif #endif /* KERNEL_BOOT_PLATFORM_H */