Qwt User's Guide 6.1.2

- Main Page
- Related Pages
- Classes

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
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 keyCode,
195 Qt::KeyboardModifiers modifierCodes = 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::MouseSelect1
Definition: qwt_event_pattern.h:53
QwtEventPattern::KeyPattern
A pattern for key events.
Definition: qwt_event_pattern.h:167
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:152
QwtEventPattern::KeySelect1
Qt::Key_Return.
Definition: qwt_event_pattern.h:114
QwtEventPattern::KeyDown
Qt::Key_Down.
Definition: qwt_event_pattern.h:132
QwtEventPattern::KeySelect2
Qt::Key_Space.
Definition: qwt_event_pattern.h:117
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition: qwt_event_pattern.h:44
QwtEventPattern::MouseSelect2
Definition: qwt_event_pattern.h:62
QwtEventPattern::KeyHome
Qt::Key_Escape.
Definition: qwt_event_pattern.h:141
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition: qwt_event_pattern.h:163
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:29
QwtEventPattern::KeyAbort
Qt::Key_Escape.
Definition: qwt_event_pattern.h:120
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition: qwt_event_pattern.h:182
QwtEventPattern::KeyUp
Qt::Key_Up.
Definition: qwt_event_pattern.h:129
QwtEventPattern::KeyLeft
Qt::Key_Left.
Definition: qwt_event_pattern.h:123
QwtEventPattern::KeyUndo
Qt::Key_Minus.
Definition: qwt_event_pattern.h:138
QwtEventPattern::KeyRight
Qt::Key_Right.
Definition: qwt_event_pattern.h:126
QwtEventPattern::MouseSelect4
Definition: qwt_event_pattern.h:80
QwtEventPattern::KeyRedo
Qt::Key_Plus.
Definition: qwt_event_pattern.h:135
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition: qwt_event_pattern.h:111
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition: qwt_event_pattern.h:148
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition: qwt_event_pattern.h:160
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:171
QwtEventPattern::MouseSelect3
Definition: qwt_event_pattern.h:71
QwtEventPattern::MouseSelect5
Definition: qwt_event_pattern.h:89
QwtEventPattern::MouseSelect6
Definition: qwt_event_pattern.h:98
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition: qwt_event_pattern.h:179