~ubuntu-dev/wxwidgets2.6/upstream-debian

« back to all changes in this revision

Viewing changes to wxPython/wx/lib/ogl/_bmpshape.py

  • Committer: Daniel T Chen
  • Date: 2006-06-26 10:15:11 UTC
  • Revision ID: crimsun@ubuntu.com-20060626101511-a4436cec4c6d9b35
Import Debian 2.6.3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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: _bmpshape.py,v 1.2 2004/06/18 16:32:02 RD Exp $
 
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