Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_EVENT_PATTERN
00011 #define QWT_EVENT_PATTERN 1
00012
00013 #include "qwt_global.h"
00014 #include <qnamespace.h>
00015 #include <qvector.h>
00016
00017 class QMouseEvent;
00018 class QKeyEvent;
00019
00029 class QWT_EXPORT QwtEventPattern
00030 {
00031 public:
00044 enum MousePatternCode
00045 {
00053 MouseSelect1,
00054
00062 MouseSelect2,
00063
00071 MouseSelect3,
00072
00080 MouseSelect4,
00081
00089 MouseSelect5,
00090
00098 MouseSelect6,
00099
00101 MousePatternCount
00102 };
00103
00111 enum KeyPatternCode
00112 {
00114 KeySelect1,
00115
00117 KeySelect2,
00118
00120 KeyAbort,
00121
00123 KeyLeft,
00124
00126 KeyRight,
00127
00129 KeyUp,
00130
00132 KeyDown,
00133
00135 KeyRedo,
00136
00138 KeyUndo,
00139
00141 KeyHome,
00142
00144 KeyPatternCount
00145 };
00146
00148 class MousePattern
00149 {
00150 public:
00152 MousePattern( Qt::MouseButton btn = Qt::NoButton,
00153 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
00154 button( btn ),
00155 modifiers( modifierCodes )
00156 {
00157 }
00158
00160 Qt::MouseButton button;
00161
00163 Qt::KeyboardModifiers modifiers;
00164 };
00165
00167 class KeyPattern
00168 {
00169 public:
00171 KeyPattern( int keyCode = Qt::Key_unknown,
00172 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
00173 key( keyCode ),
00174 modifiers( modifierCodes )
00175 {
00176 }
00177
00179 int key;
00180
00182 Qt::KeyboardModifiers modifiers;
00183 };
00184
00185 QwtEventPattern();
00186 virtual ~QwtEventPattern();
00187
00188 void initMousePattern( int numButtons );
00189 void initKeyPattern();
00190
00191 void setMousePattern( MousePatternCode, Qt::MouseButton button,
00192 Qt::KeyboardModifiers = Qt::NoModifier );
00193
00194 void setKeyPattern( KeyPatternCode, int keyCode,
00195 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier );
00196
00197 void setMousePattern( const QVector<MousePattern> & );
00198 void setKeyPattern( const QVector<KeyPattern> & );
00199
00200 const QVector<MousePattern> &mousePattern() const;
00201 const QVector<KeyPattern> &keyPattern() const;
00202
00203 QVector<MousePattern> &mousePattern();
00204 QVector<KeyPattern> &keyPattern();
00205
00206 bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
00207 bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
00208
00209 protected:
00210 virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
00211 virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
00212
00213 private:
00214
00215 #if defined(_MSC_VER)
00216 #pragma warning(push)
00217 #pragma warning(disable: 4251)
00218 #endif
00219 QVector<MousePattern> d_mousePattern;
00220 QVector<KeyPattern> d_keyPattern;
00221 #if defined(_MSC_VER)
00222 #pragma warning(pop)
00223 #endif
00224 };
00225
00227 inline bool operator==( QwtEventPattern::MousePattern b1,
00228 QwtEventPattern::MousePattern b2 )
00229 {
00230 return b1.button == b2.button && b1.modifiers == b2.modifiers;
00231 }
00232
00234 inline bool operator==( QwtEventPattern::KeyPattern b1,
00235 QwtEventPattern::KeyPattern b2 )
00236 {
00237 return b1.key == b2.key && b1.modifiers == b2.modifiers;
00238 }
00239
00240 #endif