home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / objects / h / iconbar < prev    next >
Encoding:
Text File  |  1996-09-06  |  3.1 KB  |  115 lines

  1.  
  2. // objects.h.iconbar
  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_iconbar_H
  14. #define dreamscape_iconbar_H
  15.  
  16. #include "stringt.h"
  17.  
  18. #include "command.h"
  19. #include "loader.h"
  20. #include "tboxobj.h"
  21. #include "dataload.h"
  22.  
  23. class BaseMenu;
  24.  
  25. struct toolbox_action;
  26. struct toolbox_block;
  27.  
  28. class IconbarFileInfo {
  29. public:
  30.   IconbarFileInfo(): size(0), shift(0), control(0), alt(0) {}
  31.  
  32.   Filetype type;
  33.   int size;
  34.   unsigned shift: 1;
  35.   unsigned control: 1;
  36.   unsigned alt: 1;
  37. };
  38.  
  39. class IconbarIcon {
  40.   static class Initialise: public DataLoadProtocol::Client {
  41.   public:
  42.     Initialise();
  43.  
  44.     void *accept_data(const DataLoadProtocol::Info &info);
  45.     void *accept_file(const DataLoadProtocol::Info &info);
  46.     void load_data(const DataLoadProtocol::Info &info, istream &stream,
  47.         void *handle);
  48.     void load_file(const DataLoadProtocol::Info &info, const char *filename,
  49.         void *handle);
  50.   } init;
  51.   friend Initialise;
  52.  
  53.   static IconbarIcon *icons;
  54.   IconbarIcon *next;
  55.  
  56.   static void *creator(toolbox_o object);
  57.   static void deleter(void *handle);
  58.   static void click(const toolbox_action *event, const toolbox_block *ids);
  59.  
  60.   ToolboxObject impl;
  61.   Command *select_click_handler, *adjust_click_handler;
  62.  
  63.   IconbarIcon(toolbox_o object);
  64. public:
  65.   IconbarIcon(const char *name);
  66.   virtual ~IconbarIcon();
  67.  
  68.   void set_select_click_handler(Command *handler)
  69.     { select_click_handler = handler; }
  70.   void set_adjust_click_handler(Command *handler)
  71.     { adjust_click_handler = handler; }
  72.  
  73.   void show();
  74.   void hide();
  75.   bool is_showing() const;
  76.  
  77.   typedef Loader<const char *, IconbarFileInfo> FileLoader;
  78.   typedef Loader<istream &, IconbarFileInfo> DataLoader;
  79.   typedef LoaderOneType<const char *, IconbarFileInfo> FileLoaderOneType;
  80.   typedef LoaderOneType<istream &, IconbarFileInfo> DataLoaderOneType;
  81.  
  82. private:
  83.   struct FLNode { FileLoader *l; FLNode *next; } *file_loaders;
  84.   struct DLNode { DataLoader *l; DLNode *next; } *data_loaders;
  85.   struct FLTempData { IconbarFileInfo i; FileLoader *l; };
  86.   struct DLTempData { IconbarFileInfo i; DataLoader *l; };
  87.   static void fill_in_loader_info(IconbarFileInfo &i,
  88.         const DataLoadProtocol::Info &info);
  89.  
  90. public:
  91.   void add_file_loader(FileLoader *loader);
  92.   void remove_file_loader(FileLoader *loader);
  93.   void add_data_loader(DataLoader *loader);
  94.   void remove_data_loader(DataLoader *loader);
  95.  
  96.   void set_menu(BaseMenu *menu);
  97.   BaseMenu *get_menu() const;
  98.  
  99.   void set_help(const char *text);
  100.   String get_help() const;
  101.  
  102.   void set_text(const char *text);
  103.   String get_text() const;
  104.  
  105.   void set_sprite(const char *sprite);
  106.   String get_sprite() const;
  107.  
  108.   // Low level
  109.   int get_icon_handle() const;
  110.   ToolboxObject &get_toolbox_object() { return impl; }
  111.   const ToolboxObject &get_toolbox_object() const { return impl; }
  112. };
  113.  
  114. #endif
  115.