]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/ogl/bmpshape.cpp
compile db sample conditionally only if odbc support was built
[wxWidgets.git] / contrib / src / ogl / bmpshape.cpp
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".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include <wx/wx.h>
25 #endif
26
27 #if wxUSE_PROLOGIO
28 #include <wx/deprecated/wxexpr.h>
29 #endif
30
31 #include "wx/ogl/ogl.h"
32
33
34 /*
35 * Bitmap object
36 *
37 */
38
39 IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxShape)
40
41 wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
42 {
43 m_filename = wxEmptyString;
44 }
45
46 wxBitmapShape::~wxBitmapShape()
47 {
48 }
49
50 void wxBitmapShape::OnDraw(wxDC& dc)
51 {
52 if (!m_bitmap.Ok())
53 return;
54
55 wxMemoryDC tempDC;
56 tempDC.SelectObject(m_bitmap);
57 double x, y;
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);
61 }
62
63 void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive))
64 {
65 if (m_bitmap.Ok())
66 {
67 w = m_bitmap.GetWidth();
68 h = m_bitmap.GetHeight();
69 }
70
71 SetAttachmentSize(w, h);
72
73 m_width = w;
74 m_height = h;
75 SetDefaultRegionSize();
76 }
77
78 #if wxUSE_PROLOGIO
79 void wxBitmapShape::WriteAttributes(wxExpr *clause)
80 {
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);
85 }
86
87 void wxBitmapShape::ReadAttributes(wxExpr *clause)
88 {
89 wxRectangleShape::ReadAttributes(clause);
90 clause->GetAttributeValue(_T("filename"), m_filename);
91 }
92 #endif
93
94 // Does the copying for this object
95 void wxBitmapShape::Copy(wxShape& copy)
96 {
97 wxRectangleShape::Copy(copy);
98
99 wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
100
101 wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
102
103 bitmapCopy.m_bitmap = m_bitmap;
104 bitmapCopy.SetFilename(m_filename);
105 }
106
107 void wxBitmapShape::SetBitmap(const wxBitmap& bm)
108 {
109 m_bitmap = bm;
110 if (m_bitmap.Ok())
111 SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
112 }
113
114