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
++;
34 this.clip
= where
.createEmptyMovieClip
(nam
, d
);
37 Widget
.prototype
.moveTo
= function(x
, y
)
43 function Checkbox
(where
, label
) {
49 this.clip
.createEmptyMovieClip
('box', 1);
52 lineStyle
(1, 100, 100);
56 lineTo
(this.size
, this.size
);
61 this.clip
.box
.cb
= this;
62 this.clip
.box
.onRelease
= function()
64 if ( this.cb
.checked
() ) this.cb
.uncheck
();
67 this.clip
.createEmptyMovieClip
('check', 2);
68 with (this.clip
.check
)
70 lineStyle
(1, 100, 100);
72 lineTo
(this.size
, 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
)
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
;
120 lineStyle
(1, 100, 100);
124 lineTo
(this.w
, this.h
);
131 Button.prototype
= new Widget
();
133 //-------------------
135 function Input
(where
, label
)
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
)
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() {
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
;