Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
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
18class QMouseEvent;
19class QKeyEvent;
20
30class QWT_EXPORT QwtEventPattern
31{
32 public:
104
113 {
116
119
122
125
128
131
134
137
140
143
145 KeyPatternCount
146 };
147
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
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
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
228inline bool operator==( QwtEventPattern::MousePattern b1,
230{
231 return b1.button == b2.button && b1.modifiers == b2.modifiers;
232}
233
235inline bool operator==( QwtEventPattern::KeyPattern b1,
237{
238 return b1.key == b2.key && b1.modifiers == b2.modifiers;
239}
240
241#endif
A pattern for key events.
Qt::KeyboardModifiers modifiers
Modifiers.
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
A pattern for mouse events.
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Qt::MouseButton button
Button.
A collection of event patterns.
KeyPatternCode
Symbolic keyboard input codes.
@ KeyDown
Qt::Key_Down.
@ KeyRedo
Qt::Key_Plus.
@ KeySelect1
Qt::Key_Return.
@ KeyHome
Qt::Key_Escape.
@ KeyAbort
Qt::Key_Escape.
@ KeyRight
Qt::Key_Right.
@ KeyUndo
Qt::Key_Minus.
@ KeyLeft
Qt::Key_Left.
@ KeySelect2
Qt::Key_Space.
MousePatternCode
Symbolic mouse input codes.