1
// vim: set tabstop=4 shiftwidth=4 noexpandtab
3
Gwenview - A simple image viewer for KDE
4
Copyright 2000-2004 Aur�lien G�teau
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.
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.
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.
23
#ifndef GVSCROLLPIXMAPVIEW_H
24
#define GVSCROLLPIXMAPVIEW_H
28
#ifdef HAVE_FUNC_ROUND
29
#define ROUND(x) round(x)
31
#define ROUND(x) rint(x)
35
#define __USE_ISOC99 1
41
#include <qscrollview.h>
43
#include <qvaluelist.h>
46
#include "gvbusylevelmanager.h"
47
#include "gvimageutils/gvimageutils.h"
56
class KActionCollection;
59
typedef QValueList<KAction *> KActionPtrList;
63
class GVScrollPixmapView : public QScrollView {
72
friend class ToolBase;
73
friend class ZoomTool;
74
friend class ScrollTool;
76
friend class EventFilter;
78
enum ToolID { SCROLL, ZOOM };
79
enum OSDMode { NONE, PATH, COMMENT, PATH_AND_COMMENT, FREE_OUTPUT };
80
typedef QMap<ToolID,ToolBase*> Tools;
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;
88
KToggleAction* autoZoom() const;
89
KAction* zoomIn() const;
90
KAction* zoomOut() const;
91
KAction* resetZoom() const;
92
KToggleAction* lockZoom() const;
94
void setZoom(double zoom, int centerX=-1, int centerY=-1);
95
bool fullScreen() const;
96
void setFullScreenActions(KActionPtrList);
97
void setFullScreen(bool);
99
// we use "normal"BackgroundColor because backgroundColor() already exists
100
QColor normalBackgroundColor() const;
101
void setNormalBackgroundColor(const QColor&);
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);
122
void showFileProperties();
129
void selectPrevious();
131
void zoomChanged(double);
134
virtual void openContextMenu(const QPoint&);
135
virtual void contentsDragEnterEvent(QDragEnterEvent*);
136
virtual void contentsDropEvent(QDropEvent*);
142
struct PendingPaint {
143
PendingPaint( bool s, const QRect& r ) : rect( r ), smooth( s ) {};
144
PendingPaint() {}; // stupid Qt containers
148
enum Operation { CHECK_OPERATIONS = 0, SMOOTH_PASS = 1 << 0 };
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 );
155
void cancelPending();
156
void scheduleOperation( Operation operation );
157
void checkPendingOperationsInternal();
158
void updateBusyLevels();
160
double computeZoom(bool in) const;
161
double computeAutoZoom() const;
163
void updateImageOffset();
164
void updateScrollBarMode();
165
void updateContentSize();
166
void updateFullScreenLabel();
167
void updateZoomActions();
168
void selectTool(ButtonState, bool force);
169
void restartAutoHideTimer();
171
// Used by the scroll tool
172
void emitSelectPrevious() { emit selectPrevious(); }
173
void emitSelectNext() { emit selectNext(); }
175
// Used by the zoom tool
176
QPoint offset() const;
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();
192
void slotImageSizeUpdated();
193
void slotImageRectUpdated(const QRect&);
194
void checkPendingOperations();
195
void loadingStarted();
196
void slotBusyLevelChanged(GVBusyLevel);
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);