]>
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"
27 #include <wx/deprecated/wxexpr.h>
29 #include <wx/ogl/basic.h>
30 #include <wx/ogl/basicp.h>
31 #include <wx/ogl/canvas.h>
32 #include <wx/ogl/bmpshape.h>
33 #include <wx/ogl/misc.h>
40 IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape
, wxShape
)
42 wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
44 m_filename
= wxEmptyString
;
47 wxBitmapShape::~wxBitmapShape()
51 void wxBitmapShape::OnDraw(wxDC
& dc
)
57 tempDC
.SelectObject(m_bitmap
);
59 x
= WXROUND(m_xpos
- m_bitmap
.GetWidth() / 2.0);
60 y
= WXROUND(m_ypos
- m_bitmap
.GetHeight() / 2.0);
61 dc
.Blit((long) x
, (long) y
, m_bitmap
.GetWidth(), m_bitmap
.GetHeight(), &tempDC
, 0, 0);
64 void wxBitmapShape::SetSize(double w
, double h
, bool recursive
)
68 w
= m_bitmap
.GetWidth();
69 h
= m_bitmap
.GetHeight();
72 SetAttachmentSize(w
, h
);
76 SetDefaultRegionSize();
80 void wxBitmapShape::WriteAttributes(wxExpr
*clause
)
82 // Can't really save the bitmap; so instantiate the bitmap
83 // at a higher level in the application, from a symbol library.
84 wxRectangleShape::WriteAttributes(clause
);
85 clause
->AddAttributeValueString("filename", m_filename
);
88 void wxBitmapShape::ReadAttributes(wxExpr
*clause
)
90 wxRectangleShape::ReadAttributes(clause
);
91 clause
->GetAttributeValue("filename", m_filename
);
95 // Does the copying for this object
96 void wxBitmapShape::Copy(wxShape
& copy
)
98 wxRectangleShape::Copy(copy
);
100 wxASSERT( copy
.IsKindOf(CLASSINFO(wxBitmapShape
)) ) ;
102 wxBitmapShape
& bitmapCopy
= (wxBitmapShape
&) copy
;
104 bitmapCopy
.m_bitmap
= m_bitmap
;
105 bitmapCopy
.SetFilename(m_filename
);
108 void wxBitmapShape::SetBitmap(const wxBitmap
& bm
)
112 SetSize(m_bitmap
.GetWidth(), m_bitmap
.GetHeight());