From aa1c0fd3146b4ed055d181c99d52463afa6bedbb Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 16 Sep 2011 17:47:24 +0200 Subject: Initial import --- watch.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 watch.cpp (limited to 'watch.cpp') diff --git a/watch.cpp b/watch.cpp new file mode 100644 index 0000000..e8da790 --- /dev/null +++ b/watch.cpp @@ -0,0 +1,62 @@ +#include "watch.h" +#include "watchpaintengine.h" + +using namespace sowatch; + +Watch::Watch(const QImage& image, QObject* parent) : + QObject(parent), _image(image), _paintEngine(0) +{ + +} + +Watch::~Watch() +{ + if (_paintEngine) { + delete _paintEngine; + } +} + +QPaintEngine* Watch::paintEngine() const +{ + if (!_paintEngine) { + _paintEngine = new WatchPaintEngine(const_cast(this), + const_cast(&_image)); + } + + return _paintEngine; +} + +int Watch::metric(PaintDeviceMetric metric) const +{ + switch (metric) { + case PdmWidth: + return _image.width(); + case PdmHeight: + return _image.height(); + case PdmWidthMM: + return _image.widthMM(); + case PdmHeightMM: + return _image.heightMM(); + case PdmNumColors: + return _image.numColors(); + case PdmDepth: + return _image.depth(); + case PdmDpiX: + return _image.logicalDpiX(); + case PdmDpiY: + return _image.logicalDpiY(); + case PdmPhysicalDpiX: + return _image.physicalDpiX(); + case PdmPhysicalDpiY: + return _image.physicalDpiY(); + } + + return -1; +} + +void Watch::update(const QRect &rect) +{ + QList rects; + rects << rect; + update(rects); +} -- cgit v1.2.3