]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/ogl/_bmpshape.py
Can't call ShiftDown when it is a CommandEvent
[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 __future__ import division
15
16 from _basic import RectangleShape
17
18
19 class BitmapShape(RectangleShape):
20 """Draws a bitmap (non-resizable)."""
21 def __init__(self):
22 RectangleShape.__init__(self, 100, 50)
23 self._filename=""
24
25 def OnDraw(self, dc):
26 if not self._bitmap.Ok():
27 return
28
29 x = self._xpos-self._bitmap.GetWidth() / 2
30 y = self._ypos-self._bitmap.GetHeight() / 2
31 dc.DrawBitmap(self._bitmap, x, y, True)
32
33 def SetSize(self, w, h, recursive = True):
34 if self._bitmap.Ok():
35 w = self._bitmap.GetWidth()
36 h = self._bitmap.GetHeight()
37
38 self.SetAttachmentSize(w, h)
39
40 self._width = w
41 self._height = h
42
43 self.SetDefaultRegionSize()
44
45 def GetBitmap(self):
46 """Return a the bitmap associated with this shape."""
47 return self._bitmap
48
49 def SetBitmap(self, bitmap):
50 """Set the bitmap associated with this shape.
51
52 You can delete the bitmap from the calling application, since
53 reference counting will take care of holding on to the internal bitmap
54 data.
55 """
56 self._bitmap = bitmap
57 if self._bitmap.Ok():
58 self.SetSize(self._bitmap.GetWidth(), self._bitmap.GetHeight())
59
60 def SetFilename(self, f):
61 """Set the bitmap filename."""
62 self._filename = f
63
64 def GetFilename(self):
65 """Return the bitmap filename."""
66 return self._filename