lib
KoGuides.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KOGUIDES_H
00023 #define KOGUIDES_H
00024
00025 #include <qevent.h>
00026 #include <qobject.h>
00027
00028 #include <koffice_export.h>
00029
00030 class QPaintDevice;
00031 class KoPoint;
00032 class KoRect;
00033 class KoView;
00034 class KoZoomHandler;
00035
00036 class KOFFICEUI_EXPORT KoGuides : public QObject
00037 {
00038 Q_OBJECT
00039 public:
00046 KoGuides( KoView *view, KoZoomHandler *zoomHandler );
00047
00051 ~KoGuides();
00052
00058 void paintGuides( QPainter &painter );
00059
00060 typedef int SnapStatus;
00061 static const SnapStatus SNAP_NONE, SNAP_HORIZ, SNAP_VERT, SNAP_BOTH;
00062
00080 bool mousePressEvent( QMouseEvent *e );
00081
00095 bool mouseMoveEvent( QMouseEvent *e );
00096
00104 bool mouseReleaseEvent( QMouseEvent *e );
00105
00113 bool keyPressEvent( QKeyEvent *e );
00114
00123 void setGuideLines( const QValueList<double> &horizontalPos, const QValueList<double> &verticalPos );
00124
00133 void setAutoGuideLines( const QValueList<double> &horizontalPos, const QValueList<double> &verticalPos );
00134
00144 void getGuideLines( QValueList<double> &horizontalPos, QValueList<double> &verticalPos ) const;
00145
00160 void snapToGuideLines( KoRect &rect, int snap, SnapStatus &snapStatus, KoPoint &diff );
00161
00172 void snapToGuideLines( KoPoint &pos, int snap, SnapStatus &snapStatus, KoPoint &diff );
00173
00181 void repaintSnapping( const KoRect &snappedRect );
00182
00190 void repaintSnapping( const KoPoint &snappedPoint, SnapStatus snapStatus );
00191
00198 void repaintAfterSnapping( );
00199
00207 void diffNextGuide( KoRect &rect, KoPoint &diff );
00208
00209 public slots:
00221 void moveGuide( const QPoint &pos, bool horizontal, int rulerWidth );
00222
00233 void addGuide( const QPoint &pos, bool horizontal, int rulerWidth );
00234
00235 signals:
00243 void guideLinesChanged( KoView * view );
00244
00250 void moveGuides( bool state );
00251
00261 void paintGuides( bool state );
00262
00263 private slots:
00267 void slotChangePosition();
00268
00272 void slotRemove();
00273
00274 private:
00276 struct KoGuideLine
00277 {
00278 KoGuideLine( Qt::Orientation o, double pos, bool a = false )
00279 : orientation( o )
00280 , position( pos )
00281 , selected( false )
00282 , snapping( false )
00283 , automatic( a )
00284 {}
00285 Qt::Orientation orientation;
00286 double position;
00287 bool selected;
00288 bool snapping;
00289 bool automatic;
00290 };
00291
00295 void paint();
00296
00303 void add( Qt::Orientation o, QPoint &pos );
00304
00310 void select( KoGuideLine *guideLine );
00311
00317 void unselect( KoGuideLine *guideLine );
00318
00325 bool unselectAll();
00326
00330 void removeSelected();
00331
00338 bool hasSelected();
00339
00353 KoGuideLine * find( KoPoint &p, double diff );
00354
00363 void moveSelectedBy( QPoint &p );
00364
00372 KoPoint mapFromScreen( const QPoint & pos );
00373
00381 QPoint mapToScreen( const KoPoint & pos );
00382
00392 bool virtuallyEqual( double a, double b ) { return QABS( a - b ) < 1E-4; }
00393
00395 KoView * m_view;
00397 KoZoomHandler * m_zoomHandler;
00398
00399 enum GuideLineType
00400 {
00401 GL,
00402 GL_SELECTED,
00403 GL_AUTOMATIC,
00404 GL_END
00405 };
00406
00408 QValueList<KoGuideLine *> m_guideLines[GL_END];
00409
00411 QPoint m_lastPoint;
00413 bool m_mouseSelected;
00415 bool m_insertGuide;
00417 class Popup;
00418 Popup * m_popup;
00419 };
00420
00421 #endif
|