コード例 #1
0
ファイル: Wtext.py プロジェクト: mmrvka/xbmc
 def drawbreakpoints(self, eraseall=0):
     breakrect = bl, bt, br, bb = self._getbreakrect()
     br = br - 1
     self.SetPort()
     Qd.PenPat(Qd.GetQDGlobalsGray())
     Qd.PaintRect((br, bt, br + 1, bb))
     Qd.PenNormal()
     self._parentwindow.tempcliprect(breakrect)
     Qd.RGBForeColor((0xffff, 0, 0))
     try:
         lasttop = bt
         self_ted = self.ted
         Qd_PaintOval = Qd.PaintOval
         Qd_EraseRect = Qd.EraseRect
         for lineno in self._debugger.get_file_breaks(self.file):
             start, end = self_ted.WEGetLineRange(lineno - 1)
             if lineno <> self_ted.WEOffsetToLine(start) + 1:
                 # breakpoints beyond our text: erase rest, and back out
                 Qd_EraseRect((bl, lasttop, br, bb))
                 break
             (x, y), h = self_ted.WEGetPoint(start, 0)
             bottom = y + h
             #print y, (lasttop, bottom)
             if bottom > lasttop:
                 Qd_EraseRect((bl, lasttop, br, y + h * eraseall))
                 lasttop = bottom
             redbullet = bl + 2, y + 3, bl + 8, y + 9
             Qd_PaintOval(redbullet)
         else:
             Qd_EraseRect((bl, lasttop, br, bb))
         Qd.RGBForeColor((0, 0, 0))
     finally:
         self._parentwindow.restoreclip()
コード例 #2
0
 def draw(self, visRgn=None):
     if self._visible:
         l, t, r, b = Qd.InsetRect(self._bounds, 1, 1)
         Qd.RGBForeColor(self._color)
         Qd.PaintRect((l, t, r, b))
         Qd.RGBForeColor(self._darkercolor)
         Qd.MoveTo(l, b)
         Qd.LineTo(r, b)
         Qd.LineTo(r, t)
         Qd.RGBForeColor((0, 0, 0))
コード例 #3
0
ファイル: mw_widgets.py プロジェクト: ystallonne/grins
 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)
コード例 #4
0
 def draw(self, visRgn=None):
     if self._visible:
         if not visRgn:
             visRgn = self._parentwindow.wid.GetWindowPort().visRgn
         Qd.PenPat(Qd.GetQDGlobalsGray())
         rect = self._bounds
         Qd.FrameRect(rect)
         rect = Qd.InsetRect(rect, 3, 3)
         Qd.PenNormal()
         Qd.RGBForeColor(self._color)
         Qd.PaintRect(rect)
         Qd.RGBForeColor((0, 0, 0))
コード例 #5
0
ファイル: Wlists.py プロジェクト: mmrvka/xbmc
    def listDefHighlight(self, selected, cellRect, theCell, dataOffset,
                         dataLen, theList):
        savedPort = Qd.GetPort()
        Qd.SetPort(theList.GetListPort())
        savedClip = Qd.NewRgn()
        Qd.GetClip(savedClip)
        Qd.ClipRect(cellRect)
        savedPenState = Qd.GetPenState()
        Qd.PenNormal()
        Qd.PenMode(hilitetransfermode)
        Qd.PaintRect(cellRect)

        #restore graphics environment
        Qd.SetPort(savedPort)
        Qd.SetClip(savedClip)
        Qd.DisposeRgn(savedClip)
        Qd.SetPenState(savedPenState)
コード例 #6
0
 def set(self, path_or_fss, start=0):
     self.SetPort()
     if self.movie:
         #self.GetWindow().InvalWindowRect(self.movie.GetMovieBox())
         Qd.PaintRect(self.movie.GetMovieBox())
     path = File.pathname(path)
     self.movietitle = os.path.basename(path)
     movieResRef = Qt.OpenMovieFile(path_or_fss, 1)
     self.movie, dummy, dummy = Qt.NewMovieFromFile(
         movieResRef, 0, QuickTime.newMovieActive)
     self.moviebox = self.movie.GetMovieBox()
     self.calcmoviebox()
     Qd.ObscureCursor()  # XXX does this work at all?
     self.movie.GoToBeginningOfMovie()
     if start:
         self.movie.StartMovie()
         self.running = 1
     else:
         self.running = 0
         self.movie.MoviesTask(0)
