F:/KPlato/koffice/libs/kofficeui/KoGuides.h

Aller à la documentation de ce fichier.
00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
00004    Copyright (C) 2005 Casper Boemann Rasmussen <cbr@boemann.dk>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KOGUIDES_H
00023 #define KOGUIDES_H
00024 
00025 #include <QEvent>
00026 #include <QObject>
00027 //Added by qt3to4:
00028 #include <QMouseEvent>
00029 #include <QList>
00030 #include <QKeyEvent>
00031 
00032 #include <koffice_export.h>
00033 
00034 class QPaintDevice;
00035 class KoPoint;
00036 class KoRect;
00037 class KoView;
00038 class KoZoomHandler;
00039 
00040 class KOFFICEUI_EXPORT KoGuides : public QObject
00041 {
00042     Q_OBJECT
00043 public:        
00050     KoGuides( KoView *view, KoZoomHandler *zoomHandler );
00051 
00055     ~KoGuides();
00056         
00062     void paintGuides( QPainter &painter );
00063 
00064     typedef int SnapStatus;
00065     static const SnapStatus SNAP_NONE, SNAP_HORIZ, SNAP_VERT, SNAP_BOTH;
00066 
00084     bool mousePressEvent( QMouseEvent *e );
00085 
00099     bool mouseMoveEvent( QMouseEvent *e );
00100     
00108     bool mouseReleaseEvent( QMouseEvent *e );
00109     
00117     bool keyPressEvent( QKeyEvent *e );
00118 
00127     void setGuideLines( const QList<double> &horizontalPos, const QList<double> &verticalPos );
00128 
00137     void setAutoGuideLines( const QList<double> &horizontalPos, const QList<double> &verticalPos );
00138 
00148     void getGuideLines( QList<double> &horizontalPos, QList<double> &verticalPos ) const;
00149 
00164     void snapToGuideLines( KoRect &rect, int snap, SnapStatus &snapStatus, KoPoint &diff );
00165 
00176     void snapToGuideLines( KoPoint &pos, int snap, SnapStatus &snapStatus, KoPoint &diff );
00177 
00185     void repaintSnapping( const KoRect &snappedRect );
00186 
00194     void repaintSnapping( const KoPoint &snappedPoint, SnapStatus snapStatus );
00195 
00202     void repaintAfterSnapping( );
00203 
00211     void diffNextGuide( KoRect &rect, KoPoint &diff );
00212 
00213 public slots:
00225     void moveGuide( const QPoint &pos, bool horizontal, int rulerWidth );
00226 
00237     void addGuide( const QPoint &pos, bool horizontal, int rulerWidth );
00238 
00239 signals:
00247     void guideLinesChanged( KoView * view );
00248 
00254     void moveGuides( bool state );
00255 
00265     void paintGuides( bool state );
00266 
00267 private slots:
00271     void slotChangePosition();
00272 
00276     void slotRemove();
00277 
00278 private:
00280     struct KoGuideLine 
00281     {
00282         KoGuideLine( Qt::Orientation o, double pos, bool a = false )
00283         : orientation( o )
00284         , position( pos )
00285         , selected( false )
00286         , snapping( false )
00287         , automatic( a )
00288         {}
00289         Qt::Orientation orientation;
00290         double position;
00291         bool selected; // if this guide is selected
00292         bool snapping; // if this guide is being snapped to
00293         bool automatic; // if this is a atomatic guide line
00294     };
00295 
00299     void paint();
00300 
00307     void add( Qt::Orientation o, QPoint &pos );
00308     
00314     void select( KoGuideLine *guideLine );
00315 
00321     void unselect( KoGuideLine *guideLine );
00322         
00329     bool unselectAll();
00330 
00334     void removeSelected();
00335 
00342     bool hasSelected();
00343 
00357     KoGuideLine * find( KoPoint &p, double diff );
00358 
00367     void moveSelectedBy( QPoint &p );
00368 
00376     KoPoint mapFromScreen( const QPoint & pos );
00377 
00385     QPoint mapToScreen( const KoPoint & pos );
00386 
00396     bool virtuallyEqual( double a, double b ) { return QABS( a - b ) < 1E-4; }
00397 
00399     KoView * m_view;
00401     KoZoomHandler * m_zoomHandler;
00402 
00403     enum GuideLineType
00404     {
00405         GL,
00406         GL_SELECTED, 
00407         GL_AUTOMATIC,
00408         GL_END
00409     };
00410 
00412     QList<KoGuideLine *> m_guideLines[GL_END];
00413     
00415     QPoint m_lastPoint;
00417     bool m_mouseSelected;
00419     bool m_insertGuide;
00421     class Popup;
00422     Popup * m_popup;
00423 };
00424 
00425 #endif /* KOGUIDES_H */

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1