source: ntrip/branches/BNC_2.13.beta/qwt/qwt_event_pattern.h@ 10132

Last change on this file since 10132 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 5.8 KB
Line 
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
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.
39
40 Individual settings can be configured using setMousePattern().
41
42 \sa initMousePattern(), setMousePattern(), setKeyPattern()
43 */
44 enum MousePatternCode
45 {
46 /*!
47 The default setting for 1, 2 and 3 button mice is:
48
49 - Qt::LeftButton
50 - Qt::LeftButton
51 - Qt::LeftButton
52 */
53 MouseSelect1,
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 */
62 MouseSelect2,
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 */
71 MouseSelect3,
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 */
80 MouseSelect4,
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 */
89 MouseSelect5,
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 */
98 MouseSelect6,
99
100 //! Number of mouse patterns
101 MousePatternCount
102 };
103
104 /*!
105 \brief Symbolic keyboard input codes
106
107 Individual settings can be configured using setKeyPattern()
108
109 \sa setKeyPattern(), setMousePattern()
110 */
111 enum KeyPatternCode
112 {
113 //! Qt::Key_Return
114 KeySelect1,
115
116 //! Qt::Key_Space
117 KeySelect2,
118
119 //! Qt::Key_Escape
120 KeyAbort,
121
122 //! Qt::Key_Left
123 KeyLeft,
124
125 //! Qt::Key_Right
126 KeyRight,
127
128 //! Qt::Key_Up
129 KeyUp,
130
131 //! Qt::Key_Down
132 KeyDown,
133
134 //! Qt::Key_Plus
135 KeyRedo,
136
137 //! Qt::Key_Minus
138 KeyUndo,
139
140 //! Qt::Key_Escape
141 KeyHome,
142
143 //! Number of key patterns
144 KeyPatternCount
145 };
146
147 //! A pattern for mouse events
148 class MousePattern
149 {
150 public:
151 //! Constructor
152 MousePattern( Qt::MouseButton btn = Qt::NoButton,
153 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
154 button( btn ),
155 modifiers( modifierCodes )
156 {
157 }
158
159 //! Button
160 Qt::MouseButton button;
161
162 //! Keyboard modifier
163 Qt::KeyboardModifiers modifiers;
164 };
165
166 //! A pattern for key events
167 class KeyPattern
168 {
169 public:
170 //! Constructor
171 KeyPattern( int keyCode = Qt::Key_unknown,
172 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
173 key( keyCode ),
174 modifiers( modifierCodes )
175 {
176 }
177
178 //! Key code
179 int key;
180
181 //! Modifiers
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
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{
230 return b1.button == b2.button && b1.modifiers == b2.modifiers;
231}
232
233//! Compare operator
234inline bool operator==( QwtEventPattern::KeyPattern b1,
235 QwtEventPattern::KeyPattern b2 )
236{
237 return b1.key == b2.key && b1.modifiers == b2.modifiers;
238}
239
240#endif
Note: See TracBrowser for help on using the repository browser.