コード例 #7
0
ファイル: PyBrowser.py プロジェクト: mmrvka/xbmc
    def myDrawCell(self, onlyHilite, selected, cellRect, theCell,
                    dataOffset, dataLen, theList):
        savedPort = Qd.GetPort()
        Qd.SetPort(theList.GetListPort())
        savedClip = Qd.NewRgn()
        Qd.GetClip(savedClip)
        Qd.ClipRect(cellRect)
        savedPenState = Qd.GetPenState()
        Qd.PenNormal()

        l, t, r, b = cellRect

        if not onlyHilite:
            Qd.EraseRect(cellRect)

            ascent, descent, leading, size, hm = Fm.FontMetrics()
            linefeed = ascent + descent + leading

            if dataLen >= 6:
                data = theList.LGetCell(dataLen, theCell)
                iconId, indent, tab = struct.unpack("hhh", data[:6])
                try:
                    key, value = data[6:].split("\t", 1)
                except ValueError:
                    # bogus data, at least don't crash.
                    indent = 0
                    tab = 0
                    iconId = 0
                    key = ""
                    value = data[6:]

                if iconId:
                    try:
                        theIcon = Icn.GetCIcon(iconId)
                    except Icn.Error:
                        pass
                    else:
                        rect = (0, 0, 16, 16)
                        rect = Qd.OffsetRect(rect, l, t)
                        rect = Qd.OffsetRect(rect, 0, (theList.cellSize[1] - (rect[3] - rect[1])) / 2)
                        Icn.PlotCIcon(rect, theIcon)

                if len(key) >= 0:
                    cl, ct, cr, cb = cellRect
                    vl, vt, vr, vb = self._viewbounds
                    cl = vl + PICTWIDTH + indent
                    cr = vl + tab
                    if cr > vr:
                        cr = vr
                    if cl < cr:
                        drawTextCell(key, (cl, ct, cr, cb), ascent, theList)
                    cl = vl + tab
                    cr = vr
                    if cl < cr:
                        drawTextCell(value, (cl, ct, cr, cb), ascent, theList)
            #elif dataLen != 0:
            #       drawTextCell("???", 3, cellRect, ascent, theList)
            else:
                return  # we have bogus data

            # draw nice dotted line
            l, t, r, b = cellRect
            l = self._viewbounds[0] + tab
            r = l + 1;
            if not (theList.cellSize[1] & 0x01) or (t & 0x01):
                myPat = "\xff\x00\xff\x00\xff\x00\xff\x00"
            else:
                myPat = "\x00\xff\x00\xff\x00\xff\x00\xff"
            Qd.PenPat(myPat)
            Qd.PenMode(QuickDraw.srcCopy)
            Qd.PaintRect((l, t, r, b))
            Qd.PenNormal()

        if selected or onlyHilite:
            l, t, r, b = cellRect
            l = self._viewbounds[0] + PICTWIDTH
            r = self._viewbounds[2]
            Qd.PenMode(hilitetransfermode)
            Qd.PaintRect((l, t, r, b))

        # restore graphics environment
        Qd.SetPort(savedPort)
        Qd.SetClip(savedClip)
        Qd.DisposeRgn(savedClip)
        Qd.SetPenState(savedPenState)
コード例 #8
0
ファイル: PyBrowser.py プロジェクト: mmrvka/xbmc
        abscol = l + self.col
        return abs(abscol - x) < 3

    def trackcolumn(self, (x, y)):
        from Carbon import Qd, QuickDraw, Evt
        self.SetPort()
        l, t, r, b = self._bounds
        bounds = l, t, r, b = l + 1, t + 1, r - 16, b - 1
        abscol = l + self.col
        mincol = l + self.mincol
        maxcol = r - 10
        diff = abscol - x
        Qd.PenPat('\000\377\000\377\000\377\000\377')
        Qd.PenMode(QuickDraw.srcXor)
        rect = abscol - 1, t, abscol, b
        Qd.PaintRect(rect)
        lastpoint = (x, y)
        newcol = -1
        #W.SetCursor('fist')
        while Evt.Button():
            Evt.WaitNextEvent(0, 1, None)  # needed for OSX
            (x, y) = Evt.GetMouse()
            if (x, y) <> lastpoint:
                newcol = x + diff
                newcol = max(newcol, mincol)
                newcol = min(newcol, maxcol)
                Qd.PaintRect(rect)
                rect = newcol - 1, t, newcol, b
                Qd.PaintRect(rect)
                lastpoint = (x, y)
        Qd.PaintRect(rect)
コード例 #9
0
 def draw(self, visRgn=None):
     if self._visible:
         Qd.PaintRect(self._bounds)
         if self.movie:
             self.movie.UpdateMovie()
             self.movie.MoviesTask(0)
