Esempio n. 1
0
 def tempclip(self, tempclip):
     if not hasattr(self, "saveclip"):
         self.saveclip = []
     saveclip = Qd.NewRgn()
     Qd.GetClip(saveclip)
     self.saveclip.append(saveclip)
     Qd.SetClip(tempclip)
Esempio n. 2
0
    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)
Esempio n. 3
0
 def do_update(self):
     if self.must_clear:
         self._clear_html()
     visregion = self.wid.GetWindowPort().visRgn
     myregion = Qd.NewRgn()
     Qd.RectRgn(myregion, self.rect)  # or is it self.ted.WEGetViewRect() ?
     Qd.SectRgn(myregion, visregion, myregion)
     # Waste doesn't honour the clipping region, do it ourselves
     clipregion = Qd.NewRgn()
     Qd.GetClip(clipregion)
     Qd.SectRgn(myregion, clipregion, myregion)
     if Qd.EmptyRgn(myregion):
         return
     Qd.RGBBackColor(self.bg_color)
     Qd.RGBForeColor((0, 0xffff, 0))  # DBG
     Qd.EraseRgn(visregion)
     self.ted.WEUpdate(myregion)
Esempio n. 4
0
    def listDefDraw(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.EraseRect(cellRect)

        #draw the cell if it contains data
        ascent, descent, leading, size, hm = Fm.FontMetrics()
        linefeed = ascent + descent + leading

        if dataLen:
            left, top, right, bottom = cellRect
            data = theList.LGetCell(dataLen, theCell)
            lines = data.split("\r")
            line1 = lines[0]
            if len(lines) > 1:
                line2 = lines[1]
            else:
                line2 = ""
            Qd.MoveTo(int(left + 4), int(top + ascent))
            Qd.DrawText(line1, 0, len(line1))
            if line2:
                Qd.MoveTo(int(left + 4), int(top + ascent + linefeed))
                Qd.DrawText(line2, 0, len(line2))
            Qd.PenPat("\x11\x11\x11\x11\x11\x11\x11\x11")
            bottom = top + theList.cellSize[1]
            Qd.MoveTo(left, bottom - 1)
            Qd.LineTo(right, bottom - 1)
        if selected:
            self.listDefHighlight(selected, cellRect, theCell, dataOffset,
                                  dataLen, theList)
        #restore graphics environment
        Qd.SetPort(savedPort)
        Qd.SetClip(savedClip)
        Qd.DisposeRgn(savedClip)
        Qd.SetPenState(savedPenState)
Esempio n. 5
0
    def render(self):
        #
        # On the mac, we can only render after a full setup.
        # Hence, we schedule a redraw only
        #
        window = self._window
        self._rendered = 1
        self.starttime = time.time()
        # XXXX buttons?
        oldenv = window._mac_setwin()
        if window._transparent == -1:
            window._parent._clipchanged()
        #
        # Optimize rendering. There are two cases in which we want to draw immedeately:
        # - If we are the topmost window and no update event is pending for us (so things
        #   look a bit more snappy)
        # - If we are a clone and our parent is already rendered we render now, and only
        #   the bits that are needed.
        #
        clonestart = self._clonestart
        if self._cloneof and self._cloneof == window._active_displist and \
                        self._cloneof._really_rendered:
            render_now = 1
        else:
            render_now = self._can_render_now()
        if render_now:
            clip = window._mac_getclip()
            saveclip = Qd.NewRgn()
            Qd.GetClip(saveclip)
            Qd.SetClip(clip)
            self._render(clonestart)
            Qd.SetClip(saveclip)
            Qd.DisposeRgn(saveclip)
        else:
            window._mac_invalwin()
        window._mac_unsetwin(oldenv)

        window._active_displist = self
        if self._buttons:
            window._buttonschanged()
            self._startbuttontimers()
Esempio n. 6
0
    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)