Ejemplo n.º 1
0
"""'echo' -- an AppleEvent handler which handles all events the same.
Ejemplo n.º 2
0
 def _dooneevent(self, mask=highLevelEventMask, timeout=1 * 60):
     got, event = Evt.WaitNextEvent(mask, timeout)
     if got:
         self._lowlevelhandler(event)
Ejemplo n.º 3
0
 def __ensure_WMAvailable(klass):
     if klass.__eventloop_initialized:
         return 1
     if not MacOS.WMAvailable():
         return 0
     Evt.WaitNextEvent(0, 0)
Ejemplo n.º 4
0
 def dooneevent(self, mask=everyEvent, timeout=60 * 60):
     got, event = Evt.WaitNextEvent(mask, timeout)
     if got:
         self.lowlevelhandler(event)
Ejemplo n.º 5
0
 x0, y0, x1, y1 = self.rect
 if lurf == 4:
     # Adapt pinning rectangle for middle lurf
     # XXXX This is wrong
     rx0, ry0, rx1, ry1 = self.ourrect
     ##             w = (rx1-rx0)/2
     ##             h = (ry1-ry0)/2
     ##             x0 = x0 + w
     ##             x1 = x1 - w
     ##             y0 = y0 + h
     ##             y1 = y1 - h
     x0 = x - (rx0 - x0)
     x1 = x + (x1 - rx1)
     y0 = y - (ry0 - y0)
     y1 = y + (y1 - ry1)
 while Evt.WaitMouseUp():
     newx, newy = Evt.GetMouse()
     # Pin the mouse to our rectangle
     if newx < x0: newx = x0
     if newx > x1: newx = x1
     if newy < y0: newy = y0
     if newy > y1: newy = y1
     deltax = newx - x
     deltay = newy - y
     x = newx
     y = newy
     if deltax or deltay:
         # Something has changed. Recompute and redraw
         self.drawourrect()
         rx0, ry0, rx1, ry1 = self.ourrect
         if lurf in (0, 3, 4, 6):
Ejemplo n.º 6
0
class _AreaWidget(_ControlWidget, _ImageMixin):
    def __init__(self, dlg, item, callback=None, scaleitem=None):
        self.dlg = dlg
        self.wid = dlg.GetDialogWindow()
        self.scaleitem = scaleitem
        self.control = dlg.GetDialogItemAsControl(item)
        self.rect = self.control.GetControlRect()
        self.control.SetControlData_Callback(
            0, Controls.kControlUserPaneDrawProcTag, self.redraw)
        self.control.SetControlData_Callback(
            0, Controls.kControlUserPaneHitTestProcTag, self.hittest)
        ##         self.control.SetControlData_Callback(0, Controls.kControlUserPaneTrackingProcTag, self.tracking)
        self.image = None
        self.outerrect = (0, 0, 1, 1)
        self.otherrects = []
        self.ourrect = None
        self.recalc()
        self.callback = callback
        self._background_image = None

    def close(self):
        del self.wid
        del self.dlg
        del self.control
        del self.callback
        del self._background_image

    def redraw(self, ctl, part):
        try:
            Qd.SetPort(self.wid)
            Qd.RGBBackColor((0xffff, 0xffff, 0xffff))
            if self._background_image:
                self._redrawimage(self.rect, self._background_image)
            else:
                Qd.EraseRect(self.rect)
            Qd.RGBForeColor((0x7fff, 0x7fff, 0x7fff))
            Qd.FrameRect(self.rect)
            for r in self.otherrects:
                Qd.RGBForeColor((0x0, 0x7fff, 0x7fff))
                Qd.FrameRect(r)
            self.drawourrect()
        except:
            import traceback, sys
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value, None)
            traceback.print_tb(exc_traceback)

    def drawourrect(self):
        if self.ourrect is None:
            return
        port = self.wid.GetWindowPort()
        Qd.RGBForeColor((0x0, 0, 0))
        oldmode = port.pnMode
        Qd.PenMode(QuickDraw.srcXor)
        Qd.FrameRect(self.ourrect)
        for l in self.lurven:
            Qd.PaintRect(l)
        Qd.PenMode(oldmode)

    def hittest(self, ctl, (x, y)):
        try:
            ##             print "hittest", ctl, x, y
            if self.ourrect is None:
                x0, y0, x1, y1 = self.rect
                if x < x0 or x > x1 or y < y0 or y > y1:
                    # Ignore if outside our bounds
                    return
                self.ourrect = (x, y, x, y)
                self.recalclurven()
            for i in range(len(self.lurven) - 1, -1, -1):
                lx0, ly0, lx1, ly1 = self.lurven[i]
                if lx0 <= x <= lx1 and ly0 <= y <= ly1:
                    # track
                    if Evt.StillDown():
                        self.tracklurf(i, (x, y))
                    if self.callback:
                        self.callback()
                    return 1
            return 0
        except:
            import traceback, sys
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value, None)
            traceback.print_tb(exc_traceback)
Ejemplo n.º 7
0
 def __init__(self):
     _SelectionDialog.__init__(self, "Stack", [], None, 0)
     self._dlg.HideDialogItem(ITEM_SELECT_OK)
     self.itemcount = 0
     self.lasttime = Evt.TickCount() / 5
Ejemplo n.º 8
0
"""AEservertest - Test AppleEvent server interface
Ejemplo n.º 9
0
def getoptionkey():
    return not not ord(Evt.GetKeys()[7]) & 0x04
