KDEUI
kgesture.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2006,2007 Andreas Hartmetz (ahartmetz@gmail.com) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KGESTURE_H 00021 #define KGESTURE_H 00022 00023 #include <kdeui_export.h> 00024 00025 #include <QtCore/QString> 00026 #include <QtGui/QPolygon> 00027 00028 /* 00029 kinds of gestures: 00030 -shapes like triangle, right angle, line 00031 -"rocker" (i.e. two mouse button) gestures 00032 */ 00033 00034 00035 class KShapeGesturePrivate; 00036 //TODO: implement operator== for special situations like in KKeyChooser. 00037 class KDEUI_EXPORT KShapeGesture 00038 { 00039 public: 00043 KShapeGesture(); 00044 00054 KShapeGesture(const QPolygon &shape); 00055 00060 KShapeGesture(const QString &description); 00061 00066 KShapeGesture(const KShapeGesture &other); 00067 00071 ~KShapeGesture(); 00072 00076 void setShape(const QPolygon &shape); 00077 00081 void setShapeName(const QString &friendlyName); 00082 00086 QString shapeName() const; 00087 00092 bool isValid() const; 00093 00101 QString toString() const; 00102 00110 QByteArray toSvg(const QString &attributes = QString()) const; 00111 00118 float distance(const KShapeGesture &other, float abortThreshold) const; 00119 00123 KShapeGesture &operator=(const KShapeGesture &other); 00124 00128 bool operator==(const KShapeGesture &other) const; 00129 00133 bool operator!=(const KShapeGesture &other) const; 00134 00138 uint hashable() const; 00139 00140 private: 00141 KShapeGesturePrivate * const d; 00142 }; 00143 00144 uint qHash(int); 00145 inline uint qHash(const KShapeGesture &key) 00146 { 00147 return qHash(key.hashable()); 00148 } 00149 00150 class KRockerGesturePrivate; 00151 00152 class KDEUI_EXPORT KRockerGesture 00153 { 00154 public: 00158 KRockerGesture(); 00159 00164 KRockerGesture(enum Qt::MouseButton hold, enum Qt::MouseButton thenPush); 00165 00170 KRockerGesture(const QString &description); 00171 00176 KRockerGesture(const KRockerGesture &other); 00177 00181 ~KRockerGesture(); 00182 00186 void setButtons(Qt::MouseButton hold, Qt::MouseButton thenPush); 00187 00191 void getButtons(Qt::MouseButton *hold, Qt::MouseButton *thenPush) const; 00192 00196 QString rockerName() const; 00197 00201 static QString mouseButtonName(Qt::MouseButton button); 00202 00206 bool isValid() const; 00207 00215 QString toString() const; 00216 00220 KRockerGesture &operator=(const KRockerGesture &other); 00221 00225 bool operator==(const KRockerGesture &other) const; 00226 00230 bool operator!=(const KRockerGesture &other) const; 00231 00235 uint hashable() const; 00236 00237 private: 00238 KRockerGesturePrivate * const d; 00239 }; 00240 00241 inline uint qHash(const KRockerGesture &key) 00242 { 00243 return qHash(key.hashable()); 00244 } 00245 00246 //KGESTURE_H 00247 #endif