Qwt User's Guide: qwt_event_pattern.h Source File

Qwt User's Guide 6.1.6

qwt_event_pattern.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10 #ifndef QWT_EVENT_PATTERN
11 #define QWT_EVENT_PATTERN 1
12
13 #include "qwt_global.h"
14 #include <qnamespace.h>
15 #include <qvector.h>
16
17 class QMouseEvent;
18 class QKeyEvent;
19
29 class QWT_EXPORT QwtEventPattern
30 {
31 public:
44 enum MousePatternCode
45 {
53 MouseSelect1,
54
62 MouseSelect2,
63
71 MouseSelect3,
72
80 MouseSelect4,
81
89 MouseSelect5,
90
98 MouseSelect6,
99
101 MousePatternCount
102 };
103
111 enum KeyPatternCode
112 {
114 KeySelect1,
115
117 KeySelect2,
118
120 KeyAbort,
121
123 KeyLeft,
124
126 KeyRight,
127
129 KeyUp,
130
132 KeyDown,
133
135 KeyRedo,
136
138 KeyUndo,
139
141 KeyHome,
142
144 KeyPatternCount
145 };
146
148 class MousePattern
149 {
150 public:
152 MousePattern( Qt::MouseButton btn = Qt::NoButton,
153 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
154 button( btn ),
155 modifiers( modifierCodes )
156 {
157 }
158
160 Qt::MouseButton button;
161
163 Qt::KeyboardModifiers modifiers;
164 };
165
167 class KeyPattern
168 {
169 public:
171 KeyPattern( int keyCode = Qt::Key_unknown,
172 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
173 key( keyCode ),
174 modifiers( modifierCodes )
175 {
176 }
177
179 int key;
180
182 Qt::KeyboardModifiers modifiers;
183 };
184
185 QwtEventPattern();
186 virtual ~QwtEventPattern();
187
188 void initMousePattern( int numButtons );
189 void initKeyPattern();
190
191 void setMousePattern( MousePatternCode, Qt::MouseButton button,
192 Qt::KeyboardModifiers = Qt::NoModifier );
193
194 void setKeyPattern( KeyPatternCode, int key,
195 Qt::KeyboardModifiers modifiers = Qt::NoModifier );
196
197 void setMousePattern( const QVector<MousePattern> & );
198 void setKeyPattern( const QVector<KeyPattern> & );
199
200 const QVector<MousePattern> &mousePattern() const;
201 const QVector<KeyPattern> &keyPattern() const;
202
203 QVector<MousePattern> &mousePattern();
204 QVector<KeyPattern> &keyPattern();
205
206 bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
207 bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
208
209 protected:
210 virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
211 virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
212
213 private:
214
215 #if defined(_MSC_VER)
216 #pragma warning(push)
217 #pragma warning(disable: 4251)
218 #endif
219 QVector<MousePattern> d_mousePattern;
220 QVector<KeyPattern> d_keyPattern;
221 #if defined(_MSC_VER)
222 #pragma warning(pop)
223 #endif
224 };
225
227 inline bool operator==( QwtEventPattern::MousePattern b1,
228 QwtEventPattern::MousePattern b2 )
229 {
230 return b1.button == b2.button && b1.modifiers == b2.modifiers;
231 }
232
234 inline bool operator==( QwtEventPattern::KeyPattern b1,
235 QwtEventPattern::KeyPattern b2 )
236 {
237 return b1.key == b2.key && b1.modifiers == b2.modifiers;
238 }
239
240 #endif
QwtEventPattern::MouseSelect3
@ MouseSelect3
Definition: qwt_event_pattern.h:71
QwtEventPattern::KeyUndo
@ KeyUndo
Qt::Key_Minus.
Definition: qwt_event_pattern.h:138
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition: qwt_event_pattern.h:163
QwtEventPattern::KeySelect1
@ KeySelect1
Qt::Key_Return.
Definition: qwt_event_pattern.h:114
QwtEventPattern::KeySelect2
@ KeySelect2
Qt::Key_Space.
Definition: qwt_event_pattern.h:117
QwtEventPattern::KeyPattern
A pattern for key events.
Definition: qwt_event_pattern.h:168
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition: qwt_event_pattern.h:160
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:152
QwtEventPattern::KeyAbort
@ KeyAbort
Qt::Key_Escape.
Definition: qwt_event_pattern.h:120
QwtEventPattern::KeyRedo
@ KeyRedo
Qt::Key_Plus.
Definition: qwt_event_pattern.h:135
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:171
QwtEventPattern::MouseSelect5
@ MouseSelect5
Definition: qwt_event_pattern.h:89
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition: qwt_event_pattern.h:149
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition: qwt_event_pattern.h:179
QwtEventPattern::MouseSelect6
@ MouseSelect6
Definition: qwt_event_pattern.h:98
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:30
QwtEventPattern::KeyLeft
@ KeyLeft
Qt::Key_Left.
Definition: qwt_event_pattern.h:123
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition: qwt_event_pattern.h:45
QwtEventPattern::MouseSelect4
@ MouseSelect4
Definition: qwt_event_pattern.h:80
QwtEventPattern::MouseSelect1
@ MouseSelect1
Definition: qwt_event_pattern.h:53
QwtEventPattern::KeyRight
@ KeyRight
Qt::Key_Right.
Definition: qwt_event_pattern.h:126
QwtEventPattern::MouseSelect2
@ MouseSelect2
Definition: qwt_event_pattern.h:62
QwtEventPattern::KeyDown
@ KeyDown
Qt::Key_Down.
Definition: qwt_event_pattern.h:132
QwtEventPattern::KeyHome
@ KeyHome
Qt::Key_Escape.
Definition: qwt_event_pattern.h:141
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition: qwt_event_pattern.h:112
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition: qwt_event_pattern.h:182
QwtEventPattern::KeyUp
@ KeyUp
Qt::Key_Up.
Definition: qwt_event_pattern.h:129