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
|
#include "stdafx.h"
#include "Graphics.h"
#include "Bitmap.h"
#include "GraphicsMgr.h"
namespace gui {
Graphics::Graphics() {
resources = new (this) WeakSet<Resource>();
// This works well as a dummy implementation.
mgr = new (this) GraphicsMgrRaw();
}
Graphics::~Graphics() {
// Things might be null in the destructor...
if (resources) {
WeakSet<Resource>::Iter i = resources->iter();
while (Resource *r = i.next()) {
if (runtime::liveObject(r))
r->destroy(this);
}
}
}
Bool Graphics::attach(Resource *resource) {
return resources->put(resource);
}
void Graphics::destroy() {
WeakSet<Resource>::Iter i = resources->iter();
while (Resource *r = i.next()) {
r->destroy(this);
}
resources->clear();
}
void Graphics::reset() {
while (pop())
;
}
void Graphics::draw(Bitmap *bitmap) {
draw(bitmap, Point());
}
void Graphics::draw(Bitmap *bitmap, Point topLeft) {
draw(bitmap, Rect(topLeft, topLeft + bitmap->size()));
}
void Graphics::draw(Bitmap *bitmap, Point topLeft, Float opacity) {
draw(bitmap, Rect(topLeft, topLeft + bitmap->size()), opacity);
}
void Graphics::draw(Bitmap *bitmap, Rect rect) {
draw(bitmap, rect, 1);
}
void Graphics::draw(Bitmap *bitmap, Rect src, Point topLeft) {
draw(bitmap, src, Rect(topLeft, topLeft + src.size()));
}
void Graphics::draw(Bitmap *bitmap, Rect src, Point topLeft, Float opacity) {
draw(bitmap, src, Rect(topLeft, topLeft + src.size()), opacity);
}
void Graphics::draw(Bitmap *bitmap, Rect src, Rect dest) {
draw(bitmap, src, dest, 1);
}
}
|