예제 #1
0
    def OnTimer(self, evt):
        stopTimer = False
        popup = self.GetPopupControl().GetControl()
        rect = self.aniRect
        dc = wx.ScreenDC()

        if self.IsPopupWindowState(self.Hidden):
            stopTimer = True
        else:
            pos = wx.GetLocalTimeMillis() - self.aniStart
            if pos < CUSTOM_COMBOBOX_ANIMATION_DURATION:
                # Actual animation happens here
                width = rect.width
                height = rect.height

                center_x = rect.x + (width/2)
                center_y = rect.y + (height/2)

                dc.SetPen( wx.BLACK_PEN )
                dc.SetBrush( wx.TRANSPARENT_BRUSH )

                w = (((pos*256)/CUSTOM_COMBOBOX_ANIMATION_DURATION)*width)/256
                ratio = float(w) / float(width)
                h = int(height * ratio)
                
                dc.DrawBitmap( self.aniBackBitmap, rect.x, rect.y )
                dc.DrawRectangle( center_x - w/2, center_y - h/2, w, h )
            else:
                stopTimer = True

        if stopTimer:
            dc.DrawBitmap( self.aniBackBitmap, rect.x, rect.y )
            popup.Move( (0, 0) )
            self.aniTimer.Stop()
            self.DoShowPopup( rect, self.aniFlags )
예제 #2
0
    def AnimateShow(self, rect, flags):
        self.aniStart = wx.GetLocalTimeMillis()
        self.aniRect = wx.Rect(*rect)
        self.aniFlags = flags

        dc = wx.ScreenDC()
        bmp = wx.EmptyBitmap(rect.width, rect.height)
        mdc = wx.MemoryDC(bmp)
        if "wxMac" in wx.PlatformInfo:
            pass
        else:
            mdc.Blit(0, 0, rect.width, rect.height, dc, rect.x, rect.y)
        del mdc
        self.aniBackBitmap = bmp

        self.aniTimer.Start(10, wx.TIMER_CONTINUOUS)
        self.OnTimer(None)
        return False