Qwt User's Guide: qwt_event_pattern.h Source File

Qwt User's Guide 6.2.0

qwt_event_pattern.h
1 /******************************************************************************
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
12
13 #include "qwt_global.h"
14
15 #include <qnamespace.h>
16 #include <qvector.h>
17
18 class QMouseEvent;
19 class QKeyEvent;
20
30 class QWT_EXPORT QwtEventPattern
31 {
32 public:
45 enum MousePatternCode
46 {
54 MouseSelect1,
55
63 MouseSelect2,
64
72 MouseSelect3,
73
81 MouseSelect4,
82
90 MouseSelect5,
91
99 MouseSelect6,
100
102 MousePatternCount
103 };
104
112 enum KeyPatternCode
113 {
115 KeySelect1,
116
118 KeySelect2,
119
121 KeyAbort,
122
124 KeyLeft,
125
127 KeyRight,
128
130 KeyUp,
131
133 KeyDown,
134
136 KeyRedo,
137
139 KeyUndo,
140
142 KeyHome,
143
145 KeyPatternCount
146 };
147
149 class MousePattern
150 {
151 public:
153 MousePattern( Qt::MouseButton btn = Qt::NoButton,
154 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
155 button( btn ),
156 modifiers( modifierCodes )
157 {
158 }
159
161 Qt::MouseButton button;
162
164 Qt::KeyboardModifiers modifiers;
165 };
166
168 class KeyPattern
169 {
170 public:
172 KeyPattern( int keyCode = Qt::Key_unknown,
173 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
174 key( keyCode ),
175 modifiers( modifierCodes )
176 {
177 }
178
180 int key;
181
183 Qt::KeyboardModifiers modifiers;
184 };
185
186 QwtEventPattern();
187 virtual ~QwtEventPattern();
188
189 void initMousePattern( int numButtons );
190 void initKeyPattern();
191
192 void setMousePattern( MousePatternCode, Qt::MouseButton button,
193 Qt::KeyboardModifiers = Qt::NoModifier );
194
195 void setKeyPattern( KeyPatternCode, int key,
196 Qt::KeyboardModifiers modifiers = Qt::NoModifier );
197
198 void setMousePattern( const QVector< MousePattern >& );
199 void setKeyPattern( const QVector< KeyPattern >& );
200
201 const QVector< MousePattern >& mousePattern() const;
202 const QVector< KeyPattern >& keyPattern() const;
203
204 QVector< MousePattern >& mousePattern();
205 QVector< KeyPattern >& keyPattern();
206
207 bool mouseMatch( MousePatternCode, const QMouseEvent* ) const;
208 bool keyMatch( KeyPatternCode, const QKeyEvent* ) const;
209
210 protected:
211 virtual bool mouseMatch( const MousePattern&, const QMouseEvent* ) const;
212 virtual bool keyMatch( const KeyPattern&, const QKeyEvent* ) const;
213
214 private:
215
216 #if defined( _MSC_VER )
217 #pragma warning(push)
218 #pragma warning(disable: 4251)
219 #endif
220 QVector< MousePattern > m_mousePattern;
221 QVector< KeyPattern > m_keyPattern;
222 #if defined( _MSC_VER )
223 #pragma warning(pop)
224 #endif
225 };
226
228 inline bool operator==( QwtEventPattern::MousePattern b1,
229 QwtEventPattern::MousePattern b2 )
230 {
231 return b1.button == b2.button && b1.modifiers == b2.modifiers;
232 }
233
235 inline bool operator==( QwtEventPattern::KeyPattern b1,
236 QwtEventPattern::KeyPattern b2 )
237 {
238 return b1.key == b2.key && b1.modifiers == b2.modifiers;
239 }
240
241 #endif
QVector
Definition: qwt_clipper.h:23
QwtEventPattern::KeyPattern
A pattern for key events.
Definition: qwt_event_pattern.h:169
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition: qwt_event_pattern.h:183
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:172
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition: qwt_event_pattern.h:180
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition: qwt_event_pattern.h:150
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:153
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition: qwt_event_pattern.h:164
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition: qwt_event_pattern.h:161
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:31
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition: qwt_event_pattern.h:113
QwtEventPattern::KeyDown
@ KeyDown
Qt::Key_Down.
Definition: qwt_event_pattern.h:133
QwtEventPattern::KeyUp
@ KeyUp
Qt::Key_Up.
Definition: qwt_event_pattern.h:130
QwtEventPattern::KeyRedo
@ KeyRedo
Qt::Key_Plus.
Definition: qwt_event_pattern.h:136
QwtEventPattern::KeySelect1
@ KeySelect1
Qt::Key_Return.
Definition: qwt_event_pattern.h:115
QwtEventPattern::KeyHome
@ KeyHome
Qt::Key_Escape.
Definition: qwt_event_pattern.h:142
QwtEventPattern::KeyAbort
@ KeyAbort
Qt::Key_Escape.
Definition: qwt_event_pattern.h:121
QwtEventPattern::KeyRight
@ KeyRight
Qt::Key_Right.
Definition: qwt_event_pattern.h:127
QwtEventPattern::KeyUndo
@ KeyUndo
Qt::Key_Minus.
Definition: qwt_event_pattern.h:139
QwtEventPattern::KeyLeft
@ KeyLeft
Qt::Key_Left.
Definition: qwt_event_pattern.h:124
QwtEventPattern::KeySelect2
@ KeySelect2
Qt::Key_Space.
Definition: qwt_event_pattern.h:118
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition: qwt_event_pattern.h:46
QwtEventPattern::MouseSelect1
@ MouseSelect1
Definition: qwt_event_pattern.h:54
QwtEventPattern::MouseSelect4
@ MouseSelect4
Definition: qwt_event_pattern.h:81
QwtEventPattern::MouseSelect3
@ MouseSelect3
Definition: qwt_event_pattern.h:72
QwtEventPattern::MouseSelect2
@ MouseSelect2
Definition: qwt_event_pattern.h:63
QwtEventPattern::MouseSelect5
@ MouseSelect5
Definition: qwt_event_pattern.h:90
QwtEventPattern::MouseSelect6
@ MouseSelect6
Definition: qwt_event_pattern.h:99