add skeleton for variant type support
[pywinlite.git] / cursor.py
blob14879074351e7273b3eeb3b78195c5138784e471
1 #Copyright (c) 2008 Vincent Povirk
3 #Permission is hereby granted, free of charge, to any person
4 #obtaining a copy of this software and associated documentation
5 #files (the "Software"), to deal in the Software without
6 #restriction, including without limitation the rights to use,
7 #copy, modify, merge, publish, distribute, sublicense, and/or sell
8 #copies of the Software, and to permit persons to whom the
9 #Software is furnished to do so, subject to the following
10 #conditions:
12 #The above copyright notice and this permission notice shall be
13 #included in all copies or substantial portions of the Software.
15 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 #EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 #OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 #NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 #HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 #WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 #FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 #OTHER DEALINGS IN THE SOFTWARE.
24 # Cursor definitions
25 # see http://msdn.microsoft.com/en-us/library/ms646970(VS.85).aspx
27 from ctypes import windll, Structure, POINTER, sizeof, byref
28 from windef import LPRECT, HCURSOR, HINSTANCE, INT, LPVOID, RECT, DWORD, POINT, LPPOINT, LPCTSTR, BOOL, HICON
29 from winlitecfg import get_aw_symbols
30 from winliteutils import NONZERO
31 from resource import MAKEINTRESOURCE
32 _user32 = windll.user32
34 IDC_ARROW = MAKEINTRESOURCE(32512)
35 IDC_IBEAM = MAKEINTRESOURCE(32513)
36 IDC_WAIT = MAKEINTRESOURCE(32514)
37 IDC_CROSS = MAKEINTRESOURCE(32515)
38 IDC_UPARROW = MAKEINTRESOURCE(32516)
39 IDC_SIZE = MAKEINTRESOURCE(32640)
40 IDC_ICON = MAKEINTRESOURCE(32641)
41 IDC_SIZENWSE = MAKEINTRESOURCE(32642)
42 IDC_SIZENESW = MAKEINTRESOURCE(32643)
43 IDC_SIZEWE = MAKEINTRESOURCE(32644)
44 IDC_SIZENS = MAKEINTRESOURCE(32645)
45 IDC_SIZEALL = MAKEINTRESOURCE(32646)
46 IDC_NO = MAKEINTRESOURCE(32648)
47 IDC_HAND = MAKEINTRESOURCE(32649)
48 IDC_APPSTARTING = MAKEINTRESOURCE(32650)
49 IDC_HELP = MAKEINTRESOURCE(32651)
51 OCR_NORMAL = 32512
52 OCR_IBEAM = 32513
53 OCR_WAIT = 32514
54 OCR_CROSS = 32515
55 OCR_UP = 32516
56 OCR_SIZE = 32640
57 OCR_ICON = 32641
58 OCR_SIZENWSE = 32642
59 OCR_SIZENESW = 32643
60 OCR_SIZEWE = 32644
61 OCR_SIZENS = 32645
62 OCR_SIZEALL = 32646
63 OCR_ICOCUR = 32647
64 OCR_NO = 32648
65 OCR_HAND = 32649
66 OCR_APPSTARTING = 32650
67 OCR_HELP = 32651
69 OCR_DRAGOBJECT = 32653 #defined in wine's winuser.h
71 class CURSORINFO(Structure):
72 _fields_ = [
73 ('cbSize', DWORD),
74 ('flags', DWORD),
75 ('hCursor', HCURSOR),
76 ('ptScreenPos', POINT),
78 PCURSORINFO = LPCURSORINFO = POINTER(CURSORINFO)
80 get_aw_symbols(globals(), _user32, ['LoadCursor', 'LoadCursorFromFile'])
82 _user32.ClipCursor.argtypes = [LPRECT]
83 _user32.ClipCursor.restype = NONZERO
84 ClipCursor = _user32.ClipCursor
86 _user32.CopyIcon.argtypes = [HICON]
87 _user32.CopyIcon.restype = NONZERO
88 CopyCursor = _user32.CopyIcon
90 _user32.CreateCursor.argtypes = [HINSTANCE, INT, INT, INT, INT, LPVOID, LPVOID]
91 _user32.CreateCursor.restype = NONZERO
92 CreateCursor = _user32.CreateCursor
94 _user32.DestroyCursor.argtypes = [HCURSOR]
95 _user32.DestroyCursor.restype = NONZERO
96 DestroyCursor = _user32.DestroyCursor
98 _user32.GetClipCursor.argtypes = [LPRECT]
99 _user32.GetClipCursor.restype = NONZERO
100 def GetClipCursor():
101 result = RECT()
102 _user32.GetClipCursor(byref(result))
103 return result
105 _user32.GetCursor.argtypes = []
106 _user32.GetCursor.restype = HCURSOR
107 GetCursor = _user32.GetCursor
109 _user32.GetCursorInfo.argtypes = [PCURSORINFO]
110 _user32.GetCursorInfo.restype = NONZERO
111 def GetCursorInfo():
112 result = CURSORINFO()
113 result.cbSize = sizeof(result)
114 _user32.GetCursorInfo(byref(result))
115 return result
117 _user32.GetCursorPos.argtypes = [LPPOINT]
118 _user32.GetCursorPos.restype = NONZERO
119 def GetCursorPos():
120 result = POINT()
121 _user32.GetCursorPos(byref(result))
122 return result
124 LoadCursor.argtypes = [HINSTANCE, LPCTSTR]
125 LoadCursor.restype = NONZERO
127 LoadCursorFromFile.argtypes = [LPCTSTR]
128 LoadCursorFromFile.restype = NONZERO
130 _user32.SetCursor.argtypes = [HCURSOR]
131 _user32.SetCursor.restype = HCURSOR
132 SetCursor = _user32.SetCursor
134 _user32.SetCursorPos.argtypes = [INT, INT]
135 _user32.SetCursorPos.restype = NONZERO
136 SetCursorPos = _user32.SetCursorPos
138 _user32.SetSystemCursor.argtypes = [HCURSOR, DWORD]
139 _user32.SetSystemCursor.restype = NONZERO
140 SetSystemCursor = _user32.SetSystemCursor
142 _user32.ShowCursor.argtypes = [BOOL]
143 _user32.ShowCursor.restype = INT
144 ShowCursor = _user32.ShowCursor
146 # functions in Windows Vista
147 try:
148 _user32.GetPhysicalCursorPos.argtypes = [LPPOINT]
149 _user32.GetPhysicalCursorPos.restype = NONZERO
150 def GetPhysicalCursorPos():
151 result = POINT()
152 _user32.GetPhysicalCursorPos(byref(result))
153 return result
155 _user32.SetPhysicalCursorPos.argtypes = [INT, INT]
156 _user32.SetPhysicalCursorPos.restype = NONZERO
157 SetPhysicalCursorPos = _user32.SetPhysicalCursorPos
158 except AttributeError:
159 pass