Diffstat (limited to 'noncore/graphics/opie-eye/lib') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp index 178fbd4..ffa3c0c 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp | |||
@@ -17,24 +17,28 @@ OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) | |||
17 | OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) | 17 | OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) |
18 | : QFrame( par, name, fl ) { | 18 | : QFrame( par, name, fl ) { |
19 | init(); | 19 | init(); |
20 | setImage( pix ); | 20 | setImage( pix ); |
21 | } | 21 | } |
22 | 22 | ||
23 | OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, | 23 | OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, |
24 | const char* name, WFlags fl ) | 24 | const char* name, WFlags fl ) |
25 | : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { | 25 | : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { |
26 | init(); | 26 | init(); |
27 | } | 27 | } |
28 | 28 | ||
29 | OImageZoomer::~OImageZoomer() { | ||
30 | |||
31 | } | ||
32 | |||
29 | void OImageZoomer::init() { | 33 | void OImageZoomer::init() { |
30 | setFrameStyle( Panel | Sunken ); | 34 | setFrameStyle( Panel | Sunken ); |
31 | } | 35 | } |
32 | 36 | ||
33 | void OImageZoomer::setImageSize( const QSize& size ) { | 37 | void OImageZoomer::setImageSize( const QSize& size ) { |
34 | m_imgSize = size; | 38 | m_imgSize = size; |
35 | repaint(); | 39 | repaint(); |
36 | } | 40 | } |
37 | void OImageZoomer::setViewPortSize( const QSize& size ) { | 41 | void OImageZoomer::setViewPortSize( const QSize& size ) { |
38 | m_visSize = size; | 42 | m_visSize = size; |
39 | repaint(); | 43 | repaint(); |
40 | } | 44 | } |
@@ -84,33 +88,33 @@ void OImageZoomer::drawContents( QPainter* p ) { | |||
84 | int w = (c.width()*m_visSize.width() )/len + c.x(); | 88 | int w = (c.width()*m_visSize.width() )/len + c.x(); |
85 | if ( w > c.width() ) w = c.width(); | 89 | if ( w > c.width() ) w = c.width(); |
86 | 90 | ||
87 | len = m_imgSize.height(); | 91 | len = m_imgSize.height(); |
88 | int y = (c.height()*m_visPt.y() )/len + c.y(); | 92 | int y = (c.height()*m_visPt.y() )/len + c.y(); |
89 | int h = (c.height()*m_visSize.height() )/len + c.y(); | 93 | int h = (c.height()*m_visSize.height() )/len + c.y(); |
90 | if ( h > c.height() ) h = c.height(); | 94 | if ( h > c.height() ) h = c.height(); |
91 | 95 | ||
92 | p->drawRect( x, y, w, h ); | 96 | p->drawRect( x, y, w, h ); |
93 | } | 97 | } |
94 | 98 | ||
95 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { | 99 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { |
96 | 100 | m_mouseX = m_mouseY = -1; | |
97 | } | 101 | } |
98 | 102 | ||
99 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { | 103 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { |
100 | int mx, my; | 104 | int mx, my; |
101 | mx = ev->x(); | 105 | mx = ev->x(); |
102 | my = ev->y(); | 106 | my = ev->y(); |
103 | 107 | ||
104 | if ( m_mouseX != -1 && m_mouseY != -1 ) { | 108 | if ( m_mouseX != -1 && m_mouseY != -1 ) { |
105 | int diffx = m_mouseX-mx; | 109 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); |
106 | int diffy = m_mouseY-my; | 110 | int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); |
107 | // emit zoomAreaRel( diffx, diffy ); | 111 | emit zoomAreaRel( diffx, diffy ); |
108 | // emit zoomArea( | 112 | emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); |
109 | } | 113 | } |
110 | m_mouseX = mx; | 114 | m_mouseX = mx; |
111 | m_mouseY = my; | 115 | m_mouseY = my; |
112 | } | 116 | } |
113 | 117 | ||
114 | 118 | ||
115 | } | 119 | } |
116 | } | 120 | } |