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