]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/statbmp.py
OGL fixes from Davide Salomoni
[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 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)
28 self._bitmap = bitmap
29 self.InheritAttributes()
30 self.SetBestFittingSize(size)
31
32 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
33 self.Bind(wx.EVT_PAINT, self.OnPaint)
34
35
36 def SetBitmap(self, bitmap):
37 self._bitmap = bitmap
38 self.SetBestFittingSize( (bitmap.GetWidth(), bitmap.GetHeight()) )
39 self.Refresh()
40
41
42 def GetBitmap(self):
43 return self._bitmap
44
45
46 def DoGetBestSize(self):
47 """
48 Overridden base class virtual. Determines the best size of the
49 control based on the bitmap size.
50 """
51 return wx.Size(self._bitmap.GetWidth(), self._bitmap.GetHeight())
52
53
54 def AcceptsFocus(self):
55 """Overridden base class virtual."""
56 return False
57
58
59 def GetDefaultAttributes(self):
60 """
61 Overridden base class virtual. By default we should use
62 the same font/colour attributes as the native StaticBitmap.
63 """
64 return wx.StaticBitmap.GetClassDefaultAttributes()
65
66
67 def ShouldInheritColours(self):
68 """
69 Overridden base class virtual. If the parent has non-default
70 colours then we want this control to inherit them.
71 """
72 return True
73
74
75 def OnPaint(self, event):
76 dc = wx.PaintDC(self)
77 dc.DrawBitmap(self._bitmap, 0, 0, True)
78
79
80 def OnEraseBackground(self, event):
81 pass
82
83
84
85
86 #----------------------------------------------------------------------
87
88