]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/ogl/_bmpshape.py
fixes to wint_t and wchar_t handling in unichar.h (fixes FreeBSD compilation and...
[wxWidgets.git] / wxPython / wx / lib / ogl / _bmpshape.py
1 # -*- coding: iso-8859-1 -*-
2 #----------------------------------------------------------------------------
3 # Name: bmpshape.py
4 # Purpose: Bitmap shape
5 #
6 # Author: Pierre Hjälm (from C++ original by Julian Smart)
7 #
8 # Created: 2004-05-08
9 # RCS-ID: $Id$
10 # Copyright: (c) 2004 Pierre Hjälm - 1998 Julian Smart
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------------
13
14 from _basic import RectangleShape
15
16
17 class BitmapShape(RectangleShape):
18 """Draws a bitmap (non-resizable)."""
19 def __init__(self):
20 RectangleShape.__init__(self, 100, 50)
21 self._filename = ""
22
23 def OnDraw(self, dc):
24 if not self._bitmap.Ok():
25 return
26
27 x = self._xpos - self._bitmap.GetWidth() / 2.0
28 y = self._ypos - self._bitmap.GetHeight() / 2.0
29 dc.DrawBitmap(self._bitmap, x, y, True)
30
31 def SetSize(self, w, h, recursive = True):
32 if self._bitmap.Ok():
33 w = self._bitmap.GetWidth()
34 h = self._bitmap.GetHeight()
35
36 self.SetAttachmentSize(w, h)
37
38 self._width = w
39 self._height = h
40
41 self.SetDefaultRegionSize()
42
43 def GetBitmap(self):
44 """Return a the bitmap associated with this shape."""
45 return self._bitmap
46
47 def SetBitmap(self, bitmap):
48 """Set the bitmap associated with this shape.
49
50 You can delete the bitmap from the calling application, since
51 reference counting will take care of holding on to the internal bitmap
52 data.
53 """
54 self._bitmap = bitmap
55 if self._bitmap.Ok():
56 self.SetSize(self._bitmap.GetWidth(), self._bitmap.GetHeight())
57
58 def SetFilename(self, f):
59 """Set the bitmap filename."""
60 self._filename = f
61
62 def GetFilename(self):
63 """Return the bitmap filename."""
64 return self._filename