home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / objects / h / menu < prev    next >
Encoding:
Text File  |  1996-07-28  |  3.5 KB  |  151 lines

  1.  
  2. // objects.h.menu
  3.  
  4. // Dreamscape - C++ class library for RISC OS
  5. // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2 of the License, or (at your option) any later version.
  11. // See the Dreamscape documentation for more information.
  12.  
  13. #ifndef dreamscape_menu_H
  14. #define dreamscape_menu_H
  15.  
  16. #include "list.h"
  17. #include "stringt.h"
  18.  
  19. #include "command.h"
  20. #include "basemenu.h"
  21.  
  22. class Menu;
  23. class MenuEntry;
  24. class BaseWindow;
  25.  
  26. class MenuEntryTemplate {
  27. public:
  28.   MenuEntryTemplate(): position(end), other_entry(0), faded(0), ticked(0),
  29.     separator(0), sprite(0), has_submenu(0), inform_submenu(0), text_size(0),
  30.     help_size(0) {}
  31.  
  32.   enum { before, after, start, end };
  33.   unsigned position: 2;
  34.   const MenuEntry *other_entry;
  35.   unsigned faded: 1;
  36.   unsigned ticked: 1;
  37.   unsigned separator: 1;
  38.   unsigned sprite: 1;
  39.   unsigned has_submenu: 1;
  40.   unsigned inform_submenu: 1;
  41.   String text;
  42.   int text_size;
  43.   String help;
  44.   int help_size;
  45. };
  46.  
  47. class MenuEntry {
  48.   static class Initialise {
  49.   public:
  50.     Initialise();
  51.   } init;
  52.   friend Initialise;
  53.  
  54.   static void selection(const toolbox_action *event,
  55.         const toolbox_block *ids);
  56.   static void submenu(const toolbox_action *event,
  57.         const toolbox_block *ids);
  58.  
  59.   friend Menu;
  60.   Menu *_menu;
  61.   int comp;
  62.   inline ToolboxObject &impl() const;
  63.   Command *selection_handler, *submenu_handler;
  64.  
  65.   MenuEntry(Menu *menu, int component);
  66. public:
  67.   MenuEntry(Menu *menu, const MenuEntryTemplate &t);
  68.   virtual ~MenuEntry();
  69.  
  70.   void set_selection_handler(Command *handler)
  71.     { selection_handler = handler; }
  72.   void set_submenu_handler(Command *handler) { submenu_handler = handler; }
  73.  
  74.   void set_tick(bool tick);
  75.   bool get_tick() const;
  76.  
  77.   void set_fade(bool fade);
  78.   bool get_fade() const;
  79.  
  80.   void set_text(const char *text);
  81.   String get_text() const;
  82.  
  83.   void set_sprite(const char *sprite);
  84.   String get_sprite() const;
  85.  
  86.   void set_leaf(BaseWindow *window);
  87.   void set_leaf(BaseMenu *menu);
  88.   void *get_leaf() const;
  89.  
  90.   void set_help(const char *text);
  91.   String get_help() const;
  92.  
  93.   Menu *get_menu() const { return _menu; }
  94.  
  95.   // Low level
  96.   int get_component() const { return comp; }
  97. };
  98.  
  99. class Menu: public BaseMenu {
  100.   static class Initialise {
  101.   public:
  102.     Initialise();
  103.   } init;
  104.   friend Initialise;
  105.  
  106.   static void *creator(toolbox_o object);
  107.   static void deleter(void *handle);
  108.   static void showing(const toolbox_action *event, const toolbox_block *ids);
  109.   static void hidden(const toolbox_action *event, const toolbox_block *ids);
  110.  
  111.   ToolboxObject impl;
  112.  
  113.   friend MenuEntry;
  114.   List<MenuEntry *> entries;
  115.   Command *showing_handler, *hidden_handler;
  116.  
  117.   Menu(toolbox_o object);
  118. public:
  119.   Menu(const char *name);
  120.   virtual ~Menu();
  121.  
  122.   void set_showing_handler(Command *handler) { showing_handler = handler; }
  123.   void set_hidden_handler(Command *handler) { hidden_handler = handler; }
  124.  
  125.   MenuEntry *get_entry(int component);
  126.  
  127.   int width() const;
  128.   int height() const;
  129.  
  130.   void set_help(const char *text);
  131.   String get_help() const;
  132.  
  133.   void set_title(const char *text);
  134.   String get_title() const;
  135.  
  136.   BaseMenu &get_next_menu();
  137.   const BaseMenu &get_next_menu() const;
  138.   bool has_next_menu() const;
  139.  
  140.   // Low level
  141.   ToolboxObject &get_toolbox_object();
  142.   const ToolboxObject &get_toolbox_object() const;
  143. };
  144.  
  145. inline ToolboxObject &MenuEntry::impl() const
  146. {
  147.   return _menu->get_toolbox_object();
  148. }
  149.  
  150. #endif
  151.