Fixing the previous commit so we don't have a circular include. Under the new regime...
[freeglut] / src / mswin / freeglut_cursor_mswin.c
1 /*\r
2  * freeglut_cursor_mswin.c\r
3  *\r
4  * The Windows-specific mouse cursor related stuff.\r
5  *\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
9  *\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
16  *\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
19  *\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
26  */\r
27 \r
28 #include <GL/freeglut.h>\r
29 #include "../Common/freeglut_internal.h"\r
30 \r
31 \r
32 \r
33 void fgPlatformSetCursor ( SFG_Window *window, int cursorID )\r
34 {\r
35     /*\r
36      * Joe Krahn is re-writing the following code.\r
37      */\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
41         case a:                                                  \\r
42             SetCursor( LoadCursor( NULL, b ) );                  \\r
43             SetClassLong( window->Window.Handle,                 \\r
44                           GCL_HCURSOR,                           \\r
45                           ( LONG )LoadCursor( NULL, b ) );       \\r
46         break;\r
47     /* Nuke the cursor AND change it for this window class. */\r
48 #       define ZAP_CURSOR(a,b)                                   \\r
49         case a:                                                  \\r
50             SetCursor( NULL );                                   \\r
51             SetClassLong( window->Window.Handle,                 \\r
52                           GCL_HCURSOR, ( LONG )NULL );           \\r
53         break;\r
54 #else\r
55 #       define MAP_CURSOR(a,b)                                   \\r
56         case a:                                                  \\r
57             SetCursor( LoadCursor( NULL, b ) );                  \\r
58             SetClassLongPtr( window->Window.Handle,              \\r
59                           GCLP_HCURSOR,                          \\r
60                           ( LONG )( LONG_PTR )LoadCursor( NULL, b ) );       \\r
61         break;\r
62     /* Nuke the cursor AND change it for this window class. */\r
63 #       define ZAP_CURSOR(a,b)                                   \\r
64         case a:                                                  \\r
65             SetCursor( NULL );                                   \\r
66             SetClassLongPtr( window->Window.Handle,              \\r
67                           GCLP_HCURSOR, ( LONG )( LONG_PTR )NULL );          \\r
68         break;\r
69 #endif\r
70 \r
71     switch( cursorID )\r
72     {\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
96 \r
97     default:\r
98         fgError( "Unknown cursor type: %d", cursorID );\r
99         break;\r
100     }\r
101 }\r
102 \r
103 \r
104 void fgPlatformWarpPointer ( int x, int y )\r
105 {\r
106     POINT coords;\r
107     coords.x = x;\r
108     coords.y = y;\r
109 \r
110     /* ClientToScreen() translates {coords} for us. */\r
111     ClientToScreen( fgStructure.CurrentWindow->Window.Handle, &coords );\r
112     SetCursorPos( coords.x, coords.y );\r
113 }\r
114 \r
115 \r