コード例 #10
0
    def _render_one(self, entry):
        cmd = entry[0]

        if cmd == 'clear':
            if self._bgcolor != None:
                r = self._getredrawguarantee(skipclear=1)
                if r:
                    r2 = Qd.NewRgn()
                    Qd.RectRgn(r2, self._window.qdrect())
                    Qd.DiffRgn(r2, r, r2)
                    Qd.EraseRgn(r2)
                    Qd.DisposeRgn(r)
                    Qd.DisposeRgn(r2)
                else:
                    Qd.EraseRect(self._window.qdrect())
        elif cmd == 'fg':
            self._setfgcolor(entry[1])
        elif cmd == 'font':
            entry[1]._setfont(self._render_grafport)
        elif cmd == 'text':
            x, y, w, h = self._convert_coordinates(entry[1:5])
            if not self._render_overlaprgn((x, y - h, x + w, y)):
                return
            Qd.MoveTo(x, y)
            # XXXX Incorrect for long strings:
            Qd.DrawText(entry[5], 0, len(entry[5]))
        elif cmd == 'icon':
            icon = entry[2]
            if icon == None:
                return
            rect = self._convert_coordinates(entry[1])
            if not self._render_overlaprgn(rect):
                return
            x0, y0, x1, y1 = rect
            if x1 - x0 < ICONSIZE_PXL:
                leftextra = (ICONSIZE_PXL - (x1 - x0)) / 2
                x0 = x0 + leftextra
                x1 = x0 + ICONSIZE_PXL
            if y1 - y0 < ICONSIZE_PXL:
                topextra = (ICONSIZE_PXL - (y1 - y0)) / 2
                y0 = y0 + topextra
                y1 = y0 + ICONSIZE_PXL
            Icn.PlotCIcon((x0, y0, x1, y1), icon)
        elif cmd == 'image':
            mask, image, srcx, srcy, coordinates, w, h, units = entry[1:]
            dstx, dsty = self._convert_coordinates(coordinates[:2],
                                                   units=units)
            dstrect = dstx, dsty, dstx + w, dsty + h
            if not self._render_overlaprgn(dstrect):
                return
            w = dstrect[2] - dstrect[0]
            h = dstrect[3] - dstrect[1]
            srcrect = srcx, srcy, srcx + w, srcy + h
            self._setblackwhitecolors()
            clip = self._window._mac_getclip()
            if mask:
                # XXXX We should also take note of the clip here.
                Qd.CopyMask(image[0], mask[0],
                            self._render_grafport.GetPortBitMapForCopyBits(),
                            srcrect, srcrect, dstrect)
            else:
                Qd.CopyBits(image[0],
                            self._render_grafport.GetPortBitMapForCopyBits(),
                            srcrect, dstrect,
                            QuickDraw.srcCopy + QuickDraw.ditherCopy, clip)
            self._restorecolors()
        elif cmd == 'line':
            color = entry[1]
            points = entry[2]
            self._setfgcolor(color)
            x, y = self._convert_coordinates(points[0])
            Qd.MoveTo(x, y)
            for np in points[1:]:
                x, y = self._convert_coordinates(np)
                Qd.LineTo(x, y)
            self._restorecolors()
        elif cmd == '3dhline':
            color1, color2, x0, x1, y = entry[1:]
            fgcolor = self._render_grafport.rgbFgColor
            self._setfgcolor(color1)
            x0, y0 = self._convert_coordinates((x0, y))
            x1, y1 = self._convert_coordinates((x1, y))
            if not self._render_overlaprgn((x0, y0, x1, y1 + 1)):
                return
            Qd.MoveTo(x0, y0)
            Qd.LineTo(x1, y1)
            self._setfgcolor(color2)
            Qd.MoveTo(x0, y0 + 1)
            Qd.LineTo(x1, y1 + 1)
            self._setfgcolor(fgcolor)
            self._restorecolors()
        elif cmd == 'box':
            rect = self._convert_coordinates(entry[1])
            if not self._render_overlaprgn(rect):
                return
            Qd.FrameRect(rect)
        elif cmd == 'fbox':
            color = entry[1]
            units = entry[3]
            rect = self._convert_coordinates(entry[2], units)
            if not self._render_overlaprgn(rect):
                return
            self._setfgcolor(color)
            Qd.PaintRect(rect)
            self._restorecolors()
        elif cmd == 'linewidth':
            Qd.PenSize(entry[1], entry[1])
        elif cmd == 'fpolygon':
            polyhandle = self._polyhandle(entry[2],
                                          cliprgn=self._render_cliprgn)
            if not polyhandle:
                return
            self._setfgcolor(entry[1])
            Qd.PaintPoly(polyhandle)
            self._restorecolors()
        elif cmd == '3dbox':
            rect = self._convert_coordinates(entry[2])
            if not self._render_overlaprgn(rect):
                return
            l, t, r, b = rect
            cl, ct, cr, cb = entry[1]
            clt = _colormix(cl, ct)
            ctr = _colormix(ct, cr)
            crb = _colormix(cr, cb)
            cbl = _colormix(cb, cl)
            ##             print '3Dbox', (l, t, r, b) # DBG
            ##             print 'window', self._window.qdrect() # DBG
            # l, r, t, b are the corners
            l3 = l + SIZE_3DBORDER
            t3 = t + SIZE_3DBORDER
            r3 = r - SIZE_3DBORDER
            b3 = b - SIZE_3DBORDER
            # draw left side
            self._setfgcolor(cl)
            polyhandle = self._polyhandle([(l, t), (l3, t3), (l3, b3), (l, b)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)
            # draw top side
            self._setfgcolor(ct)
            polyhandle = self._polyhandle([(l, t), (r, t), (r3, t3), (l3, t3)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)
            # draw right side
            self._setfgcolor(cr)
            polyhandle = self._polyhandle([(r3, t3), (r, t), (r, b), (r3, b3)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)
            # draw bottom side
            self._setfgcolor(cb)
            polyhandle = self._polyhandle([(l3, b3), (r3, b3), (r, b), (l, b)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)
            # draw topleft
            self._setfgcolor(clt)
            Qd.PaintRect((l, t, l3, t3))
            # draw topright
            self._setfgcolor(ctr)
            Qd.PaintRect((r3, t, r, t3))
            # draw botright
            self._setfgcolor(crb)
            Qd.PaintRect((r3, b3, r, b))
            # draw leftbot
            self._setfgcolor(cbl)
            Qd.PaintRect((l, b3, l3, b))

            self._restorecolors()
        elif cmd == 'diamond':
            rect = self._convert_coordinates(entry[1])
            if not self._render_overlaprgn(rect):
                return
            x, y, x1, y1 = rect
            w = x1 - x
            h = y1 - y
            Qd.MoveTo(x, y + h / 2)
            Qd.LineTo(x + w / 2, y)
            Qd.LineTo(x + w, y + h / 2)
            Qd.LineTo(x + w / 2, y + h)
            Qd.LineTo(x, y + h / 2)
        elif cmd == 'fdiamond':
            rect = self._convert_coordinates(entry[2])
            if not self._render_overlaprgn(rect):
                return
            x, y, x1, y1 = rect
            w = x1 - x
            h = y1 - y
            self._setfgcolor(entry[1])
            polyhandle = self._polyhandle([(x, y + h / 2), (x + w / 2, y),
                                           (x + w, y + h / 2),
                                           (x + w / 2, y + h), (x, y + h / 2)])
            if polyhandle: Qd.PaintPoly(polyhandle)
            self._restorecolors()
        elif cmd == '3ddiamond':
            rect = self._convert_coordinates(entry[2])
            if not self._render_overlaprgn(rect):
                return
            l, t, r, b = rect
            cl, ct, cr, cb = entry[1]
            w = r - l
            h = b - t
            r = l + w
            b = t + h
            x = l + w / 2
            y = t + h / 2
            n = int(3.0 * w / h + 0.5)
            ll = l + n
            tt = t + 3
            rr = r - n
            bb = b - 3

            self._setfgcolor(cl)
            polyhandle = self._polyhandle([(l, y), (x, t), (x, tt), (ll, y)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)

            self._setfgcolor(ct)
            polyhandle = self._polyhandle([(x, t), (r, y), (rr, y), (x, tt)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)

            self._setfgcolor(cr)
            polyhandle = self._polyhandle([(r, y), (x, b), (x, bb), (rr, y)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)

            self._setfgcolor(cb)
            polyhandle = self._polyhandle([(l, y), (ll, y), (x, bb), (x, b)],
                                          conv=0)
            if polyhandle: Qd.PaintPoly(polyhandle)

            self._restorecolors()
        elif cmd == 'arrow':
            color = entry[1]
            src = entry[2]
            dst = entry[3]
            x0, y0, x1, y1, points = self._arrowdata(src, dst)
            if not self._render_overlaprgn((x0, y0, x1, y1)):
                return

            self._setfgcolor(color)

            Qd.MoveTo(x0, y0)
            Qd.LineTo(x1, y1)
            polyhandle = self._polyhandle(points)
            if polyhandle: Qd.PaintPoly(polyhandle)
            self._restorecolors()
        else:
            raise 'Unknown displaylist command', cmd
        self._dbg_did = self._dbg_did + 1
コード例 #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()
コード例 #12
0
 def draw(self, visRgn=None):
     if self._visible:
         Qd.PaintRect(self._bounds)