]>
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 tempDC
.SelectObject(m_bitmap
);
58 x
= WXROUND(m_xpos
- m_bitmap
.GetWidth() / 2.0);
59 y
= WXROUND(m_ypos
- m_bitmap
.GetHeight() / 2.0);
60 dc
.Blit((long) x
, (long) y
, m_bitmap
.GetWidth(), m_bitmap
.GetHeight(), &tempDC
, 0, 0);
63 void wxBitmapShape::SetSize(double w
, double h
, bool WXUNUSED(recursive
))
67 w
= m_bitmap
.GetWidth();
68 h
= m_bitmap
.GetHeight();
71 SetAttachmentSize(w
, h
);
75 SetDefaultRegionSize();
79 void wxBitmapShape::WriteAttributes(wxExpr
*clause
)
81 // Can't really save the bitmap; so instantiate the bitmap
82 // at a higher level in the application, from a symbol library.
83 wxRectangleShape::WriteAttributes(clause
);
84 clause
->AddAttributeValueString(_T("filename"), m_filename
);
87 void wxBitmapShape::ReadAttributes(wxExpr
*clause
)
89 wxRectangleShape::ReadAttributes(clause
);
90 clause
->GetAttributeValue(_T("filename"), m_filename
);
94 // Does the copying for this object
95 void wxBitmapShape::Copy(wxShape
& copy
)
97 wxRectangleShape::Copy(copy
);
99 wxASSERT( copy
.IsKindOf(CLASSINFO(wxBitmapShape
)) ) ;
101 wxBitmapShape
& bitmapCopy
= (wxBitmapShape
&) copy
;
103 bitmapCopy
.m_bitmap
= m_bitmap
;
104 bitmapCopy
.SetFilename(m_filename
);
107 void wxBitmapShape::SetBitmap(const wxBitmap
& bm
)
111 SetSize(m_bitmap
.GetWidth(), m_bitmap
.GetHeight());