]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/ogl/bmpshape.cpp
Regenerated makefiles
[wxWidgets.git] / contrib / src / ogl / bmpshape.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: bmpshape.cpp
3 // Purpose: Bitmap shape class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "bmpshape.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include <wx/wx.h>
25 #endif
26
27 #if wxUSE_PROLOGIO
28 #include <wx/deprecated/wxexpr.h>
29 #endif
30
31 #include "wx/ogl/ogl.h"
32
33
34 /*
35 * Bitmap object
36 *
37 */
38
39 IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxRectangleShape)
40
41 wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
42 {
43 m_filename = wxEmptyString;
44 }
45
46 wxBitmapShape::~wxBitmapShape()
47 {
48 }
49
50 void wxBitmapShape::OnDraw(wxDC& dc)
51 {
52 if (!m_bitmap.Ok())
53 return;
54
55 int x, y;
56 x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
57 y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
58 dc.DrawBitmap(m_bitmap, x, y, true);
59 }
60
61 void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive))
62 {
63 if (m_bitmap.Ok())
64 {
65 w = m_bitmap.GetWidth();
66 h = m_bitmap.GetHeight();
67 }
68
69 SetAttachmentSize(w, h);
70
71 m_width = w;
72 m_height = h;
73 SetDefaultRegionSize();
74 }
75
76 #if wxUSE_PROLOGIO
77 void wxBitmapShape::WriteAttributes(wxExpr *clause)
78 {
79 // Can't really save the bitmap; so instantiate the bitmap
80 // at a higher level in the application, from a symbol library.
81 wxRectangleShape::WriteAttributes(clause);
82 clause->AddAttributeValueString(_T("filename"), m_filename);
83 }
84
85 void wxBitmapShape::ReadAttributes(wxExpr *clause)
86 {
87 wxRectangleShape::ReadAttributes(clause);
88 clause->GetAttributeValue(_T("filename"), m_filename);
89 }
90 #endif
91
92 // Does the copying for this object
93 void wxBitmapShape::Copy(wxShape& copy)
94 {
95 wxRectangleShape::Copy(copy);
96
97 wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
98
99 wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
100
101 bitmapCopy.m_bitmap = m_bitmap;
102 bitmapCopy.SetFilename(m_filename);
103 }
104
105 void wxBitmapShape::SetBitmap(const wxBitmap& bm)
106 {
107 m_bitmap = bm;
108 if (m_bitmap.Ok())
109 SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
110 }
111
112