~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/sdk/kis_canvas_controller.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#ifndef KIS_CANVAS_CONTROLLER_H_
 
20
#define KIS_CANVAS_CONTROLLER_H_
 
21
 
 
22
#include <qglobal.h>
 
23
#include <qpoint.h>
 
24
#include <qrect.h>
 
25
#include "kis_types.h"
 
26
 
 
27
class QWidget;
 
28
class KisTool;
 
29
class KisRect;
 
30
class KisPoint;
 
31
class KisCanvas;
 
32
class KisInputDevice;
 
33
 
 
34
/**
 
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.
 
38
 */
 
39
class KisCanvasController {
 
40
public:
 
41
    KisCanvasController() {};
 
42
    virtual ~KisCanvasController() {};
 
43
 
 
44
public:
 
45
 
 
46
    /**
 
47
     * @return the canvas object
 
48
     */
 
49
    virtual KisCanvas *kiscanvas() const = 0;
 
50
 
 
51
 
 
52
    /**
 
53
     * @return the value of the horizontal scrollbar.
 
54
     */
 
55
    virtual Q_INT32 horzValue() const = 0;
 
56
 
 
57
    /**
 
58
     * @return the value of the vertical scrollbar
 
59
     */
 
60
    virtual Q_INT32 vertValue() const = 0;
 
61
    
 
62
    /**
 
63
     * Sets the horizontal and vertical scrollbars to the specified values
 
64
     *
 
65
     * @param x the value the horizontal scrollbar is set to
 
66
     * @param y the value the vertical scrollbar is set to
 
67
     */
 
68
    virtual void scrollTo(Q_INT32 x, Q_INT32 y) = 0;
 
69
    
 
70
    /**
 
71
     * Tell all of the canvas to repaint itself.
 
72
     */
 
73
    virtual void updateCanvas() = 0;
 
74
 
 
75
 
 
76
    /**
 
77
     * Tell the canvas to repaint the rectangle defined by x, y, w and h.
 
78
     * The coordinates are image coordinates.
 
79
     */
 
80
    virtual void updateCanvas(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h) = 0;
 
81
 
 
82
    /**
 
83
     * Tell the canvas repaint the specified rectangle. The coordinates
 
84
     * are image coordinates, not view coordinates.
 
85
     */
 
86
    virtual void updateCanvas(const QRect& rc) = 0;
 
87
    
 
88
    /**
 
89
     * Increase the zoomlevel one step
 
90
     */
 
91
    virtual void zoomIn() = 0;
 
92
 
 
93
    /**
 
94
     * Increase the zoomlevel one step and make sure that x,y is the center point of the view.
 
95
     *
 
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
 
98
     */
 
99
    virtual void zoomIn(Q_INT32 x, Q_INT32 y) = 0;
 
100
    
 
101
    /**
 
102
     * Decrease the zoomlevel one step
 
103
     */
 
104
    virtual void zoomOut() = 0;
 
105
 
 
106
 
 
107
    /**
 
108
     * Decrease the zoomlevel one step and make sure that x,y is the center point of the view.
 
109
     *
 
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
 
112
     */
 
113
    virtual void zoomOut(Q_INT32 x, Q_INT32 y) = 0;
 
114
    
 
115
    /**
 
116
     * To centre the view on the given point with the given zoom factor.
 
117
     *
 
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
 
121
     */
 
122
    virtual void zoomAroundPoint(double x, double y, double zf) = 0;
 
123
 
 
124
    /**
 
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.
 
128
     */
 
129
    virtual void zoomTo(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h) = 0;
 
130
 
 
131
    /**
 
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.
 
135
     */
 
136
    virtual void zoomTo(const QRect& r) = 0;
 
137
    
 
138
    /**
 
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.
 
142
     */
 
143
    virtual void zoomTo(const KisRect& r) = 0;
 
144
    
 
145
    /**
 
146
     * Conversion functions from view coordinates to image coordinates
 
147
     *
 
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)).
 
151
     *
 
152
     * Here, the view is the canvas widget in the view widget, and the window
 
153
     * is the window on the image.
 
154
     */
 
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;
 
160
    
 
161
    /**
 
162
     * Conversion functions from image coordinates to view coordinates
 
163
     */
 
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;
 
169
    
 
170
    /**
 
171
     * Set the cursor shown when the pointer is over the canvas widget to 
 
172
     * the specified cursor.
 
173
     *
 
174
     * @param cursor the new cursor
 
175
     * @return the old cursor
 
176
     */
 
177
    virtual QCursor setCanvasCursor(const QCursor & cursor) = 0;
 
178
    
 
179
    /**
 
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
 
182
     * device.
 
183
     *
 
184
     * @param inputDevice the new input device
 
185
     */
 
186
    virtual void setInputDevice(KisInputDevice inputDevice) = 0;
 
187
 
 
188
    /**
 
189
     * @return the current input device, such as a mouse or a stylus
 
190
     */
 
191
    virtual KisInputDevice currentInputDevice() const = 0;
 
192
 
 
193
 
 
194
private:
 
195
    KisCanvasController(const KisCanvasController&);
 
196
    KisCanvasController& operator=(const KisCanvasController&);
 
197
};
 
198
 
 
199
#endif // KIS_CANVAS_CONTROLLER_H_
 
200