Esempio n. 1
0
    def _do_resize(self, new_width=None, new_height=None):
        if self._topwindow != self:
            print '_do_resize called from the non-toplevel wnd', self
        self._destroy_displists_tree()
        rc = win32mu.Rect(self._rect)  # rem: self has not been resized yet
        old_width, old_height = rc.width(), rc.height()
        self._rect = self._canvas = 0, 0, new_width, new_height

        if old_width <= 0: old_width = 1  # raise error
        if old_height <= 0: old_height = 1
        xf = float(new_width) / old_width
        yf = float(new_height) / old_height

        self._resize_exec_list = []
        hdwp = Sdk.BeginDeferWindowPos(8)
        for w in self._subwindows:
            hdwp = w._resize_wnds_tree(hdwp, xf, yf)
        Sdk.EndDeferWindowPos(hdwp)

        while len(self._resize_exec_list):
            exec_list = self._resize_exec_list[:]
            self._resize_exec_list = []
            hdwp = Sdk.BeginDeferWindowPos(8)
            for w, xf, yf in exec_list:
                hdwp = w._resize_wnds_tree(hdwp, xf, yf)
            Sdk.EndDeferWindowPos(hdwp)
Esempio n. 2
0
 def getKeyTime(self, point):
     l, t, r, b = self.GetWindowRect()
     l, t, r, b = self._parent.ScreenToClient((l, t, r, b))
     x0 = l + self.TICKS_OFFSET  # first tick in pixels or pos zero
     w = r - l - 2 * self.TICKS_OFFSET - 2  # last tick in pixels or pos 100
     dw = self.MARKER_WIDTH / 2
     index = 0
     point = win32mu.Point(point)
     for p in self._keyTimes:
         x = int(p * w + 0.5)
         rect = win32mu.Rect(
             (x0 + x - dw, b, x0 + x + dw, b + self.MARKER_HEIGHT))
         if rect.isPtInRect(point):
             return index, rect.ltrb_tuple()
         index = index + 1
     return -1, None
Esempio n. 3
0
    def PaintOn(self,dc):
        if self._isminimized:
            return

        # only paint the rect that needs repainting
        rect=win32mu.Rect(dc.GetClipBox())

        # draw to offscreen bitmap for fast looking repaints
        dcc = dc.CreateCompatibleDC()

        self.assertBmpHasMinSize(rect.width(), rect.height(), dc)
        if self._bmp is None:
            print 'failed to create offscreen bitmap'
            return

        # called by win32ui
        #self.OnPrepareDC(dcc)

        # offset origin more because bitmap is just piece of the whole drawing
        dcc.OffsetViewportOrg((-rect.left, -rect.top))
        oldBitmap = dcc.SelectObject(self._bmp)
        dcc.SetBrushOrg((rect.left % 8, rect.top % 8))
        dcc.IntersectClipRect(rect.ltrb_tuple())

        # background decoration on dcc
        if self._active_displist:color=self._active_displist._bgcolor
        else: color=self._bgcolor
        dcc.FillSolidRect(rect.ltrb_tuple(),win32mu.RGB(color))

        # draw objects on dcc
        if self._active_displist:
            self._active_displist._render(dcc, rect.ltrb_tuple())

        # copy bitmap
        dcc.SetViewportOrg((0, 0))
        dcc.SetWindowOrg((0,0))
        dcc.SetMapMode(win32con.MM_TEXT)
        dc.BitBlt(rect.pos(),rect.size(),dcc,(0, 0), win32con.SRCCOPY)

        # clean up
        dcc.SelectObject(oldBitmap)
        dcc.DeleteDC()
Esempio n. 4
0
    def _resize_wnds_tree(self, hdwp, xf, yf):
        (flags,showCmd,ptMinPosition,ptMaxPosition,rcNormalPosition)=\
                self.GetWindowPlacement()
        rc = win32mu.Rect(rcNormalPosition)
        l = int(float(rc.left) * xf + 0.5)
        t = int(float(rc.top) * yf + 0.5)
        w = int(float(rc.width()) * xf + 0.5)
        h = int(float(rc.height()) * yf + 0.5)
        self._rect = self._canvas = (0, 0, w, h)
        flags = win32con.SWP_NOACTIVATE | win32con.SWP_NOZORDER | win32con.SWP_NOREDRAW | win32con.SWP_SHOWWINDOW
        hdwp=Sdk.DeferWindowPos(hdwp,self.GetSafeHwnd(),0,\
                (l,t,w,h),flags)

        # factors for self
        xf = float(w) / rc.width()
        yf = float(h) / rc.height()
        for w in self._subwindows:
            self._topwindow._resize_exec_list.append((w, xf, yf))

        return hdwp
Esempio n. 5
0
 def insideKeyTimes(self, point):
     l, t, r, b = self.GetWindowRect()
     l, t, r, b = self._parent.ScreenToClient((l, t, r, b))
     rc = l + self.TICKS_OFFSET + self.DELTA, b, r - self.TICKS_OFFSET - self.DELTA, b + self.MARKER_HEIGHT
     rect = win32mu.Rect(rc)
     return rect.isPtInRect(win32mu.Point(point))
Esempio n. 6
0
 def getsizes(self, rc_child=None):
     if not rc_child: rc = win32mu.Rect(self.GetWindowRect())
     else: rc = rc_child
     rcParent = win32mu.Rect(self._parent.GetWindowRect())
     return self._pxl2rel(rc.xywh_tuple(), rcParent.xywh_tuple())
Esempio n. 7
0
 def inside(self, pt):
     rc = win32mu.Rect(self.GetClientRect())
     return rc.isPtInRect(win32mu.Point(pt))