summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/imagescrollview.h
blob: 44f2a640e79bd1581763176ae218d2d19080c019 (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
63
64
65
66
67
68
69
70
71
72
#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( QWidget* parent, const char* name = 0, WFlags fl = 0 );
    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&);
    void setImage( const QString& path );
    void setDestructiveClose();

    void setAutoRotate(bool);
    void setAutoScale(bool);

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

signals:
    void sig_return();

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;
    QString m_lastName;
    void rescaleImage(int w, int h);

    void rotate_into_data(Rotation r);
    void generateImage();

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