/* * videlay * * Provides a bit more control than the original version * * © 1994-1998 Straylight */ /*----- Licensing note ----------------------------------------------------* * * This file is part of Straylight's Steel library. * * Steel is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Steel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Steel. If not, write to the Free Software Foundation, * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "visdelay.h" #include "os.h" #include "swiv.h" #include "swis.h" #include "wimpt.h" #include #include "dll.h" #ifndef _dll_NODLL extern void _dllEntry(visdelay__exitHandler)(void); #endif static visdelay_state visdelay__state={0,-1}; static BOOL visdelay__exit; /* * void visdelay__exitHandler(void) * * Use * Shuts the hourglass off if we've used it */ _dll_static void visdelay__exitHandler(void) { if (visdelay__state.count) wimpt_noerr(_swix(XHourglass_Off,0)); } /* * void visdelay_begin(void) * * Use * Starts the hourglass. */ void visdelay_begin(void) { if (!visdelay__state.count) { wimpt_noerr(_swix(XHourglass_On,0)); visdelay__state.percent=-1; } visdelay__state.count++; if (!visdelay__exit) { atexit(_dllEntry(visdelay__exitHandler)); visdelay__exit=TRUE; } } /* * void visdelay_end(void) * * Use * Turns off the hourglass. Note that calls to visdelay_begin() and * visdelay_end() must be matched. */ void visdelay_end(void) { if (visdelay__state.count) { visdelay__state.count--; wimpt_noerr(_swix(XHourglass_Off,0)); } } /* * void visdelay_percent(int percent) * * Use * Puts up the little percentage indicator on the hourglass. * * Parameters * int percent == the percentage number to indicate. */ void visdelay_percent(int percent) { wimpt_noerr(_swix(XHourglass_Percentage,_in(0),percent)); visdelay__state.percent=percent; } /* * visdelay_state visdelay_suspend(void) * * Use * Turns the hourglass right off. It also returns information about the * current state of the hourglass so that it can be resumed. * * Returns * State information recorded in an undefined manner. */ visdelay_state visdelay_suspend(void) { visdelay_state c=visdelay__state; wimpt_noerr(_swix(XHourglass_Off,0)); visdelay__state.count=0; return (c); } /* * void visdelay_resume(visdelay_state state) * * Use * Returns the hourglass to the state it was in when the last * visdelay_suspend() call was made. * * Parameters * visdelay_state state == the hourglass state as returned by * visdelay_suspend(). */ void visdelay_resume(visdelay_state state) { visdelay__state=state; if (visdelay__state.count) { wimpt_noerr(_swix(XHourglass_On,0)); wimpt_noerr(_swix(XHourglass_Percentage,_in(0),visdelay__state.percent)); } }