summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/imagescrollview.h
blob: e25f95511d0cdddb548c38c794b5b89416590a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#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,bool always_scale=false,bool rfit=false );
    ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
    virtual ~ImageScrollView();

    void setImage(const QImage&);

    enum  Rotation {
        Rotate0,
        Rotate90,
        Rotate180,
        Rotate270
    };

protected:
    virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
    void init();

    QImage _image_data;
    QImage _original_data;

    int _mouseStartPosX,_mouseStartPosY;

    bool scale_to_fit;
    bool rotate_to_fit;
    bool first_resize_done;
    Rotation last_rot;

    void rescaleImage(int w, int h);

    void rotate_into_data(Rotation r);

protected slots:
    virtual void viewportMouseMoveEvent(QMouseEvent* e);
    virtual void contentsMousePressEvent ( QMouseEvent * e);
    virtual void contentsMouseReleaseEvent ( QMouseEvent * e);
    virtual void resizeEvent(QResizeEvent * e);
};

/* for testing */
class ImageDlg:public QDialog
{
    Q_OBJECT
public:
    ImageDlg(const QString&,QWidget * parent=0, const char * name=0);
    virtual ~ImageDlg();
};

#endif