From 93715c46a99c96d6c866968312691ec9ab0f6a03 Mon Sep 17 00:00:00 2001 From: jcid Date: Sun, 7 Oct 2007 00:36:34 +0200 Subject: Initial revision --- src/form.hh | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/form.hh (limited to 'src/form.hh') diff --git a/src/form.hh b/src/form.hh new file mode 100644 index 00000000..9ea47bb0 --- /dev/null +++ b/src/form.hh @@ -0,0 +1,87 @@ +#ifndef __FORM_HH__ +#define __FORM_HH__ + +#include "dw/core.hh" +#include "dw/ui.hh" + +namespace form { + +/** + * \brief Handles HTML form data. + * + * Add resources by calling the respective add...Resource method. Furtermore, + * this class impelements dw::core::ui::ButtonResource::ClickedReceiver, the + * form data is printed to stdout, when the "clicked" signal is received. + */ +class Form: public dw::core::ui::ButtonResource::ClickedReceiver +{ +private: + /** + * \brief Decorates instances of dw::core::ui::Resource. + * + * This is the abstract base class, sub classes have to be defined to + * decorate specific sub interfaces of dw::core::ui::Resource. + */ + class ResourceDecorator: public object::Object + { + private: + const char *name; + + protected: + ResourceDecorator (const char *name); + ~ResourceDecorator (); + + public: + inline const char *getName () { return name; } + virtual const char *getValue () = 0; + }; + + /** + * \brief Decorates instances of dw::core::ui::TextResource. + */ + class TextResourceDecorator: public ResourceDecorator + { + private: + dw::core::ui::TextResource *resource; + + public: + TextResourceDecorator (const char *name, + dw::core::ui::TextResource *resource); + const char *getValue (); + }; + + /** + * \brief Decorates instances of dw::core::ui::RadioButtonResource. + * + * This class has to be instanciated only once for a group of radio + * buttons. + */ + class RadioButtonResourceDecorator: public ResourceDecorator + { + private: + dw::core::ui::RadioButtonResource *resource; + const char **values; + + public: + RadioButtonResourceDecorator (const char *name, + dw::core::ui::RadioButtonResource + *resource, + const char **values); + ~RadioButtonResourceDecorator (); + const char *getValue (); + }; + + container::typed::List *resources; + + void *ext_data; // external data pointer + +public: + Form (void *p); + ~Form (); + void clicked (dw::core::ui::ButtonResource *resource, int buttonNo); + +}; + +} // namespace form + +#endif // __FORM_HH__ -- cgit v1.2.3