summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/imagescrollview.h
blob: f6e187d07a6981ab5129b1a29c56a996ee84ad8a (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
73
74
75
76
77
78
#ifndef _IMAGE_SCROLL_VIEW_H
#define _IMAGE_SCROLL_VIEW_H

#include <lib/oimagezoomer.h>

#include <qscrollview.h>
#include <qimage.h>
#include <qpixmap.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();

    virtual void setImage(const QImage&);
    virtual void setImage( const QString& path );
    virtual void setDestructiveClose();

    virtual void setAutoRotate(bool);
    virtual void setAutoScale(bool);
    virtual void setShowZoomer(bool);

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

signals:
    void sig_return();
    void imageSizeChanged( const QSize& );
    void viewportSizeChanged( const QSize& );

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

    Opie::MM::OImageZoomer *_zoomer;
    QImage _image_data;
    QImage _original_data;
    QPixmap _pdata;

    int _mouseStartPosX,_mouseStartPosY;

    bool scale_to_fit;
    bool rotate_to_fit;
    bool show_zoomer;
    bool first_resize_done;
    bool image_is_jpeg;
    bool image_scaled_loaded;
    Rotation last_rot;
    QString m_lastName;
    virtual void rescaleImage(int w, int h);

    virtual void rotate_into_data(Rotation r);
    virtual void generateImage();
    virtual void loadJpeg(bool interncall = false);
    bool image_fit_into(const QSize&s);
    void check_zoomer();

protected slots:
    virtual void viewportMouseMoveEvent(QMouseEvent* e);
    virtual void contentsMousePressEvent ( QMouseEvent * e);
    virtual void resizeEvent(QResizeEvent * e);
    virtual void keyPressEvent(QKeyEvent * e);
};
#endif