1CursorManager class 2################### 3 4The CursorManager class handles token creation, calling the 5cursor-related graphics driver functions, and freeing heap memory for 6all ServerCursor instances. 7 8Enumerated Types 9================ 10 11cursor_which 12------------ 13 14- CURSOR_DEFAULT 15- CURSOR_TEXT 16- CURSOR_MOVE 17- CURSOR_DRAG 18- CURSOR_RESIZE 19- CURSOR_RESIZE_NW 20- CURSOR_RESIZE_SE 21- CURSOR_RESIZE_NS 22- CURSOR_RESIZE_EW 23- CURSOR_OTHER 24 25Member Functions 26================ 27 28CursorManager(void) 29------------------- 30 311. Create the cursor list empty 322. Set the token index to 0 333. Allocate the default system cursor and pass it to AddCursor 344. Initialize the member pointer for the graphics driver 355. Create the cursorlock semaphore 366. Call SetDefaultCursor 37 38~CursorManager(void) 39-------------------- 40 411. Empty and delete the cursor list 422. Delete the cursorlock semaphore 43 44int32 AddCursor(ServerCursor \*sc) 45---------------------------------- 46 47AddCursor() is used to register the cursor in question with the 48manager, allowing for the user application to have the identifying 49token, if necessary. The cursor becomes the property of the manager. 50If a user application deletes a BCursor, its ServerApp will call 51DeleteCursor(). 52 531. Acquire cursor lock 542. Add \*sc to the cursor list 553. Set sc->token to the current token index value 564. Increment the token index 575. Assign sc->token to temporary variable 586. Release cursor lock 597. Return the saved token value 60 61void DeleteCursor(int32 ctoken) 62------------------------------- 63 641. Acquire cursor lock 652. Iterate through the cursor list, looking for ctoken 663. If any ServerCursor->token equals ctoken, remove and delete it 674. Release cursor lock 68 69void RemoveAppCursors(ServerApp \*app) 70-------------------------------------- 71 721. Acquire cursor lock 732. Iterate through the cursor list, checking each cursor's ServerApp 74 pointer 753. If any have a ServerApp pointer which matches the passed pointer, 76 remove and delete them 774. Release cursor lock 78 79void ShowCursor(void), void HideCursor(void), void ObscureCursor(void) 80---------------------------------------------------------------------- 81 82Simple pass-through functions which call the graphics driver's 83functions. Note that acquiring the cursor lock will be necessary for 84all three calls. 85 86void SetCursor(int32 token), void SetCursor(cursor_which cursor) 87---------------------------------------------------------------- 88 89These set the current cursor for the graphics driver to the passed 90cursor, either one previously added via AddCursor or a system cursor. 91 921. Acquire cursor lock 93 94Token version: 95 962. Find the cursor in the cursor list and call the graphics driver if 97 non-NULL 983. Iterate through list of system cursor tokens and see if there's a 99 match. If so, set the internal cursor_which to the match. 100 101cursor_which version: 102 1032. determine which cursor to use via a switch statement and call the 104 graphics driver with the internal pointer for the appropriate cursor 1053. set the internal cursor_which to the one passed to the function 106 107.. 108 1094. Release cursor lock 110 111ServerCursor \*GetCursor(cursor_which which) 112-------------------------------------------- 113 114GetCursor is intended for use in figuring out what cursor is in use 115for a particular system cursor. 116 1171. Acquire cursor lock 1182. use a switch statement to figure which cursor to return and assign a 119 temporary pointer its value 1203. Release cursor lock 1214. Return the temporary pointer 122 123void ChangeCursor(cursor_which which, int32 token) 124-------------------------------------------------- 125 126Calling ChangeCursor will allow a user to change a system cursor's 127appearance. Note that in calling this, the cursor changes ownership 128and belongs to the system. Thus, the BCursor destructor will not 129ultimately cause the cursor to be deleted. 130 1311. Acquire cursor lock 1322. Call FindCursor and, if NULL, release the cursor lock and return 1333. Look up the pointer for the system cursor in question and check to 134 see if it is active. If active, then set the local active flag to true. 135 Set the system cursor pointer to the one looked up. 1364. If active flag is true, call SetCursor() 1375. Release cursor lock 138 139cursor_which GetCursorWhich(void) 140--------------------------------- 141 142Returns the current cursor_which attribute which describes the 143currently active cursor. If the active cursor is not a system cursor, 144it will return CURSOR_OTHER. 145 1461. Acquire cursor lock 1472. Create a local cursor_which and assign it the value of the 148 CursorManager's cursor_which 1493. Release cursor lock 1504. Return the local copy 151 152