]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/ogl/bmpshape.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Bitmap shape class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
24 #include <wx/deprecated/wxexpr.h>
27 #include "wx/ogl/ogl.h"
35 IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape
, wxRectangleShape
)
37 wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
39 m_filename
= wxEmptyString
;
42 wxBitmapShape::~wxBitmapShape()
46 void wxBitmapShape::OnDraw(wxDC
& dc
)
52 x
= WXROUND(m_xpos
- m_bitmap
.GetWidth() / 2.0);
53 y
= WXROUND(m_ypos
- m_bitmap
.GetHeight() / 2.0);
54 dc
.DrawBitmap(m_bitmap
, x
, y
, true);
57 void wxBitmapShape::SetSize(double w
, double h
, bool WXUNUSED(recursive
))
61 w
= m_bitmap
.GetWidth();
62 h
= m_bitmap
.GetHeight();
65 SetAttachmentSize(w
, h
);
69 SetDefaultRegionSize();
73 void wxBitmapShape::WriteAttributes(wxExpr
*clause
)
75 // Can't really save the bitmap; so instantiate the bitmap
76 // at a higher level in the application, from a symbol library.
77 wxRectangleShape::WriteAttributes(clause
);
78 clause
->AddAttributeValueString(_T("filename"), m_filename
);
81 void wxBitmapShape::ReadAttributes(wxExpr
*clause
)
83 wxRectangleShape::ReadAttributes(clause
);
84 clause
->GetAttributeValue(_T("filename"), m_filename
);
88 // Does the copying for this object
89 void wxBitmapShape::Copy(wxShape
& copy
)
91 wxRectangleShape::Copy(copy
);
93 wxASSERT( copy
.IsKindOf(CLASSINFO(wxBitmapShape
)) ) ;
95 wxBitmapShape
& bitmapCopy
= (wxBitmapShape
&) copy
;
97 bitmapCopy
.m_bitmap
= m_bitmap
;
98 bitmapCopy
.SetFilename(m_filename
);
101 void wxBitmapShape::SetBitmap(const wxBitmap
& bm
)
105 SetSize(m_bitmap
.GetWidth(), m_bitmap
.GetHeight());