]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/statbmp.py
   1 #---------------------------------------------------------------------- 
   3 # Purpose:     A generic StaticBitmap class.   
   9 # Copyright:   (c) 2004 by Total Control Software 
  10 # Licence:     wxWindows license 
  11 #---------------------------------------------------------------------- 
  15 #---------------------------------------------------------------------- 
  17 class GenStaticBitmap(wx
.PyControl
): 
  20     def __init__(self
, parent
, ID
, bitmap
, 
  21                  pos 
= wx
.DefaultPosition
, size 
= wx
.DefaultSize
, 
  24         wx
.PyControl
.__init
__(self
, parent
, ID
, pos
, size
, style|wx
.NO_BORDER
, 
  25                              wx
.DefaultValidator
, name
) 
  27         self
.InheritAttributes() 
  28         self
.SetBestFittingSize(size
) 
  30         self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
) 
  31         self
.Bind(wx
.EVT_PAINT
,            self
.OnPaint
) 
  34     def SetBitmap(self
, bitmap
): 
  36         self
.SetBestFittingSize( (bitmap
.GetWidth(), bitmap
.GetHeight()) ) 
  44     def DoGetBestSize(self
): 
  46         Overridden base class virtual.  Determines the best size of the 
  47         control based on the bitmap size. 
  49         return wx
.Size(self
._bitmap
.GetWidth(), self
._bitmap
.GetHeight()) 
  52     def AcceptsFocus(self
): 
  53         """Overridden base class virtual.""" 
  57     def GetDefaultAttributes(self
): 
  59         Overridden base class virtual.  By default we should use 
  60         the same font/colour attributes as the native StaticBitmap. 
  62         return wx
.StaticBitmap
.GetClassDefaultAttributes() 
  65     def ShouldInheritColours(self
): 
  67         Overridden base class virtual.  If the parent has non-default 
  68         colours then we want this control to inherit them. 
  73     def OnPaint(self
, event
): 
  75         dc
.DrawBitmap(self
._bitmap
, 0, 0, True) 
  78     def OnEraseBackground(self
, event
): 
  84 #----------------------------------------------------------------------