Pass ImlibImageLists over to the view
[qcomicbook-oblomov] / src / imgview.h
1 /*
2  * This file is a part of QComicBook.
3  *
4  * Copyright (C) 2005-2006 Pawel Stolowski <yogin@linux.bydg.org>
5  *
6  * QComicBook is free software; you can redestribute it and/or modify it
7  * under terms of GNU General Public License by Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY. See GPL for more details.
11  */
12
13 #ifndef __IMGVIEW_H
14 #define __IMGVIEW_H
15
16 #include "imlibimage.h"
17 #include <qscrollview.h>
18
19 class QPopupMenu;
20 class QImage;
21 class QPixmap;
22 class QColor;
23 class QCursor;
24
25 namespace QComicBook
26 {
27         enum Size { Original, FitWidth, FitHeight, WholePage, BestFit };
28         //enum Scaling { Smooth, Fast };
29         enum Rotation { None, Left, Right };
30
31         class ImlibImage;
32
33         class ComicImageView: public QScrollView
34         {
35                 Q_OBJECT
36
37                 private:
38                         QPopupMenu *context_menu;
39                         ImlibImageList orgimage[2];
40                         Size isize;
41                         //Scaling iscaling;
42                         int iangle; //rotation angle, 0..3, multipled by 90
43                         int spdx, spdy; //scroll speed
44                         int xoff, yoff;
45                         int lx, ly; //last mouse position when tracking mouse moves
46                         int wheelupcnt, wheeldowncnt;
47                         QCursor *smallcursor;
48                         static const int EXTRA_WHEEL_SPIN; //number of extra wheel spins to flip the page
49
50                         // test - na potrzeby imlib
51                         double asp;
52                         double w_asp;
53                         double h_asp;
54
55                 signals:
56                         void bottomReached();
57                         void topReached();
58                         void doubleClick();
59
60                 protected:
61                         void resizeEvent(QResizeEvent *e);
62                         void updateImageSize();
63                         virtual void contentsContextMenuEvent(QContextMenuEvent *e);
64                         virtual void contentsWheelEvent(QWheelEvent *e);
65                         virtual void contentsMouseMoveEvent(QMouseEvent *e);
66                         virtual void contentsMousePressEvent(QMouseEvent *e);
67                         virtual void contentsMouseDoubleClickEvent(QMouseEvent *e);
68                         virtual void contentsMouseReleaseEvent(QMouseEvent *e);
69                         virtual void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
70
71                 public slots:
72                         void setImage(ImlibImage *img, bool preserveangle=false);
73                         void setImage(ImlibImageList &imglist, bool preserveangle=false);
74                         void setImage(ImlibImage *img1, ImlibImage *img2, bool preserveangle=false);
75                         void setImage(ImlibImageList &imglist1, ImlibImageList &imglist2, bool preserveangle=false);
76                         //void setScaling(Scaling s);
77                         void setRotation(Rotation r);
78                         void setSize(Size s);
79                         void setSizeOriginal();
80                         void setSizeFitWidth();
81                         void setSizeFitHeight();
82                         void setSizeWholePage();
83                         void setSizeBestFit();
84                         void scrollToTop();
85                         void scrollToBottom();
86                         void scrollRight();
87                         void scrollLeft();
88                         void scrollRightFast();
89                         void scrollLeftFast();
90                         void scrollUp();
91                         void scrollDown();
92                         void scrollUpFast();
93                         void scrollDownFast();
94                         void rotateRight();
95                         void rotateLeft();
96                         void resetRotation();
97                         void jumpUp();
98                         void jumpDown();
99                         void clear();
100                         void enableScrollbars(bool f);
101                         void setBackground(const QColor &color);
102                         void setSmallCursor(bool f);
103
104                 public:
105                         ComicImageView(QWidget *parent, Size size=Original, const QColor &color=Qt::black);
106                         ~ComicImageView();
107                         bool onBottom();
108                         bool onTop();
109                         QPopupMenu *contextMenu() const;
110                         Size getSize() const;
111                         int imageWidth() const;
112         };
113 }
114
115 #endif
116