def move_resize(self): """Internal: recompute the region and rect on which this transition operates""" if self.dstrgn: Qd.DisposeRgn(self.dstrgn) if self.verbatimrgn: Qd.DisposeRgn(self.verbatimrgn) exclude_first_window = self.exclude_first_window x0, y0, x1, y1 = self.windows[0].qdrect() self.dstrgn = Qd.NewRgn() for w in self.windows: rect = w.qdrect() newrgn = w._mac_getclip() if exclude_first_window: exclude_first_window = 0 self.verbatimrgn = Qd.NewRgn() Qd.CopyRgn(newrgn, self.verbatimrgn) else: Qd.UnionRgn(self.dstrgn, newrgn, self.dstrgn) nx0, ny0, nx1, ny1 = rect if nx0 < x0: x0 = nx0 if ny0 < y0: y0 = ny0 if nx1 > x1: x1 = nx1 if ny1 > y1: y1 = ny1 # We still subtract our children (there may be transparent windows in there) if self.verbatimrgn: Qd.DiffRgn(self.verbatimrgn, self.dstrgn, self.verbatimrgn) self.ltrb = (x0, y0, x1, y1) self.transitiontype.move_resize(self.ltrb)
def updatebitmap(self, parameters, src1, src2, tmp, dst, dstrgn): rectlist, rect2 = parameters Qd.CopyBits(src2, tmp, rect2, rect2, QuickDraw.srcCopy, None) x0, y0, x1, y1 = self.ltrb rgn = Qd.NewRgn() for rect in rectlist: rgn2 = Qd.NewRgn() Qd.RectRgn(rgn2, rect) Qd.UnionRgn(rgn, rgn2, rgn) Qd.DisposeRgn(rgn2) Qd.CopyBits(src1, tmp, self.ltrb, self.ltrb, QuickDraw.srcCopy, rgn) Qd.DisposeRgn(rgn) Qd.CopyBits(tmp, dst, self.ltrb, self.ltrb, QuickDraw.srcCopy, dstrgn)
def windowbounds(preferredsize, minsize=None): "Return sensible window bounds" global _windowcounter if len(preferredsize) == 4: bounds = l, t, r, b = preferredsize desktopRgn = Win.GetGrayRgn() tempRgn = Qd.NewRgn() Qd.RectRgn(tempRgn, bounds) union = Qd.UnionRgn(tempRgn, desktopRgn, tempRgn) equal = Qd.EqualRgn(tempRgn, desktopRgn) Qd.DisposeRgn(tempRgn) if equal: return bounds else: preferredsize = r - l, b - t if not minsize: minsize = preferredsize minwidth, minheight = minsize width, height = preferredsize sl, st, sr, sb = screenbounds = Qd.InsetRect( Qd.GetQDGlobalsScreenBits().bounds, 4, 4) l, t = getnextwindowpos() if (l + width) > sr: _windowcounter = 0 l, t = getnextwindowpos() r = l + width b = t + height if (t + height) > sb: b = sb if (b - t) < minheight: b = t + minheight return l, t, r, b
def _get_button_region(self): """Return our region, in global coordinates, if we are active""" # XXXX Only rectangulars for now if not self._sensitive: return None if not self._insidetemporal(): return None rgn = Qd.NewRgn() if self._shape == 'rect': x0, y0 = self._convert_point(self._coordinates[0:2]) x1, y1 = self._convert_point(self._coordinates[2:4]) box = x0, y0, x1, y1 Qd.RectRgn(rgn, box) elif self._shape == 'poly': Qd.OpenRgn() xl, yl = self._convert_point(self._coordinates[-2:]) Qd.MoveTo(xl, yl) for i in range(0, len(self._coordinates), 2): x, y = self._convert_point(self._coordinates[i:i + 2]) Qd.LineTo(x, y) Qd.CloseRgn(rgn) elif self._shape == 'circle': print 'Circle not supported yet' elif self._shape == 'ellipse': # Note: rx/ry are width/height, not points x, y, rx, ry = self._dispobj._window._convert_coordinates( self._coordinates) Qd.OpenRgn() Qd.FrameOval((x - rx, y - ry, x + rx, y + ry)) Qd.CloseRgn(rgn) else: print 'Invalid shape type', self._shape return rgn
def tempclip(self, tempclip): if not hasattr(self, "saveclip"): self.saveclip = [] saveclip = Qd.NewRgn() Qd.GetClip(saveclip) self.saveclip.append(saveclip) Qd.SetClip(tempclip)
def __init__(self, window, bgcolor, units): self.__units = units self.starttime = 0 self._window = window window._displists.append(self) self._bgcolor = bgcolor self._fgcolor = window._fgcolor self._linewidth = 1 self._buttons = [] self._list = [] self._rendered = 0 ## if self._window._transparent <= 0: ## self._list.append(('clear',)) self._list.append(('clear', )) self._optimdict = {} self._cloneof = None self._clonestart = 0 self._rendered = FALSE self._font = None self._old_fontinfo = None ## self._clonebboxes = [] self._really_rendered = FALSE # Set to true after the first real redraw self._tmprgn = Qd.NewRgn() self._need_convert_coordinates = 1 # associate cmd names with list indices # used by animation experimental methods self.__cmddict = {} self.__butdict = {}
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)
def _mkpolyrgn(pointlist): rgn = Qd.NewRgn() Qd.OpenRgn() apply(Qd.MoveTo, pointlist[-1]) for x, y in pointlist: Qd.LineTo(x, y) Qd.CloseRgn(rgn) return rgn
def _get_button_region(self): rgn = Qd.NewRgn() for b in self._buttons: brgn = b._get_button_region() if brgn: Qd.UnionRgn(rgn, brgn, rgn) Qd.DisposeRgn(brgn) return rgn
def _getredrawguarantee(self, skipclear=0): """Return a region that we promise we will redraw. Simple implementation, only return the initial clear or the first image (good enough for now)""" window = self._window for entry in self._list: cmd = entry[0] if cmd == 'clear' and self._bgcolor != None and not skipclear: r = Qd.NewRgn() Qd.RectRgn(r, window.qdrect()) return r if cmd == 'image': xscrolloffset, yscrolloffset = window._scrolloffset() 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 r = Qd.NewRgn() Qd.RectRgn(r, dstrect) return r return None
def _can_render_now(self): """Return true if we can do the render now, in stead of scheduling the update event""" # First check that no update events are pending. window = self._window if window._transition: return 0 rgn = Qd.NewRgn() window._onscreen_wid.GetWindowUpdateRgn(rgn) ok = Qd.EmptyRgn(rgn) # Next check that we're topmost if ok: ok = window._is_on_top() Qd.DisposeRgn(rgn) return ok
def set(self, text): if not self.ted: self.temptext = text else: self.ted.WEUseText(Res.Resource(text)) self.ted.WECalText() self.SetPort() viewrect, destrect = self._calctextbounds() self.ted.WESetViewRect(viewrect) self.ted.WESetDestRect(destrect) rgn = Qd.NewRgn() Qd.RectRgn(rgn, viewrect) Qd.EraseRect(viewrect) self.draw(rgn) self.updatescrollbars() self.textchanged(1)
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 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)
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()
# A minimal text editor. # # To be done: # - Functionality: find, etc. from Carbon.Menu import DrawMenuBar from FrameWork import * from Carbon import Win from Carbon import Qd from Carbon import Res import waste import WASTEconst from Carbon import Scrap import os import macfs UNDOLABELS = [ # Indexed by WEGetUndoInfo() value None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style" ] BIGREGION = Qd.NewRgn() Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) class WasteWindow(ScrolledWindow): def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) self.wid = w vr = 0, 0, r[2] - r[0] - 15, r[3] - r[1] - 15 dr = (0, 0, 10240, 0) Qd.SetPort(w)
# A minimal text editor. # # To be done: # - Functionality: find, etc. from Carbon.Menu import DrawMenuBar from FrameWork import * from Carbon import Win from Carbon import Qd from Carbon import Res from Carbon import Fm import waste import WASTEconst from Carbon import Scrap import os import macfs import MACFS UNDOLABELS = [ # Indexed by WEGetUndoInfo() value None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style" ] # Style and size menu. Note that style order is important (tied to bit values) STYLES = [("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), ("Shadow", ""), ("Condensed", ""), ("Extended", "")] SIZES = [9, 10, 12, 14, 18, 24] BIGREGION = Qd.NewRgn() Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) class WasteWindow(ScrolledWindow): def open(self, path, name, data): self.path = path self.name = name
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
LEFTMARGIN = 0 UNDOLABELS = [ # Indexed by WEGetUndoInfo() value None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style" ] # Style and size menu. Note that style order is important (tied to bit values) STYLES = [("Bold", "B"), ("Italic", "I"), ("Underline", "U"), ("Outline", "O"), ("Shadow", ""), ("Condensed", ""), ("Extended", "")] SIZES = [9, 10, 12, 14, 18, 24] # Sizes for HTML tag types HTML_SIZE = {'h1': 18, 'h2': 14} BIGREGION = Qd.NewRgn() Qd.SetRectRgn(BIGREGION, -16000, -16000, 16000, 16000) class WasteWindow(ScrolledWindow): def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0) self.wid = w vr = LEFTMARGIN, 0, r[2] - r[0] - 15, r[3] - r[1] - 15 dr = (0, 0, vr[2], 0) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9)
return bounds else: preferredsize = r - l, b - t if not minsize: minsize = preferredsize minwidth, minheight = minsize width, height = preferredsize sl, st, sr, sb = screenbounds = Qd.InsetRect( Qd.GetQDGlobalsScreenBits().bounds, 4, 4) l, t = getnextwindowpos() if (l + width) > sr: _windowcounter = 0 l, t = getnextwindowpos() r = l + width b = t + height if (t + height) > sb: b = sb if (b - t) < minheight: b = t + minheight return l, t, r, b scratchRegion = Qd.NewRgn() # util -- move somewhere convenient??? def GetRgnBounds(the_Rgn): (t, l, b, r) = struct.unpack("hhhh", the_Rgn.data[2:10]) return (l, t, r, b)
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 tempcliprect(self, tempcliprect): tempclip = Qd.NewRgn() Qd.RectRgn(tempclip, tempcliprect) self.tempclip(tempclip) Qd.DisposeRgn(tempclip)