summaryrefslogtreecommitdiff
path: root/libopie2/opiemm/oimagescrollview.h
blob: 3d2ea385c16c587d8e5729fb97161734c6f2839f (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef _IMAGE_SCROLL_VIEW_H
#define _IMAGE_SCROLL_VIEW_H

#include <qscrollview.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qstring.h>
#include <qdialog.h>
#include <qbitarray.h>


class QPainter;

namespace Opie { namespace MM { 

    class OImageZoomer; 

class OImageScrollView:public QScrollView
{
    Q_OBJECT
public:
    enum  Rotation {
        Rotate0,
        Rotate90,
        Rotate180,
        Rotate270
    };

    OImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 );
    OImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
    OImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
    virtual ~OImageScrollView();


    virtual void setDestructiveClose();

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

    virtual bool AutoRotate()const;
    virtual bool AutoScale()const;
    virtual bool ShowZoomer()const;

public slots:
    virtual void setImage(const QImage&);
    virtual void setImage( const QString& path );


signals:
    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;

    QBitArray m_states;

    Rotation m_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();

    /* internal bitset manipulation */
    virtual bool ImageIsJpeg()const;
    virtual void setImageIsJpeg(bool how);
    virtual bool ImageScaledLoaded()const;
    virtual void setImageScaledLoaded(bool how);
    virtual bool FirstResizeDone()const;
    virtual void setFirstResizeDone(bool how);

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

}
}

#endif