cursor.c

Go to the documentation of this file.
00001 
00002 /*  $Id: cursor.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "cursor.h"
00032 
00033 
00034 
00035 static tycursortype lastcursor = cursorisdirty;
00036 
00037 static tycursortype beachballstate = cursorisbeachball4;
00038 
00039 /*
00040 static short earthstate = cursorisearth7;
00041 */
00042 
00043 static long ticklastroll = 0;
00044 
00045 static tydirection rolldirection = right;
00046 
00047 
00048 
00049 
00050 void setcursortype (tycursortype newcursor) {
00051     
00052     /*
00053     7/30/90 dmb:  don't assume that cursor is never changed behind your back
00054     */
00055 
00056     register tycursortype cursor = newcursor;
00057     #ifdef MACVERSION
00058         CursHandle hcursor;
00059     #endif
00060     #ifdef WIN95VERSION
00061         LPTSTR idc;
00062         HCURSOR hcursor;
00063     #endif
00064     
00065     lastcursor = cursor; /*remember for next time*/
00066 
00067     if (cursor == cursorisdirty)
00068         return;
00069     
00070 #ifdef MACVERSION   
00071     if (cursor == cursorisarrow)
00072         ticklastroll = 0; /*disable rolling until reinitialized*/
00073 
00074     if (cursor == cursorisarrow) {
00075         
00076         //Code change by Timothy Paustian Sunday, May 7, 2000 11:00:01 PM
00077         //Changed to Opaque call for Carbon
00078         #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
00079         Cursor  theArrow;
00080         GetQDGlobalsArrow(&theArrow);
00081         SetCursor(&theArrow);
00082         #else
00083         SetCursor (&qd.arrow);
00084         #endif
00085         return;
00086         }
00087     
00088     hcursor = GetCursor (cursor);
00089     
00090     if (hcursor == nil) /*resource error*/
00091         return;
00092     
00093     SetCursor (*hcursor);
00094 #endif
00095 
00096 #ifdef WIN95VERSION
00097     if (cursor < cursorisbeachball1 || cursor > cursorisbeachball4)
00098         ticklastroll = 0; /*disable rolling until reinitialized*/
00099     
00100     switch (cursor) {
00101         
00102         case cursorisibeam:
00103             idc = IDC_IBEAM;
00104             break;
00105 
00106         case cursoriswatch:
00107             idc = IDC_WAIT;
00108             break;
00109 
00110         case cursorisverticalrails:
00111             idc = IDC_SIZEWE;
00112             break;
00113 
00114         case cursorishorizontalrails:
00115             idc = IDC_SIZENS;
00116             break;
00117 
00118         case cursorisarrow:
00119             idc = IDC_ARROW;
00120             break;
00121 
00122         default:
00123             hcursor = LoadCursor (shellinstance, MAKEINTRESOURCE (cursor));
00124             
00125             if (hcursor != NULL) {
00126                 
00127                 SetCursor (hcursor);
00128                 
00129                 return;
00130                 }
00131 
00132             idc = IDC_ARROW;
00133             break;
00134         }
00135 
00136     
00137     SetCursor (LoadCursor (NULL, idc));
00138 #endif
00139 
00140     } /*setcursortype*/
00141 
00142 
00143 void obscurecursor (void) {
00144 #ifdef MACVERSION   
00145     ObscureCursor ();
00146 #endif
00147     } /*obscurecursor*/
00148 
00149 
00150 static boolean rollingtimerexpired (void) {
00151     
00152     register long tc;
00153     
00154     if (ticklastroll == 0) /*timer hasn't been initted*/
00155         return (false);
00156     
00157     tc = gettickcount ();
00158 
00159 #ifdef WIN95VERSION
00160     if ((ticklastroll + 30) > tc) /*7.0b20 PBS: don't let the Windows cursor change often -- it flashes*/
00161         return (false);
00162 #endif
00163 
00164 #ifdef MACVERSION
00165     
00166     if ((ticklastroll + 6) > tc) /*a tenth of a second hasn't passed since last bump*/
00167         return (false);
00168 #endif
00169         
00170     ticklastroll = tc; /*enough time has passed, reset the timer*/
00171     
00172     return (true);
00173     } /*rollingtimerexpired*/
00174 
00175 
00176 void initbeachball (tydirection dir) {
00177     
00178     rolldirection = dir; /*always set*/
00179     
00180     if (ticklastroll == 0) { /*beach ball isn't already initted*/
00181         
00182         beachballstate = cursorisbeachball4;
00183         
00184 #ifdef MACVERSION
00185         InitCursor (); /*make sure it's visible*/
00186 #endif
00187 #ifdef WIN95VERSION
00188         ShowCursor(TRUE);
00189         SetCursor (LoadCursor (NULL, MAKEINTRESOURCE(IDC_ARROW)));
00190 #endif
00191         ticklastroll = gettickcount ();
00192         }
00193     } /*initbeachball*/
00194 
00195 
00196 void rollbeachball (void) {
00197     
00198     #ifdef MACVERSION
00199         register tycursortype state;
00200         
00201         if (rollingtimerexpired ()) {
00202             
00203             state = beachballstate;
00204             
00205             if (rolldirection == right) {
00206                 
00207                 if (--state < cursorisbeachball1)
00208                     state = cursorisbeachball4;
00209                 }
00210             else {
00211                 
00212                 if (++state > cursorisbeachball4) /*wrap around*/
00213                     state = cursorisbeachball1;
00214                 }
00215             
00216             setcursortype (state);
00217             
00218             beachballstate = state;
00219             }
00220     #endif
00221 
00222     #ifdef WIN95VERSION
00223         if (rollingtimerexpired ())
00224             setcursortype (cursoriswatch);
00225     #endif
00226     } /*rollbeachball*/
00227 
00228 
00229 boolean beachballcursor (void) {
00230     
00231     /*
00232     return true if the cursor is one of the beachballs.
00233     
00234     12/26/90 dmb: new test accounts for the fact that, after an initbeachball, 
00235     lastcursor won't be a beach ball until the timer has expired.  this test 
00236     will return true if either rolling cursor is active (earth or beach ball)
00237     */
00238     
00239     /*
00240     return ((lastcursor >= cursorisbeachball1) && (lastcursor <= cursorisbeachball4));
00241     */
00242     
00243     return (ticklastroll != 0);
00244     } /*beachballcursor*/
00245 
00246 /*
00247 void initearth (void) {
00248     
00249     earthstate = cursorisearth1;
00250     
00251     ticklastroll = gettickcount ();
00252     } /%initearth%/
00253 
00254 
00255 void rollearth (void) {
00256     
00257     register short state;
00258     
00259     if (rollingtimerexpired ()) {
00260     
00261         state = earthstate + 1; 
00262         
00263         if (state > cursorisearth7) /%wrap around%/
00264             state = cursorisearth1;
00265                         
00266         setcursortype (state);
00267         
00268         earthstate = state;
00269         }
00270     } /%rollearth%/
00271 */
00272 
00273 
00274 
00275 

Generated on Wed May 31 18:19:45 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6