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

  1.  
  2. // gadgets.h.button
  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_button_H
  14. #define dreamscape_button_H
  15.  
  16. #include "gadget.h"
  17. #include "window.h"
  18.  
  19. class ButtonTemplate: public GadgetTemplate {
  20. public:
  21.   ButtonTemplate(): flags(0), value_size(0), validation_size(0)
  22.     { bbox = WinBBox(0, -52, 100, 0); }
  23.  
  24.   unsigned flags;
  25.   String value;
  26.   int value_size;
  27.   String validation;
  28.   int validation_size;
  29. };
  30.  
  31. class Button: public Gadget {
  32.   static class Initialise {
  33.   public:
  34.     Initialise();
  35.   } init;
  36.   friend Initialise;
  37.  
  38.   static Gadget *create(Window *window, int component);
  39.   static bool click(const wimp_block *event, const toolbox_block *ids,
  40.         void *handle);
  41.  
  42.   ClickHandler *click_handler;
  43.  
  44.   Button(Window *window, int component);
  45. public:
  46.   Button(Window *window, const ButtonTemplate &t);
  47.   virtual ~Button();
  48.  
  49.   Button &operator=(const char *value) { set_value(value); return *this; }
  50.   Button &operator+=(const char *value)
  51.     { set_value(get_value() + value); return *this; }
  52.   String operator+(const char *value) const { return get_value() + value; }
  53.   operator String() const { return get_value(); }
  54.  
  55.   void set_handler(ClickHandler *handler) { click_handler = handler; }
  56.  
  57.   void set_value(const char *value);
  58.   String get_value() const;
  59.  
  60.   void set_validation(const char *value);
  61.   String get_validation() const;
  62.  
  63.   void set_selected(bool select);
  64.   bool get_selected() const;
  65.  
  66.   void set_font(const char *font = 0, float width = 12, float height = 0);
  67. };
  68.  
  69. class VirtualButton: public WindowRedrawable {
  70. public:
  71.   VirtualButton(): flags(0), bbox(0, -52, 100, 0) {}
  72.   VirtualButton(const ButtonTemplate &t): flags(t.flags), value(t.value),
  73.     validation(t.validation), bbox(t.bbox) {}
  74.  
  75.   VirtualButton &operator=(const ButtonTemplate &t)
  76.     { flags = t.flags; value = t.value; validation = t.validation;
  77.       bbox = t.bbox; return *this; }
  78.  
  79.   unsigned flags;
  80.   String value;
  81.   String validation;
  82.   WinBBox bbox;
  83.  
  84.   void redraw(const RedrawInfo &info) const;
  85. };
  86.  
  87. #endif
  88.