Пример #1
0
def _get_icon(which):
    if not _icons:
        for name, resid in _icon_ids.items():
            _icons[name] = Icn.GetCIcon(resid)
        _icons[''] = None
    try:
        return _icons[which]
    except KeyError:
        print 'Unknown icon:', which
        return None
Пример #2
0
class CIconwindow(FrameWork.Window):
    def open(self, (resid, resname)):
        if not resname:
            resname = '#%r' % (resid, )
        self.resid = resid
        self.picture = Icn.GetCIcon(self.resid)
        l, t, r, b = 0, 0, 32, 32
        self.pictrect = (l, t, r, b)
        width = r - l
        height = b - t
        if width < MINWIDTH: width = MINWIDTH
        elif width > MAXWIDTH: width = MAXWIDTH
        if height < MINHEIGHT: height = MINHEIGHT
        elif height > MAXHEIGHT: height = MAXHEIGHT
        bounds = (LEFT, TOP, LEFT + width, TOP + height)

        self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
        self.do_postopen()
Пример #3
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)
Пример #4
0
"""browsepict - Display all "cicn" resources found"""