]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/ogl/bmpshape.cpp
reSWIGged
[wxWidgets.git] / contrib / src / ogl / bmpshape.cpp
CommitLineData
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
39IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxShape)
40
41wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
42{
9e053640 43 m_filename = wxEmptyString;
1fc25a89
JS
44}
45
46wxBitmapShape::~wxBitmapShape()
47{
48}
49
50void wxBitmapShape::OnDraw(wxDC& dc)
51{
52 if (!m_bitmap.Ok())
53 return;
2b5f62a0 54
1fc25a89
JS
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
1484b5cc 63void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive))
1fc25a89
JS
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
2b5f62a0 78#if wxUSE_PROLOGIO
1fc25a89
JS
79void 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);
1484b5cc 84 clause->AddAttributeValueString(_T("filename"), m_filename);
1fc25a89
JS
85}
86
87void wxBitmapShape::ReadAttributes(wxExpr *clause)
88{
89 wxRectangleShape::ReadAttributes(clause);
1484b5cc 90 clause->GetAttributeValue(_T("filename"), m_filename);
1fc25a89
JS
91}
92#endif
93
94// Does the copying for this object
95void 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
107void 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