diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-16 17:47:24 +0200 |
---|---|---|
committer | Javier <javier@pcjavier.(none)> | 2011-09-16 17:47:24 +0200 |
commit | aa1c0fd3146b4ed055d181c99d52463afa6bedbb (patch) | |
tree | f6fb8d9693ad8c545ddabf76312f8f33b5b9878f /watch.cpp | |
download | sowatch-aa1c0fd3146b4ed055d181c99d52463afa6bedbb.tar.gz sowatch-aa1c0fd3146b4ed055d181c99d52463afa6bedbb.zip |
Initial import
Diffstat (limited to 'watch.cpp')
-rw-r--r-- | watch.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
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<Watch*>(this), + const_cast<QImage*>(&_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<QRect> rects; + rects << rect; + update(rects); +} |