예제 #1
0
    def setPosSize(self, posSize, animate=True):
        """
        Set the position and size of the window.

        **posSize** A tuple of form *(left, top, width, height)*.
        """
        titlebarHeight = self._calculateTitlebarHeight()
        l, t, w, h = posSize
        t -= titlebarHeight
        h += titlebarHeight
        screenFrame = self._window.screen().visibleFrame()
        # if the top is less than zero, force it to zero.
        # otherwise the window will be thrown to the bottom
        # of the screen.
        if t < 0:
            t = 0
            # the screen frame could have a bottom
            # value that is not zero. this will cause
            # an error if (and only if) a window is
            # being positioned at the top of the screen.
            # so, asjust it.
            (sL, sB), (sW, sH) = screenFrame
            screenFrame = ((sL, 0), (sW, sH + sB))
        frame = _calcFrame(screenFrame, ((l, t), (w, h)), absolutePositioning=True)
        self._window.setFrame_display_animate_(frame, True, animate)
예제 #2
0
 def __init__(self, posSize, title="", minSize=None, maxSize=None, textured=False,
             autosaveName=None, closable=True, miniaturizable=True, initiallyVisible=True, screen=None):
     mask = self.nsWindowStyleMask
     if closable:
         mask = mask | NSClosableWindowMask
     if miniaturizable:
         mask = mask | NSMiniaturizableWindowMask
     if minSize or maxSize:
         mask = mask | NSResizableWindowMask
     if textured:
         mask = mask | NSTexturedBackgroundWindowMask
     # start the window
     ## too magical?
     if len(posSize) == 2:
         l = t = 100
         w, h = posSize
         cascade = True
     else:
         l, t, w, h = posSize
         cascade = False
     if screen is None:
         screen = NSScreen.mainScreen()
     frame = _calcFrame(screen.visibleFrame(), ((l, t), (w, h)))
     self._window = self.nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_screen_(
         frame, mask, NSBackingStoreBuffered, False, screen)
     if autosaveName is not None:
         # This also sets the window frame if it was previously stored.
         # Make sure we do this before cascading.
         self._window.setFrameAutosaveName_(autosaveName)
     if cascade:
         self._cascade()
     #
     if minSize is not None:
         self._window.setMinSize_(minSize)
     if maxSize is not None:
         self._window.setMaxSize_(maxSize)
     self._window.setTitle_(title)
     self._window.setLevel_(self.nsWindowLevel)
     self._window.setReleasedWhenClosed_(False)
     self._window.setDelegate_(self)
     self._bindings = {}
     self._initiallyVisible = initiallyVisible
예제 #3
0
 def __init__(self, posSize, title="", minSize=None, maxSize=None, textured=False,
             autosaveName=None, closable=True, miniaturizable=True, initiallyVisible=True, screen=None):
     mask = self.nsWindowStyleMask
     if closable:
         mask = mask | NSClosableWindowMask
     if miniaturizable:
         mask = mask | NSMiniaturizableWindowMask
     if minSize or maxSize:
         mask = mask | NSResizableWindowMask
     if textured:
         mask = mask | NSTexturedBackgroundWindowMask
     # start the window
     ## too magical?
     if len(posSize) == 2:
         l = t = 100
         w, h = posSize
         cascade = True
     else:
         l, t, w, h = posSize
         cascade = False
     if screen is None:
         screen = NSScreen.mainScreen()
     frame = _calcFrame(screen.visibleFrame(), ((l, t), (w, h)))
     self._window = self.nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_screen_(
         frame, mask, NSBackingStoreBuffered, False, screen)
     if autosaveName is not None:
         # This also sets the window frame if it was previously stored.
         # Make sure we do this before cascading.
         self._window.setFrameAutosaveName_(autosaveName)
     if cascade:
         self._cascade()
     #
     if minSize is not None:
         self._window.setMinSize_(minSize)
     if maxSize is not None:
         self._window.setMaxSize_(maxSize)
     self._window.setTitle_(title)
     self._window.setLevel_(self.nsWindowLevel)
     self._window.setReleasedWhenClosed_(False)
     self._window.setDelegate_(self)
     self._bindings = {}
     self._initiallyVisible = initiallyVisible
예제 #4
0
 def __init__(self, posSize, title="", minSize=None, maxSize=None, textured=False,
             autosaveName=None, closable=True, miniaturizable=True, initiallyVisible=True,
             fullScreenMode=None, screen=None):
     mask = self.nsWindowStyleMask
     if closable:
         mask = mask | NSClosableWindowMask
     if miniaturizable:
         mask = mask | NSMiniaturizableWindowMask
     if minSize or maxSize:
         mask = mask | NSResizableWindowMask
     if textured:
         mask = mask | NSTexturedBackgroundWindowMask
     # start the window
     ## too magical?
     if len(posSize) == 2:
         l = t = 100
         w, h = posSize
         cascade = True
     else:
         l, t, w, h = posSize
         cascade = False
     if screen is None:
         screen = NSScreen.mainScreen()
     frame = _calcFrame(screen.visibleFrame(), ((l, t), (w, h)))
     self._window = self.nsWindowClass.alloc().initWithContentRect_styleMask_backing_defer_screen_(
         frame, mask, NSBackingStoreBuffered, False, screen)
     if autosaveName is not None:
         # This also sets the window frame if it was previously stored.
         # Make sure we do this before cascading.
         self._window.setFrameAutosaveName_(autosaveName)
     if cascade:
         self._cascade()
     # set the full screen mode.
     # this is only available 10.7+, so see if it is possible
     # before going to far
     try:
         self._window.setCollectionBehavior_
         # okay, we're >= 10.7
         if fullScreenMode is None:
             pass
         elif fullScreenMode == "primary":
             try:
                 NSWindowCollectionBehaviorFullScreenPrimary
             except NameError:
                 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7
             self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenPrimary)
         elif fullScreenMode == "auxiliary":
             try:
                 NSWindowCollectionBehaviorFullScreenAuxiliary
             except NameError:
                 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
             self._window.setCollectionBehavior_(NSWindowCollectionBehaviorFullScreenAuxiliary)
     except AttributeError:
         pass
     #
     if minSize is not None:
         self._window.setMinSize_(minSize)
     if maxSize is not None:
         self._window.setMaxSize_(maxSize)
     self._window.setTitle_(title)
     self._window.setLevel_(self.nsWindowLevel)
     self._window.setReleasedWhenClosed_(False)
     self._window.setDelegate_(self)
     self._bindings = {}
     self._initiallyVisible = initiallyVisible