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 keyCode,
Qt::KeyboardModifiers modifierCodes = 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::MouseSelect1
Definition: qwt_event_pattern.h:53
QwtEventPattern::KeyPattern
A pattern for key events.
Definition: qwt_event_pattern.h:167
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:152
QwtEventPattern::KeySelect1
Qt::Key_Return.
Definition: qwt_event_pattern.h:114
QwtEventPattern::KeyDown
Qt::Key_Down.
Definition: qwt_event_pattern.h:132
QwtEventPattern::KeySelect2
Qt::Key_Space.
Definition: qwt_event_pattern.h:117
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition: qwt_event_pattern.h:44
QwtEventPattern::MouseSelect2
Definition: qwt_event_pattern.h:62
QwtEventPattern::KeyHome
Qt::Key_Escape.
Definition: qwt_event_pattern.h:141
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition: qwt_event_pattern.h:163
QwtEventPattern
A collection of event patterns.
Definition: qwt_event_pattern.h:29
QwtEventPattern::KeyAbort
Qt::Key_Escape.
Definition: qwt_event_pattern.h:120
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition: qwt_event_pattern.h:182
QwtEventPattern::KeyUp
Qt::Key_Up.
Definition: qwt_event_pattern.h:129
QwtEventPattern::KeyLeft
Qt::Key_Left.
Definition: qwt_event_pattern.h:123
QwtEventPattern::KeyUndo
Qt::Key_Minus.
Definition: qwt_event_pattern.h:138
QwtEventPattern::KeyRight
Qt::Key_Right.
Definition: qwt_event_pattern.h:126
QwtEventPattern::MouseSelect4
Definition: qwt_event_pattern.h:80
QwtEventPattern::KeyRedo
Qt::Key_Plus.
Definition: qwt_event_pattern.h:135
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition: qwt_event_pattern.h:111
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition: qwt_event_pattern.h:148
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition: qwt_event_pattern.h:160
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition: qwt_event_pattern.h:171
QwtEventPattern::MouseSelect3
Definition: qwt_event_pattern.h:71
QwtEventPattern::MouseSelect5
Definition: qwt_event_pattern.h:89
QwtEventPattern::MouseSelect6
Definition: qwt_event_pattern.h:98
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition: qwt_event_pattern.h:179