QWT 7.0.1
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_EVENT_PATTERN
28#define QWT_EVENT_PATTERN
29
30#include "qwt_global.h"
31
32#include <qnamespace.h>
33#include <qvector.h>
34
35class QMouseEvent;
36class QKeyEvent;
37
47class QWT_EXPORT QwtEventPattern
48{
49 public:
121
130 {
133
136
139
142
145
148
151
154
157
160
162 KeyPatternCount
163 };
164
167 {
168 public:
170 MousePattern( Qt::MouseButton btn = Qt::NoButton,
171 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
172 button( btn ),
173 modifiers( modifierCodes )
174 {
175 }
176
178 Qt::MouseButton button;
179
181 Qt::KeyboardModifiers modifiers;
182 };
183
186 {
187 public:
189 KeyPattern( int keyCode = Qt::Key_unknown,
190 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
191 key( keyCode ),
192 modifiers( modifierCodes )
193 {
194 }
195
197 int key;
198
200 Qt::KeyboardModifiers modifiers;
201 };
202
204 virtual ~QwtEventPattern();
205
206 void initMousePattern( int numButtons );
207 void initKeyPattern();
208
209 void setMousePattern( MousePatternCode, Qt::MouseButton button,
210 Qt::KeyboardModifiers = Qt::NoModifier );
211
212 void setKeyPattern( KeyPatternCode, int key,
213 Qt::KeyboardModifiers modifiers = Qt::NoModifier );
214
215 void setMousePattern( const QVector< MousePattern >& );
216 void setKeyPattern( const QVector< KeyPattern >& );
217
218 const QVector< MousePattern >& mousePattern() const;
219 const QVector< KeyPattern >& keyPattern() const;
220
221 QVector< MousePattern >& mousePattern();
222 QVector< KeyPattern >& keyPattern();
223
224 bool mouseMatch( MousePatternCode, const QMouseEvent* ) const;
225 bool keyMatch( KeyPatternCode, const QKeyEvent* ) const;
226
227 protected:
228 virtual bool mouseMatch( const MousePattern&, const QMouseEvent* ) const;
229 virtual bool keyMatch( const KeyPattern&, const QKeyEvent* ) const;
230
231 private:
232
233#if defined( _MSC_VER )
234#pragma warning(push)
235#pragma warning(disable: 4251)
236#endif
237 QVector< MousePattern > m_mousePattern;
238 QVector< KeyPattern > m_keyPattern;
239#if defined( _MSC_VER )
240#pragma warning(pop)
241#endif
242};
243
245inline bool operator==( QwtEventPattern::MousePattern b1,
247{
248 return b1.button == b2.button && b1.modifiers == b2.modifiers;
249}
250
252inline bool operator==( QwtEventPattern::KeyPattern b1,
254{
255 return b1.key == b2.key && b1.modifiers == b2.modifiers;
256}
257
258#endif
Definition qwt_clipper.h:40
A pattern for key events.
Definition qwt_event_pattern.h:186
Qt::KeyboardModifiers modifiers
Modifiers.
Definition qwt_event_pattern.h:200
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition qwt_event_pattern.h:189
int key
Key code.
Definition qwt_event_pattern.h:197
A pattern for mouse events.
Definition qwt_event_pattern.h:167
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition qwt_event_pattern.h:170
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition qwt_event_pattern.h:181
Qt::MouseButton button
Button.
Definition qwt_event_pattern.h:178
A collection of event patterns.
Definition qwt_event_pattern.h:48
KeyPatternCode
Symbolic keyboard input codes.
Definition qwt_event_pattern.h:130
@ KeyDown
Qt::Key_Down.
Definition qwt_event_pattern.h:150
@ KeyUp
Qt::Key_Up.
Definition qwt_event_pattern.h:147
@ KeyRedo
Qt::Key_Plus.
Definition qwt_event_pattern.h:153
@ KeySelect1
Qt::Key_Return.
Definition qwt_event_pattern.h:132
@ KeyHome
Qt::Key_Escape.
Definition qwt_event_pattern.h:159
@ KeyAbort
Qt::Key_Escape.
Definition qwt_event_pattern.h:138
@ KeyRight
Qt::Key_Right.
Definition qwt_event_pattern.h:144
@ KeyUndo
Qt::Key_Minus.
Definition qwt_event_pattern.h:156
@ KeyLeft
Qt::Key_Left.
Definition qwt_event_pattern.h:141
@ KeySelect2
Qt::Key_Space.
Definition qwt_event_pattern.h:135
MousePatternCode
Symbolic mouse input codes.
Definition qwt_event_pattern.h:63
@ MouseSelect1
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:71
@ MouseSelect4
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:98
@ MouseSelect3
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:89
@ MouseSelect2
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:80
@ MouseSelect5
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:107
@ MouseSelect6
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:116