]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/statbmp.py
Added default values for some parameters
[wxWidgets.git] / wxPython / wx / lib / statbmp.py
1 #----------------------------------------------------------------------
2 # Name: wx.lib.statbmp
3 # Purpose: A generic StaticBitmap class.
4 #
5 # Author: Robin Dunn
6 #
7 # Created: 12-May-2004
8 # RCS-ID: $Id$
9 # Copyright: (c) 2004 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------
12
13 import wx
14
15 #----------------------------------------------------------------------
16
17 class GenStaticBitmap(wx.PyControl):
18 labelDelta = 1
19
20 def __init__(self, parent, ID, bitmap,
21 pos = wx.DefaultPosition, size = wx.DefaultSize,
22 style = 0,
23 name = "genstatbmp"):
24 wx.PyControl.__init__(self, parent, ID, pos, size, style|wx.NO_BORDER,
25 wx.DefaultValidator, name)
26 self._bitmap = bitmap
27 self.InheritAttributes()
28 self.SetBestFittingSize(size)
29
30 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
31 self.Bind(wx.EVT_PAINT, self.OnPaint)
32
33
34 def SetBitmap(self, bitmap):
35 self._bitmap = bitmap
36 self.SetBestFittingSize( (bitmap.GetWidth(), bitmap.GetHeight()) )
37 self.Refresh()
38
39
40 def GetBitmap(self):
41 return self._bitmap
42
43
44 def DoGetBestSize(self):
45 """
46 Overridden base class virtual. Determines the best size of the
47 control based on the bitmap size.
48 """
49 return wx.Size(self._bitmap.GetWidth(), self._bitmap.GetHeight())
50
51
52 def AcceptsFocus(self):
53 """Overridden base class virtual."""
54 return False
55
56
57 def GetDefaultAttributes(self):
58 """
59 Overridden base class virtual. By default we should use
60 the same font/colour attributes as the native StaticBitmap.
61 """
62 return wx.StaticBitmap.GetClassDefaultAttributes()
63
64
65 def ShouldInheritColours(self):
66 """
67 Overridden base class virtual. If the parent has non-default
68 colours then we want this control to inherit them.
69 """
70 return True
71
72
73 def OnPaint(self, event):
74 dc = wx.PaintDC(self)
75 dc.DrawBitmap(self._bitmap, 0, 0, True)
76
77
78 def OnEraseBackground(self, event):
79 pass
80
81
82
83
84 #----------------------------------------------------------------------
85
86