-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cursor.cpp
77 lines (67 loc) · 2.06 KB
/
Cursor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "StandardCursor.hpp"
#ifdef SFML_SYSTEM_WINDOWS
sf::StandardCursor::StandardCursor(const sf::StandardCursor::TYPE t)
{
switch (t)
{
case sf::StandardCursor::WAIT:
Cursor = LoadCursor(NULL, IDC_WAIT);
break;
case sf::StandardCursor::HAND:
Cursor = LoadCursor(NULL, IDC_HAND);
break;
case sf::StandardCursor::NORMAL:
Cursor = LoadCursor(NULL, IDC_ARROW);
break;
case sf::StandardCursor::TEXT:
Cursor = LoadCursor(NULL, IDC_IBEAM);
break;
//For more cursor options on Windows go here:
// http://msdn.microsoft.com/en-us/library/ms648391%28v=vs.85%29.aspx
}
}
void sf::StandardCursor::set(const sf::WindowHandle& aWindowHandle) const
{
SetClassLongPtr(aWindowHandle, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(Cursor));
}
sf::StandardCursor::~StandardCursor()
{
// Nothing to do for destructor :
// no memory has been allocated (shared ressource principle)
}
#elif defined(SFML_SYSTEM_LINUX)
sf::StandardCursor::StandardCursor(const sf::StandardCursor::TYPE t)
{
display = XOpenDisplay(NULL);
switch (t)
{
case sf::StandardCursor::WAIT:
Cursor = XCreateFontCursor(display, XC_watch);
break;
case sf::StandardCursor::HAND:
Cursor = XCreateFontCursor(display, XC_hand1);
break;
case sf::StandardCursor::NORMAL:
Cursor = XCreateFontCursor(display, XC_left_ptr);
break;
case sf::StandardCursor::TEXT:
Cursor = XCreateFontCursor(display, XC_xterm);
break;
// For more cursor options on Linux go here:
// http://www.tronche.com/gui/x/xlib/appendix/b/
}
}
void sf::StandardCursor::set(const sf::WindowHandle& aWindowHandle) const
{
XDefineCursor(display, aWindowHandle, Cursor);
XFlush(display);
}
sf::StandardCursor::~StandardCursor()
{
XFreeCursor(display, Cursor);
delete display;
display = NULL;
}
#else
#error This OS is not yet supported by the cursor library.
#endif