2 * freeglut_cursor_mswin.c
\r
4 * The Windows-specific mouse cursor related stuff.
\r
6 * Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
\r
7 * Written by John F. Fay, <fayjf@sourceforge.net>
\r
8 * Creation date: Thu Jan 19, 2012
\r
10 * Permission is hereby granted, free of charge, to any person obtaining a
\r
11 * copy of this software and associated documentation files (the "Software"),
\r
12 * to deal in the Software without restriction, including without limitation
\r
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
\r
14 * and/or sell copies of the Software, and to permit persons to whom the
\r
15 * Software is furnished to do so, subject to the following conditions:
\r
17 * The above copyright notice and this permission notice shall be included
\r
18 * in all copies or substantial portions of the Software.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
\r
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
\r
23 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
24 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
28 #include <GL/freeglut.h>
\r
29 #include "freeglut_internal_mswin.h"
\r
33 void fgPlatformSetCursor ( SFG_Window *window, int cursorID )
\r
36 * Joe Krahn is re-writing the following code.
\r
38 /* Set the cursor AND change it for this window class. */
\r
39 #if !defined(__MINGW64__) && _MSC_VER <= 1200
\r
40 # define MAP_CURSOR(a,b) \
\r
42 SetCursor( LoadCursor( NULL, b ) ); \
\r
43 SetClassLong( window->Window.Handle, \
\r
45 ( LONG )LoadCursor( NULL, b ) ); \
\r
47 /* Nuke the cursor AND change it for this window class. */
\r
48 # define ZAP_CURSOR(a,b) \
\r
50 SetCursor( NULL ); \
\r
51 SetClassLong( window->Window.Handle, \
\r
52 GCL_HCURSOR, ( LONG )NULL ); \
\r
55 # define MAP_CURSOR(a,b) \
\r
57 SetCursor( LoadCursor( NULL, b ) ); \
\r
58 SetClassLongPtr( window->Window.Handle, \
\r
60 ( LONG )( LONG_PTR )LoadCursor( NULL, b ) ); \
\r
62 /* Nuke the cursor AND change it for this window class. */
\r
63 # define ZAP_CURSOR(a,b) \
\r
65 SetCursor( NULL ); \
\r
66 SetClassLongPtr( window->Window.Handle, \
\r
67 GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL ); \
\r
73 MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
\r
74 MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
\r
75 MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
\r
76 MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
\r
77 MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
\r
78 MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
\r
79 MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
\r
80 MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
\r
81 MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_IBEAM );
\r
82 MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
\r
83 MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_SIZENS );
\r
84 MAP_CURSOR( GLUT_CURSOR_LEFT_RIGHT, IDC_SIZEWE );
\r
85 MAP_CURSOR( GLUT_CURSOR_TOP_SIDE, IDC_ARROW ); /* XXX ToDo */
\r
86 MAP_CURSOR( GLUT_CURSOR_BOTTOM_SIDE, IDC_ARROW ); /* XXX ToDo */
\r
87 MAP_CURSOR( GLUT_CURSOR_LEFT_SIDE, IDC_ARROW ); /* XXX ToDo */
\r
88 MAP_CURSOR( GLUT_CURSOR_RIGHT_SIDE, IDC_ARROW ); /* XXX ToDo */
\r
89 MAP_CURSOR( GLUT_CURSOR_TOP_LEFT_CORNER, IDC_SIZENWSE );
\r
90 MAP_CURSOR( GLUT_CURSOR_TOP_RIGHT_CORNER, IDC_SIZENESW );
\r
91 MAP_CURSOR( GLUT_CURSOR_BOTTOM_RIGHT_CORNER, IDC_SIZENWSE );
\r
92 MAP_CURSOR( GLUT_CURSOR_BOTTOM_LEFT_CORNER, IDC_SIZENESW );
\r
93 MAP_CURSOR( GLUT_CURSOR_INHERIT, IDC_ARROW ); /* XXX ToDo */
\r
94 ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
\r
95 MAP_CURSOR( GLUT_CURSOR_FULL_CROSSHAIR, IDC_CROSS ); /* XXX ToDo */
\r
98 fgError( "Unknown cursor type: %d", cursorID );
\r
104 void fgPlatformWarpPointer ( int x, int y )
\r
110 /* ClientToScreen() translates {coords} for us. */
\r
111 ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords );
\r
112 SetCursorPos( coords.x, coords.y );
\r