lib

KoGuides.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
3 Copyright (C) 2005 Casper Boemann Rasmussen <cbr@boemann.dk>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KOGUIDES_H
22#define KOGUIDES_H
23
24#include <tqevent.h>
25#include <tqobject.h>
26
27#include <koffice_export.h>
28
29class TQPaintDevice;
30class KoPoint;
31class KoRect;
32class KoView;
33class KoZoomHandler;
34
35class KOFFICEUI_EXPORT KoGuides : public TQObject
36{
37 TQ_OBJECT
38
39public:
46 KoGuides( KoView *view, KoZoomHandler *zoomHandler );
47
51 ~KoGuides();
52
58 void paintGuides( TQPainter &painter );
59
60 typedef int SnapStatus;
61 static const SnapStatus SNAP_NONE, SNAP_HORIZ, SNAP_VERT, SNAP_BOTH;
62
80 bool mousePressEvent( TQMouseEvent *e );
81
95 bool mouseMoveEvent( TQMouseEvent *e );
96
104 bool mouseReleaseEvent( TQMouseEvent *e );
105
113 bool keyPressEvent( TQKeyEvent *e );
114
123 void setGuideLines( const TQValueList<double> &horizontalPos, const TQValueList<double> &verticalPos );
124
133 void setAutoGuideLines( const TQValueList<double> &horizontalPos, const TQValueList<double> &verticalPos );
134
144 void getGuideLines( TQValueList<double> &horizontalPos, TQValueList<double> &verticalPos ) const;
145
160 void snapToGuideLines( KoRect &rect, int snap, SnapStatus &snapStatus, KoPoint &diff );
161
172 void snapToGuideLines( KoPoint &pos, int snap, SnapStatus &snapStatus, KoPoint &diff );
173
181 void repaintSnapping( const KoRect &snappedRect );
182
190 void repaintSnapping( const KoPoint &snappedPoint, SnapStatus snapStatus );
191
198 void repaintAfterSnapping( );
199
207 void diffNextGuide( KoRect &rect, KoPoint &diff );
208
209public slots:
221 void moveGuide( const TQPoint &pos, bool horizontal, int rulerWidth );
222
233 void addGuide( const TQPoint &pos, bool horizontal, int rulerWidth );
234
235signals:
243 void guideLinesChanged( KoView * view );
244
250 void moveGuides( bool state );
251
261 void paintGuides( bool state );
262
263private slots:
267 void slotChangePosition();
268
272 void slotRemove();
273
274private:
276 struct KoGuideLine
277 {
278 KoGuideLine( TQt::Orientation o, double pos, bool a = false )
279 : orientation( o )
280 , position( pos )
281 , selected( false )
282 , snapping( false )
283 , automatic( a )
284 {}
285 TQt::Orientation orientation;
286 double position;
287 bool selected; // if this guide is selected
288 bool snapping; // if this guide is being snapped to
289 bool automatic; // if this is a atomatic guide line
290 };
291
295 void paint();
296
303 void add( TQt::Orientation o, TQPoint &pos );
304
310 void select( KoGuideLine *guideLine );
311
317 void unselect( KoGuideLine *guideLine );
318
325 bool unselectAll();
326
330 void removeSelected();
331
338 bool hasSelected();
339
353 KoGuideLine * find( KoPoint &p, double diff );
354
363 void moveSelectedBy( TQPoint &p );
364
372 KoPoint mapFromScreen( const TQPoint & pos );
373
381 TQPoint mapToScreen( const KoPoint & pos );
382
392 bool virtuallyEqual( double a, double b ) { return TQABS( a - b ) < 1E-4; }
393
395 KoView * m_view;
397 KoZoomHandler * m_zoomHandler;
398
399 enum GuideLineType
400 {
401 GL,
402 GL_SELECTED,
403 GL_AUTOMATIC,
404 GL_END
405 };
406
408 TQValueList<KoGuideLine *> m_guideLines[GL_END];
409
411 TQPoint m_lastPoint;
413 bool m_mouseSelected;
415 bool m_insertGuide;
417 class Popup;
418 Popup * m_popup;
419};
420
421#endif /* KOGUIDES_H */
A point whose coordinates are floating-point values ( "double"s ).
Definition KoPoint.h:30
A rect whose coordinates are floating-point values ( "double"s ).
Definition KoRect.h:31
This class is used to display a KoDocument.
Definition KoView.h:58
This class handles the zooming and DPI stuff (conversions between pt values and pixels).
TDEAction * find(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)