2
* Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#ifndef KIS_CANVAS_CONTROLLER_H_
20
#define KIS_CANVAS_CONTROLLER_H_
25
#include "kis_types.h"
35
* Interface for classes that implement a canvas; i.e., a widget where KisImages
36
* are painted onto. This is the "view" part of the model-view-controller paradigm;
37
* the naming is a confusing historical artefact.
39
class KisCanvasController {
41
KisCanvasController() {};
42
virtual ~KisCanvasController() {};
47
* @return the canvas object
49
virtual KisCanvas *kiscanvas() const = 0;
53
* @return the value of the horizontal scrollbar.
55
virtual Q_INT32 horzValue() const = 0;
58
* @return the value of the vertical scrollbar
60
virtual Q_INT32 vertValue() const = 0;
63
* Sets the horizontal and vertical scrollbars to the specified values
65
* @param x the value the horizontal scrollbar is set to
66
* @param y the value the vertical scrollbar is set to
68
virtual void scrollTo(Q_INT32 x, Q_INT32 y) = 0;
71
* Tell all of the canvas to repaint itself.
73
virtual void updateCanvas() = 0;
77
* Tell the canvas to repaint the rectangle defined by x, y, w and h.
78
* The coordinates are image coordinates.
80
virtual void updateCanvas(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h) = 0;
83
* Tell the canvas repaint the specified rectangle. The coordinates
84
* are image coordinates, not view coordinates.
86
virtual void updateCanvas(const QRect& rc) = 0;
89
* Increase the zoomlevel one step
91
virtual void zoomIn() = 0;
94
* Increase the zoomlevel one step and make sure that x,y is the center point of the view.
96
* @param x The x coordinate of the visible point in image coordinates
97
* @param y the y coordinate of the visible point in image coordinates
99
virtual void zoomIn(Q_INT32 x, Q_INT32 y) = 0;
102
* Decrease the zoomlevel one step
104
virtual void zoomOut() = 0;
108
* Decrease the zoomlevel one step and make sure that x,y is the center point of the view.
110
* @param x the x coordinate of the visible point in image coordinates
111
* @param y the y coordinate of the visible point in image coordinates
113
virtual void zoomOut(Q_INT32 x, Q_INT32 y) = 0;
116
* To centre the view on the given point with the given zoom factor.
118
* @param x the x coordinate of the center point in image coordinates
119
* @param y the y coordinate of the center point in image coordinates
120
* @param zf the zoomfactor
122
virtual void zoomAroundPoint(double x, double y, double zf) = 0;
125
* Make the rect defined by x, y, w and h visible, zooming in or
126
* out as necessary. The view will be centered around the center point
127
* of the specified rect.
129
virtual void zoomTo(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h) = 0;
132
* Make the rect defined by x, y, w and h visible, zooming in or
133
* out as necessary. The view will be centered around the center point
134
* of the specified rect.
136
virtual void zoomTo(const QRect& r) = 0;
139
* Make the rect defined by x, y, w and h visible, zooming in or
140
* out as necessary. The view will be centered around the center point
141
* of the specified rect.
143
virtual void zoomTo(const KisRect& r) = 0;
146
* Conversion functions from view coordinates to image coordinates
148
* You can get the rectangle of the image that's visible using the
149
* viewToWindow() functions (KisCanvasController). E.g.
150
* viewToWindow(QRect(0, 0, canvasWidth, canvasHeight)).
152
* Here, the view is the canvas widget in the view widget, and the window
153
* is the window on the image.
155
virtual QPoint viewToWindow(const QPoint& pt) = 0;
156
virtual KisPoint viewToWindow(const KisPoint& pt) = 0;
157
virtual QRect viewToWindow(const QRect& rc) = 0;
158
virtual KisRect viewToWindow(const KisRect& rc) = 0;
159
virtual void viewToWindow(Q_INT32 *x, Q_INT32 *y) = 0;
162
* Conversion functions from image coordinates to view coordinates
164
virtual QPoint windowToView(const QPoint& pt) = 0;
165
virtual KisPoint windowToView(const KisPoint& pt) = 0;
166
virtual QRect windowToView(const QRect& rc) = 0;
167
virtual KisRect windowToView(const KisRect& rc) = 0;
168
virtual void windowToView(Q_INT32 *x, Q_INT32 *y) = 0;
171
* Set the cursor shown when the pointer is over the canvas widget to
172
* the specified cursor.
174
* @param cursor the new cursor
175
* @return the old cursor
177
virtual QCursor setCanvasCursor(const QCursor & cursor) = 0;
180
* Set the active input device to the specified input device, This
181
* could be a mouse, a stylus, an eraser or any other pointing input
184
* @param inputDevice the new input device
186
virtual void setInputDevice(KisInputDevice inputDevice) = 0;
189
* @return the current input device, such as a mouse or a stylus
191
virtual KisInputDevice currentInputDevice() const = 0;
195
KisCanvasController(const KisCanvasController&);
196
KisCanvasController& operator=(const KisCanvasController&);
199
#endif // KIS_CANVAS_CONTROLLER_H_