chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / c / visdelay
1 /*
2  * videlay
3  *
4  * Provides a bit more control than the original version
5  *
6  * © 1994-1998 Straylight
7  */
8
9 /*----- Licensing note ----------------------------------------------------*
10  *
11  * This file is part of Straylight's Steel library.
12  *
13  * Steel is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * Steel is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with Steel.  If not, write to the Free Software Foundation,
25  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27
28 #include "visdelay.h"
29 #include "os.h"
30 #include "swiv.h"
31 #include "swis.h"
32 #include "wimpt.h"
33 #include <stdlib.h>
34
35 #include "dll.h"
36
37 #ifndef _dll_NODLL
38   extern void _dllEntry(visdelay__exitHandler)(void);
39 #endif
40
41 static visdelay_state visdelay__state={0,-1};
42 static BOOL visdelay__exit;
43
44 /*
45  * void visdelay__exitHandler(void)
46  *
47  * Use
48  *  Shuts the hourglass off if we've used it
49  */
50
51 _dll_static void visdelay__exitHandler(void)
52 {
53   if (visdelay__state.count)
54     wimpt_noerr(_swix(XHourglass_Off,0));
55 }
56
57 /*
58  * void visdelay_begin(void)
59  *
60  * Use
61  *  Starts the hourglass.
62  */
63
64 void visdelay_begin(void)
65 {
66   if (!visdelay__state.count)
67   {
68     wimpt_noerr(_swix(XHourglass_On,0));
69     visdelay__state.percent=-1;
70   }
71   visdelay__state.count++;
72   if (!visdelay__exit)
73   {
74     atexit(_dllEntry(visdelay__exitHandler));
75     visdelay__exit=TRUE;
76   }
77 }
78
79 /*
80  * void visdelay_end(void)
81  *
82  * Use
83  *  Turns off the hourglass.  Note that calls to visdelay_begin() and
84  *  visdelay_end() must be matched.
85  */
86
87 void visdelay_end(void)
88 {
89   if (visdelay__state.count)
90   {
91     visdelay__state.count--;
92     wimpt_noerr(_swix(XHourglass_Off,0));
93   }
94 }
95
96 /*
97  * void visdelay_percent(int percent)
98  *
99  * Use
100  *  Puts up the little percentage indicator on the hourglass.
101  *
102  * Parameters
103  *  int percent == the percentage number to indicate.
104  */
105
106 void visdelay_percent(int percent)
107 {
108   wimpt_noerr(_swix(XHourglass_Percentage,_in(0),percent));
109   visdelay__state.percent=percent;
110 }
111
112 /*
113  * visdelay_state visdelay_suspend(void)
114  *
115  * Use
116  *  Turns the hourglass right off.  It also returns information about the
117  *  current state of the hourglass so that it can be resumed.
118  *
119  * Returns
120  *  State information recorded in an undefined manner.
121  */
122
123 visdelay_state visdelay_suspend(void)
124 {
125   visdelay_state c=visdelay__state;
126   wimpt_noerr(_swix(XHourglass_Off,0));
127   visdelay__state.count=0;
128   return (c);
129 }
130
131 /*
132  * void visdelay_resume(visdelay_state state)
133  *
134  * Use
135  *  Returns the hourglass to the state it was in when the last
136  *  visdelay_suspend() call was made.
137  *
138  * Parameters
139  *  visdelay_state state == the hourglass state as returned by
140  *  visdelay_suspend().
141  */
142
143 void visdelay_resume(visdelay_state state)
144 {
145   visdelay__state=state;
146   if (visdelay__state.count)
147   {
148     wimpt_noerr(_swix(XHourglass_On,0));
149     wimpt_noerr(_swix(XHourglass_Percentage,_in(0),visdelay__state.percent));
150   }
151 }