annotate test/form.cc @ 347:e5955ab8dafb

- Moved the dw2 tree into dillo2's tree.
author jcid
date Wed, 24 Sep 2008 18:44:40 +0200
parents
children e864ed116f26
rev   line source
347
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
1 /*
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
2 * Dillo Widget
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
3 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
5 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
9 * (at your option) any later version.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
10 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
14 * GNU General Public License for more details.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
15 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
19 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
20
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
21
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
22
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
23 #include "form.hh"
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
24
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
25 namespace form {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
26
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
27 using namespace dw::core::ui;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
28
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
29 Form::ResourceDecorator::ResourceDecorator (const char *name)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
30 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
31 this->name = strdup (name);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
32 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
33
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
34 Form::ResourceDecorator::~ResourceDecorator ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
35 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
36 delete name;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
37 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
38
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
39 Form::TextResourceDecorator::TextResourceDecorator (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
40 TextResource *resource):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
41 Form::ResourceDecorator (name)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
42 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
43 this->resource = resource;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
44 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
45
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
46 const char *Form::TextResourceDecorator::getValue ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
47 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
48 return resource->getText ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
49 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
50
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
51 Form::RadioButtonResourceDecorator::RadioButtonResourceDecorator
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
52 (const char *name, RadioButtonResource *resource, const char **values):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
53 Form::ResourceDecorator (name)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
54 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
55 this->resource = resource;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
56
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
57 int n = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
58 while (values[n])
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
59 n++;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
60 this->values = new const char*[n + 1];
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
61 for(int i = 0; i < n; i++)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
62 this->values[i] = strdup (values[i]);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
63 values[n] = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
64 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
65
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
66 Form::RadioButtonResourceDecorator::~RadioButtonResourceDecorator ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
67 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
68 for(int i = 0; values[i]; i++)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
69 delete values[i];
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
70 delete[] values;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
71 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
72
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
73 const char *Form::RadioButtonResourceDecorator::getValue ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
74 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
75 RadioButtonResource::GroupIterator *it;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
76 int i;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
77 for (it = resource->groupIterator (), i = 0; it->hasNext (); i++) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
78 RadioButtonResource *resource = it->getNext ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
79 if(resource->isActivated ()) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
80 it->unref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
81 return values[i];
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
82 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
83 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
84
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
85 it->unref ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
86 return NULL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
87 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
88
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
89 Form::CheckButtonResourceDecorator::CheckButtonResourceDecorator
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
90 (const char *name, CheckButtonResource *resource):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
91 Form::ResourceDecorator (name)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
92 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
93 this->resource = resource;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
94 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
95
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
96 const char *Form::CheckButtonResourceDecorator::getValue ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
97 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
98 return resource->isActivated () ? "true" : NULL;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
99 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
100
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
101 Form::SelectionResourceDecorator::SelectionResourceDecorator
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
102 (const char *name, SelectionResource *resource, const char **values):
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
103 Form::ResourceDecorator (name)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
104 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
105 this->resource = resource;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
106
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
107 int n = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
108 while (values[n])
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
109 n++;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
110 this->values = new const char*[n + 1];
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
111 for(int i = 0; i < n; i++)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
112 this->values[i] = strdup (values[i]);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
113 this->values[n] = 0;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
114 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
115
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
116 Form::SelectionResourceDecorator::~SelectionResourceDecorator ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
117 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
118 for(int i = 0; values[i]; i++)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
119 delete values[i];
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
120 delete[] values;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
121 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
122
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
123 const char *Form::SelectionResourceDecorator::getValue ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
124 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
125 valueBuf.clear();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
126 int n = resource->getNumberOfItems ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
127 bool first = true;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
128 for (int i = 0; i < n; i++) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
129 if (resource->isSelected (i)) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
130 if (!first)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
131 valueBuf.append (", ");
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
132 valueBuf.append (values[i]);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
133 first = false;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
134 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
135 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
136
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
137 return valueBuf.getChars ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
138 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
139
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
140 void Form::FormActivateReceiver::activate (Resource *resource)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
141 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
142 form->send (NULL, NULL, -1, -1);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
143 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
144
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
145 void Form::FormActivateReceiver::enter (Resource *resource)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
146 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
147 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
148
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
149 void Form::FormActivateReceiver::leave (Resource *resource)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
150 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
151 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
152
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
153 Form::FormClickedReceiver::FormClickedReceiver (Form *form, const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
154 const char *value)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
155 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
156 this->form = form;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
157 this->name = strdup (name);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
158 this->value = strdup (value);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
159 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
160
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
161 Form::FormClickedReceiver::~FormClickedReceiver ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
162 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
163 delete name;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
164 delete[] value;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
165 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
166
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
167 void Form::FormClickedReceiver::clicked (ButtonResource *resource,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
168 int buttonNo, int x, int y)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
169 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
170 form->send (name, value, x, y);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
171 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
172
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
173 Form::Form ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
174 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
175 resources = new lout::container::typed::List <ResourceDecorator> (true);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
176 activateReceiver = new FormActivateReceiver (this);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
177 clickedReceivers =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
178 new lout::container::typed::List <FormClickedReceiver> (true);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
179 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
180
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
181 Form::~Form ()
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
182 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
183 delete resources;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
184 delete activateReceiver;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
185 delete clickedReceivers;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
186 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
187
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
188 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
189 * \brief Adds an instance of dw::core::ui::TextResource.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
190 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
191 void Form::addTextResource (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
192 dw::core::ui::TextResource *resource)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
193 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
194 resources->append (new TextResourceDecorator (name, resource));
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
195 resource->connectActivate (activateReceiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
196 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
197
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
198 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
199 * \brief Adds an instance of dw::core::ui::RadioButtonResource.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
200 *
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
201 * This method has to be called only once for a group of radio buttons.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
202 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
203 void Form::addRadioButtonResource (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
204 dw::core::ui::RadioButtonResource *resource,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
205 const char **values)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
206 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
207 resources->append (new RadioButtonResourceDecorator (name, resource,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
208 values));
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
209 resource->connectActivate (activateReceiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
210 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
211
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
212 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
213 * \brief Adds an instance of dw::core::ui::CheckButtonResource.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
214 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
215 void Form::addCheckButtonResource (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
216 dw::core::ui::CheckButtonResource *resource)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
217 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
218 resources->append (new CheckButtonResourceDecorator (name, resource));
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
219 resource->connectActivate (activateReceiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
220 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
221
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
222 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
223 * \brief Adds an instance of dw::core::ui::SelectionResource.
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
224 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
225 void Form::addSelectionResource (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
226 dw::core::ui::SelectionResource *resource,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
227 const char **values)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
228 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
229 resources->append (new SelectionResourceDecorator (name, resource, values));
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
230 resource->connectActivate (activateReceiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
231 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
232
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
233 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
234 * \todo Comment this;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
235 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
236 void Form::addButtonResource (const char *name,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
237 dw::core::ui::ButtonResource *resource,
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
238 const char *value)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
239 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
240 FormClickedReceiver *receiver =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
241 new FormClickedReceiver (this, name, value);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
242 resource->connectClicked (receiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
243 clickedReceivers->append (receiver);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
244 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
245
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
246 /**
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
247 * \todo Comment this;
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
248 */
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
249 void Form::send (const char *buttonName, const char *buttonValue, int x, int y)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
250 {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
251 for (lout::container::typed::Iterator <ResourceDecorator> it =
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
252 resources->iterator ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
253 it.hasNext (); ) {
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
254 ResourceDecorator *resource = it.getNext ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
255 const char *value = resource->getValue ();
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
256 if (value)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
257 printf ("%s = %s; x=%d y=%d\n", resource->getName (), value, x, y);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
258 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
259
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
260 if(buttonName && buttonValue)
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
261 printf ("%s = %s\n", buttonName, buttonValue);
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
262 }
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
263
e5955ab8dafb - Moved the dw2 tree into dillo2's tree.
jcid
parents:
diff changeset
264 } // namespace form