qwt_event_pattern.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_EVENT_PATTERN
#define QWT_EVENT_PATTERN 1
#include "qwt_global.h"
#include <qnamespace.h>
#include <qvector.h>
class QMouseEvent;
class QKeyEvent;
class QWT_EXPORT QwtEventPattern
{
public:
enum MousePatternCode
{
MouseSelect1,
MouseSelect2,
MouseSelect3,
MouseSelect4,
MouseSelect5,
MouseSelect6,
MousePatternCount
};
enum KeyPatternCode
{
KeySelect1,
KeySelect2,
KeyAbort,
KeyLeft,
KeyRight,
KeyUp,
KeyDown,
KeyRedo,
KeyUndo,
KeyHome,
KeyPatternCount
};
class MousePattern
{
public:
MousePattern( Qt::MouseButton btn = Qt::NoButton,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
button( btn ),
modifiers( modifierCodes )
{
}
Qt::MouseButton button;
Qt::KeyboardModifiers modifiers;
};
class KeyPattern
{
public:
KeyPattern( int keyCode = Qt::Key_unknown,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
key( keyCode ),
modifiers( modifierCodes )
{
}
int key;
Qt::KeyboardModifiers modifiers;
};
QwtEventPattern();
virtual ~QwtEventPattern();
void initMousePattern( int numButtons );
void initKeyPattern();
void setMousePattern( MousePatternCode, Qt::MouseButton button,
Qt::KeyboardModifiers = Qt::NoModifier );
void setKeyPattern( KeyPatternCode, int key,
Qt::KeyboardModifiers modifiers = Qt::NoModifier );
void setMousePattern( const QVector<MousePattern> & );
void setKeyPattern( const QVector<KeyPattern> & );
const QVector<MousePattern> &mousePattern() const;
const QVector<KeyPattern> &keyPattern() const;
QVector<MousePattern> &mousePattern();
QVector<KeyPattern> &keyPattern();
bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
protected:
virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
private:
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
QVector<MousePattern> d_mousePattern;
QVector<KeyPattern> d_keyPattern;
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
};
inline bool operator==( QwtEventPattern::MousePattern b1,
QwtEventPattern::MousePattern b2 )
{
return b1.button == b2.button && b1.modifiers == b2.modifiers;
}
inline bool operator==( QwtEventPattern::KeyPattern b1,
QwtEventPattern::KeyPattern b2 )
{
return b1.key == b2.key && b1.modifiers == b2.modifiers;
}
#endif
QwtEventPattern::MouseSelect3
@ MouseSelect3
Definition: qwt_event_pattern.h:71
QwtEventPattern::KeyUndo
@ KeyUndo
Qt::Key_Minus.
Definition: qwt_event_pattern.h:138
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition: qwt_event_pattern.h:163
QwtEventPattern::KeySelect1
@ KeySelect1
Qt::Key_Return.
Definition: qwt_event_pattern.h:114
QwtEventPattern::KeySelect2
@ KeySelect2
Qt::Key_Space.
Definition: qwt_event_pattern.h:117
QwtEventPattern::KeyPattern
A pattern for key events.
Definition: qwt_event_pattern.h:168
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition: qwt_event_pattern.h:160
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:152
QwtEventPattern::KeyAbort
@ KeyAbort
Qt::Key_Escape.
Definition: qwt_event_pattern.h:120
QwtEventPattern::KeyRedo
@ KeyRedo
Qt::Key_Plus.
Definition: qwt_event_pattern.h:135
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:171
QwtEventPattern::MouseSelect5
@ MouseSelect5
Definition: qwt_event_pattern.h:89
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition: qwt_event_pattern.h:149
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition: qwt_event_pattern.h:179
QwtEventPattern::MouseSelect6
@ MouseSelect6
Definition: qwt_event_pattern.h:98
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:30
QwtEventPattern::KeyLeft
@ KeyLeft
Qt::Key_Left.
Definition: qwt_event_pattern.h:123
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition: qwt_event_pattern.h:45
QwtEventPattern::MouseSelect4
@ MouseSelect4
Definition: qwt_event_pattern.h:80
QwtEventPattern::MouseSelect1
@ MouseSelect1
Definition: qwt_event_pattern.h:53
QwtEventPattern::KeyRight
@ KeyRight
Qt::Key_Right.
Definition: qwt_event_pattern.h:126
QwtEventPattern::MouseSelect2
@ MouseSelect2
Definition: qwt_event_pattern.h:62
QwtEventPattern::KeyDown
@ KeyDown
Qt::Key_Down.
Definition: qwt_event_pattern.h:132
QwtEventPattern::KeyHome
@ KeyHome
Qt::Key_Escape.
Definition: qwt_event_pattern.h:141
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition: qwt_event_pattern.h:112
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition: qwt_event_pattern.h:182
QwtEventPattern::KeyUp
@ KeyUp
Qt::Key_Up.
Definition: qwt_event_pattern.h:129