home *** CD-ROM | disk | FTP | other *** search
-
- // objects.h.menu
-
- // Dreamscape - C++ class library for RISC OS
- // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
- //
- // This library is free software; you can redistribute it and/or
- // modify it under the terms of the GNU Library General Public
- // License as published by the Free Software Foundation; either
- // version 2 of the License, or (at your option) any later version.
- // See the Dreamscape documentation for more information.
-
- #ifndef dreamscape_menu_H
- #define dreamscape_menu_H
-
- #include "list.h"
- #include "stringt.h"
-
- #include "command.h"
- #include "basemenu.h"
-
- class Menu;
- class MenuEntry;
- class BaseWindow;
-
- class MenuEntryTemplate {
- public:
- MenuEntryTemplate(): position(end), other_entry(0), faded(0), ticked(0),
- separator(0), sprite(0), has_submenu(0), inform_submenu(0), text_size(0),
- help_size(0) {}
-
- enum { before, after, start, end };
- unsigned position: 2;
- const MenuEntry *other_entry;
- unsigned faded: 1;
- unsigned ticked: 1;
- unsigned separator: 1;
- unsigned sprite: 1;
- unsigned has_submenu: 1;
- unsigned inform_submenu: 1;
- String text;
- int text_size;
- String help;
- int help_size;
- };
-
- class MenuEntry {
- static class Initialise {
- public:
- Initialise();
- } init;
- friend Initialise;
-
- static void selection(const toolbox_action *event,
- const toolbox_block *ids);
- static void submenu(const toolbox_action *event,
- const toolbox_block *ids);
-
- friend Menu;
- Menu *_menu;
- int comp;
- inline ToolboxObject &impl() const;
- Command *selection_handler, *submenu_handler;
-
- MenuEntry(Menu *menu, int component);
- public:
- MenuEntry(Menu *menu, const MenuEntryTemplate &t);
- virtual ~MenuEntry();
-
- void set_selection_handler(Command *handler)
- { selection_handler = handler; }
- void set_submenu_handler(Command *handler) { submenu_handler = handler; }
-
- void set_tick(bool tick);
- bool get_tick() const;
-
- void set_fade(bool fade);
- bool get_fade() const;
-
- void set_text(const char *text);
- String get_text() const;
-
- void set_sprite(const char *sprite);
- String get_sprite() const;
-
- void set_leaf(BaseWindow *window);
- void set_leaf(BaseMenu *menu);
- void *get_leaf() const;
-
- void set_help(const char *text);
- String get_help() const;
-
- Menu *get_menu() const { return _menu; }
-
- // Low level
- int get_component() const { return comp; }
- };
-
- class Menu: public BaseMenu {
- static class Initialise {
- public:
- Initialise();
- } init;
- friend Initialise;
-
- static void *creator(toolbox_o object);
- static void deleter(void *handle);
- static void showing(const toolbox_action *event, const toolbox_block *ids);
- static void hidden(const toolbox_action *event, const toolbox_block *ids);
-
- ToolboxObject impl;
-
- friend MenuEntry;
- List<MenuEntry *> entries;
- Command *showing_handler, *hidden_handler;
-
- Menu(toolbox_o object);
- public:
- Menu(const char *name);
- virtual ~Menu();
-
- void set_showing_handler(Command *handler) { showing_handler = handler; }
- void set_hidden_handler(Command *handler) { hidden_handler = handler; }
-
- MenuEntry *get_entry(int component);
-
- int width() const;
- int height() const;
-
- void set_help(const char *text);
- String get_help() const;
-
- void set_title(const char *text);
- String get_title() const;
-
- BaseMenu &get_next_menu();
- const BaseMenu &get_next_menu() const;
- bool has_next_menu() const;
-
- // Low level
- ToolboxObject &get_toolbox_object();
- const ToolboxObject &get_toolbox_object() const;
- };
-
- inline ToolboxObject &MenuEntry::impl() const
- {
- return _menu->get_toolbox_object();
- }
-
- #endif
-