Mercurial > dillo_port1.3
annotate test/form.hh @ 2104:3e7e5395f0bc
non-ASCII keybindings
Alexander Voigt has kindly done some testing, and it seems that this
makes bindings to most keys on a German keyboard possible -- except
those that need AltGr don't work yet.
author | corvid <corvid@lavabit.com> |
---|---|
date | Thu, 23 Jun 2011 19:24:11 +0000 |
parents | 02ef25700865 |
children |
rev | line source |
---|---|
347 | 1 #ifndef __TEST_FORM_HH__ |
2 #define __TEST_FORM_HH__ | |
3 | |
4 #include "../dw/core.hh" | |
5 #include "../dw/ui.hh" | |
6 | |
7 namespace form { | |
8 | |
9 /** | |
10 * \brief Handles HTML form data. | |
11 * | |
12 * Add resources by calling the respective add...Resource method. Furtermore, | |
13 * this class impelements dw::core::ui::ButtonResource::ClickedReceiver, the | |
14 * form data is printed to stdout, when the "clicked" signal is received. | |
15 * | |
16 * \todo wrong comment | |
17 */ | |
18 class Form | |
19 { | |
20 private: | |
21 /** | |
22 * \brief Decorates instances of dw::core::ui::Resource. | |
23 * | |
24 * This is the abstract base class, sub classes have to be defined to | |
25 * decorate specific sub interfaces of dw::core::ui::Resource. | |
26 */ | |
27 class ResourceDecorator: public lout::object::Object | |
28 { | |
29 private: | |
30 const char *name; | |
31 | |
32 protected: | |
33 ResourceDecorator (const char *name); | |
34 ~ResourceDecorator (); | |
35 | |
36 public: | |
37 inline const char *getName () { return name; } | |
38 virtual const char *getValue () = 0; | |
39 }; | |
40 | |
41 /** | |
42 * \brief Decorates instances of dw::core::ui::TextResource. | |
43 */ | |
44 class TextResourceDecorator: public ResourceDecorator | |
45 { | |
46 private: | |
47 dw::core::ui::TextResource *resource; | |
48 | |
49 public: | |
50 TextResourceDecorator (const char *name, | |
51 dw::core::ui::TextResource *resource); | |
52 const char *getValue (); | |
53 }; | |
54 | |
55 /** | |
56 * \brief Decorates instances of dw::core::ui::RadioButtonResource. | |
57 * | |
1147 | 58 * This class has to be instantiated only once for a group of radio |
347 | 59 * buttons. |
60 */ | |
61 class RadioButtonResourceDecorator: public ResourceDecorator | |
62 { | |
63 private: | |
64 dw::core::ui::RadioButtonResource *resource; | |
65 const char **values; | |
66 | |
67 public: | |
68 RadioButtonResourceDecorator (const char *name, | |
69 dw::core::ui::RadioButtonResource | |
70 *resource, | |
71 const char **values); | |
72 ~RadioButtonResourceDecorator (); | |
73 const char *getValue (); | |
74 }; | |
75 | |
76 /** | |
77 * \brief Decorates instances of dw::core::ui::CheckButtonResource. | |
78 */ | |
79 class CheckButtonResourceDecorator: public ResourceDecorator | |
80 { | |
81 private: | |
82 dw::core::ui::CheckButtonResource *resource; | |
83 | |
84 public: | |
85 CheckButtonResourceDecorator (const char *name, | |
86 dw::core::ui::CheckButtonResource | |
87 *resource); | |
88 const char *getValue (); | |
89 }; | |
90 | |
91 /** | |
92 * \brief Decorates instances of dw::core::ui::SelectionResource. | |
93 */ | |
94 class SelectionResourceDecorator: public ResourceDecorator | |
95 { | |
96 private: | |
97 dw::core::ui::SelectionResource *resource; | |
98 const char **values; | |
99 lout::misc::StringBuffer valueBuf; | |
100 | |
101 public: | |
102 SelectionResourceDecorator (const char *name, | |
103 dw::core::ui::SelectionResource *resource, | |
104 const char **values); | |
105 ~SelectionResourceDecorator (); | |
106 const char *getValue (); | |
107 }; | |
108 | |
109 class FormActivateReceiver: public dw::core::ui::Resource::ActivateReceiver | |
110 { | |
111 private: | |
112 Form *form; | |
113 | |
114 public: | |
115 inline FormActivateReceiver (Form *form) { this->form = form; } | |
1326 | 116 |
347 | 117 void activate (dw::core::ui::Resource *resource); |
118 void enter (dw::core::ui::Resource *resource); | |
119 void leave (dw::core::ui::Resource *resource); | |
120 }; | |
121 | |
122 class FormClickedReceiver: | |
468
6ddee709a59a
Moved clicked from ButtonResource to Resource.
Jorge Arellano Cid <jcid@dillo.org>
parents:
459
diff
changeset
|
123 public dw::core::ui::Resource::ClickedReceiver |
347 | 124 { |
125 private: | |
126 Form *form; | |
127 const char *name, *value; | |
128 | |
129 public: | |
130 FormClickedReceiver (Form *form, const char *name, const char *value); | |
131 ~FormClickedReceiver (); | |
1326 | 132 |
468
6ddee709a59a
Moved clicked from ButtonResource to Resource.
Jorge Arellano Cid <jcid@dillo.org>
parents:
459
diff
changeset
|
133 void clicked(dw::core::ui::Resource *resource, |
459
ddf513f18af5
- Set middle click to submit in a new TAB. (Helps to keep form data!)
Jorge Arellano Cid <jcid@dillo.org>
parents:
347
diff
changeset
|
134 dw::core::EventButton *event); |
347 | 135 }; |
136 | |
137 lout::container::typed::List <ResourceDecorator> *resources; | |
138 FormActivateReceiver *activateReceiver; | |
139 lout::container::typed::List <FormClickedReceiver> *clickedReceivers; | |
140 | |
141 public: | |
142 Form (); | |
143 ~Form (); | |
144 | |
145 void addTextResource (const char *name, | |
146 dw::core::ui::TextResource *resource); | |
147 void addRadioButtonResource (const char *name, | |
148 dw::core::ui::RadioButtonResource *resource, | |
149 const char **values); | |
150 void addCheckButtonResource (const char *name, | |
151 dw::core::ui::CheckButtonResource *resource); | |
152 void addSelectionResource (const char *name, | |
153 dw::core::ui::SelectionResource *resource, | |
154 const char **values); | |
155 void addButtonResource (const char *name, | |
156 dw::core::ui::ButtonResource *resource, | |
157 const char *value); | |
158 | |
159 void send (const char *buttonName, const char *buttonValue, int x, int y); | |
160 }; | |
161 | |
162 } // namespace form | |
163 | |
164 #endif // __TEST_FORM_HH__ |