home *** CD-ROM | disk | FTP | other *** search
-
- // gadgets.h.button
-
- // 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_button_H
- #define dreamscape_button_H
-
- #include "gadget.h"
- #include "window.h"
-
- class ButtonTemplate: public GadgetTemplate {
- public:
- ButtonTemplate(): flags(0), value_size(0), validation_size(0)
- { bbox = WinBBox(0, -52, 100, 0); }
-
- unsigned flags;
- String value;
- int value_size;
- String validation;
- int validation_size;
- };
-
- class Button: public Gadget {
- static class Initialise {
- public:
- Initialise();
- } init;
- friend Initialise;
-
- static Gadget *create(Window *window, int component);
- static bool click(const wimp_block *event, const toolbox_block *ids,
- void *handle);
-
- ClickHandler *click_handler;
-
- Button(Window *window, int component);
- public:
- Button(Window *window, const ButtonTemplate &t);
- virtual ~Button();
-
- Button &operator=(const char *value) { set_value(value); return *this; }
- Button &operator+=(const char *value)
- { set_value(get_value() + value); return *this; }
- String operator+(const char *value) const { return get_value() + value; }
- operator String() const { return get_value(); }
-
- void set_handler(ClickHandler *handler) { click_handler = handler; }
-
- void set_value(const char *value);
- String get_value() const;
-
- void set_validation(const char *value);
- String get_validation() const;
-
- void set_selected(bool select);
- bool get_selected() const;
-
- void set_font(const char *font = 0, float width = 12, float height = 0);
- };
-
- class VirtualButton: public WindowRedrawable {
- public:
- VirtualButton(): flags(0), bbox(0, -52, 100, 0) {}
- VirtualButton(const ButtonTemplate &t): flags(t.flags), value(t.value),
- validation(t.validation), bbox(t.bbox) {}
-
- VirtualButton &operator=(const ButtonTemplate &t)
- { flags = t.flags; value = t.value; validation = t.validation;
- bbox = t.bbox; return *this; }
-
- unsigned flags;
- String value;
- String validation;
- WinBBox bbox;
-
- void redraw(const RedrawInfo &info) const;
- };
-
- #endif
-