1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
/*
* Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_CANVAS_CONTROLLER_H_
#define KIS_CANVAS_CONTROLLER_H_
#include <tqglobal.h>
#include <tqpoint.h>
#include <tqrect.h>
#include "kis_types.h"
class TQWidget;
class KisTool;
class KisRect;
class KisPoint;
class KisCanvas;
class KisInputDevice;
/**
* Interface for classes that implement a canvas; i.e., a widget where KisImages
* are painted onto. This is the "view" part of the model-view-controller paradigm;
* the naming is a confusing historical artefact.
*/
class KisCanvasController {
public:
KisCanvasController() {};
virtual ~KisCanvasController() {};
public:
/**
* @return the canvas object
*/
virtual KisCanvas *kiscanvas() const = 0;
/**
* @return the value of the horizontal scrollbar.
*/
virtual TQ_INT32 horzValue() const = 0;
/**
* @return the value of the vertical scrollbar
*/
virtual TQ_INT32 vertValue() const = 0;
/**
* Sets the horizontal and vertical scrollbars to the specified values
*
* @param x the value the horizontal scrollbar is set to
* @param y the value the vertical scrollbar is set to
*/
virtual void scrollTo(TQ_INT32 x, TQ_INT32 y) = 0;
/**
* Tell all of the canvas to tqrepaint itself.
*/
virtual void updateCanvas() = 0;
/**
* Tell the canvas to tqrepaint the rectangle defined by x, y, w and h.
* The coordinates are image coordinates.
*/
virtual void updateCanvas(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h) = 0;
/**
* Tell the canvas tqrepaint the specified rectangle. The coordinates
* are image coordinates, not view coordinates.
*/
virtual void updateCanvas(const TQRect& rc) = 0;
/**
* Increase the zoomlevel one step
*/
virtual void zoomIn() = 0;
/**
* Increase the zoomlevel one step and make sure that x,y is the center point of the view.
*
* @param x The x coordinate of the visible point in image coordinates
* @param y the y coordinate of the visible point in image coordinates
*/
virtual void zoomIn(TQ_INT32 x, TQ_INT32 y) = 0;
/**
* Decrease the zoomlevel one step
*/
virtual void zoomOut() = 0;
/**
* Decrease the zoomlevel one step and make sure that x,y is the center point of the view.
*
* @param x the x coordinate of the visible point in image coordinates
* @param y the y coordinate of the visible point in image coordinates
*/
virtual void zoomOut(TQ_INT32 x, TQ_INT32 y) = 0;
/**
* To centre the view on the given point with the given zoom factor.
*
* @param x the x coordinate of the center point in image coordinates
* @param y the y coordinate of the center point in image coordinates
* @param zf the zoomfactor
*/
virtual void zoomAroundPoint(double x, double y, double zf) = 0;
/**
* Make the rect defined by x, y, w and h visible, zooming in or
* out as necessary. The view will be centered around the center point
* of the specified rect.
*/
virtual void zoomTo(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h) = 0;
/**
* Make the rect defined by x, y, w and h visible, zooming in or
* out as necessary. The view will be centered around the center point
* of the specified rect.
*/
virtual void zoomTo(const TQRect& r) = 0;
/**
* Make the rect defined by x, y, w and h visible, zooming in or
* out as necessary. The view will be centered around the center point
* of the specified rect.
*/
virtual void zoomTo(const KisRect& r) = 0;
/**
* Conversion functions from view coordinates to image coordinates
*
* You can get the rectangle of the image that's visible using the
* viewToWindow() functions (KisCanvasController). E.g.
* viewToWindow(TQRect(0, 0, canvasWidth, canvasHeight)).
*
* Here, the view is the canvas widget in the view widget, and the window
* is the window on the image.
*/
virtual TQPoint viewToWindow(const TQPoint& pt) = 0;
virtual KisPoint viewToWindow(const KisPoint& pt) = 0;
virtual TQRect viewToWindow(const TQRect& rc) = 0;
virtual KisRect viewToWindow(const KisRect& rc) = 0;
virtual void viewToWindow(TQ_INT32 *x, TQ_INT32 *y) = 0;
/**
* Conversion functions from image coordinates to view coordinates
*/
virtual TQPoint windowToView(const TQPoint& pt) = 0;
virtual KisPoint windowToView(const KisPoint& pt) = 0;
virtual TQRect windowToView(const TQRect& rc) = 0;
virtual KisRect windowToView(const KisRect& rc) = 0;
virtual void windowToView(TQ_INT32 *x, TQ_INT32 *y) = 0;
/**
* Set the cursor shown when the pointer is over the canvas widget to
* the specified cursor.
*
* @param cursor the new cursor
* @return the old cursor
*/
virtual TQCursor setCanvasCursor(const TQCursor & cursor) = 0;
/**
* Set the active input device to the specified input device, This
* could be a mouse, a stylus, an eraser or any other pointing input
* device.
*
* @param inputDevice the new input device
*/
virtual void setInputDevice(KisInputDevice inputDevice) = 0;
/**
* @return the current input device, such as a mouse or a stylus
*/
virtual KisInputDevice currentInputDevice() const = 0;
private:
KisCanvasController(const KisCanvasController&);
KisCanvasController& operator=(const KisCanvasController&);
};
#endif // KIS_CANVAS_CONTROLLER_H_
|