Ejemplo n.º 10
0
"""VerySimplePlayer converted to python
Ejemplo n.º 11
0
    def click(self, point, modifiers):
        # what a mess...
        orgmouse = point[self._direction]
        halfgutter = self._gutter / 2
        l, t, r, b = self._bounds
        if self._direction:
            begin, end = t, b
        else:
            begin, end = l, r

        i = self.findgutter(orgmouse, begin, end)
        if i is None:
            return

        pos = orgpos = begin + (end - begin) * self._gutters[
            i]  # init pos too, for fast click on border, bug done by Petr

        minpos = self._panesizes[i][0]
        maxpos = self._panesizes[i + 1][1]
        minpos = begin + (end - begin) * minpos + 64
        maxpos = begin + (end - begin) * maxpos - 64
        if minpos > orgpos and maxpos < orgpos:
            return

        #SetCursor("fist")
        self.SetPort()
        if self._direction:
            rect = l, orgpos - 1, r, orgpos
        else:
            rect = orgpos - 1, t, orgpos, b

        # track mouse --- XXX  move to separate method?
        Qd.PenMode(QuickDraw.srcXor)
        Qd.PenPat(Qd.GetQDGlobalsGray())
        Qd.PaintRect(_intRect(rect))
        lastpos = None
        while Evt.Button():
            pos = orgpos - orgmouse + Evt.GetMouse()[self._direction]
            pos = max(pos, minpos)
            pos = min(pos, maxpos)
            if pos == lastpos:
                continue
            Qd.PenPat(Qd.GetQDGlobalsGray())
            Qd.PaintRect(_intRect(rect))
            if self._direction:
                rect = l, pos - 1, r, pos
            else:
                rect = pos - 1, t, pos, b
            Qd.PenPat(Qd.GetQDGlobalsGray())
            Qd.PaintRect(_intRect(rect))
            lastpos = pos
            self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None)
            Evt.WaitNextEvent(0, 3)
        Qd.PaintRect(_intRect(rect))
        Qd.PenNormal()
        SetCursor("watch")

        newpos = (pos - begin) / float(end - begin)
        self._gutters[i] = newpos
        self._panesizes[i] = self._panesizes[i][0], newpos
        self._panesizes[i + 1] = newpos, self._panesizes[i + 1][1]
        self.makepanebounds()
        self.installbounds()
        self._calcbounds()
Ejemplo n.º 12
0
"""MovieInWindow converted to python
Ejemplo n.º 13
0
def main():
    print 'hello world'  # XXXX
    # skip the toolbox initializations, already done
    # XXXX Should use gestalt here to check for quicktime version
    Qt.EnterMovies()

    # Get the movie file
    fss = EasyDialogs.AskFileForOpen(
        wanted=File.FSSpec)  # Was: QuickTime.MovieFileType
    if not fss:
        sys.exit(0)

    # Open the window
    bounds = (175, 75, 175 + 160, 75 + 120)
    theWindow = Win.NewCWindow(bounds, fss.as_tuple()[2], 0, 0, -1, 1, 0)
    # XXXX Needed? SetGWorld((CGrafPtr)theWindow, nil)
    Qd.SetPort(theWindow)

    # Get the movie
    theMovie = loadMovie(fss)

    # Relocate to (0, 0)
    bounds = theMovie.GetMovieBox()
    bounds = 0, 0, bounds[2] - bounds[0], bounds[3] - bounds[1]
    theMovie.SetMovieBox(bounds)

    # Create a controller
    theController = theMovie.NewMovieController(bounds,
                                                QuickTime.mcTopLeftMovie)

    # Get movie size and update window parameters
    rv, bounds = theController.MCGetControllerBoundsRect()
    theWindow.SizeWindow(bounds[2], bounds[3], 0)  # XXXX or [3] [2]?
    Qt.AlignWindow(theWindow, 0)
    theWindow.ShowWindow()

    # XXXX MCDoAction(theController, mcActionSetGrowBoxBounds, &maxBounds)
    theController.MCDoAction(QuickTime.mcActionSetKeysEnabled, '1')

    # XXXX MCSetActionFilterWithRefCon(theController, movieControllerEventFilter, (long)theWindow)

    done = 0
    while not done:
        gotone, evt = Evt.WaitNextEvent(0xffff, 0)
        (what, message, when, where, modifiers) = evt
        ##              print what, message, when, where, modifiers # XXXX

        if theController.MCIsPlayerEvent(evt):
            continue

        if what == Events.mouseDown:
            part, whichWindow = Win.FindWindow(where)
            if part == Windows.inGoAway:
                done = whichWindow.TrackGoAway(where)
            elif part == Windows.inDrag:
                Qt.DragAlignedWindow(whichWindow, where, (0, 0, 4000, 4000))
        elif what == Events.updateEvt:
            whichWindow = Win.WhichWindow(message)
            if not whichWindow:
                # Probably the console window. Print something, hope it helps.
                print 'update'
            else:
                Qd.SetPort(whichWindow)
                whichWindow.BeginUpdate()
                Qd.EraseRect(whichWindow.GetWindowPort().GetPortBounds())
                whichWindow.EndUpdate()