1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>qooxdoo » Demo » Sample</title>
<link type="text/css" rel="stylesheet" href="../../css/layout.css"/>
<!--[if IE]>
<link type="text/css" rel="stylesheet" href="../../css/layout_ie.css"/>
<![endif]-->
<script type="text/javascript" src="../../script/sample.js"></script>
</head>
<body>
<script type="text/javascript" src="../../script/layout.js"></script>
<div id="demoDescription">
<p>Test the setting of background color of form fields.</p>
</div>
<script type="text/javascript">
function changeBackgrounds(parent, color)
{
var children = parent.getChildren();
var child;
for (var i=0; i<children.length; i++)
{
child = children[i];
switch(child.classname)
{
case 'qx.ui.form.TextArea':
case 'qx.ui.form.TextField':
case 'qx.ui.form.ComboBox':
case 'qx.ui.form.PasswordField':
child.setBackgroundColor(color);
break;
};
};
};
qx.core.Init.getInstance().defineMain(function()
{
var d = qx.ui.core.ClientDocument.getInstance();
function textChange(e) {
this.debug("Text changed: " + e.getData());
}
var t1 = new qx.ui.form.TextField;
t1.setValue("textfield");
t1.setTop(48);
t1.setLeft(20);
t1.addEventListener("changeText", textChange);
t1.addEventListener("input", function(e) {
this.debug("Input: " + e.getData());
});
d.add(t1);
var t2 = new qx.ui.form.PasswordField;
t2.setValue("passwordfield");
t2.setTop(80);
t2.setLeft(20);
t2.addEventListener("changeText", textChange);
d.add(t2);
var t3 = new qx.ui.form.TextArea;
t3.setValue("textarea");
t3.setTop(110);
t3.setLeft(20);
t3.setWidth(300);
t3.setHeight(60);
t3.addEventListener("changeText", textChange);
d.add(t3);
var t4 = new qx.ui.form.TextField;
t4.setValue("textfield");
t4.setTop(200);
t4.setLeft(20);
t4.setWidth(200);
t4.setMaxLength(100);
t4.setReadOnly(true);
t4.addEventListener("changeText", textChange);
d.add(t4);
var t5 = new qx.ui.form.TextField;
t5.setValue("You are foo!");
t5.setTop(240);
t5.setLeft(20);
t5.addEventListener("changeText", textChange);
d.add(t5);
var c1 = new qx.ui.form.ComboBox;
c1.setTop(280);
c1.setLeft(20);
c1.addEventListener("beforeInitialOpen", function(e)
{
var item;
for(var i=1; i<=30; i++)
{
item = new qx.ui.form.ListItem("Item No " + i);
!(i % 10) && (item.setEnabled(false));
c1.add(item);
};
});
// this does not work here (if there is no content)
c1.setSelected(c1.getList().getFirstChild());
c1.addEventListener("changeValue", function(e) {
this.debug("New value: " + e.getData());
});
c1.addEventListener("changeSelected", function(e) {
this.debug("New selected: " + e.getData());
});
var b1 = new qx.ui.form.CheckBox("Editable");
b1.set({ top: 282, left: 150 });
b1.addEventListener("changeChecked", function(e) {
c1.setEditable(e.getData());
});
var b2 = new qx.ui.form.Button("red", "icon/16/actions/format-color.png"); b2.set({left:10,top:10});
var b3 = new qx.ui.form.Button("green", "icon/16/actions/format-color.png"); b3.set({left:10,top:40});
var b4 = new qx.ui.form.Button("white", "icon/16/actions/format-color.png"); b4.set({left:10,top:70});
b2.addEventListener("click", function(e) { changeBackgrounds(d,this.getLabel()); });
b3.addEventListener("click", function(e) { changeBackgrounds(d,this.getLabel()); });
b4.addEventListener("click", function(e) { changeBackgrounds(d,this.getLabel()); });
var fs = new qx.ui.groupbox.GroupBox("BackgroundColor");
fs.set({left:400,top:50,width:150,height:"auto"});
fs.add(b2,b3,b4);
d.add(c1, b1, fs);
// Color Themes
qx.manager.object.ColorManager.getInstance().createThemeList(d, 20, 320);
});
</script>
</body>
</html>
|