1
2
3
4
5
6
7 import time
8 from ctypes import *
9 from ctypes.wintypes import *
10 import oleacc
11 import controlTypes
12 import speech
13 import api
14 import eventHandler
15 import winKernel
16 import winUser
17 from . import IAccessible, List
18 from ..window import Window
19 import watchdog
20
21
22 LVM_FIRST=0x1000
23 LVM_GETITEMSTATE=LVM_FIRST+44
24 LVM_GETFOCUSEDGROUP=LVM_FIRST+93
25 LVM_GETGROUPINFOBYINDEX=LVM_FIRST+153
26 LVM_GETITEMCOUNT=LVM_FIRST+4
27 LVM_GETITEM=LVM_FIRST+75
28 LVN_GETDISPINFO=0xFFFFFF4F
29
30
31 LVIF_TEXT=0x01
32 LVIF_IMAGE=0x02
33 LVIF_PARAM=0x04
34 LVIF_STATE=0x08
35 LVIF_INDENT=0x10
36 LVIF_GROUPID=0x100
37 LVIF_COLUMNS=0x200
38
39
40 LVGF_HEADER=0x1
41 LVGF_FOOTER=0x2
42 LVGF_STATE=0x4
43 LVGF_ALIGN=0x8
44 LVGF_GROUPID=0x10
45
46
47 LVIS_FOCUSED=0x01
48 LVIS_SELECTED=0x02
49 LVIS_STATEIMAGEMASK=0xF000
50
51 LVS_OWNERDRAWFIXED=0x0400
52
54 _fields_=[
55 ('cbSize',c_uint),
56 ('mask',c_uint),
57 ('pszHeader',c_void_p),
58 ('cchHeader',c_int),
59 ('pszFooter',c_void_p),
60 ('cchFooter',c_int),
61 ('iGroupId',c_int),
62 ('stateMask',c_uint),
63 ('state',c_uint),
64 ('uAlign',c_uint),
65 ('pszSubtitle',c_void_p),
66 ('cchSubtitle',c_uint),
67 ('pszTask',c_void_p),
68 ('cchTask',c_uint),
69 ('pszDescriptionTop',c_void_p),
70 ('cchDescriptionTop',c_uint),
71 ('pszDescriptionBottom',c_void_p),
72 ('cchDescriptionBottom',c_uint),
73 ('iTitleImage',c_int),
74 ('iExtendedImage',c_int),
75 ('iFirstItem',c_int),
76 ('cItems',c_uint),
77 ('pszSubsetTitle',c_void_p),
78 ('cchSubsetTitle',c_uint),
79 ]
80
82 _fields_=[
83 ('mask',c_uint),
84 ('iItem',c_int),
85 ('iSubItem',c_int),
86 ('state',c_uint),
87 ('stateMask',c_uint),
88 ('text',LPWSTR),
89 ('cchTextMax',c_int),
90 ('iImage',c_int),
91 ('lParam',LPARAM),
92 ('iIndent',c_int),
93 ('iGroupID',c_int),
94 ('cColumns',c_uint),
95 ('puColumns',c_uint),
96 ('piColFmt',POINTER(c_int)),
97 ('iGroup',c_int),
98 ]
99
105
107 processHandle=oleacc.GetProcessHandleFromHwnd(windowHandle)
108 if not processHandle:
109 return None
110 localInfo=LVGROUP()
111 localInfo.cbSize=sizeof(LVGROUP)
112 localInfo.mask=LVGF_HEADER|LVGF_FOOTER|LVGF_STATE|LVGF_ALIGN|LVGF_GROUPID
113 localInfo.stateMask=0xffffffff
114 remoteInfo=winKernel.virtualAllocEx(processHandle,None,sizeof(LVGROUP),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
115 try:
116 winKernel.writeProcessMemory(processHandle,remoteInfo,byref(localInfo),sizeof(LVGROUP),None)
117 messageRes=watchdog.cancellableSendMessage(windowHandle,LVM_GETGROUPINFOBYINDEX,groupIndex,remoteInfo)
118 winKernel.readProcessMemory(processHandle,remoteInfo,byref(localInfo),sizeof(LVGROUP),None)
119 finally:
120 winKernel.virtualFreeEx(processHandle,remoteInfo,0,winKernel.MEM_RELEASE)
121 localHeader=create_unicode_buffer(localInfo.cchHeader)
122 winKernel.readProcessMemory(processHandle,localInfo.pszHeader,localHeader,localInfo.cchHeader*2,None)
123 localFooter=create_unicode_buffer(localInfo.cchFooter)
124 winKernel.readProcessMemory(processHandle,localInfo.pszFooter,localFooter,localInfo.cchFooter*2,None)
125 winKernel.closeHandle(processHandle)
126 if messageRes==1:
127 return dict(header=localHeader.value,footer=localFooter.value,groupID=localInfo.iGroupId,state=localInfo.state,uAlign=localInfo.uAlign,groupIndex=groupIndex)
128 else:
129 return None
130
153
155
156 - def __init__(self,windowHandle=None,parentNVDAObject=None,groupInfo=None):
157 super(GroupingItem,self).__init__(windowHandle=windowHandle)
158 self.parent=parentNVDAObject
159 self.groupInfo=groupInfo
160
162 return isinstance(other,self.__class__) and self.groupInfo==other.groupInfo
163
165 self._groupInfoTime=time.time()
166 self._groupInfo=info
167
169 now=time.time()
170 if (now-self._groupInfoTime)>0.25:
171 self._groupInfoTime=now
172 self._groupInfo=getListGroupInfo(self.windowHandle,self._groupInfo['groupIndex'])
173 return self._groupInfo
174
176 return self.groupInfo['header']
177
180
182 return self.groupInfo['footer']
183
191
195
197 for gesture in ("kb:leftArrow", "kb:rightArrow"):
198 self.bindGesture(gesture, "collapseOrExpand")
199
201
203 item=LVItemStruct(iItem=self.IAccessibleChildID-1,mask=LVIF_IMAGE)
204 processHandle=self.processHandle
205 internalItem=winKernel.virtualAllocEx(processHandle,None,sizeof(LVItemStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
206 try:
207 winKernel.writeProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
208 watchdog.cancellableSendMessage(self.windowHandle,LVM_GETITEM,0,internalItem)
209 dispInfo=NMLVDispInfoStruct()
210 dispInfo.item=internalItem
211 dispInfo.hdr.hwndFrom=self.windowHandle
212 dispInfo.hdr.idFrom=self.windowControlID
213 dispInfo.hdr.code=LVN_GETDISPINFO
214 internalDispInfo=winKernel.virtualAllocEx(processHandle,None,sizeof(NMLVDispInfoStruct),winKernel.MEM_COMMIT,winKernel.PAGE_READWRITE)
215 try:
216 winKernel.writeProcessMemory(processHandle,internalDispInfo,byref(dispInfo),sizeof(NMLVDispInfoStruct),None)
217 watchdog.cancellableSendMessage(self.parent.parent.windowHandle,winUser.WM_NOTIFY,LVN_GETDISPINFO,internalDispInfo)
218 finally:
219 winKernel.virtualFreeEx(processHandle,internalDispInfo,0,winKernel.MEM_RELEASE)
220 winKernel.readProcessMemory(processHandle,internalItem,byref(item),sizeof(LVItemStruct),None)
221 finally:
222 winKernel.virtualFreeEx(processHandle,internalItem,0,winKernel.MEM_RELEASE)
223 return item.iImage
224
227
238
243
247