wxPython-2424.throbber.patch
上传用户:lswyart
上传日期:2008-06-12
资源大小:3441k
文件大小:3k
源码类别:

杀毒

开发平台:

Visual C++

  1. --- throbber.py Fri Jul 18 17:59:00 2003
  2. +++ throbber.py.new Sat May  8 01:19:13 2004
  3. @@ -52,10 +52,14 @@
  4.                   frameWidth = 0,  # width of each frame (only necessary for composite image)
  5.                   label = None,    # optional text to be displayed
  6.                   overlay = None,  # optional image to overlay on animation
  7. -                 reverse = 0,     # reverse direction at end of animation
  8. +                 reverse = 0,     # reverse direction at end of animation                 
  9.                   style = 0,       # window style
  10. +                 useParentBackground = False, # shall parent background be used
  11. +                                  # when drawing transparent bitmap 
  12.                   name = "throbber"):
  13.          wx.Panel.__init__(self, parent, id, pos, size, style, name)
  14. +        self.useParentBackground = useParentBackground
  15. +        self.savedBackground = None
  16.          self.name = name
  17.          self.label = label
  18.          self.running = (1 != 1)
  19. @@ -133,8 +137,39 @@
  20.          event.Skip()
  21.  
  22.  
  23. -    def Draw(self, dc):
  24. -        dc.DrawBitmap(self.submaps[self.sequence[self.current]], 0, 0, True)
  25. +    def SaveBackground(self):
  26. +        self.savedBackground = wx.EmptyBitmap(self.width, self.height)
  27. +        memDC = wx.MemoryDC()
  28. +        memDC.SelectObject(self.savedBackground)
  29. +        try:
  30. +            parent = self.GetParent()
  31. +        except:
  32. +            parent = None
  33. +
  34. +        if self.useParentBackground and (parent is not None):          
  35. +            dc = wx.ClientDC(parent);
  36. +            pt = wx.Point(0, 0);
  37. +            screenPt = self.ClientToScreen(pt);
  38. +            parentPt = parent.ScreenToClient(screenPt);
  39. +            memDC.Blit(0, 0, self.width, self.height, dc, parentPt.x, parentPt.y);
  40. +        else:
  41. +            dc = wx.ClientDC(self)
  42. +            memDC.Blit(0, 0, self.width, self.height, dc, 0, 0);    
  43. +            
  44. +        memDC.SelectObject(wx.NullBitmap);
  45. +
  46. +        
  47. +    def Draw(self, dc):           
  48. +        if self.savedBackground is None:
  49. +            self.SaveBackground()            
  50. +        bmp = wx.EmptyBitmap(self.width,self.height)   
  51. +        memDC = wx.MemoryDC()
  52. +        memDC.SelectObject(bmp)
  53. +        memDC.DrawBitmap(self.savedBackground, 0, 0)
  54. +        memDC.DrawBitmap(self.submaps[self.sequence[self.current]], 0, 0, True)
  55. +        memDC.SelectObject(wx.NullBitmap)
  56. +           
  57. +        dc.DrawBitmap(bmp, 0, 0, False)
  58.          if self.overlay and self.showOverlay:
  59.              dc.DrawBitmap(self.overlay, self.overlayX, self.overlayY, True)
  60.          if self.label and self.showLabel:
  61. @@ -193,8 +228,9 @@
  62.      def Start(self):
  63.          """Start the animation"""
  64.          if not self.running:
  65. +            self.SaveBackground()
  66.              self.running = not self.running
  67. -            self.timer.Start(self.frameDelay * 1000)
  68. +            self.timer.Start(int(self.frameDelay * 1000))
  69.  
  70.  
  71.      def Stop(self):