コード例 #1
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
    def saveCursorPos(self):
        if (not self.windowID) or (self.windowID != getFocalWindowID()):
            return
        if _has_aqutil:
            scrnPosDict = aqutil.getPointerGlobalPosition()
            self.lastScreenX = scrnPosDict['x']
            self.lastScreenY = scrnPosDict['y']
            return
        if not WUTIL_USING_X:
            return # some of the following xutil methods are undefined

        # This also won't work on a Mac if running from the Terminal app
        # but it WILL work on a Mac from an X11 xterm window
        if WUTIL_USING_X and WUTIL_ON_MAC and self.windowID < 2:
            return

        posdict = getPointerPosition(self.windowID)
        if posdict:
            x = posdict['win_x']
            y = posdict['win_y']
        else:
            return
        windict = getWindowAttributes(self.windowID)
        if windict and windict['width'] > 0:
            maxX = windict['width']
            maxY = windict['height']
        else:
            return
        # do nothing if position out of window
        if x < 0 or y < 0 or x >= maxX or y >= maxY:
            return
        self.lastX = x
        self.lastY = y
コード例 #2
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
    def saveCursorPos(self):
        if (not self.windowID) or (self.windowID != getFocalWindowID()):
            return
        if _has_aqutil:
            scrnPosDict = aqutil.getPointerGlobalPosition()
            self.lastScreenX = scrnPosDict['x']
            self.lastScreenY = scrnPosDict['y']
            return
        if not WUTIL_USING_X:
            return  # some of the following xutil methods are undefined

        # This also won't work on a Mac if running from the Terminal app
        # but it WILL work on a Mac from an X11 xterm window
        if WUTIL_USING_X and WUTIL_ON_MAC and self.windowID < 2:
            return

        posdict = getPointerPosition(self.windowID)
        if posdict:
            x = posdict['win_x']
            y = posdict['win_y']
        else:
            return
        windict = getWindowAttributes(self.windowID)
        if windict and windict['width'] > 0:
            maxX = windict['width']
            maxY = windict['height']
        else:
            return
        # do nothing if position out of window
        if x < 0 or y < 0 or x >= maxX or y >= maxY:
            return
        self.lastX = x
        self.lastY = y
コード例 #3
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
    def restoreLast(self):

        if not self.hasGraphics:
            return
        if len(self.focusStack) > 1:
            # update current position if we're in the correct window
            current = self.focusStack.pop()
            if current.getWindowID() == getFocalWindowID():
                current.saveCursorPos()
        if self.focusInFamily():
            self.focusStack[-1].forceFocus()
コード例 #4
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
    def restoreLast(self):

        if not self.hasGraphics:
            return
        if len(self.focusStack) > 1:
            # update current position if we're in the correct window
            current = self.focusStack.pop()
            if current.getWindowID() == getFocalWindowID():
                current.saveCursorPos()
        if self.focusInFamily():
            self.focusStack[-1].forceFocus()
コード例 #5
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
 def getCurrentFocusEntity(self):
     """Return the focus entity that currently has focus.
     Return None if focus is not in the focus family"""
     if not self.hasGraphics:
         return None, None
     currentFocusWinID = getFocalWindowID()
     currentTopID = getTopID(currentFocusWinID)
     for name, focusEntity in self.focusEntities.items():
         if getTopID(focusEntity.getWindowID()) == currentTopID:
             return name, focusEntity
     else:
         return None, None
コード例 #6
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
    def getCurrentFocusEntity(self):

        """Return the focus entity that currently has focus.
        Return None if focus is not in the focus family"""
        if not self.hasGraphics:
            return None, None
        currentFocusWinID = getFocalWindowID()
        currentTopID = getTopID(currentFocusWinID)
        for name,focusEntity in self.focusEntities.items():
            if getTopID(focusEntity.getWindowID()) == currentTopID:
                return name, focusEntity
        else:
            return None, None
