summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/lib/oimagezoomer.cpp90
-rw-r--r--noncore/graphics/opie-eye/lib/oimagezoomer.h84
2 files changed, 166 insertions, 8 deletions
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp
index ffa3c0c..4df5dcc 100644
--- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp
+++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp
@@ -11,2 +11,13 @@ namespace Opie {
11namespace MM { 11namespace MM {
12
13/**
14 * \brief The most simple c'tor
15 * The main c'tor. You still need to set a QPixmap/QIMage,
16 * setImageSize,setViewPortSize,setVisiblePoint
17 *
18 * @param parent The parent widget
19 * @param name A name for this widget
20 * @param fl The widget flags
21 *
22 */
12OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) 23OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl )
@@ -16,2 +27,14 @@ OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl )
16 27
28
29/**
30 * \brief This c'tor takes a QPixmap additional
31 *
32 * You initially set the QPixmap but you still need to provide
33 * the additional data to make this widget useful
34 *
35 * @param pix A Pixmap it'll be converted to a QImage later!
36 * @param par The parent widget
37 * @param name The name of this widget
38 * @param fl The widget flags
39 */
17OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) 40OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl )
@@ -22,2 +45,31 @@ OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name,
22 45
46
47/**
48 * \brief This c'tor takes a QImage instead
49 * You just provide a QImage which is saved. It behaves the same as the others.
50 *
51 * @param img A Image which will be used for the zoomer content
52 * @param par The parent of the widget
53 * @param name The name of the widget
54 * @param fl The widgets flags
55 */
56OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl)
57 : QFrame( par, name, fl ) {
58 init();
59 setImage( img );
60}
61
62
63/**
64 * \brief overloaded c'tor
65 *
66 * This differs only in the arguments it takes
67 *
68 *
69 * @param pSize The size of the Page you show
70 * @param vSize The size of the viewport. The size of the visible part of the widget
71 * @param par The parent of the widget
72 * @param name The name
73 * @param fl The window flags
74 */
23OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, 75OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par,
@@ -28,2 +80,5 @@ OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par
28 80
81/**
82 * d'tor
83 */
29OImageZoomer::~OImageZoomer() { 84OImageZoomer::~OImageZoomer() {
@@ -36,2 +91,10 @@ void OImageZoomer::init() {
36 91
92
93/**
94 * \brief set the page/image size
95 * Tell us the QSize of the Data you show to the user. We need this
96 * to do the calculations
97 *
98 * @param size The size of the stuff you want to zoom on
99 */
37void OImageZoomer::setImageSize( const QSize& size ) { 100void OImageZoomer::setImageSize( const QSize& size ) {
@@ -40,2 +103,12 @@ void OImageZoomer::setImageSize( const QSize& size ) {
40} 103}
104
105/**
106 * \brief Set the size of the viewport
107 * Tell us the QSize of the viewport. The viewport is the part
108 * of the widget which is exposed on the screen
109 *
110 * @param size Te size of the viewport
111 *
112 * @see QScrollView::viewport()
113 */
41void OImageZoomer::setViewPortSize( const QSize& size ) { 114void OImageZoomer::setViewPortSize( const QSize& size ) {
@@ -45,2 +118,9 @@ void OImageZoomer::setViewPortSize( const QSize& size ) {
45 118
119/**
120 * \brief the point in the topleft corner which is currently visible
121 * Set the visible point. This most of the times relate to QScrollView::contentsX()
122 * and QScrollView::contentsY()
123 *
124 * @see setVisiblePoint(int,int)
125 */
46void OImageZoomer::setVisiblePoint( const QPoint& pt ) { 126void OImageZoomer::setVisiblePoint( const QPoint& pt ) {
@@ -50,2 +130,9 @@ void OImageZoomer::setVisiblePoint( const QPoint& pt ) {
50 130
131
132/**
133 * Set the Image. The image will be resized on resizeEvent
134 * and it'll set the QPixmap background
135 *
136 * @param img The image will be stored internally and used as the background
137 */
51void OImageZoomer::setImage( const QImage& img) { 138void OImageZoomer::setImage( const QImage& img) {
@@ -56,2 +143,5 @@ void OImageZoomer::setImage( const QImage& img) {
56 143
144/**
145 * overloaded function it calls the QImage version
146 */
57void OImageZoomer::setImage( const QPixmap& pix) { 147void OImageZoomer::setImage( const QPixmap& pix) {
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.h b/noncore/graphics/opie-eye/lib/oimagezoomer.h
index 605416c..2516c61 100644
--- a/noncore/graphics/opie-eye/lib/oimagezoomer.h
+++ b/noncore/graphics/opie-eye/lib/oimagezoomer.h
@@ -15,8 +15,25 @@ namespace MM {
15/** 15/**
16 * \brief small class to zoom over a widget 16 * \brief small class to zoom over a Page
17 * This class takes a QImage or QPixmap 17 *
18 * and gets the size of the original image 18 * This class represents your page but smaller.
19 * and provides depending of this widgets size 19 * It can draw a Rect on top of an Image/Pixmap you supply
20 * a zoomer and emits the region which should 20 * and you can allow the user easily zooming/moving
21 * be shown / zoomed to 21 * over your widget.
22 * All you need to do is to supply a image/pixmap, the visible size
23 * and the original image/pixmap size and the current visible top/left
24 * position.
25 *
26 * This Image works perfectly with QScrollView as you can connect
27 * QScrollView::contentsMoving to setVisiblePoint slot and the zoomAreRel
28 * to the QScrollView::scrollBy slot. Now you would only need to watch
29 * the resize event anf give us the new information about QScrollView::viewport
30 *
31 * You need to position and set the size of this widget! using setFixedSize() is quite
32 * a good idea for this widget
33 *
34 * @see QScrollView
35 * @see QScrollView::viewport()
36 *
37 * @since 1.2
38 *
22 */ 39 */
@@ -40,6 +57,32 @@ public slots:
40signals: 57signals:
41 void zoomAreaRel( int,int ); 58 /**
42 void zoomArea( int,int ); 59 * Relative movement in the coordinates of the viewport
60 * This signal can easily be connected to QScrollView::scrollBy.
61 * This signal is emitted from within the mouseMoveEvent of this widget
62 *
63 *
64 * @param x The way to move relative on the X-Axis
65 * @param y The way to move relative on the Y-Axis
66 *
67 * @see setVisiblePoint
68 * @see QScrollView::scrollBy
69 */
70 void zoomAreaRel( int x,int y);
71
72 /**
73 * Here you get absolute coordinates.
74 * This slot will be emitted from within the mouseMoveEvent of this widget.
75 * So you may not delete this widget
76 *
77 * @param x The absolute X Coordinate to scroll to.
78 * @param y The absolute Y Coordinate to scroll to.
79 *
80 */
81 void zoomArea( int x,int y);
43 82
44public: 83public:
84 /**
85 * make sure to call these if you reimplement
86 * @internal
87 */
45 void resizeEvent( QResizeEvent* ); 88 void resizeEvent( QResizeEvent* );
@@ -47,4 +90,17 @@ public:
47protected: 90protected:
91 /**
92 * make sure to call these if you reimplement
93 * @internal
94 */
48 void drawContents( QPainter* p ); 95 void drawContents( QPainter* p );
96
97 /**
98 * make sure to call these if you reimplememt
99 * @internal
100 */
49 void mousePressEvent( QMouseEvent* ev ); 101 void mousePressEvent( QMouseEvent* ev );
102 /**
103 * make sure to call these if you reimplement
104 * @internal
105 */
50 void mouseMoveEvent( QMouseEvent* ev ); 106 void mouseMoveEvent( QMouseEvent* ev );
@@ -52,2 +108,5 @@ protected:
52private: 108private:
109 /**
110 * @internal
111 */
53 void init(); 112 void init();
@@ -59,2 +118,11 @@ private:
59 118
119/**
120 * This slot is present for convience. You can connect the
121 * QScrollView::contentsMoved to this slot and it calls the QPoint
122 * version for you
123 * This realtes to QScrollView::contentsX() and QScrollView::contentsY()
124 *
125 * @param x The top left x coordinate
126 * @param y The top left y coorisnate
127 */
60inline void OImageZoomer::setVisiblePoint( int x, int y ) { 128inline void OImageZoomer::setVisiblePoint( int x, int y ) {