]> git.saurik.com Git - wxWidgets.git/blame - utils/ogl/src/bmpshape.cpp
Added sys/types.h needed for Solaris.
[wxWidgets.git] / utils / ogl / src / bmpshape.cpp
CommitLineData
68278f98
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".
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#ifdef PROLOGIO
28#include <wx/wxexpr.h>
29#endif
30
31#include "basic.h"
32#include "basicp.h"
33#include "canvas.h"
34#include "bmpshape.h"
35#include "misc.h"
36
37/*
38 * Bitmap object
39 *
40 */
41
42IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxShape)
43
44wxBitmapShape::wxBitmapShape():wxRectangleShape(100.0, 50.0)
45{
46 m_filename = "";
47}
48
49wxBitmapShape::~wxBitmapShape()
50{
51}
52
53void wxBitmapShape::OnDraw(wxDC& dc)
54{
55 if (!m_bitmap.Ok())
56 return;
57
58 wxMemoryDC tempDC;
59 tempDC.SelectObject(m_bitmap);
60 double x, y;
61 x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
62 y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
63 dc.Blit(x, y, m_bitmap.GetWidth(), m_bitmap.GetHeight(), &tempDC, 0, 0);
64}
65
66void wxBitmapShape::SetSize(double w, double h, bool recursive)
67{
68 if (m_bitmap.Ok())
69 {
70 w = m_bitmap.GetWidth();
71 h = m_bitmap.GetHeight();
72 }
73
74 SetAttachmentSize(w, h);
75
76 m_width = w;
77 m_height = h;
78 SetDefaultRegionSize();
79}
80
81#ifdef PROLOGIO
6f5f3ca0 82void wxBitmapShape::WriteAttributes(wxExpr *clause)
68278f98
JS
83{
84 // Can't really save the bitmap; so instantiate the bitmap
85 // at a higher level in the application, from a symbol library.
6f5f3ca0 86 wxRectangleShape::WriteAttributes(clause);
68278f98
JS
87 clause->AddAttributeValueString("filename", m_filename);
88}
89
6f5f3ca0 90void wxBitmapShape::ReadAttributes(wxExpr *clause)
68278f98 91{
6f5f3ca0 92 wxRectangleShape::ReadAttributes(clause);
68278f98
JS
93 clause->GetAttributeValue("filename", m_filename);
94}
95#endif
96
97// Does the copying for this object
98void wxBitmapShape::Copy(wxShape& copy)
99{
100 wxRectangleShape::Copy(copy);
101
102 wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;
103
104 wxBitmapShape& bitmapCopy = (wxBitmapShape&) copy;
105
106 bitmapCopy.m_bitmap = m_bitmap;
107 bitmapCopy.SetFilename(m_filename);
108}
109
110void wxBitmapShape::SetBitmap(const wxBitmap& bm)
111{
112 m_bitmap = bm;
113 if (m_bitmap.Ok())
114 SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
115}
116
117