Beispiel #1
0
 def _getPointFromOffset(self, offset):
     for nextWord in self._parser.words:
         if nextWord.offset > offset:
             break
         word = nextWord
     else:
         # No matching word, so use the top left of the object.
         return locationHelper.Point(int(self._parser.leftCoordOffset),
                                     int(self._parser.topCoordOffset))
     return locationHelper.Point(int(word.left), int(word.top))
Beispiel #2
0
 def _get_pointAtStart(self):
     p = locationHelper.Point(
         *self._rangeObj.GetPoint(comInterfaces.tom.tomStart))
     if p.x and p.y:
         return p
     else:
         raise NotImplementedError
Beispiel #3
0
	def _getPointFromOffset(self,offset):
		point=locationHelper.Point(
			watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_POINTXFROMPOSITION,None,offset),
			watchdog.cancellableSendMessage(self.obj.windowHandle,SCI_POINTYFROMPOSITION,None,offset)
		).toScreen(self.obj.windowHandle)
		if point.x is not None and point.y is not None:
			return point
		else:
			raise NotImplementedError
Beispiel #4
0
 def _getPointFromOffset(self, offset):
     if self.obj.editAPIVersion == 1 or self.obj.editAPIVersion >= 3:
         processHandle = self.obj.processHandle
         internalP = winKernel.virtualAllocEx(processHandle, None,
                                              ctypes.sizeof(PointLStruct),
                                              winKernel.MEM_COMMIT,
                                              winKernel.PAGE_READWRITE)
         try:
             p = PointLStruct(0, 0)
             winKernel.writeProcessMemory(processHandle, internalP,
                                          ctypes.byref(p), ctypes.sizeof(p),
                                          None)
             watchdog.cancellableSendMessage(self.obj.windowHandle,
                                             winUser.EM_POSFROMCHAR,
                                             internalP, offset)
             winKernel.readProcessMemory(processHandle, internalP,
                                         ctypes.byref(p), ctypes.sizeof(p),
                                         None)
         finally:
             winKernel.virtualFreeEx(processHandle, internalP, 0,
                                     winKernel.MEM_RELEASE)
         point = locationHelper.Point(p.x, p.y)
     else:
         res = watchdog.cancellableSendMessage(self.obj.windowHandle,
                                               winUser.EM_POSFROMCHAR,
                                               offset, None)
         point = locationHelper.Point(winUser.GET_X_LPARAM(res),
                                      winUser.GET_Y_LPARAM(res))
     # A returned coordinate can be a negative value if
     # the specified character is not displayed in the edit control's client area.
     # If the specified index is greater than the index of the last character in the control,
     # the control returns -1.
     if point.x < 0 or point.y < 0:
         raise LookupError(
             "Point with client coordinates x=%d, y=%d not within client area of object"
             % (point.x, point.y))
     try:
         return point.toScreen(self.obj.windowHandle)
     except WindowsError as e:
         raise LookupError(
             f"Couldn't convert point at offset {offset} to screen coordinates: {e.strerror}"
         )
Beispiel #5
0
	def _getPointFromOffset(self,offset):
		consoleScreenBufferInfo = self.consoleScreenBufferInfo
		characterX, characterY = self._consoleCoordFromOffset(offset)
		screenLeft, screenTop, screenWidth, screenHeight = self.obj.location
		lineLength = (consoleScreenBufferInfo.srWindow.Right + 1)- consoleScreenBufferInfo.srWindow.Left
		numLines = (consoleScreenBufferInfo.srWindow.Bottom + 1) - consoleScreenBufferInfo.srWindow.Top
		characterWidth = screenWidth // lineLength
		characterHeight = screenHeight // numLines
		relativeX = (characterX - consoleScreenBufferInfo.srWindow.Left) * characterWidth
		relativeY = (characterY - consoleScreenBufferInfo.srWindow.Top) * characterHeight
		x = relativeX + screenLeft
		y = relativeY + screenTop
		return locationHelper.Point(x,y)
Beispiel #6
0
 def moveTo(self, x, y, new=False, unit=textInfos.UNIT_LINE):
     obj = api.getDesktopObject().objectFromPoint(x, y)
     prevObj = None
     while obj and obj.beTransparentToMouse:
         prevObj = obj
         obj = obj.parent
     if not obj or (obj.presentationType != obj.presType_content
                    and obj.role != controlTypes.ROLE_PARAGRAPH):
         obj = prevObj
     if not obj:
         return
     hasNewObj = False
     if obj != self._obj:
         self._obj = obj
         hasNewObj = True
         if self.updateReview:
             api.setNavigatorObject(obj)
     else:
         obj = self._obj
     pos = None
     if obj.treeInterceptor:
         try:
             pos = obj.treeInterceptor.makeTextInfo(obj)
         except LookupError:
             pos = None
         if pos:
             obj = obj.treeInterceptor.rootNVDAObject
             if hasNewObj and self._obj and obj.treeInterceptor is self._obj.treeInterceptor:
                 hasNewObj = False
     if not pos:
         try:
             pos = obj.makeTextInfo(locationHelper.Point(x, y))
         except (NotImplementedError, LookupError):
             pass
         if pos: pos.expand(unit)
     if pos and self.updateReview:
         api.setReviewPosition(pos)
     speechCanceled = False
     if hasNewObj:
         speech.cancelSpeech()
         speechCanceled = True
         speech.speakObject(obj)
     if pos and (new or not self._pos
                 or pos.__class__ != self._pos.__class__
                 or pos.compareEndPoints(self._pos, "startToStart") != 0
                 or pos.compareEndPoints(self._pos, "endToEnd") != 0):
         self._pos = pos
         if not speechCanceled:
             speech.cancelSpeech()
         speech.speakTextInfo(pos, reason=controlTypes.OutputReason.CARET)
Beispiel #7
0
def getMouseRect() -> locationHelper.RectLTRB:
	point = locationHelper.Point(*mouseHandler.curMousePos)
	return locationHelper.RectLTRB.fromPoint(point)
Beispiel #8
0
	def _get_cellSize(self) -> locationHelper.Point:
		val = self._getUIACacheablePropertyValue(_UIAHandler.UIA_SizePropertyId, True)
		x = val[0]
		y = val[1]
		return locationHelper.Point(x, y)