1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
10
#ifndef QWT_EVENT_PATTERN
11
#define QWT_EVENT_PATTERN 1
13
#include "qwt_global.h"
14
#include <qnamespace.h>
21
\brief A collection of event patterns
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.
27
\sa QwtPicker, QwtPickerMachine, QwtPlotZoomer
29
class QWT_EXPORT QwtEventPattern
33
\brief Symbolic mouse input codes
35
The default initialization for 3 button mice is:
43
Qt::LeftButton + Qt::ShiftButton
45
Qt::RightButton + Qt::ShiftButton
47
Qt::MidButton + Qt::ShiftButton
49
The default initialization for 2 button mice is:
55
Qt::LeftButton + Qt::AltButton
57
Qt::LeftButton + Qt::ShiftButton
59
Qt::RightButton + Qt::ShiftButton
61
Qt::LeftButton + Qt::AltButton + Qt::ShiftButton
63
The default initialization for 1 button mice is:
67
Qt::LeftButton + Qt::ControlButton
69
Qt::LeftButton + Qt::AltButton
71
Qt::LeftButton + Qt::ShiftButton
73
Qt::LeftButton + Qt::ControlButton + Qt::ShiftButton
75
Qt::LeftButton + Qt::AltButton + Qt::ShiftButton
77
\sa initMousePattern()
93
\brief Symbolic keyboard input codes
95
Default initialization:
137
//! A pattern for mouse events
142
MousePattern( int btn = Qt::NoButton, int st = Qt::NoButton )
155
//! A pattern for key events
160
KeyPattern( int k = 0, int st = Qt::NoButton )
174
virtual ~QwtEventPattern();
176
void initMousePattern( int numButtons );
177
void initKeyPattern();
179
void setMousePattern( uint pattern, int button, int state = Qt::NoButton );
180
void setKeyPattern( uint pattern, int key, int state = Qt::NoButton );
182
void setMousePattern( const QVector<MousePattern> & );
183
void setKeyPattern( const QVector<KeyPattern> & );
185
const QVector<MousePattern> &mousePattern() const;
186
const QVector<KeyPattern> &keyPattern() const;
188
QVector<MousePattern> &mousePattern();
189
QVector<KeyPattern> &keyPattern();
191
bool mouseMatch( uint pattern, const QMouseEvent * ) const;
192
bool keyMatch( uint pattern, const QKeyEvent * ) const;
195
virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
196
virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
200
#if defined(_MSC_VER)
201
#pragma warning(push)
202
#pragma warning(disable: 4251)
204
QVector<MousePattern> d_mousePattern;
205
QVector<KeyPattern> d_keyPattern;
206
#if defined(_MSC_VER)
212
inline bool operator==( QwtEventPattern::MousePattern b1,
213
QwtEventPattern::MousePattern b2 )
215
return b1.button == b2.button && b1.state == b2.state;
219
inline bool operator==( QwtEventPattern::KeyPattern b1,
220
QwtEventPattern::KeyPattern b2 )
222
return b1.key == b2.key && b1.state == b2.state;