1 /*********************************************************** 2 * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby. 3 * 4 * This program is freely distributable without licensing fees 5 * and is provided without guarantee or warrantee expressed or 6 * implied. This program is -not- in the public domain. 7 * 8 * 9 * FILE: glutCursor.cpp 10 * 11 * DESCRIPTION: code for handling custom mouse cursors 12 ***********************************************************/ 13 14 /*********************************************************** 15 * Headers 16 ***********************************************************/ 17 #include <GL/glut.h> 18 #include "glutint.h" 19 #include "glutState.h" 20 #include "glutCursors.h" 21 22 static const unsigned char *cursorTable[] = { 23 XC_arrow, /* GLUT_CURSOR_RIGHT_ARROW */ 24 XC_top_left_arrow, /* GLUT_CURSOR_LEFT_ARROW */ 25 XC_hand1, /* GLUT_CURSOR_INFO */ 26 XC_pirate, /* GLUT_CURSOR_DESTROY */ 27 XC_question_arrow, /* GLUT_CURSOR_HELP */ 28 XC_exchange, /* GLUT_CURSOR_CYCLE */ 29 XC_spraycan, /* GLUT_CURSOR_SPRAY */ 30 XC_watch, /* GLUT_CURSOR_WAIT */ 31 XC_xterm, /* GLUT_CURSOR_TEXT */ 32 XC_crosshair, /* GLUT_CURSOR_CROSSHAIR */ 33 XC_sb_v_double_arrow, /* GLUT_CURSOR_UP_DOWN */ 34 XC_sb_h_double_arrow, /* GLUT_CURSOR_LEFT_RIGHT */ 35 XC_top_side, /* GLUT_CURSOR_TOP_SIDE */ 36 XC_bottom_side, /* GLUT_CURSOR_BOTTOM_SIDE */ 37 XC_left_side, /* GLUT_CURSOR_LEFT_SIDE */ 38 XC_right_side, /* GLUT_CURSOR_RIGHT_SIDE */ 39 XC_top_left_corner, /* GLUT_CURSOR_TOP_LEFT_CORNER */ 40 XC_top_right_corner, /* GLUT_CURSOR_TOP_RIGHT_CORNER */ 41 XC_bottom_right_corner, /* GLUT_CURSOR_BOTTOM_RIGHT_CORNER */ 42 XC_bottom_left_corner, /* GLUT_CURSOR_BOTTOM_LEFT_CORNER */ 43 }; 44 45 /*********************************************************** 46 * FUNCTION: glutSetCursor (4.13) 47 * 48 * DESCRIPTION: set a new mouse cursor for current window 49 ***********************************************************/ 50 void glutSetCursor(int cursor) { 51 gState.currentWindow->Window()->Lock(); 52 gState.currentWindow->cursor = cursor; 53 __glutSetCursor(cursor); 54 gState.currentWindow->Window()->Unlock(); 55 } 56 57 /*********************************************************** 58 * FUNCTION: __glutSetCursor 59 * 60 * DESCRIPTION: the actual cursor changing routine 61 ***********************************************************/ 62 void __glutSetCursor(int cursor) { 63 int realcursor = cursor; 64 if (cursor < 0 || cursor > GLUT_CURSOR_BOTTOM_LEFT_CORNER) { 65 switch(cursor) { 66 case GLUT_CURSOR_INHERIT: 67 return; // don't change cursor 68 case GLUT_CURSOR_NONE: 69 // this hides the cursor until the user moves the mouse 70 // change it to HideCursor() AT YOUR OWN RISK! 71 be_app->ObscureCursor(); 72 return; 73 case GLUT_CURSOR_FULL_CROSSHAIR: 74 realcursor = GLUT_CURSOR_CROSSHAIR; 75 break; 76 default: 77 __glutWarning("unknown cursor\n"); 78 return; 79 } 80 } 81 be_app->SetCursor(cursorTable[realcursor]); 82 } 83 84 /*********************************************************** 85 * FUNCTION: glutWarpPointer (x.xx) 86 * 87 * DESCRIPTION: move the mouse pointer to a new location 88 * (note: can't do this in BeOS!) 89 ***********************************************************/ 90 void glutWarpPointer(int x, int y) { } 91