def getChildrenRgn(self, rel=None): rgn = wingdi.CreateRectRgn((0,0,0,0)) for w in self._subwindows: x, y, w, h = w.getwindowpos(rel) newrgn = wingdi.CreateRectRgn((x,y,x+w,y+h)) rgn.CombineRgn(rgn, newrgn, win32con.RGN_OR) newrgn.DeleteObject() # finally clip to this argn = self.getClipRgn(rel) rgn.CombineRgn(rgn,argn,win32con.RGN_AND) argn.DeleteObject() return rgn
def _update_bbox(self, minx, miny, maxx, maxy): assert type(minx) == type(maxx) == type(miny) == type(maxy) == type(1) if minx > maxx: minx, maxx = maxx, minx if miny > maxy: miny, maxy = maxy, miny self._clonebboxes.append((minx, miny, maxx, maxy)) if not self._win32rgn: self._win32rgn = wingdi.CreateRectRgn((minx, miny, maxx, maxy)) else: addrgn = wingdi.CreateRectRgn((minx, miny, maxx, maxy)) self._win32rgn.CombineRgn(self._win32rgn, addrgn, win32con.RGN_OR) addrgn.DeleteObject() del addrgn
def paintOn(self, dc): if self._viewport is None or not self._ready: # show splash when no document is open self.paintSplash(dc) if self._status_msg: rc = self.getStatusRect() dc.DrawText(self._status_msg, rc) else: # blit offscreen bmp buf = self._viewport.getBackBuffer() if buf: device_org = self._xd_org, self._yd_org dc.SetViewportOrg(device_org) ltrb1 = dc.GetClipBox() bsize = w, h = buf.GetSize() ltrb2 = 0, 0, w, h ltrb = winstruct.rectAnd(ltrb1, ltrb2) if ltrb: ltrb = winstruct.inflate(ltrb, 2, 2) dcc = dc.CreateCompatibleDC() dcc.SetViewportOrg((0, 0)) oldbuf = dcc.SelectObject(buf) rgn = wingdi.CreateRectRgn(ltrb) dcc.SelectClipRgn(rgn) rgn.DeleteObject() self._viewport.paint(dcc) dc.BitBlt((0, 0), bsize, dcc, (0, 0), wincon.SRCCOPY) dcc.SelectObject(oldbuf) dcc.DeleteDC() dc.SetViewportOrg((0, 0))
def updateSurface(self, surf, region, exclwnd=None): # what rect to update rcd = xd, yd, wd, hd = self.LRtoDR(region.getVisibleWindowPos(), round=1) wnd = self._ctx dc = wingdi.GetDesktopDC() dcBack = dc.CreateCompatibleDC() oldBack = dcBack.SelectObject(self._backBuffer) ltrb = xd, yd, xd + wd, yd + hd rgn = wingdi.CreateRectRgn(ltrb) dcBack.SelectClipRgn(rgn) rgn.DeleteObject() self.paint(dcBack, exlwnd=exclwnd) dcReg = dcBack.CreateCompatibleDC() oldReg = dcReg.SelectObject(surf) # copy back to reg dcReg.BitBlt((0, 0), (wd, hd), dcBack, (xd, yd), wincon.SRCCOPY) # cleanup dcReg.SelectObject(oldReg) dcReg.DeleteDC() dcBack.SelectObject(oldBack) dcBack.DeleteDC() dc.DeleteDC()
def getClipRgn(self, rel=None): x, y, w, h = self.getwindowpos(rel) rgn = wingdi.CreateRectRgn((x,y,x+w,y+h)) if rel==self: return rgn prgn = self._parent.getClipRgn(rel) rgn.CombineRgn(rgn, prgn, win32con.RGN_AND) prgn.DeleteObject() return rgn
def tkClipBox(self, clipbox): if clipbox is not None: tmprev = svgtypes.TM(self.dc.GetWorldTransform()) self.dc.SetWorldTransform(self.ctm.getElements()) x, y, w, h = clipbox ltrb = x, y, x + w, y + h tm = svgtypes.TM(self.dc.GetWorldTransform()) ltrb = tm.URtoDR(ltrb) self.dc.SetWorldTransform([1, 0, 0, 1, 0, 0]) rgn = wingdi.CreateRectRgn(ltrb) self.dc.SelectClipRgn(rgn) rgn.DeleteObject() self.dc.SetWorldTransform(tmprev.getElements())
def createRegion(self, pointlist): npl = [] l, t, r, b = 10000, 10000, -10000, -10000 for p in pointlist: x = int(p[0] + 0.5) y = int(p[1] + 0.5) l, r = min(l, x), max(r, x) t, b = min(t, y), max(b, y) #npl.append((x,y)) rgn = None try: #rgn = wingdi.CreatePolygonRgn(npl) rgn = wingdi.CreateRectRgn((l, t, r, b)) except wingdi.error, arg: print arg rgn = None
def _paint_0(self, rc=None, exclwnd=None): # if self._transition and self._transition._isrunning(): # print 'normal paint while in transition', self if exclwnd==self: return # first paint self dst = self.getwindowpos(self._topwindow) rgn = self.getClipRgn(self._topwindow) if rc: prgn = wingdi.CreateRectRgn(self.ltrb(rc)) rgn.CombineRgn(rgn,prgn,win32con.RGN_AND) prgn.DeleteObject() buf = self._topwindow.getDrawBuffer() if buf.IsLost() and not buf.Restore(): return try: self._paintOnDDS(buf, dst, rgn) except ddraw.error, arg: print arg
def getClipRgn(self, rel=None): x, y, w, h = self._rectb return wingdi.CreateRectRgn((x,y,x+w,y+h))
def getrelativeClipRgn(self, rel): x, y, w, h = self.getrelativepos(rel); return wingdi.CreateRectRgn((x,y,x+w,y+h))
def clipRect(self, rc, rgn): newrgn = wingdi.CreateRectRgn(self.ltrb(rc)) newrgn.CombineRgn(rgn,newrgn,win32con.RGN_AND) ltrb = newrgn.GetRgnBox() newrgn.DeleteObject() return self.xywh(ltrb)