~ubuntu-branches/ubuntu/edgy/gwenview/edgy

« back to all changes in this revision

Viewing changes to src/gvscrollpixmapview.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-12-06 17:59:19 UTC
  • mfrom: (1.1.3 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20051206175919-8yv9nfmw0pws6p52
Tags: 1.3.1-0ubuntu1
* Sync with Debian
* Edit kde.mk for .pot generation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab
2
 
/*
3
 
Gwenview - A simple image viewer for KDE
4
 
Copyright 2000-2004 Aur�lien G�teau
5
 
 
6
 
This program is free software; you can redistribute it and/or
7
 
modify it under the terms of the GNU General Public License
8
 
as published by the Free Software Foundation; either version 2
9
 
of the License, or (at your option) any later version.
10
 
 
11
 
This program is distributed in the hope that it will be useful,
12
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
GNU General Public License for more details.
15
 
 
16
 
You should have received a copy of the GNU General Public License
17
 
along with this program; if not, write to the Free Software
18
 
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 
20
 
*/
21
 
 
22
 
 
23
 
#ifndef GVSCROLLPIXMAPVIEW_H
24
 
#define GVSCROLLPIXMAPVIEW_H
25
 
 
26
 
#include "config.h"
27
 
 
28
 
#ifdef HAVE_FUNC_ROUND
29
 
#define ROUND(x) round(x)
30
 
#else
31
 
#define ROUND(x) rint(x)
32
 
#endif
33
 
 
34
 
#if __GNUC__ < 3
35
 
#define __USE_ISOC99 1
36
 
#endif
37
 
#include <math.h>
38
 
 
39
 
// Qt
40
 
#include <qmap.h>
41
 
#include <qscrollview.h>
42
 
#include <qtimer.h>
43
 
#include <qvaluelist.h>
44
 
 
45
 
// Local
46
 
#include "gvbusylevelmanager.h"
47
 
#include "gvimageutils/gvimageutils.h"
48
 
 
49
 
class QEvent;
50
 
class QLabel;
51
 
class QMouseEvent;
52
 
class QPainter;
53
 
class QTimer;
54
 
class QWheelEvent;
55
 
class KAction;
56
 
class KActionCollection;
57
 
class KConfig;
58
 
class KToggleAction;
59
 
typedef QValueList<KAction *> KActionPtrList;
60
 
 
61
 
class GVDocument;
62
 
 
63
 
class GVScrollPixmapView : public QScrollView {
64
 
Q_OBJECT
65
 
 
66
 
public:
67
 
        class ToolBase;
68
 
        class ZoomTool;
69
 
        class ScrollTool;
70
 
        class EventFilter;
71
 
#if __GNUC__ < 3
72
 
        friend class ToolBase;
73
 
        friend class ZoomTool;
74
 
        friend class ScrollTool;
75
 
#endif
76
 
        friend class EventFilter;
77
 
 
78
 
        enum ToolID { SCROLL, ZOOM };
79
 
        enum OSDMode { NONE, PATH, COMMENT, PATH_AND_COMMENT, FREE_OUTPUT };
80
 
        typedef QMap<ToolID,ToolBase*> Tools;
81
 
 
82
 
        GVScrollPixmapView(QWidget* parent,GVDocument*,KActionCollection*);
83
 
        ~GVScrollPixmapView();
84
 
        void readConfig(KConfig* config, const QString& group);
85
 
        void writeConfig(KConfig* config, const QString& group) const;
86
 
 
87
 
        // Properties
88
 
        KToggleAction* autoZoom() const; 
89
 
        KAction* zoomIn() const; 
90
 
        KAction* zoomOut() const; 
91
 
        KAction* resetZoom() const; 
92
 
        KToggleAction* lockZoom() const; 
93
 
        double zoom() const; 
94
 
        void setZoom(double zoom, int centerX=-1, int centerY=-1);
95
 
        bool fullScreen() const; 
96
 
        void setFullScreenActions(KActionPtrList);
97
 
        void setFullScreen(bool);
98
 
 
99
 
        // we use "normal"BackgroundColor because backgroundColor() already exists
100
 
        QColor normalBackgroundColor() const; 
101
 
        void setNormalBackgroundColor(const QColor&);
102
 
 
103
 
        OSDMode osdMode() const; 
104
 
        void setOSDMode(OSDMode);
105
 
        QString freeOutputFormat() const; 
106
 
        void setFreeOutputFormat(const QString& outFormat); 
107
 
        GVImageUtils::SmoothAlgorithm smoothAlgorithm() const; 
108
 
        void setSmoothAlgorithm(GVImageUtils::SmoothAlgorithm);
109
 
        bool doDelayedSmoothing() const; 
110
 
        bool delayedSmoothing() const; 
111
 
        void setDelayedSmoothing(bool);
112
 
        bool enlargeSmallImages() const; 
113
 
        void setEnlargeSmallImages(bool);
114
 
        bool showScrollBars() const; 
115
 
        void setShowScrollBars(bool);
116
 
        bool mouseWheelScroll() const; 
117
 
        void setMouseWheelScroll(bool);
118
 
 
119
 
 
120
 
public slots:
121
 
        // File operations
122
 
        void showFileProperties();
123
 
        void renameFile();
124
 
        void copyFile();
125
 
        void moveFile();
126
 
        void deleteFile();
127
 
 
128
 
signals:
129
 
        void selectPrevious();
130
 
        void selectNext();
131
 
        void zoomChanged(double);
132
 
 
133
 
protected:
134
 
        virtual void openContextMenu(const QPoint&);
135
 
        virtual void contentsDragEnterEvent(QDragEnterEvent*);
136
 
        virtual void contentsDropEvent(QDropEvent*);
137
 
        
138
 
private:
139
 
        struct Private;
140
 
        Private* d;
141
 
 
142
 
        struct PendingPaint {
143
 
                PendingPaint( bool s, const QRect& r ) : rect( r ), smooth( s ) {};
144
 
                PendingPaint() {}; // stupid Qt containers
145
 
                QRect rect;
146
 
                bool smooth;
147
 
        };
148
 
        enum Operation { CHECK_OPERATIONS = 0, SMOOTH_PASS = 1 << 0 };
149
 
 
150
 
        void addPendingPaint( bool smooth, QRect rect = QRect());
151
 
        void addPendingPaintInternal( bool smooth, QRect rect = QRect());
152
 
        void performPaint( QPainter* painter, int clipx, int clipy, int clipw, int cliph, bool smooth );
153
 
        void limitPaintSize( PendingPaint& paint );
154
 
        void fullRepaint();
155
 
        void cancelPending();
156
 
        void scheduleOperation( Operation operation );
157
 
        void checkPendingOperationsInternal();
158
 
        void updateBusyLevels();
159
 
 
160
 
        double computeZoom(bool in) const;
161
 
        double computeAutoZoom() const;
162
 
        
163
 
        void updateImageOffset();
164
 
        void updateScrollBarMode();
165
 
        void updateContentSize();
166
 
        void updateFullScreenLabel();
167
 
        void updateZoomActions();
168
 
        void selectTool(ButtonState, bool force);
169
 
        void restartAutoHideTimer();
170
 
 
171
 
        // Used by the scroll tool
172
 
        void emitSelectPrevious() { emit selectPrevious(); }
173
 
        void emitSelectNext() { emit selectNext(); }
174
 
 
175
 
        // Used by the zoom tool
176
 
        QPoint offset() const;
177
 
 
178
 
private slots:
179
 
        void slotLoaded();
180
 
        void slotModified();
181
 
        void slotZoomIn();
182
 
        void slotZoomOut();
183
 
        void slotResetZoom();
184
 
        void setAutoZoom(bool);
185
 
        void increaseGamma();
186
 
        void decreaseGamma();
187
 
        void increaseBrightness();
188
 
        void decreaseBrightness();
189
 
        void increaseContrast();
190
 
        void decreaseContrast();
191
 
        void slotAutoHide();
192
 
        void slotImageSizeUpdated();
193
 
        void slotImageRectUpdated(const QRect&);
194
 
        void checkPendingOperations();
195
 
        void loadingStarted();
196
 
        void slotBusyLevelChanged(GVBusyLevel);
197
 
        
198
 
protected:
199
 
        // Overloaded methods
200
 
        bool eventFilter(QObject*, QEvent*);
201
 
        void viewportMousePressEvent(QMouseEvent*);
202
 
        void viewportMouseMoveEvent(QMouseEvent*);
203
 
        void viewportMouseReleaseEvent(QMouseEvent*);
204
 
        bool viewportKeyEvent(QKeyEvent*); // This one is not inherited, it's called from the eventFilter
205
 
        void wheelEvent(QWheelEvent* event);
206
 
        void resizeEvent(QResizeEvent* event);
207
 
        void drawContents(QPainter* p,int clipx,int clipy,int clipw,int cliph);
208
 
};
209
 
 
210
 
#endif