3 * Provides handling for a dialogue box without polling (for error boxes
6 * v. 1.00 (30 July 1993)
8 * © 1993-1998 Straylight
11 /*----- Licensing note ----------------------------------------------------*
13 * This file is part of Straylight's Steel library.
15 * Steel is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * Steel is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with Steel. If not, write to the Free Software Foundation,
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 /*---------------------------------------------------------------------------
32 Support is provided for three action buttons, here referred to as 'OK',
33 'Cancel' and 'Other'. Fair enough? Good. 'OK' is the default action
34 button, which may also be selected by pressing return. Pressing escape
35 is equivalent to clicking Cancel. The 'Other' button (good, eh?) has no
36 keyboard equivalent. To indicate that you don't want a particular button
37 to exist, just pass -1 as the number.
39 ---------------------------------------------------------------------------*/
47 #include "interface.h"
48 #include "sculptrix.h"
53 #define OS_Mouse 0x2001C
54 #define XWimpExt_Redraw 0x65783
56 static dbox nopoll__d;
57 static dbox_field nopoll__f;
60 * void nopoll__clickicon(dbox d,dbox_field f)
63 * Clicks in a given field in a nice way
66 static void nopoll__clickicon(dbox d,dbox_field f)
70 if (wimpt_options() & 7)
73 dbox_selecticon(d,f,TRUE);
77 * void nopoll__unclick(void)
80 * Unclicks a clicked icon
83 static void nopoll__unclick(void)
85 if (wimpt_options() & 7)
88 dbox_selecticon(nopoll__d,nopoll__f,FALSE);
92 * void nopoll__mouseRectangle(wimp_w window)
95 * Sets up the mouse rectangle to the limits of the window specified.
98 * wimp_w window == the window handle
101 static void nopoll__mouseRectangle(wimp_w window)
104 wimpt_noerr(wimp_get_wind_state(window,&s));
105 wimpt_noerr((os_error *)bbc_mouserect(s.o.box.x0-wimpt_dx(),
106 s.o.box.y0-wimpt_dy(),
112 * void nopoll__freeMouse(void)
115 * Frees the mouse from the current mouse rectangle.
118 static void nopoll__freeMouse(void)
120 bbc_mouserect(0,0,wimpt_scwidth()-wimpt_dx(),wimpt_scheight()-wimpt_dy());
124 * void nopoll_showDbox(dbox d,nopoll_appearFlags flags)
127 * Displays a dbox on-screen without polling the WIMP. Useful for
128 * copyright windows and things.
131 * dbox d == the dbox handle
132 * nopoll_appearFlags flags == how you want the dbox to appear
135 void nopoll_showDbox(dbox d,nopoll_appearFlags flags)
137 wimp_w wind=dbox_syshandle(d);
144 dbox_display(d,dbox_STATIC_LASTPOS);
147 dbox_display(d,dbox_STATIC_CENTRE);
150 dbox_display(d,dbox_STATIC_OVERPTR);
154 wimpt_noerr(wimp_redraw_wind(&rdr,&more));
157 if (wimpt_options() & wimpt_OSCULPTRIX)
159 wimpt_noerr(sculptrix_setSpriteArea(resspr_area()));
160 wimpt_noerr(sculptrix_redrawWindow(&rdr));
162 if (wimpt_options() & wimpt_OINTERFACE)
163 wimpt_noerr(interface_render3dWindow(&rdr));
164 if (wimpt_options() & wimpt_OWIMPEXT)
165 wimpt_noerr(_swix(XWimpExt_Redraw,_in(1),&rdr));
166 if (!dbox_hasTitle(d))
167 dbox_drawEmbeddedTitle(&rdr,d);
168 wimpt_noerr(wimp_get_rectangle(&rdr,&more));
176 * nopoll_appearFlags flags,
183 * Opens a NoPoll dialogue box, continues until it gets a sensible result,
184 * closes it, and then returns the result.
187 * dbox d == the dialogue box you want to use for this.
188 * nopoll_appearFlags flags == how you want the box to appear (see above)
189 * dbox_field OK == the number of the OK button
190 * dbox_field cancel == the number of the Cancel button
191 * dbox_field other == the number of the Other button
194 * One of the macros defined above, depending on what the user did.
200 nopoll_appearFlags flags,
206 wimp_w wind=dbox_syshandle(d);
209 wimp_box okBox={-1,-1,-1,-1};
210 wimp_box cancelBox=okBox;
211 wimp_box otherBox=okBox;
215 BOOL ignoreClick=TRUE;
220 visdelay_state visstate=visdelay_suspend();
221 wimpt_noerr(wimp_get_point_info(&m));
222 nopoll_showDbox(d,flags);
223 nopoll__mouseRectangle(wind);
224 wimpt_noerr(wimp_get_wind_state(wind,&state));
225 crds.box=state.o.box;
230 wimpt_noerr(wimp_get_icon_info(wind,OK,&icn));
232 coords_box_toscreen(&okBox,&crds);
236 wimpt_noerr(wimp_get_icon_info(wind,cancel,&icn));
238 coords_box_toscreen(&cancelBox,&crds);
242 wimpt_noerr(wimp_get_icon_info(wind,other,&icn));
244 coords_box_toscreen(&otherBox,&crds);
248 bbc_mouse(&p.x,&p.y,&b,0);
249 if ((b==1 || b==4) && !ignoreClick)
251 if (coords_withinbox(&p,&okBox))
253 else if (coords_withinbox(&p,&cancelBox))
255 else if (coords_withinbox(&p,&otherBox))
266 wimpt_noerr(os_byte(129,&key,&dummy));
284 visdelay_resume(visstate);
288 nopoll__clickicon(d,OK);
291 nopoll__clickicon(d,cancel);
294 nopoll__clickicon(d,other);