home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / gadgets / h / stringset < prev    next >
Encoding:
Text File  |  1996-07-29  |  2.2 KB  |  79 lines

  1.  
  2. // gadgets.h.stringset
  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_stringset_H
  14. #define dreamscape_stringset_H
  15.  
  16. #include "command.h"
  17. #include "gadget.h"
  18.  
  19. class StringSetTemplate: public GadgetTemplate {
  20. public:
  21.   StringSetTemplate(): justify(centre), inform_changed(0), inform_clicked(0),
  22.     writable(0), no_field(0), string_size(0), allow_size(0), previous(0),
  23.     next(0)
  24.       { bbox = WinBBox(0, -52, 100, 0); }
  25.  
  26.   enum { left, centre, right };
  27.   unsigned justify: 2;
  28.   unsigned inform_changed: 1;
  29.   unsigned inform_clicked: 1;
  30.   unsigned writable: 1;
  31.   unsigned no_field: 1;
  32.   String strings, title, initial;
  33.   int string_size;
  34.   String allow;
  35.   int allow_size;
  36.   const Gadget *previous, *next;
  37. };
  38.  
  39. class StringSet: public Gadget {
  40.   static class Initialise {
  41.   public:
  42.     Initialise();
  43.   } init;
  44.   friend Initialise;
  45.  
  46.   static Gadget *create(Window *window, int component);
  47.   static void changed(const toolbox_action *event, const toolbox_block *ids);
  48.   static void showing(const toolbox_action *event, const toolbox_block *ids);
  49.  
  50.   Command *changed_handler, *menu_showing_handler;
  51.  
  52.   StringSet(Window *window, int component);
  53. public:
  54.   StringSet(Window *window, const StringSetTemplate &t);
  55.   virtual ~StringSet();
  56.  
  57.   StringSet &operator=(const char *entry)
  58.     { set_selected(entry); return *this; }
  59.   operator String() const { return get_selected(); }
  60.   StringSet &operator=(int entry) { set_selected_no(entry); return *this; }
  61.   operator int() const { return get_selected_no(); }
  62.  
  63.   void set_changed_handler(Command *handler) { changed_handler = handler; }
  64.   void set_menu_showing_handler(Command *handler)
  65.     { menu_showing_handler = handler; }
  66.  
  67.   void set_available(const char *list);
  68.  
  69.   void set_selected(const char *entry);
  70.   String get_selected() const;
  71.  
  72.   void set_selected_no(int entry);
  73.   int get_selected_no() const;
  74.  
  75.   void set_allowable(const char *allow);
  76. };
  77.  
  78. #endif
  79.