File: bmpshape.cpp

package info (click to toggle)
pgadmin3 1.20.0~beta2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 73,704 kB
  • ctags: 18,591
  • sloc: cpp: 193,786; ansic: 18,736; sh: 5,154; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (95 lines) | stat: -rw-r--r-- 2,067 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Portions Copyright (C) 1998 - 2011, Julian Smart
// Portions Copyright (C) 2011 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// bmpshape.cpp - Bitmap shape class
//
//////////////////////////////////////////////////////////////////////////

#include "pgAdmin3.h"

#include "ogl/ogl.h"

/*
 * Bitmap object
 *
 */

IMPLEMENT_DYNAMIC_CLASS(wxBitmapShape, wxRectangleShape)

wxBitmapShape::wxBitmapShape(): wxRectangleShape(100.0, 50.0)
{
	m_filename = wxEmptyString;
}

wxBitmapShape::~wxBitmapShape()
{
}

void wxBitmapShape::OnDraw(wxDC &dc)
{
	if (!m_bitmap.Ok())
		return;

	double x, y;
	x = WXROUND(m_xpos - m_bitmap.GetWidth() / 2.0);
	y = WXROUND(m_ypos - m_bitmap.GetHeight() / 2.0);
	dc.DrawBitmap(m_bitmap, (int) x, (int) y, true);
}

void wxBitmapShape::SetSize(double w, double h, bool WXUNUSED(recursive))
{
	if (m_bitmap.Ok())
	{
		w = m_bitmap.GetWidth();
		h = m_bitmap.GetHeight();
	}

	SetAttachmentSize(w, h);

	m_width = w;
	m_height = h;
	SetDefaultRegionSize();
}

#if wxUSE_PROLOGIO
void wxBitmapShape::WriteAttributes(wxExpr *clause)
{
	// Can't really save the bitmap; so instantiate the bitmap
	// at a higher level in the application, from a symbol library.
	wxRectangleShape::WriteAttributes(clause);
	clause->AddAttributeValueString(wxT("filename"), m_filename);
}

void wxBitmapShape::ReadAttributes(wxExpr *clause)
{
	wxRectangleShape::ReadAttributes(clause);
	clause->GetAttributeValue(wxT("filename"), m_filename);
}
#endif

// Does the copying for this object
void wxBitmapShape::Copy(wxShape &copy)
{
	wxRectangleShape::Copy(copy);

	wxASSERT( copy.IsKindOf(CLASSINFO(wxBitmapShape)) ) ;

	wxBitmapShape &bitmapCopy = (wxBitmapShape &) copy;

	bitmapCopy.m_bitmap = m_bitmap;
	bitmapCopy.SetFilename(m_filename);
}

void wxBitmapShape::SetBitmap(const wxBitmap &bm)
{
	m_bitmap = bm;
	if (m_bitmap.Ok())
		SetSize(m_bitmap.GetWidth(), m_bitmap.GetHeight());
}