Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / misc-ming.all / widgets.as
blobb69419bb532749449b82345f5a4209f1474c1d03
1 /***********************************************************************
3 * Copyright (C) 2005, 2006, 2009, 2010 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ***********************************************************************
22 * Set of widget to use in 'makeswf' based quick tests
24 * Initial author: Sandro Santilli <strk@keybit.net>
26 ***********************************************************************/
28 function Widget(where) {
29 //trace("Widget ctor called");
30 if ( ! arguments.length ) return;
31 if ( ! where.hasOwnProperty('nextHighestDepth') ) where.nextHighestDepth=1;
32 var d = where.nextHighestDepth++;
33 var nam = 'clip'+d;
34 this.clip = where.createEmptyMovieClip(nam, d);
37 Widget.prototype.moveTo = function(x, y)
39 this.clip._x = x;
40 this.clip._y = y;
43 function Checkbox(where, label) {
45 super(where);
47 this.size = 10;
49 this.clip.createEmptyMovieClip('box', 1);
50 with (this.clip.box)
52 lineStyle(1, 100, 100);
53 beginFill(0, 0);
54 moveTo(0, 0);
55 lineTo(this.size, 0);
56 lineTo(this.size, this.size);
57 lineTo(0, this.size);
58 lineTo(0, 0);
59 endFill();
61 this.clip.box.cb = this;
62 this.clip.box.onRelease = function()
64 if ( this.cb.checked() ) this.cb.uncheck();
65 else this.cb.check();
67 this.clip.createEmptyMovieClip('check', 2);
68 with (this.clip.check)
70 lineStyle(1, 100, 100);
71 moveTo(0, 0);
72 lineTo(this.size, this.size);
73 moveTo(this.size, 0);
74 lineTo(0, this.size);
76 this.clip.check._visible=false;
78 this.clip.createTextField('label', 3, this.size+this.size, 0, 0, 0);
79 this.clip.label.autoSize = true;
80 this.clip.label.text = label;
83 Checkbox.prototype = new Widget();
85 Checkbox.prototype.check = function()
87 trace("Making check visible");
88 this.clip.check._visible=true;
91 Checkbox.prototype.uncheck = function()
93 trace("Making check invisible");
94 this.clip.check._visible=false;
97 Checkbox.prototype.checked = function()
99 trace("Checkbox checked? "+this.clip.check._visible);
100 return this.clip.check._visible;
103 // ------------------------------------------------------------------
105 function Button(where, label, cb)
107 super(where);
109 this.clip.createEmptyMovieClip('eh', 1); // event handler
110 this.clip.onRelease = cb;
112 this.clip.createTextField('label', 3, 0, 0, 0, 0);
113 this.clip.label.autoSize = true;
114 this.clip.label.text = label;
116 this.w = this.clip.label._width;
117 this.h = this.clip.label._height;
118 with (this.clip.eh)
120 lineStyle(1, 100, 100);
121 beginFill(0, 0);
122 moveTo(0, 0);
123 lineTo(this.w, 0);
124 lineTo(this.w, this.h);
125 lineTo(0, this.h);
126 lineTo(0, 0);
127 endFill();
131 Button.prototype = new Widget();
133 //-------------------
135 function Input(where, label)
137 super(where);
139 this.clip.createTextField('label', 3, 0, 0, 0, 0, 0);
140 this.clip.label.autoSize = true;
141 this.clip.label.text = label;
143 this.clip.createTextField('inp', 4, 0, 0, 100, 20); // TODO: take as params
144 this.clip.inp.autoSize = true;
145 this.clip.inp.type = 'input';
146 this.clip.inp.border = true;
147 //this.clip.inp.text = 'your input here';
148 this.clip.inp._x = this.clip.label._x+this.clip.label._width+5;
151 Input.prototype = new Widget();
153 Input.prototype.setText = function(txt)
155 this.clip.inp.text = txt;
158 Input.prototype.getText = function()
160 return this.clip.inp.text;
163 // -------------------------------------------
165 function InfoLine(where, label, cb)
167 super(where);
169 this.clip.createEmptyMovieClip('eh', 1); // event handler
171 this.clip.createTextField('label', 3, 0, 0, 0, 0);
172 this.clip.label.autoSize = true;
173 this.clip.label.text = label;
175 this.clip.createTextField('inp', 4, 0, 0, 100, 20); // TODO: take as params
176 this.clip.inp.autoSize = false;
177 this.clip.inp.type = 'dynamic';
178 this.clip.inp.border = true;
179 this.clip.inp.text = 'your input here';
180 this.clip.inp._x = this.clip.label._x+this.clip.label._width+5;
181 //trace('this clip inp is: '+this.clip.inp);
183 this.clip.onEnterFrame = function() {
184 info = cb();
185 //trace("cb: "+cb()+" inp:"+inp+" clip:"+clip+" this:"+this);
186 this.inp.text = info;
190 InfoLine.prototype = new Widget();
192 InfoLine.prototype.setText = function(txt)
194 this.clip.inp.text = txt;