]>
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 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "bmpshape.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
28 #include <wx/deprecated/wxexpr.h>
31 #include "wx/ogl/ogl.h"
39 IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape
, wxShape
)
41 wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
43 m_filename
= wxEmptyString
;
46 wxBitmapShape::~wxBitmapShape()
50 void wxBitmapShape::OnDraw(wxDC
& dc
)
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);
61 void wxBitmapShape::SetSize(double w
, double h
, bool WXUNUSED(recursive
))
65 w
= m_bitmap
.GetWidth();
66 h
= m_bitmap
.GetHeight();
69 SetAttachmentSize(w
, h
);
73 SetDefaultRegionSize();
77 void wxBitmapShape::WriteAttributes(wxExpr
*clause
)
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
);
85 void wxBitmapShape::ReadAttributes(wxExpr
*clause
)
87 wxRectangleShape::ReadAttributes(clause
);
88 clause
->GetAttributeValue(_T("filename"), m_filename
);
92 // Does the copying for this object
93 void wxBitmapShape::Copy(wxShape
& copy
)
95 wxRectangleShape::Copy(copy
);
97 wxASSERT( copy
.IsKindOf(CLASSINFO(wxBitmapShape
)) ) ;
99 wxBitmapShape
& bitmapCopy
= (wxBitmapShape
&) copy
;
101 bitmapCopy
.m_bitmap
= m_bitmap
;
102 bitmapCopy
.SetFilename(m_filename
);
105 void wxBitmapShape::SetBitmap(const wxBitmap
& bm
)
109 SetSize(m_bitmap
.GetWidth(), m_bitmap
.GetHeight());