QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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
45class QWT_EXPORT QwtEventPattern
46{
47public:
119
128 {
131
134
137
140
143
146
149
152
155
158
160 KeyPatternCount
161 };
162
165 {
166 public:
168 MousePattern(Qt::MouseButton btn = Qt::NoButton, Qt::KeyboardModifiers modifierCodes = Qt::NoModifier)
169 : button(btn), modifiers(modifierCodes)
170 {
171 }
172
174 Qt::MouseButton button;
175
177 Qt::KeyboardModifiers modifiers;
178 };
179
182 {
183 public:
185 KeyPattern(int keyCode = Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes = Qt::NoModifier)
186 : key(keyCode), modifiers(modifierCodes)
187 {
188 }
189
191 int key;
192
194 Qt::KeyboardModifiers modifiers;
195 };
196
197 // Constructor
199 // Destructor
200 virtual ~QwtEventPattern();
201
202 // Initialize mouse patterns depending on number of mouse buttons
203 void initMousePattern(int numButtons);
204 // Initialize key patterns with default settings
205 void initKeyPattern();
206
207 // Set a single mouse pattern by code
208 void setMousePattern(MousePatternCode, Qt::MouseButton button, Qt::KeyboardModifiers = Qt::NoModifier);
209
210 // Set a single key pattern by code
211 void setKeyPattern(KeyPatternCode, int key, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
212
213 // Set all mouse patterns
214 void setMousePattern(const QVector< MousePattern >&);
215 // Set all key patterns
216 void setKeyPattern(const QVector< KeyPattern >&);
217
218 // Return the mouse pattern vector (const)
219 const QVector< MousePattern >& mousePattern() const;
220 // Return the key pattern vector (const)
221 const QVector< KeyPattern >& keyPattern() const;
222
223 // Return the mouse pattern vector (mutable)
224 QVector< MousePattern >& mousePattern();
225 // Return the key pattern vector (mutable)
226 QVector< KeyPattern >& keyPattern();
227
228 // Check if mouse event matches a pattern code
229 bool mouseMatch(MousePatternCode, const QMouseEvent*) const;
230 // Check if key event matches a pattern code
231 bool keyMatch(KeyPatternCode, const QKeyEvent*) const;
232
233protected:
234 virtual bool mouseMatch(const MousePattern&, const QMouseEvent*) const;
235 virtual bool keyMatch(const KeyPattern&, const QKeyEvent*) const;
236
237private:
238#if defined(_MSC_VER)
239#pragma warning(push)
240#pragma warning(disable : 4251)
241#endif
242 QVector< MousePattern > m_mousePattern;
243 QVector< KeyPattern > m_keyPattern;
244#if defined(_MSC_VER)
245#pragma warning(pop)
246#endif
247};
248
251{
252 return b1.button == b2.button && b1.modifiers == b2.modifiers;
253}
254
256inline bool operator==(QwtEventPattern::KeyPattern b1, QwtEventPattern::KeyPattern b2)
257{
258 return b1.key == b2.key && b1.modifiers == b2.modifiers;
259}
260
261#endif
Definition qwt_clipper.h:41
A pattern for key events
Definition qwt_event_pattern.h:182
Qt::KeyboardModifiers modifiers
Modifiers
Definition qwt_event_pattern.h:194
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor
Definition qwt_event_pattern.h:185
int key
Key code
Definition qwt_event_pattern.h:191
A pattern for mouse events
Definition qwt_event_pattern.h:165
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor
Definition qwt_event_pattern.h:168
Qt::KeyboardModifiers modifiers
Keyboard modifier
Definition qwt_event_pattern.h:177
Qt::MouseButton button
Button
Definition qwt_event_pattern.h:174
A collection of event patterns
Definition qwt_event_pattern.h:46
KeyPatternCode
Symbolic keyboard input codes
Definition qwt_event_pattern.h:128
@ KeyDown
Qt::Key_Down
Definition qwt_event_pattern.h:148
@ KeyUp
Qt::Key_Up
Definition qwt_event_pattern.h:145
@ KeyRedo
Qt::Key_Plus
Definition qwt_event_pattern.h:151
@ KeySelect1
Qt::Key_Return
Definition qwt_event_pattern.h:130
@ KeyHome
Qt::Key_Escape
Definition qwt_event_pattern.h:157
@ KeyAbort
Qt::Key_Escape
Definition qwt_event_pattern.h:136
@ KeyRight
Qt::Key_Right
Definition qwt_event_pattern.h:142
@ KeyUndo
Qt::Key_Minus
Definition qwt_event_pattern.h:154
@ KeyLeft
Qt::Key_Left
Definition qwt_event_pattern.h:139
@ KeySelect2
Qt::Key_Space
Definition qwt_event_pattern.h:133
MousePatternCode
Symbolic mouse input codes
Definition qwt_event_pattern.h:61
@ MouseSelect1
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:69
@ MouseSelect4
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:96
@ MouseSelect3
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:87
@ MouseSelect2
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:78
@ MouseSelect5
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:105
@ MouseSelect6
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:114