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 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)
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)
def incolumn(self, (x, y)): l, t, r, b = self._list.LRect((0, 0)) 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)
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()