]>
Commit | Line | Data |
---|---|---|
1fc25a89 JS |
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 | |
2ba06d5a | 9 | // Licence: wxWindows licence |
1fc25a89 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
1fc25a89 | 12 | // For compilers that support precompilation, includes "wx.h". |
92a19c2e | 13 | #include "wx/wxprec.h" |
1fc25a89 JS |
14 | |
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
6b62c9ad | 20 | #include "wx/wx.h" |
1fc25a89 JS |
21 | #endif |
22 | ||
5f331691 | 23 | #if wxUSE_PROLOGIO |
6b62c9ad | 24 | #include "wx/deprecated/wxexpr.h" |
fd657b8a | 25 | #endif |
1fc25a89 | 26 | |
5f331691 RD |
27 | #include "wx/ogl/ogl.h" |
28 | ||
1fc25a89 JS |
29 | |
30 | /* | |
31 | * Bitmap object | |
32 | * | |
33 | */ | |
34 | ||
a20ad557 | 35 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxRectangleShape) |
1fc25a89 JS |
36 | |
37 | wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0) | |
38 | { | |
9e053640 | 39 | m_filename = wxEmptyString; |
1fc25a89 JS |
40 | } |
41 | ||
42 | wxBitmapShape::~wxBitmapShape() | |
43 | { | |
44 | } | |
45 | ||
46 | void wxBitmapShape::OnDraw(wxDC& dc) | |
47 | { | |
48 | if (!m_bitmap.Ok()) | |
49 | return; | |
2b5f62a0 | 50 | |
93210c68 | 51 | int x, y; |
1fc25a89 JS |
52 | x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0); |
53 | y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0); | |
dd33b115 | 54 | dc.DrawBitmap(m_bitmap, x, y, true); |
1fc25a89 JS |
55 | } |
56 | ||
1484b5cc | 57 | void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive)) |
1fc25a89 JS |
58 | { |
59 | if (m_bitmap.Ok()) | |
60 | { | |
61 | w = m_bitmap.GetWidth(); | |
62 | h = m_bitmap.GetHeight(); | |
63 | } | |
64 | ||
65 | SetAttachmentSize(w, h); | |
66 | ||
67 | m_width = w; | |
68 | m_height = h; | |
69 | SetDefaultRegionSize(); | |
70 | } | |
71 | ||
2b5f62a0 | 72 | #if wxUSE_PROLOGIO |
1fc25a89 JS |
73 | void wxBitmapShape::WriteAttributes(wxExpr *clause) |
74 | { | |
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); | |
1484b5cc | 78 | clause->AddAttributeValueString(_T("filename"), m_filename); |
1fc25a89 JS |
79 | } |
80 | ||
81 | void wxBitmapShape::ReadAttributes(wxExpr *clause) | |
82 | { | |
83 | wxRectangleShape::ReadAttributes(clause); | |
1484b5cc | 84 | clause->GetAttributeValue(_T("filename"), m_filename); |
1fc25a89 JS |
85 | } |
86 | #endif | |
87 | ||
88 | // Does the copying for this object | |
89 | void wxBitmapShape::Copy(wxShape& copy) | |
90 | { | |
91 | wxRectangleShape::Copy(copy); | |
92 | ||
93 | wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ; | |
94 | ||
95 | wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy; | |
96 | ||
97 | bitmapCopy.m_bitmap = m_bitmap; | |
98 | bitmapCopy.SetFilename(m_filename); | |
99 | } | |
100 | ||
101 | void wxBitmapShape::SetBitmap(const wxBitmap& bm) | |
102 | { | |
103 | m_bitmap = bm; | |
104 | if (m_bitmap.Ok()) | |
105 | SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight()); | |
106 | } | |
107 | ||
108 |