コード例 #7
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
 def focusInFamily(self):
     """Determine if current focus is within the pyraf family
     (as defined by self.focusEntities)"""
     if not self.hasGraphics:
         return 0
     currentFocusWinID = getFocalWindowID()
     currentTopID = getTopID(currentFocusWinID)
     for focusEntity in self.focusEntities.values():
         fwid = focusEntity.getWindowID()
         if fwid:
             if getTopID(fwid) == currentTopID:
                 return 1
     return 0  # not in family
コード例 #8
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
    def focusInFamily(self):

        """Determine if current focus is within the pyraf family
        (as defined by self.focusEntities)"""
        if not self.hasGraphics:
            return 0
        currentFocusWinID = getFocalWindowID()
        currentTopID = getTopID(currentFocusWinID)
        for focusEntity in self.focusEntities.values():
            fwid = focusEntity.getWindowID()
            if fwid:
                if getTopID(fwid) == currentTopID:
                    return 1
        return 0  # not in family
コード例 #9
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
 def __init__(self):
     """IMPORTANT: This class must be instantiated while focus
     is in the terminal window"""
     self.lastScreenX = None
     self.lastScreenY = None
     try:
         self.windowID = getFocalWindowID()
         if self.windowID == -1:
             self.windowID = None
         if _has_aqutil:
             scrnPosDict = aqutil.getPointerGlobalPosition()
             self.lastScreenX = scrnPosDict['x']
             self.lastScreenY = scrnPosDict['y']
     except EnvironmentError, e:
         self.windowID = None
コード例 #10
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
 def __init__(self):
     """IMPORTANT: This class must be instantiated while focus
     is in the terminal window"""
     self.lastScreenX = None
     self.lastScreenY = None
     try:
         self.windowID = getFocalWindowID()
         if self.windowID == -1:
             self.windowID = None
         if _has_aqutil:
             scrnPosDict = aqutil.getPointerGlobalPosition()
             self.lastScreenX = scrnPosDict['x']
             self.lastScreenY = scrnPosDict['y']
     except EnvironmentError, e:
         self.windowID = None
コード例 #11
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
 def forceFocus(self, cursorToo=True):
     if WUTIL_ON_MAC and WUTIL_USING_X:
         return # X ver. under dev. on OSX...  (was broken anyway)
     if not (self.windowID and isViewable(self.windowID)):
         # no window or not viewable
         return
     if self.windowID == getFocalWindowID():
         # focus is already here
         return
     if _has_aqutil:
         if self.lastScreenX is not None and cursorToo:
             moveCursorTo(self.windowID, self.lastScreenX, self.lastScreenY,
                          0, 0)
     else: # WUTIL_USING_X
         if self.lastX is not None and cursorToo:
             moveCursorTo(self.windowID, 0, 0, self.lastX, self.lastY)
     if not GRAPHICS_ALWAYS_ON_TOP:
         setFocusTo(self.windowID)
コード例 #12
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
 def forceFocus(self, cursorToo=True):
     if WUTIL_ON_MAC and WUTIL_USING_X:
         return  # X ver. under dev. on OSX...  (was broken anyway)
     if not (self.windowID and isViewable(self.windowID)):
         # no window or not viewable
         return
     if self.windowID == getFocalWindowID():
         # focus is already here
         return
     if _has_aqutil:
         if self.lastScreenX is not None and cursorToo:
             moveCursorTo(self.windowID, self.lastScreenX, self.lastScreenY,
                          0, 0)
     else:  # WUTIL_USING_X
         if self.lastX is not None and cursorToo:
             moveCursorTo(self.windowID, 0, 0, self.lastX, self.lastY)
     if not GRAPHICS_ALWAYS_ON_TOP:
         setFocusTo(self.windowID)
コード例 #13
0
ファイル: wutil.py プロジェクト: spacetelescope/pyraf
 def updateWindowID(self, id=None):
     """Update terminal window ID (to current window if id is not given)"""
     if id is None:
         id = getFocalWindowID()
     self.windowID = id
コード例 #14
0
ファイル: wutil.py プロジェクト: rendinam/pyraf
 def updateWindowID(self, id=None):
     """Update terminal window ID (to current window if id is not given)"""
     if id is None:
         id = getFocalWindowID()
     self.windowID = id