[Nvda-dev] commit r1879 - in trunk: . source source/appModules

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Nvda-dev] commit r1879 - in trunk: . source source/appModules

NVDA Subversion
Author: jteh
Date: Thu Apr  3 08:16:31 2008
New Revision: 1879

Log:
Move the logic for retrieving the status bar object and its text into api.getStatusBarObject() and api.GetStatusBarText() so that they can be used elsewhere. The reportStatusLine script now uses these functions.

Modified:
   trunk/   (props changed)
   trunk/source/api.py
   trunk/source/appModules/_default.py

Modified: trunk/source/api.py
==============================================================================
--- trunk/source/api.py (original)
+++ trunk/source/api.py Thu Apr  3 08:16:31 2008
@@ -14,6 +14,7 @@
 import speech
 import virtualBufferHandler
 import NVDAObjects
+import NVDAObjects.IAccessible
 import winUser
 import wx
 import core
@@ -218,3 +219,34 @@
  if got == text:
  return True
  return False
+
+def getStatusBar():
+ """Obtain the status bar for the current foreground object.
+ @return: The status bar object or C{None} if no status bar was found.
+ @rtype: L{NVDAObjects.NVDAObject}
+ """
+ # The status bar is usually at the bottom of the screen.
+ # Therefore, get the object at the bottom left of the foreground object using screen coordinates.
+ foreground = getForegroundObject()
+ left, top, width, height = foreground.location
+ bottom = top + height - 1
+ obj = NVDAObjects.IAccessible.getNVDAObjectFromPoint(left, bottom)
+
+ # We may have landed in a child of the status bar, so search the ancestry for a status bar.
+ while obj and not obj.role == controlTypes.ROLE_STATUSBAR:
+ obj = obj.parent
+
+ return obj
+
+def getStatusBarText(obj):
+ """Get the text from a status bar.
+ This includes the name of the status bar and the names and values of all of its children.
+ @param obj: The status bar.
+ @type obj: L{NVDAObjects.NVDAObject}
+ @return: The status bar text.
+ @rtype: str
+ """
+ text = obj.name
+ if text is None:
+ text = ""
+ return text + " ".join(chunk for child in obj.children for chunk in (child.name, child.value) if chunk and isinstance(chunk, basestring) and not chunk.isspace())

Modified: trunk/source/appModules/_default.py
==============================================================================
--- trunk/source/appModules/_default.py (original)
+++ trunk/source/appModules/_default.py Thu Apr  3 08:16:31 2008
@@ -598,26 +598,11 @@
  script_reportCurrentFocus.__doc__ = _("reports the object with focus")
 
  def script_reportStatusLine(self,keyPress,nextScript):
- import NVDAObjects.IAccessible
- # The status bar is usually at the bottom of the screen.
- # Therefore, get the object at the bottom left of the foreground object using screen coordinates.
- foreground = api.getForegroundObject()
- left, top, width, height = foreground.location
- bottom = top + height - 1
- obj = NVDAObjects.IAccessible.getNVDAObjectFromPoint(left, bottom)
-
- # We may have landed in a child of the status bar, so search the ancestry for a status bar.
- while obj and not obj.role == controlTypes.ROLE_STATUSBAR:
- obj = obj.parent
-
+ obj = api.getStatusBar()
  if not obj:
  speech.speakMessage(_("no status bar found"))
  return
-
- text = obj.name
- if text is None:
- text = ""
- text += " ".join(chunk for child in obj.children for chunk in (child.name, child.value) if chunk and isinstance(chunk, basestring) and not chunk.isspace())
+ text = api.getStatusBarText(obj)
 
  if keyboardHandler.lastKeyCount == 1:
  speech.speakMessage(text)


Loading...