~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Frontier Kernel
Frontier/Common/source/cursor.c

Version: ~ [ 10.0 ] ~

** Warning: Cannot open xref database.

1 2 /* $Id: cursor.c,v 1.4 2005/01/11 22:48:05 andreradke Exp $ */ 3 4 /****************************************************************************** 5 6 UserLand Frontier(tm) -- High performance Web content management, 7 object database, system-level and Internet scripting environment, 8 including source code editing and debugging. 9 10 Copyright (C) 1992-2004 UserLand Software, Inc. 11 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License as published by 14 the Free Software Foundation; either version 2 of the License, or 15 (at your option) any later version. 16 17 This program is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 GNU General Public License for more details. 21 22 You should have received a copy of the GNU General Public License 23 along with this program; if not, write to the Free Software 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 26 ******************************************************************************/ 27 28 #include "frontier.h" 29 #include "standard.h" 30 31 #include "cursor.h" 32 33 34 35 static tycursortype lastcursor = cursorisdirty; 36 37 static tycursortype beachballstate = cursorisbeachball4; 38 39 /* 40 static short earthstate = cursorisearth7; 41 */ 42 43 static long ticklastroll = 0; 44 45 static tydirection rolldirection = right; 46 47 48 49 50 void setcursortype (tycursortype newcursor) { 51 52 /* 53 7/30/90 dmb: don't assume that cursor is never changed behind your back 54 */ 55 56 register tycursortype cursor = newcursor; 57 #ifdef MACVERSION 58 CursHandle hcursor; 59 #endif 60 #ifdef WIN95VERSION 61 LPTSTR idc; 62 HCURSOR hcursor; 63 #endif 64 65 lastcursor = cursor; /*remember for next time*/ 66 67 if (cursor == cursorisdirty) 68 return; 69 70 #ifdef MACVERSION 71 if (cursor == cursorisarrow) 72 ticklastroll = 0; /*disable rolling until reinitialized*/ 73 74 if (cursor == cursorisarrow) { 75 76 //Code change by Timothy Paustian Sunday, May 7, 2000 11:00:01 PM 77 //Changed to Opaque call for Carbon 78 #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1 79 Cursor theArrow; 80 GetQDGlobalsArrow(&theArrow); 81 SetCursor(&theArrow); 82 #else 83 SetCursor (&qd.arrow); 84 #endif 85 return; 86 } 87 88 hcursor = GetCursor (cursor); 89 90 if (hcursor == nil) /*resource error*/ 91 return; 92 93 SetCursor (*hcursor); 94 #endif 95 96 #ifdef WIN95VERSION 97 if (cursor < cursorisbeachball1 || cursor > cursorisbeachball4) 98 ticklastroll = 0; /*disable rolling until reinitialized*/ 99 100 switch (cursor) { 101 102 case cursorisibeam: 103 idc = IDC_IBEAM; 104 break; 105 106 case cursoriswatch: 107 idc = IDC_WAIT; 108 break; 109 110 case cursorisverticalrails: 111 idc = IDC_SIZEWE; 112 break; 113 114 case cursorishorizontalrails: 115 idc = IDC_SIZENS; 116 break; 117 118 case cursorisarrow: 119 idc = IDC_ARROW; 120 break; 121 122 default: 123 hcursor = LoadCursor (shellinstance, MAKEINTRESOURCE (cursor)); 124 125 if (hcursor != NULL) { 126 127 SetCursor (hcursor); 128 129 return; 130 } 131 132 idc = IDC_ARROW; 133 break; 134 } 135 136 137 SetCursor (LoadCursor (NULL, idc)); 138 #endif 139 140 } /*setcursortype*/ 141 142 143 void obscurecursor (void) { 144 #ifdef MACVERSION 145 ObscureCursor (); 146 #endif 147 } /*obscurecursor*/ 148 149 150 static boolean rollingtimerexpired (void) { 151 152 register long tc; 153 154 if (ticklastroll == 0) /*timer hasn't been initted*/ 155 return (false); 156 157 tc = gettickcount (); 158 159 #ifdef WIN95VERSION 160 if ((ticklastroll + 30) > tc) /*7.0b20 PBS: don't let the Windows cursor change often -- it flashes*/ 161 return (false); 162 #endif 163 164 #ifdef MACVERSION 165 166 if ((ticklastroll + 6) > tc) /*a tenth of a second hasn't passed since last bump*/ 167 return (false); 168 #endif 169 170 ticklastroll = tc; /*enough time has passed, reset the timer*/ 171 172 return (true); 173 } /*rollingtimerexpired*/ 174 175 176 void initbeachball (tydirection dir) { 177 178 rolldirection = dir; /*always set*/ 179 180 if (ticklastroll == 0) { /*beach ball isn't already initted*/ 181 182 beachballstate = cursorisbeachball4; 183 184 #ifdef MACVERSION 185 InitCursor (); /*make sure it's visible*/ 186 #endif 187 #ifdef WIN95VERSION 188 ShowCursor(TRUE); 189 SetCursor (LoadCursor (NULL, MAKEINTRESOURCE(IDC_ARROW))); 190 #endif 191 ticklastroll = gettickcount (); 192 } 193 } /*initbeachball*/ 194 195 196 void rollbeachball (void) { 197 198 #ifdef MACVERSION 199 register tycursortype state; 200 201 if (rollingtimerexpired ()) { 202 203 state = beachballstate; 204 205 if (rolldirection == right) { 206 207 if (--state < cursorisbeachball1) 208 state = cursorisbeachball4; 209 } 210 else { 211 212 if (++state > cursorisbeachball4) /*wrap around*/ 213 state = cursorisbeachball1; 214 } 215 216 setcursortype (state); 217 218 beachballstate = state; 219 } 220 #endif 221 222 #ifdef WIN95VERSION 223 if (rollingtimerexpired ()) 224 setcursortype (cursoriswatch); 225 #endif 226 } /*rollbeachball*/ 227 228 229 boolean beachballcursor (void) { 230 231 /* 232 return true if the cursor is one of the beachballs. 233 234 12/26/90 dmb: new test accounts for the fact that, after an initbeachball, 235 lastcursor won't be a beach ball until the timer has expired. this test 236 will return true if either rolling cursor is active (earth or beach ball) 237 */ 238 239 /* 240 return ((lastcursor >= cursorisbeachball1) && (lastcursor <= cursorisbeachball4)); 241 */ 242 243 return (ticklastroll != 0); 244 } /*beachballcursor*/ 245 246 /* 247 void initearth (void) { 248 249 earthstate = cursorisearth1; 250 251 ticklastroll = gettickcount (); 252 } /%initearth%/ 253 254 255 void rollearth (void) { 256 257 register short state; 258 259 if (rollingtimerexpired ()) { 260 261 state = earthstate + 1; 262 263 if (state > cursorisearth7) /%wrap around%/ 264 state = cursorisearth1; 265 266 setcursortype (state); 267 268 earthstate = state; 269 } 270 } /%rollearth%/ 271 */ 272 273 274 275 276

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.