F:/KPlato/koffice/libs/flake/KoPointerEvent.h

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002 
00003    Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
00004    Copyright (C) 2006 Casper Boemann Rasmussen <cbr@boemann.dk>
00005    Copyright (C) 2006 Thomas Zander <zander@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public License
00018    along with this library; see the file COPYING.LIB.  If not, write to
00019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #ifndef KOGFXEVENT_H
00024 #define KOGFXEVENT_H
00025 
00026 #include <QTabletEvent>
00027 #include <QMouseEvent>
00028 #include <QWheelEvent>
00029 
00030 #include <koffice_export.h>
00031 
00039 class FLAKE_EXPORT KoPointerEvent
00040 {
00041 public:
00048     KoPointerEvent( QMouseEvent *ev, const QPointF &pnt )
00049         : point( pnt )
00050         , m_tabletEvent( 0 )
00051         , m_mouseEvent( ev )
00052         , m_wheelEvent( 0 )
00053         , m_event( ev )
00054     {
00055     }
00056 
00063     KoPointerEvent( QTabletEvent *ev, const QPointF &pnt )
00064         : point( pnt )
00065         , m_tabletEvent( ev )
00066         , m_mouseEvent( 0 )
00067         , m_wheelEvent( 0 )
00068         , m_event( ev )
00069     {
00070     }    
00071 
00078     KoPointerEvent( QWheelEvent *ev, const QPointF &pnt )
00079         : point( pnt )
00080         , m_tabletEvent( 0 )
00081         , m_mouseEvent( 0 )
00082         , m_wheelEvent( ev )
00083         , m_event( ev )
00084     {
00085     }    
00091     void accept() { m_event->accept(); }
00092 
00098     void ignore() { m_event->ignore(); }
00099 
00104     Qt::KeyboardModifiers modifiers () const { return m_event->modifiers(); }
00105 
00107     bool isAccepted () const { return m_event->isAccepted(); }
00108 
00110     bool spontaneous () const { return m_event->spontaneous(); }
00111 
00113     Qt::MouseButton button () const 
00114         { 
00115             if (m_mouseEvent)
00116                 return m_mouseEvent->button(); 
00117             else
00118                 return Qt::NoButton;
00119         }
00120 
00122     Qt::MouseButtons buttons () const 
00123         { 
00124             if (m_mouseEvent)
00125                 return m_mouseEvent->buttons(); 
00126             else if (m_wheelEvent)
00127                 return m_wheelEvent->buttons();
00128             else
00129                 return Qt::NoButton;
00130         }
00131 
00132     // Not needed, since we send the event to the right tool. Enable
00133     // as soon as there are tools that do different things depending
00134     // on the type of event. I don't think we checked in Krita tools
00135     // for these values.
00136     //
00137     //TabletDevice device () const 
00138     //PointerType pointerType () const 
00139     //qint64 uniqueId () const 
00140      
00142     const QPoint & globalPos()
00143         {
00144             if (m_mouseEvent)
00145                 return m_mouseEvent->globalPos();
00146             else if (m_wheelEvent)
00147                 return m_wheelEvent->globalPos();
00148             else
00149                 return m_tabletEvent->globalPos();
00150         }
00151 
00153     const QPoint & pos () const 
00154         {
00155             if (m_mouseEvent)
00156                 return m_mouseEvent->pos();
00157             else if (m_wheelEvent)
00158                 return m_wheelEvent->pos();
00159             else
00160                 return m_tabletEvent->pos();
00161         }
00162 
00164     qreal pressure () const 
00165         {
00166             if (m_tabletEvent) 
00167                 return m_tabletEvent->pressure();
00168             else 
00169                 return 1.0;
00170         }
00171 
00173     qreal rotation () const 
00174         {
00175             if (m_tabletEvent)
00176                 return m_tabletEvent->rotation();
00177             else 
00178                 return 0.0;
00179         }
00180 
00188     qreal tangentialPressure () const 
00189         {
00190             if (m_tabletEvent)
00191                 return m_tabletEvent->tangentialPressure();
00192             else
00193                 return 0.0;
00194         }
00195 
00197     int x () const 
00198         {
00199             if (m_tabletEvent)
00200                 return m_tabletEvent->x();
00201             if (m_wheelEvent)
00202                 return m_wheelEvent->x();
00203             else
00204                 return m_mouseEvent->x();
00205         }
00206     
00213     int xTilt () const 
00214         {
00215             if (m_tabletEvent)
00216                 return m_tabletEvent->xTilt();
00217             else
00218                 return 0;
00219         }
00220 
00222     int y () const 
00223         {
00224             if (m_tabletEvent)
00225                 return m_tabletEvent->y();
00226             if (m_wheelEvent)
00227                 return m_wheelEvent->y();
00228             else
00229                 return m_mouseEvent->y();
00230         }
00231 
00238     int yTilt () const 
00239         {
00240             if (m_tabletEvent)
00241                 return m_tabletEvent->yTilt();
00242             else
00243                 return 0;
00244         }
00245 
00251     int z () const
00252         {
00253             if (m_tabletEvent)
00254                 return m_tabletEvent->z();
00255             else
00256                 return 0;
00257         }
00258 
00259     int delta() const 
00260         {
00261             if (m_wheelEvent)
00262                 return m_wheelEvent->delta();
00263             else
00264                 return 0;
00265         }
00266 
00267     Qt::Orientation orientation() const
00268         {
00269             if (m_wheelEvent)
00270                 return m_wheelEvent->orientation();
00271             else
00272                 return Qt::Horizontal;
00273         }
00274 
00276     const QPointF &point;
00277 
00278 private:
00279     QTabletEvent * m_tabletEvent;
00280     QMouseEvent * m_mouseEvent;
00281     QWheelEvent * m_wheelEvent;
00282     QInputEvent * m_event;
00283 };
00284 
00285 #endif /* KOGFXEVENT_H */
00286 

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