home *** CD-ROM | disk | FTP | other *** search
-
- // gadgets.h.stringset
-
- // 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_stringset_H
- #define dreamscape_stringset_H
-
- #include "command.h"
- #include "gadget.h"
-
- class StringSetTemplate: public GadgetTemplate {
- public:
- StringSetTemplate(): justify(centre), inform_changed(0), inform_clicked(0),
- writable(0), no_field(0), string_size(0), allow_size(0), previous(0),
- next(0)
- { bbox = WinBBox(0, -52, 100, 0); }
-
- enum { left, centre, right };
- unsigned justify: 2;
- unsigned inform_changed: 1;
- unsigned inform_clicked: 1;
- unsigned writable: 1;
- unsigned no_field: 1;
- String strings, title, initial;
- int string_size;
- String allow;
- int allow_size;
- const Gadget *previous, *next;
- };
-
- class StringSet: public Gadget {
- static class Initialise {
- public:
- Initialise();
- } init;
- friend Initialise;
-
- static Gadget *create(Window *window, int component);
- static void changed(const toolbox_action *event, const toolbox_block *ids);
- static void showing(const toolbox_action *event, const toolbox_block *ids);
-
- Command *changed_handler, *menu_showing_handler;
-
- StringSet(Window *window, int component);
- public:
- StringSet(Window *window, const StringSetTemplate &t);
- virtual ~StringSet();
-
- StringSet &operator=(const char *entry)
- { set_selected(entry); return *this; }
- operator String() const { return get_selected(); }
- StringSet &operator=(int entry) { set_selected_no(entry); return *this; }
- operator int() const { return get_selected_no(); }
-
- void set_changed_handler(Command *handler) { changed_handler = handler; }
- void set_menu_showing_handler(Command *handler)
- { menu_showing_handler = handler; }
-
- void set_available(const char *list);
-
- void set_selected(const char *entry);
- String get_selected() const;
-
- void set_selected_no(int entry);
- int get_selected_no() const;
-
- void set_allowable(const char *allow);
- };
-
- #endif
-