home *** CD-ROM | disk | FTP | other *** search
-
- // objects.h.iconbar
-
- // 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_iconbar_H
- #define dreamscape_iconbar_H
-
- #include "stringt.h"
-
- #include "command.h"
- #include "loader.h"
- #include "tboxobj.h"
- #include "dataload.h"
-
- class BaseMenu;
-
- struct toolbox_action;
- struct toolbox_block;
-
- class IconbarFileInfo {
- public:
- IconbarFileInfo(): size(0), shift(0), control(0), alt(0) {}
-
- Filetype type;
- int size;
- unsigned shift: 1;
- unsigned control: 1;
- unsigned alt: 1;
- };
-
- class IconbarIcon {
- static class Initialise: public DataLoadProtocol::Client {
- public:
- Initialise();
-
- void *accept_data(const DataLoadProtocol::Info &info);
- void *accept_file(const DataLoadProtocol::Info &info);
- void load_data(const DataLoadProtocol::Info &info, istream &stream,
- void *handle);
- void load_file(const DataLoadProtocol::Info &info, const char *filename,
- void *handle);
- } init;
- friend Initialise;
-
- static IconbarIcon *icons;
- IconbarIcon *next;
-
- static void *creator(toolbox_o object);
- static void deleter(void *handle);
- static void click(const toolbox_action *event, const toolbox_block *ids);
-
- ToolboxObject impl;
- Command *select_click_handler, *adjust_click_handler;
-
- IconbarIcon(toolbox_o object);
- public:
- IconbarIcon(const char *name);
- virtual ~IconbarIcon();
-
- void set_select_click_handler(Command *handler)
- { select_click_handler = handler; }
- void set_adjust_click_handler(Command *handler)
- { adjust_click_handler = handler; }
-
- void show();
- void hide();
- bool is_showing() const;
-
- typedef Loader<const char *, IconbarFileInfo> FileLoader;
- typedef Loader<istream &, IconbarFileInfo> DataLoader;
- typedef LoaderOneType<const char *, IconbarFileInfo> FileLoaderOneType;
- typedef LoaderOneType<istream &, IconbarFileInfo> DataLoaderOneType;
-
- private:
- struct FLNode { FileLoader *l; FLNode *next; } *file_loaders;
- struct DLNode { DataLoader *l; DLNode *next; } *data_loaders;
- struct FLTempData { IconbarFileInfo i; FileLoader *l; };
- struct DLTempData { IconbarFileInfo i; DataLoader *l; };
- static void fill_in_loader_info(IconbarFileInfo &i,
- const DataLoadProtocol::Info &info);
-
- public:
- void add_file_loader(FileLoader *loader);
- void remove_file_loader(FileLoader *loader);
- void add_data_loader(DataLoader *loader);
- void remove_data_loader(DataLoader *loader);
-
- void set_menu(BaseMenu *menu);
- BaseMenu *get_menu() const;
-
- void set_help(const char *text);
- String get_help() const;
-
- void set_text(const char *text);
- String get_text() const;
-
- void set_sprite(const char *sprite);
- String get_sprite() const;
-
- // Low level
- int get_icon_handle() const;
- ToolboxObject &get_toolbox_object() { return impl; }
- const ToolboxObject &get_toolbox_object() const { return impl; }
- };
-
- #endif
-