diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-17 03:03:23 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2011-09-17 03:03:23 +0200 |
commit | 3a755f46d9cf6e3650d40a960d0d0db8c1ad9fa1 (patch) | |
tree | f330f63caec08b6626c808b5ae70c64cab0246a6 /libsowatch/watch.cpp | |
parent | 0dca79a8c15b76ca53617c0ed3396ab6435f0152 (diff) | |
download | sowatch-3a755f46d9cf6e3650d40a960d0d0db8c1ad9fa1.tar.gz sowatch-3a755f46d9cf6e3650d40a960d0d0db8c1ad9fa1.zip |
preparing for library package
Diffstat (limited to 'libsowatch/watch.cpp')
-rw-r--r-- | libsowatch/watch.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/libsowatch/watch.cpp b/libsowatch/watch.cpp new file mode 100644 index 0000000..e8da790 --- /dev/null +++ b/libsowatch/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); +} |