Loading...
Searching...
No Matches
qwt_event_pattern.h
/******************************************************************************
* 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
#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 > m_mousePattern;
QVector< KeyPattern > m_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
QVector
Definition qwt_clipper.h:23
QwtEventPattern::KeyPattern
A pattern for key events.
Definition qwt_event_pattern.h:169
QwtEventPattern::KeyPattern::modifiers
Qt::KeyboardModifiers modifiers
Modifiers.
Definition qwt_event_pattern.h:183
QwtEventPattern::KeyPattern::KeyPattern
KeyPattern(int keyCode=Qt::Key_unknown, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition qwt_event_pattern.h:172
QwtEventPattern::KeyPattern::key
int key
Key code.
Definition qwt_event_pattern.h:180
QwtEventPattern::MousePattern
A pattern for mouse events.
Definition qwt_event_pattern.h:150
QwtEventPattern::MousePattern::MousePattern
MousePattern(Qt::MouseButton btn=Qt::NoButton, Qt::KeyboardModifiers modifierCodes=Qt::NoModifier)
Constructor.
Definition qwt_event_pattern.h:153
QwtEventPattern::MousePattern::modifiers
Qt::KeyboardModifiers modifiers
Keyboard modifier.
Definition qwt_event_pattern.h:164
QwtEventPattern::MousePattern::button
Qt::MouseButton button
Button.
Definition qwt_event_pattern.h:161
QwtEventPattern
A collection of event patterns.
Definition qwt_event_pattern.h:31
QwtEventPattern::KeyPatternCode
KeyPatternCode
Symbolic keyboard input codes.
Definition qwt_event_pattern.h:113
QwtEventPattern::KeyDown
@ KeyDown
Qt::Key_Down.
Definition qwt_event_pattern.h:133
QwtEventPattern::KeyUp
@ KeyUp
Qt::Key_Up.
Definition qwt_event_pattern.h:130
QwtEventPattern::KeyRedo
@ KeyRedo
Qt::Key_Plus.
Definition qwt_event_pattern.h:136
QwtEventPattern::KeySelect1
@ KeySelect1
Qt::Key_Return.
Definition qwt_event_pattern.h:115
QwtEventPattern::KeyHome
@ KeyHome
Qt::Key_Escape.
Definition qwt_event_pattern.h:142
QwtEventPattern::KeyAbort
@ KeyAbort
Qt::Key_Escape.
Definition qwt_event_pattern.h:121
QwtEventPattern::KeyRight
@ KeyRight
Qt::Key_Right.
Definition qwt_event_pattern.h:127
QwtEventPattern::KeyUndo
@ KeyUndo
Qt::Key_Minus.
Definition qwt_event_pattern.h:139
QwtEventPattern::KeyLeft
@ KeyLeft
Qt::Key_Left.
Definition qwt_event_pattern.h:124
QwtEventPattern::KeySelect2
@ KeySelect2
Qt::Key_Space.
Definition qwt_event_pattern.h:118
QwtEventPattern::MousePatternCode
MousePatternCode
Symbolic mouse input codes.
Definition qwt_event_pattern.h:46
QwtEventPattern::MouseSelect1
@ MouseSelect1
Definition qwt_event_pattern.h:54
QwtEventPattern::MouseSelect4
@ MouseSelect4
Definition qwt_event_pattern.h:81
QwtEventPattern::MouseSelect3
@ MouseSelect3
Definition qwt_event_pattern.h:72
QwtEventPattern::MouseSelect2
@ MouseSelect2
Definition qwt_event_pattern.h:63
QwtEventPattern::MouseSelect5
@ MouseSelect5
Definition qwt_event_pattern.h:90
QwtEventPattern::MouseSelect6
@ MouseSelect6
Definition qwt_event_pattern.h:99