QWT API (中文) 7.0.1
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
53class QWT_EXPORT QwtEventPattern
54{
55 public:
127
136 {
139
142
145
148
151
154
157
160
163
166
168 KeyPatternCount
169 };
170
173 {
174 public:
176 MousePattern( Qt::MouseButton btn = Qt::NoButton,
177 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
178 button( btn ),
179 modifiers( modifierCodes )
180 {
181 }
182
184 Qt::MouseButton button;
185
187 Qt::KeyboardModifiers modifiers;
188 };
189
192 {
193 public:
195 KeyPattern( int keyCode = Qt::Key_unknown,
196 Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
197 key( keyCode ),
198 modifiers( modifierCodes )
199 {
200 }
201
203 int key;
204
206 Qt::KeyboardModifiers modifiers;
207 };
208
209 // Constructor
211 // Destructor
212 virtual ~QwtEventPattern();
213
214 // Initialize mouse patterns depending on number of mouse buttons
215 void initMousePattern( int numButtons );
216 // Initialize key patterns with default settings
217 void initKeyPattern();
218
219 // Set a single mouse pattern by code
220 void setMousePattern( MousePatternCode, Qt::MouseButton button,
221 Qt::KeyboardModifiers = Qt::NoModifier );
222
223 // Set a single key pattern by code
224 void setKeyPattern( KeyPatternCode, int key,
225 Qt::KeyboardModifiers modifiers = Qt::NoModifier );
226
227 // Set all mouse patterns
228 void setMousePattern( const QVector< MousePattern >& );
229 // Set all key patterns
230 void setKeyPattern( const QVector< KeyPattern >& );
231
232 // Return the mouse pattern vector (const)
233 const QVector< MousePattern >& mousePattern() const;
234 // Return the key pattern vector (const)
235 const QVector< KeyPattern >& keyPattern() const;
236
237 // Return the mouse pattern vector (mutable)
238 QVector< MousePattern >& mousePattern();
239 // Return the key pattern vector (mutable)
240 QVector< KeyPattern >& keyPattern();
241
242 // Check if mouse event matches a pattern code
243 bool mouseMatch( MousePatternCode, const QMouseEvent* ) const;
244 // Check if key event matches a pattern code
245 bool keyMatch( KeyPatternCode, const QKeyEvent* ) const;
246
247 protected:
248 virtual bool mouseMatch( const MousePattern&, const QMouseEvent* ) const;
249 virtual bool keyMatch( const KeyPattern&, const QKeyEvent* ) const;
250
251 private:
252
253#if defined( _MSC_VER )
254#pragma warning(push)
255#pragma warning(disable: 4251)
256#endif
257 QVector< MousePattern > m_mousePattern;
258 QVector< KeyPattern > m_keyPattern;
259#if defined( _MSC_VER )
260#pragma warning(pop)
261#endif
262};
263
265inline bool operator==( QwtEventPattern::MousePattern b1,
267{
268 return b1.button == b2.button && b1.modifiers == b2.modifiers;
269}
270
272inline bool operator==( QwtEventPattern::KeyPattern b1,
274{
275 return b1.key == b2.key && b1.modifiers == b2.modifiers;
276}
277
278#endif
Definition qwt_clipper.h:40
A pattern for key events
Definition qwt_event_pattern.h:192
Qt::KeyboardModifiers modifiers
Modifiers
Definition qwt_event_pattern.h:206
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor
Definition qwt_event_pattern.h:195
int key
Key code
Definition qwt_event_pattern.h:203
A pattern for mouse events
Definition qwt_event_pattern.h:173
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor
Definition qwt_event_pattern.h:176
Qt::KeyboardModifiers modifiers
Keyboard modifier
Definition qwt_event_pattern.h:187
Qt::MouseButton button
Button
Definition qwt_event_pattern.h:184
事件模式的集合
Definition qwt_event_pattern.h:54
KeyPatternCode
Symbolic keyboard input codes
Definition qwt_event_pattern.h:136
@ KeyDown
Qt::Key_Down
Definition qwt_event_pattern.h:156
@ KeyUp
Qt::Key_Up
Definition qwt_event_pattern.h:153
@ KeyRedo
Qt::Key_Plus
Definition qwt_event_pattern.h:159
@ KeySelect1
Qt::Key_Return
Definition qwt_event_pattern.h:138
@ KeyHome
Qt::Key_Escape
Definition qwt_event_pattern.h:165
@ KeyAbort
Qt::Key_Escape
Definition qwt_event_pattern.h:144
@ KeyRight
Qt::Key_Right
Definition qwt_event_pattern.h:150
@ KeyUndo
Qt::Key_Minus
Definition qwt_event_pattern.h:162
@ KeyLeft
Qt::Key_Left
Definition qwt_event_pattern.h:147
@ KeySelect2
Qt::Key_Space
Definition qwt_event_pattern.h:141
MousePatternCode
Symbolic mouse input codes
Definition qwt_event_pattern.h:69
@ MouseSelect1
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:77
@ MouseSelect4
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:104
@ MouseSelect3
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:95
@ MouseSelect2
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:86
@ MouseSelect5
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:113
@ MouseSelect6
The default setting for 1, 2 and 3 button mice is:
Definition qwt_event_pattern.h:122