地面站终端 App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

241 lines
5.8 KiB

15 years ago
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
15 years ago
* 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"
15 years ago
#include <qnamespace.h>
#include <qvector.h>
15 years ago
class QMouseEvent;
class QKeyEvent;
/*!
\brief A collection of event patterns
QwtEventPattern introduces an level of indirection for mouse and
keyboard inputs. Those are represented by symbolic names, so
15 years ago
the application code can be configured by individual mappings.
\sa QwtPicker, QwtPickerMachine, QwtPlotZoomer
*/
class QWT_EXPORT QwtEventPattern
{
public:
/*!
\brief Symbolic mouse input codes
QwtEventPattern implements 3 different settings for
mice with 1, 2, or 3 buttons that can be activated
using initMousePattern(). The default setting is for
3 button mice.
Individual settings can be configured using setMousePattern().
\sa initMousePattern(), setMousePattern(), setKeyPattern()
15 years ago
*/
enum MousePatternCode
{
/*!
The default setting for 1, 2 and 3 button mice is:
15 years ago
- Qt::LeftButton
- Qt::LeftButton
- Qt::LeftButton
*/
15 years ago
MouseSelect1,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ControlModifier
- Qt::RightButton
- Qt::RightButton
*/
15 years ago
MouseSelect2,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::AltModifier
- Qt::LeftButton + Qt::AltModifier
- Qt::MidButton
*/
15 years ago
MouseSelect3,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ShiftModifier
- Qt::LeftButton + Qt::ShiftModifier
- Qt::LeftButton + Qt::ShiftModifier
*/
15 years ago
MouseSelect4,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier
- Qt::RightButton + Qt::ShiftModifier
- Qt::RightButton + Qt::ShiftModifier
*/
15 years ago
MouseSelect5,
/*!
The default setting for 1, 2 and 3 button mice is:
- Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier
- Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier
- Qt::MidButton + Qt::ShiftModifier
*/
15 years ago
MouseSelect6,
//! Number of mouse patterns
15 years ago
MousePatternCount
};
/*!
\brief Symbolic keyboard input codes
Individual settings can be configured using setKeyPattern()
\sa setKeyPattern(), setMousePattern()
15 years ago
*/
enum KeyPatternCode
{
//! Qt::Key_Return
15 years ago
KeySelect1,
//! Qt::Key_Space
15 years ago
KeySelect2,
//! Qt::Key_Escape
15 years ago
KeyAbort,
//! Qt::Key_Left
15 years ago
KeyLeft,
//! Qt::Key_Right
15 years ago
KeyRight,
//! Qt::Key_Up
15 years ago
KeyUp,
//! Qt::Key_Down
15 years ago
KeyDown,
//! Qt::Key_Plus
15 years ago
KeyRedo,
//! Qt::Key_Minus
15 years ago
KeyUndo,
//! Qt::Key_Escape
15 years ago
KeyHome,
//! Number of key patterns
15 years ago
KeyPatternCount
};
//! A pattern for mouse events
class MousePattern
{
public:
//! Constructor
MousePattern( Qt::MouseButton btn = Qt::NoButton,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
button( btn ),
modifiers( modifierCodes )
{
15 years ago
}
//! Button
Qt::MouseButton button;
//! Keyboard modifier
Qt::KeyboardModifiers modifiers;
15 years ago
};
//! A pattern for key events
class KeyPattern
{
public:
//! Constructor
KeyPattern( int keyCode = Qt::Key_unknown,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
key( keyCode ),
modifiers( modifierCodes )
{
15 years ago
}
//! Key code
15 years ago
int key;
//! Modifiers
Qt::KeyboardModifiers modifiers;
15 years ago
};
QwtEventPattern();
virtual ~QwtEventPattern();
void initMousePattern( int numButtons );
15 years ago
void initKeyPattern();
void setMousePattern( MousePatternCode, Qt::MouseButton button,
Qt::KeyboardModifiers = Qt::NoModifier );
15 years ago
void setKeyPattern( KeyPatternCode, int keyCode,
Qt::KeyboardModifiers modifierCodes = Qt::NoModifier );
15 years ago
void setMousePattern( const QVector<MousePattern> & );
void setKeyPattern( const QVector<KeyPattern> & );
15 years ago
const QVector<MousePattern> &mousePattern() const;
const QVector<KeyPattern> &keyPattern() const;
15 years ago
QVector<MousePattern> &mousePattern();
QVector<KeyPattern> &keyPattern();
bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
15 years ago
protected:
virtual bool mouseMatch( const MousePattern &, const QMouseEvent * ) const;
virtual bool keyMatch( const KeyPattern &, const QKeyEvent * ) const;
15 years ago
private:
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
QVector<MousePattern> d_mousePattern;
QVector<KeyPattern> d_keyPattern;
15 years ago
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
};
//! Compare operator
inline bool operator==( QwtEventPattern::MousePattern b1,
QwtEventPattern::MousePattern b2 )
{
return b1.button == b2.button && b1.modifiers == b2.modifiers;
15 years ago
}
//! Compare operator
inline bool operator==( QwtEventPattern::KeyPattern b1,
QwtEventPattern::KeyPattern b2 )
{
return b1.key == b2.key && b1.modifiers == b2.modifiers;
15 years ago
}
#endif