Copy purify.fvwm2rc to /tmp - add instructions in README.
[fvwm.git] / tests / FvwmButtons / FvwmButtons.sh
blob17056cd5ad628913efc0b9ea845832372efe5675
1 #!/bin/sh
3 # Test shell for FvwmButtons.
5 # If you don't have the FvwmCommand server running, first start it:
7 # Module FvwmCommandS
9 # Then, run this shell.
11 # Args are:
12 # -d debug by echoing commands instead of issuing them.
13 # -k do not kill FvwmButtons if script is interrupted with ctrl-c
14 # -t trace exection
15 # -s run slowly. Needed on very slow connections.
16 # -S specify a delay between the test steps. -S 1 is the default, -S 20 is
17 # equivalent to -s
18 # -o just operate the 4 button setup once.
19 # -c just create the window, don't operate it or kill it.
21 # Modification History
23 # Created on 03/02/01 by Dan Espen (dane):
24 # - Tests for FvwmButtons.
27 # Base unit in seconds for delay
28 DEFAULT_DELAY=1
29 DEFAULT_SLOWNESS_FACTOR=20
31 # Function for running an Fvwm command:
32 FC () {
33 $DEBUG FvwmCommand "$*"
34 $TALK "`date '+%m/%d/%y %H:%M:%S'` FvwmCommand $*"
37 # This doesn't really do it for me...comment out for now
38 # was being used at the beginning of Operate.
39 # Draw attention to the pointer
40 # Pointer_Attn () {
41 # # Can't use FC here, tracing destroys the effect.
42 # x=1
43 # while [ $x -lt 40 ] ; do
44 # FvwmCommand "WindowId root WarpToWindow $x $x"
45 # x=`expr $x + 4`
46 # done
47 # while [ $x -gt 10 ] ; do
48 # FvwmCommand "WindowId root WarpToWindow $x $x"
49 # x=`expr $x - 2`
50 # done
51 # }
53 trap_sigint () {
54 FC KillModule FvwmButtons FButt
55 exit 0
58 # Function to insert a pause
59 Delay () {
60 if [ x$1 = x ] ; then
61 DELAY=$DEFAULT_DELAY
62 else
63 DELAY=$1
65 sleep `expr $DELAY \* $SLOW`
68 # Push a button
69 # arg 1 row
70 # arg 2 col
71 # global button_size gives multiplier
72 Push () {
73 Delay
74 FC 'Next (FButt) WarpToWindow 20p 20p'
75 FC "CursorMove `expr $button_size \* $1`p `expr $button_size \* $2`p"
76 FC 'FakeClick Depth 4 press 1 wait 300 release 1'
78 # Push all the buttons,
79 # uses globals:
80 # button_size for distance to move
81 # rows for number of rows of buttons
82 # cols for number of cols of buttons
83 Operate () {
84 rowc=0
85 colc=0
86 while [ $rowc -lt $rows -a $colc -lt $cols ] ; do
87 Push $rowc $colc
88 rowc=`expr $rowc + 1`
89 if [ $rowc -eq $rows ] ; then
90 colc=`expr $colc + 1`
91 rowc=0
93 done
96 TALK=true
97 SLOW=1
98 DO_SOME=n
99 KILL=1
100 CREATE_ONLY=n
101 while getopts cdkosS:t1234 arg ; do
102 case $arg in
104 DO_1=y
105 DO_SOME=y;;
107 DO_2=y
108 DO_SOME=y;;
110 DO_3=y
111 DO_SOME=y;;
113 DO_4=y
114 DO_SOME=y;;
116 CREATE_ONLY=y;;
118 DEBUG=echo;;
120 KILL=0;;
122 Operate
123 exit 0;;
125 SLOW=$DEFAULT_SLOWNESS_FACTOR;;
127 SLOW=$OPTARG;;
129 TALK=echo;;
131 # usage would be nice here...
132 exit 1;;
133 esac
134 done
136 if [ $KILL = 1 ] ; then
137 trap trap_sigint 2
140 # Create shortcut function to create a window
141 # arg 0, window name
142 FC DestroyFunc W
143 FC AddToFunc W I Exec xterm -font 10x20 -name '\$0' -g 10x10-20000-20000
144 # On my system, the window width is 104, the border width is 6
145 ww=120
147 # Setup window style for FvwmButtons
148 FC Style FButt CirculateHit, neverfocus, mousefocusclickraisesoff, HandleWidth 6
149 FC Style FButt NoTitle
150 # Setup window styles for the 4 slideout panels:
151 FC 'Style b* HandleWidth 6, NoTitle'
153 if [ "$DO_SOME" = "n" -o "$DO_1" = "y" ] ; then
154 # Create a button box with 4 panels, one for each direction
155 button_size=32
156 rows=2
157 cols=2
158 FC destroymoduleconfig FButt: \'*\'
159 # Somewhere near the middle of the screen:
160 FC '*FButt: Geometry +300+300'
161 FC '*FButt: ButtonGeometry '"${button_size}x${button_size}"
162 FC '*FButt: Back gray'
163 FC '*FButt: Fore white'
164 FC '*FButt: BoxSize smart'
165 FC '*FButt: Columns '"$cols"
166 FC '*FButt: Rows '"$rows"
167 FC '*FButt: Font 9x15bold'
168 FC '*FButt: (Panel(up, indicator) bu "W bu")'
169 FC 'Style br HandleWidth 0'
170 FC '*FButt: (Panel(right, indicator, noborder) br "W br")'
171 FC '*FButt: (Title "<<", Panel(left) bl "W bl")'
172 FC '*FButt: (Padding 1 1, Panel(down, indicator) bd "W bd")'
173 FC Module FvwmButtons FButt
175 if [ $CREATE_ONLY != 'y' ] ; then
176 Operate
177 Operate
178 # Need a long delay here, or the window just goes away
179 Delay
180 FC Beep
181 FC KillModule FvwmButtons FButt
182 FC 'Style br HandleWidth 6'
186 # Test 2 issues:
187 # The test with 1 step doesn't work, the window doesn't appear, sometimes
188 # I see just piece of the frame. 2 steps works.
190 if [ "$DO_SOME" = "n" -o "$DO_2" = "y" ] ; then
191 button_size=64
192 rows=2
193 cols=2
194 # Create a button box with 4 panels, one for each direction
195 FC destroymoduleconfig FButt: \'*\'
196 FC '*FButt: Geometry +400+400'
197 FC '*FButt: ButtonGeometry '"${button_size}x${button_size}"
198 FC '*FButt: Back cornflowerblue'
199 FC '*FButt: Fore white'
200 FC '*FButt: BoxSize fixed'
201 FC '*FButt: Columns '"$cols"
202 FC '*FButt: Rows '"$rows"
203 FC '*FButt: Font 9x15bold'
204 FC '*FButt: (Panel(up, indicator, delay 250, smooth, steps 3) bu "W bu")'
205 FC '*FButt: (Panel(right, indicator, hints) br "W br")'
206 FC '*FButt: (Panel(left, indicator 16, steps 2) bl "W bl")'
207 FC '*FButt: (Panel(down, indicator 33, steps 1) bd "W bd")'
208 FC Module FvwmButtons FButt
210 if [ $CREATE_ONLY != 'y' ] ; then
211 Operate
212 Operate
213 # Need a long delay here, or the window just goes away
214 Delay
215 FC Beep
216 FC KillModule FvwmButtons FButt
220 # Test 3 issues:
221 # Panel bul doesn't seem to be where it should be, or is it panel bur?
222 # Panel brc, and the bottom panels seem to come out from the wrong place,
223 # but slide in OK.
225 # Test 3, use a 3x3 panel, test positioning.
226 # Make sure no panel is positioned over FvwmButtons itself, you can't push
227 # a button if somethings in the way.
229 if [ "$DO_SOME" = "n" -o "$DO_3" = "y" ] ; then
230 button_size=48
231 rows=3
232 cols=3
233 # Create a button box with 4 panels, one for each direction
234 FC destroymoduleconfig FButt: \'*\'
235 FC '*FButt: Geometry +500+500'
236 FC '*FButt: ButtonGeometry '"${button_size}x${button_size}"
237 FC '*FButt: Back wheat'
238 FC '*FButt: Fore black'
239 FC '*FButt: BoxSize fixed'
240 FC '*FButt: Columns '"$cols"
241 FC '*FButt: Rows '"$rows"
242 FC '*FButt: Font 10x20'
243 FC '*FButt: Padding 12'
244 base='indicator, smooth, delay 30, steps 3, position'
245 FC '*FButt: (Panel(up, '"$base "'Module top -'"$ww"'p 0 mlr mtb) bul "W bul")'
246 FC '*FButt: (Panel(up, '"$base"' Button top center mlr mtb) buc "W buc")'
247 FC '*FButt: (Panel(up, '"$base"' Module top 100 0 mlr mtb) bur "W bur")'
248 # Root right 0 50 put brl down a page in the middle. isn't that 100?
249 # This goes to the bottom right. why?
250 FC '*FButt: (Panel(left, '"$base"' Root right 0 0) brl "W brl")'
251 FC '*FButt: (Panel(right, '"$base"' Module right) brc "W brc")'
252 # This ends up on the left bottom, -10p off screen, 20p up from the bottom
253 FC '*FButt: (Panel(right, '"$base"' Root right -5p -100p) brr "W brr")'
254 FC '*FButt: (Panel(down, '"$base"' Module bottom) bdl "W bdl")'
255 FC '*FButt: (Panel(down, '"$base"' Button bottom) bdc "W bdc")'
256 FC '*FButt: (Panel(down, '"$base"' Module bottom) bdr "W bdr")'
257 FC Module FvwmButtons FButt
259 if [ $CREATE_ONLY != 'y' ] ; then
260 Operate
261 Operate
262 # Need a long delay here, or the window just goes away
263 Delay
264 FC Beep
265 FC KillModule FvwmButtons FButt
269 # Test 4, 1 Button.
270 if [ "$DO_SOME" = "n" -o "$DO_4" = "y" ] ; then
271 button_size=180
272 rows=1
273 cols=1
274 # Create a button box with 1 button
275 FC destroymoduleconfig FButt: \'*\'
276 FC '*FButt: Geometry +600+600'
277 FC '*FButt: ButtonGeometry '"${button_size}x${button_size}"
278 FC '*FButt: Back lightblue'
279 FC '*FButt: Fore black'
280 FC '*FButt: BoxSize smart'
281 FC '*FButt: Columns '"$cols"
282 FC '*FButt: Rows '"$rows"
283 FC '*FButt: Font 9x15bold'
284 FC '*FButt: Padding 12'
285 FC '*FButt: (Title "OneButton", Panel(up) bd "W bd")'
286 FC 'Module FvwmButtons FButt'
287 if [ $CREATE_ONLY != 'y' ] ; then
288 Operate
289 Operate
290 # Need a long delay here, or the window just goes away
291 Delay
292 FC Beep
293 FC KillModule FvwmButtons FButt