chalk

kobirdeyepanel.h
1/*
2 * This file is part of the KDE project
3 *
4 * Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#ifndef KO_BIRD_EYE_PANEL
22#define KO_BIRD_EYE_PANEL
23
24#include <tqrect.h>
25#include <tqwidget.h>
26
27#include <KoPoint.h>
28#include <KoRect.h>
29
30class TQPixmap;
31class TDEAction;
32class KoDocument;
33class WdgBirdEye;
34
35
36class KoCanvasAdapter {
37
38public:
39
40 KoCanvasAdapter();
41 virtual ~KoCanvasAdapter();
42
46 virtual KoRect visibleArea() = 0;
47
52 virtual TQRect size() = 0;
53
57 virtual double zoomFactor() = 0;
58
62 virtual void setViewCenterPoint(double x, double y) = 0;
63};
64
71
72public:
73
75 virtual ~KoZoomAdapter();
76
80 virtual void zoomTo(double x, double y, double factor ) = 0;
81
85 virtual void zoomIn() = 0;
86
90 virtual void zoomOut() = 0;
91
95 virtual double getMinZoom() = 0;
96
100 virtual double getMaxZoom() = 0;
101
102};
103
104
105class KoThumbnailAdapter
106{
107 public:
108
109 KoThumbnailAdapter();
110 ~KoThumbnailAdapter();
111
120 virtual TQSize pixelSize() = 0;
121
130 virtual TQImage image(TQRect r, TQSize thumbnailSize) = 0;
131};
132
138class KoBirdEyePanel : public TQWidget {
139
140 TQ_OBJECT
141
142
143public:
144
156 KoBirdEyePanel( KoZoomAdapter * zoomListener,
157 KoThumbnailAdapter * thumbnailProvider,
158 KoCanvasAdapter * canvas,
159 TQWidget * parent,
160 const char * name = 0,
161 WFlags f = 0 );
162
163 virtual ~KoBirdEyePanel();
164
165 bool eventFilter(TQObject*, TQEvent*);
166
167public slots:
168
169 void setZoomListener( KoZoomAdapter * zoomListener) { m_zoomListener = zoomListener; }
170
174 void setThumbnailProvider( KoThumbnailAdapter * thumbnailProvider );
175
181
182 void cursorPosChanged(TQ_INT32 xpos, TQ_INT32 ypos);
183
184 void zoomMinus();
185 void zoomPlus();
186
192 void slotUpdate(const TQRect & r);
193
194protected slots:
195
196 void updateVisibleArea();
197 void zoomValueChanged(int zoom);
198 void zoom100();
199 void sliderChanged(int);
200
201protected:
202 void setZoom(int zoom);
203
204 void handleMouseMove(TQPoint);
205 void handleMouseMoveAction(TQPoint);
206 void handleMousePress(TQPoint);
207 void fitThumbnailToView();
208 void renderView();
209 void resizeViewEvent(TQSize size);
210 void paintViewEvent(TQPaintEvent *e);
211 void makeThumbnailRectVisible(const TQRect& r);
212
213 enum enumDragHandle {
214 DragHandleNone,
215 DragHandleLeft,
216 DragHandleCentre,
217 DragHandleRight,
218 DragHandleTop,
219 DragHandleBottom
220 };
221
222 /*
223 * Returns the drag handle type at point p in thumbnail coordinates.
224 */
225 enumDragHandle dragHandleAt(TQPoint p);
226
230 TQRect documentToThumbnail(const KoRect& docRect);
231
235 KoRect thumbnailToDocument(const TQRect& thumbnailRect);
236
240 TQPoint viewToThumbnail(const TQPoint& viewPoint);
241
242private:
243
244 WdgBirdEye * m_page;
245
246 KoZoomAdapter * m_zoomListener;
247 KoThumbnailAdapter * m_thumbnailProvider;
248 KoCanvasAdapter * m_canvas;
249
250 TDEAction* m_zoomIn;
251 TDEAction* m_zoomOut;
252 TQPixmap m_viewBuffer;
253 TQPixmap m_thumbnail;
254
255 TQSize m_documentSize;
256 TQRect m_visibleAreaInThumbnail;
257 bool m_dragging;
258 enumDragHandle m_dragHandle;
259 TQPoint m_lastDragPos;
260
261};
262
263#endif
A complex widget that provides an overview of a document with a red panning rectangle to and a zoom s...
void slotViewTransformationChanged()
Connect to this slot to inform the bird's eye view of changes in the view transformation,...
KoRect thumbnailToDocument(const TQRect &thumbnailRect)
Returns the rectangle in the document covered by the given thumbnail rectangle.
void setThumbnailProvider(KoThumbnailAdapter *thumbnailProvider)
Set a new thumbnail provider.
void slotUpdate(const TQRect &r)
Connect to this slot if a (rectangular) area of your document is changed.
TQRect documentToThumbnail(const KoRect &docRect)
Returns the rectangle in the thumbnail covered by the given document rectangle.
TQPoint viewToThumbnail(const TQPoint &viewPoint)
Converts a point in the view to a point in the thumbnail.
The zoom listener interface defines methods that the bird eye panel will call whenever the zoomlevel ...
virtual double getMaxZoom()=0
Get the maximum zoom factor that this listener supports.
virtual void zoomOut()=0
Zoom one step out.
virtual double getMinZoom()=0
Get the minimum zoom factor that this listener supports.
virtual void zoomIn()=0
Zoom one step in.
virtual void zoomTo(double x, double y, double factor)=0
Zoom to the specified factor around the point x and y.