]>
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 if not style
& wx
.BORDER_MASK
:
25 style
= style | wx
.BORDER_NONE
26 wx
.PyControl
.__init
__(self
, parent
, ID
, pos
, size
, style
,
27 wx
.DefaultValidator
, name
)
29 self
.InheritAttributes()
30 self
.SetInitialSize(size
)
32 self
.Bind(wx
.EVT_ERASE_BACKGROUND
, self
.OnEraseBackground
)
33 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
36 def SetBitmap(self
, bitmap
):
38 self
.SetInitialSize( (bitmap
.GetWidth(), bitmap
.GetHeight()) )
46 def DoGetBestSize(self
):
48 Overridden base class virtual. Determines the best size of the
49 control based on the bitmap size.
51 return wx
.Size(self
._bitmap
.GetWidth(), self
._bitmap
.GetHeight())
54 def AcceptsFocus(self
):
55 """Overridden base class virtual."""
59 def GetDefaultAttributes(self
):
61 Overridden base class virtual. By default we should use
62 the same font/colour attributes as the native StaticBitmap.
64 return wx
.StaticBitmap
.GetClassDefaultAttributes()
67 def ShouldInheritColours(self
):
69 Overridden base class virtual. If the parent has non-default
70 colours then we want this control to inherit them.
75 def OnPaint(self
, event
):
78 dc
.DrawBitmap(self
._bitmap
, 0, 0, True)
81 def OnEraseBackground(self
, event
):
87 #----------------------------------------------------------------------