svn update: 48958 (latest:48959)
[framework/uifw/ecore.git] / src / lib / ecore_win32 / ecore_win32_cursor.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #define WIN32_LEAN_AND_MEAN
10 #include <windows.h>
11 #undef WIN32_LEAN_AND_MEAN
12
13 #include <Eina.h>
14
15 #include "Ecore_Win32.h"
16 #include "ecore_win32_private.h"
17
18
19 /***** API *****/
20
21 Ecore_Win32_Cursor *
22 ecore_win32_cursor_new(const void *pixels_and,
23                        const void *pixels_xor,
24                        int         width,
25                        int         height,
26                        int         hot_x,
27                        int         hot_y)
28 {
29    Ecore_Win32_Cursor *cursor = NULL;
30    int                 cursor_width;
31    int                 cursor_height;
32
33    INF("creating cursor");
34
35    cursor_width = GetSystemMetrics(SM_CXCURSOR);
36    cursor_height = GetSystemMetrics(SM_CYCURSOR);
37
38    if ((cursor_width != width) ||
39        (cursor_height != height))
40      return NULL;
41
42    if (!(cursor = CreateCursor(_ecore_win32_instance,
43                                hot_x, hot_y,
44                                width, height,
45                                pixels_and,
46                                pixels_xor)))
47      return NULL;
48
49    return cursor;
50 }
51
52 void
53 ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
54 {
55    INF("destroying cursor");
56
57    DestroyCursor(cursor);
58 }
59
60 Ecore_Win32_Cursor *
61 ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape)
62 {
63    Ecore_Win32_Cursor *cursor = NULL;
64    const char         *cursor_name;
65
66    INF("geting shape cursor");
67
68    switch (shape)
69      {
70        case ECORE_WIN32_CURSOR_SHAPE_APP_STARTING:
71          cursor_name = IDC_APPSTARTING;
72          break;
73        case ECORE_WIN32_CURSOR_SHAPE_ARROW:
74          cursor_name = IDC_ARROW;
75          break;
76        case ECORE_WIN32_CURSOR_SHAPE_CROSS:
77          cursor_name = IDC_CROSS;
78          break;
79        case ECORE_WIN32_CURSOR_SHAPE_HAND:
80          cursor_name = IDC_HAND;
81          break;
82        case ECORE_WIN32_CURSOR_SHAPE_HELP:
83          cursor_name = IDC_HELP;
84          break;
85        case ECORE_WIN32_CURSOR_SHAPE_I_BEAM:
86          cursor_name = IDC_IBEAM;
87          break;
88        case ECORE_WIN32_CURSOR_SHAPE_NO:
89          cursor_name = IDC_NO;
90          break;
91        case ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL:
92          cursor_name = IDC_SIZEALL;
93          break;
94        case ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW:
95          cursor_name = IDC_SIZENESW;
96          break;
97        case ECORE_WIN32_CURSOR_SHAPE_SIZE_NS:
98          cursor_name = IDC_SIZENS;
99          break;
100        case ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE:
101          cursor_name = IDC_SIZENWSE;
102          break;
103        case ECORE_WIN32_CURSOR_SHAPE_SIZE_WE:
104          cursor_name = IDC_SIZEWE;
105          break;
106        case ECORE_WIN32_CURSOR_SHAPE_UP_ARROW:
107          cursor_name = IDC_UPARROW;
108          break;
109        case ECORE_WIN32_CURSOR_SHAPE_WAIT:
110          cursor_name = IDC_WAIT;
111          break;
112      default:
113          return NULL;
114      }
115
116    if (!(cursor = LoadCursor(NULL, cursor_name)))
117      return NULL;
118
119    return cursor;
120 }
121
122 int
123 ecore_win32_cursor_size_get(void)
124 {
125    int width;
126    int height;
127
128    INF("geting size cursor");
129
130    width = GetSystemMetrics(SM_CXCURSOR);
131    height = GetSystemMetrics(SM_CYCURSOR);
132    return (width > height) ? width : height;
133 }