summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-05 00:09:04 (UTC)
committer alwin <alwin>2004-04-05 00:09:04 (UTC)
commitb0ceb8843ebe9ee3054faa98f08bd255df955aa3 (patch) (side-by-side diff)
tree0ff209155b8b442b7810bc33b5e49cdd34d1fad2
parent7485cd42befd86ad035ef4fa29d6e8f728b1e211 (diff)
downloadopie-b0ceb8843ebe9ee3054faa98f08bd255df955aa3.zip
opie-b0ceb8843ebe9ee3054faa98f08bd255df955aa3.tar.gz
opie-b0ceb8843ebe9ee3054faa98f08bd255df955aa3.tar.bz2
ok, found the problem with moving the image via pen/mouse
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp22
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h4
2 files changed, 17 insertions, 9 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
index f36b717..019f376 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
@@ -1,97 +1,105 @@
#include "imagescrollview.h"
+#include <opie2/odebug.h>
+
+using namespace Opie::Core;
+
#include <qimage.h>
#include <qlayout.h>
ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f)
:QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(img)
{
init();
}
ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f)
- :QScrollView(parent,name,f/*|Qt::WRepaintNoErase*/),_image_data(img)
+ :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(img)
{
init();
}
void ImageScrollView::setImage(const QImage&img)
{
_image_data = img;
init();
}
/* should be called every time the QImage changed it content */
void ImageScrollView::init()
{
viewport()->setBackgroundColor(white);
resizeContents(_image_data.width(),_image_data.height());
}
ImageScrollView::~ImageScrollView()
{
}
void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph)
{
int w = clipw;
int h = cliph;
int x = clipx;
int y = clipy;
bool erase = false;
if (w>_image_data.width()) {
w=_image_data.width();
x = 0;
erase = true;
} else if (x+w>_image_data.width()){
x = _image_data.width()-w;
}
if (h>_image_data.height()) {
h=_image_data.height();
y = 0;
erase = true;
} else if (y+h>_image_data.height()){
y = _image_data.height()-h;
}
if (erase) {
p->fillRect(clipx,clipy,clipw,cliph,white);
}
p->drawImage(clipx,clipy,_image_data,x,y,w,h);
}
+/* using the real geometry points and not the translated points is wanted! */
void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
{
int mx, my;
- viewportToContents( e->x(), e->y(), mx, my );
-
- scrollBy(_mouseStartPosX-mx,my-_mouseStartPosY);
-
+ mx = e->x();
+ my = e->y();
+ int diffx = _mouseStartPosX-mx;
+ int diffy = _mouseStartPosY-my;
+ scrollBy(diffx,diffy);
_mouseStartPosX=mx;
_mouseStartPosY=my;
}
void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e)
{
- viewportToContents( e->x(), e->y(), _mouseStartPosX,_mouseStartPosY );
+ _mouseStartPosX = e->x();
+ _mouseStartPosY = e->y();
}
void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e)
{
- viewportToContents( e->x(), e->y(), _mouseStartPosX,_mouseStartPosY );
+ _mouseStartPosX = e->x();
+ _mouseStartPosY = e->y();
}
/* for testing */
ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name)
:QDialog(parent,name,true,WStyle_ContextHelp)
{
QVBoxLayout*dlglayout = new QVBoxLayout(this);
dlglayout->setSpacing(2);
dlglayout->setMargin(1);
ImageScrollView*inf = new ImageScrollView(fname,this);
dlglayout->addWidget(inf);
}
ImageDlg::~ImageDlg()
{
}
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h
index 5836c8d..edea235 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.h
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.h
@@ -1,43 +1,43 @@
-#ifndef __IMAGE_SCROLL_VIEW_H
-#define __IMAGE_SCROLL_VIEW_H
+#ifndef _IMAGE_SCROLL_VIEW_H
+#define _IMAGE_SCROLL_VIEW_H
#include <qscrollview.h>
#include <qimage.h>
#include <qstring.h>
#include <qdialog.h>
class QPainter;
class ImageScrollView:public QScrollView
{
Q_OBJECT
public:
ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0 );
ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0 );
virtual ~ImageScrollView();
void setImage(const QImage&);
protected:
virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
void init();
QImage _image_data;
int _mouseStartPosX,_mouseStartPosY;
protected slots:
virtual void viewportMouseMoveEvent(QMouseEvent* e);
virtual void contentsMousePressEvent ( QMouseEvent * e);
virtual void contentsMouseReleaseEvent ( QMouseEvent * e);
};
/* for testing */
class ImageDlg:public QDialog
{
Q_OBJECT
public:
ImageDlg(const QString&,QWidget * parent=0, const char * name=0);
virtual ~ImageDlg();
};
#endif