source: ntrip/trunk/BNC/qwt/qwt_event_pattern.h@ 9267

Last change on this file since 9267 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 5.8 KB
RevLine 
[4271]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
17class QMouseEvent;
18class QKeyEvent;
19
20/*!
21 \brief A collection of event patterns
22
23 QwtEventPattern introduces an level of indirection for mouse and
24 keyboard inputs. Those are represented by symbolic names, so
25 the application code can be configured by individual mappings.
26
27 \sa QwtPicker, QwtPickerMachine, QwtPlotZoomer
28*/
29class QWT_EXPORT QwtEventPattern
30{
31public:
32 /*!
33 \brief Symbolic mouse input codes
34
[8127]35 QwtEventPattern implements 3 different settings for
36 mice with 1, 2, or 3 buttons that can be activated
37 using initMousePattern(). The default setting is for
38 3 button mice.
[4271]39
[8127]40 Individual settings can be configured using setMousePattern().
[4271]41
[8127]42 \sa initMousePattern(), setMousePattern(), setKeyPattern()
[4271]43 */
44 enum MousePatternCode
45 {
[8127]46 /*!
47 The default setting for 1, 2 and 3 button mice is:
48
49 - Qt::LeftButton
50 - Qt::LeftButton
51 - Qt::LeftButton
52 */
[4271]53 MouseSelect1,
[8127]54
55 /*!
56 The default setting for 1, 2 and 3 button mice is:
57
58 - Qt::LeftButton + Qt::ControlModifier
59 - Qt::RightButton
60 - Qt::RightButton
61 */
[4271]62 MouseSelect2,
[8127]63
64 /*!
65 The default setting for 1, 2 and 3 button mice is:
66
67 - Qt::LeftButton + Qt::AltModifier
68 - Qt::LeftButton + Qt::AltModifier
69 - Qt::MidButton
70 */
[4271]71 MouseSelect3,
[8127]72
73 /*!
74 The default setting for 1, 2 and 3 button mice is:
75
76 - Qt::LeftButton + Qt::ShiftModifier
77 - Qt::LeftButton + Qt::ShiftModifier
78 - Qt::LeftButton + Qt::ShiftModifier
79 */
[4271]80 MouseSelect4,
[8127]81
82 /*!
83 The default setting for 1, 2 and 3 button mice is:
84
85 - Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier
86 - Qt::RightButton + Qt::ShiftModifier
87 - Qt::RightButton + Qt::ShiftModifier
88 */
[4271]89 MouseSelect5,
[8127]90
91 /*!
92 The default setting for 1, 2 and 3 button mice is:
93
94 - Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier
95 - Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier
96 - Qt::MidButton + Qt::ShiftModifier
97 */
[4271]98 MouseSelect6,
99
[8127]100 //! Number of mouse patterns
[4271]101 MousePatternCount
102 };
103
104 /*!
105 \brief Symbolic keyboard input codes
106
[8127]107 Individual settings can be configured using setKeyPattern()
[4271]108
[8127]109 \sa setKeyPattern(), setMousePattern()
[4271]110 */
111 enum KeyPatternCode
112 {
[8127]113 //! Qt::Key_Return
[4271]114 KeySelect1,
[8127]115
116 //! Qt::Key_Space
[4271]117 KeySelect2,
[8127]118
119 //! Qt::Key_Escape
[4271]120 KeyAbort,
121
[8127]122 //! Qt::Key_Left
[4271]123 KeyLeft,
[8127]124
125 //! Qt::Key_Right
[4271]126 KeyRight,
[8127]127
128 //! Qt::Key_Up
[4271]129 KeyUp,
[8127]130
131 //! Qt::Key_Down
[4271]132 KeyDown,
133
[8127]134 //! Qt::Key_Plus
[4271]135 KeyRedo,
[8127]136
137 //! Qt::Key_Minus
[4271]138 KeyUndo,
[8127]139
140 //! Qt::Key_Escape
[4271]141 KeyHome,
142
[8127]143 //! Number of key patterns
[4271]144 KeyPatternCount
145 };
146
147 //! A pattern for mouse events
148 class MousePattern
149 {
150 public:
151 //! Constructor
[8127]152 MousePattern( Qt::MouseButton btn = Qt::NoButton,
153 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
154 button( btn ),
155 modifiers( modifierCodes )
[4271]156 {
157 }
158
[8127]159 //! Button
160 Qt::MouseButton button;
[4271]161
[8127]162 //! Keyboard modifier
163 Qt::KeyboardModifiers modifiers;
[4271]164 };
165
166 //! A pattern for key events
167 class KeyPattern
168 {
169 public:
170 //! Constructor
[8127]171 KeyPattern( int keyCode = Qt::Key_unknown,
172 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
173 key( keyCode ),
174 modifiers( modifierCodes )
[4271]175 {
176 }
177
178 //! Key code
179 int key;
180
[8127]181 //! Modifiers
182 Qt::KeyboardModifiers modifiers;
[4271]183 };
184
185 QwtEventPattern();
186 virtual ~QwtEventPattern();
187
188 void initMousePattern( int numButtons );
189 void initKeyPattern();
190
[8127]191 void setMousePattern( MousePatternCode, Qt::MouseButton button,
192 Qt::KeyboardModifiers = Qt::NoModifier );
[4271]193
[8127]194 void setKeyPattern( KeyPatternCode, int keyCode,
195 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier );
196
[4271]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
[8127]206 bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
207 bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
[4271]208
209protected:
210 virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
211 virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
212
213private:
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
226//! Compare operator
227inline bool operator==( QwtEventPattern::MousePattern b1,
228 QwtEventPattern::MousePattern b2 )
229{
[8127]230 return b1.button == b2.button && b1.modifiers == b2.modifiers;
[4271]231}
232
233//! Compare operator
234inline bool operator==( QwtEventPattern::KeyPattern b1,
235 QwtEventPattern::KeyPattern b2 )
236{
[8127]237 return b1.key == b2.key && b1.modifiers == b2.modifiers;
[4271]238}
239
240#endif
Note: See TracBrowser for help on using the repository browser.