Qwt User's Guide: QwtEventPattern Class Reference

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# QwtEventPattern Class Reference

Inheritance diagram for QwtEventPattern:

[legend]
List of all members.

## Detailed Description

A collection of event patterns.

QwtEventPattern introduces an level of indirection for mouse and keyboard inputs. Those are represented by symbolic names, so the application code can be configured by individual mappings.

See also:
  QwtPicker, QwtPickerMachine, QwtPlotZoomer

Definition at line 28 of file qwt_event_pattern.h.

## Public Types
enum | MousePatternCode { MouseSelect1, MouseSelect2, MouseSelect3, MouseSelect4, MouseSelect5, MouseSelect6, MousePatternCount }
enum | KeyPatternCode { KeySelect1, KeySelect2, KeyAbort, KeyLeft, KeyRight, KeyUp, KeyDown, KeyRedo, KeyUndo, KeyHome, KeyPatternCount }
## Public Member Functions
| QwtEventPattern ()
virtual | ~QwtEventPattern ()
void | initMousePattern (int numButtons)
void | initKeyPattern ()
void | setMousePattern (uint pattern, int button, int state=Qt::NoButton)
void | setKeyPattern (uint pattern, int key, int state=Qt::NoButton)
void | setMousePattern (const QwtArray< MousePattern > &)
void | setKeyPattern (const QwtArray< KeyPattern > &)
const QwtArray< MousePattern > & | mousePattern () const
const QwtArray< KeyPattern > & | keyPattern () const
QwtArray< MousePattern > & | mousePattern ()
QwtArray< KeyPattern > & | keyPattern ()
bool | mouseMatch (uint pattern, const QMouseEvent *) const
bool | keyMatch (uint pattern, const QKeyEvent *) const
## Protected Member Functions
virtual bool | mouseMatch (const MousePattern &, const QMouseEvent *) const
virtual bool | keyMatch (const KeyPattern &, const QKeyEvent *) const
## Classes
class | KeyPattern
| A pattern for key events. More...
class | MousePattern
| A pattern for mouse events. More...

## Member Enumeration Documentation

enum QwtEventPattern::MousePatternCode

Symbolic mouse input codes.

The default initialization for 3 button mice is:

- MouseSelect1
  Qt::LeftButton
- MouseSelect2
  Qt::RightButton
- MouseSelect3
  Qt::MidButton
- MouseSelect4
  Qt::LeftButton + Qt::ShiftButton
- MouseSelect5
  Qt::RightButton + Qt::ShiftButton
- MouseSelect6
  Qt::MidButton + Qt::ShiftButton

The default initialization for 2 button mice is:

- MouseSelect1
  Qt::LeftButton
- MouseSelect2
  Qt::RightButton
- MouseSelect3
  Qt::LeftButton + Qt::AltButton
- MouseSelect4
  Qt::LeftButton + Qt::ShiftButton
- MouseSelect5
  Qt::RightButton + Qt::ShiftButton
- MouseSelect6
  Qt::LeftButton + Qt::AltButton + Qt::ShiftButton

The default initialization for 1 button mice is:

- MouseSelect1
  Qt::LeftButton
- MouseSelect2
  Qt::LeftButton + Qt::ControlButton
- MouseSelect3
  Qt::LeftButton + Qt::AltButton
- MouseSelect4
  Qt::LeftButton + Qt::ShiftButton
- MouseSelect5
  Qt::LeftButton + Qt::ControlButton + Qt::ShiftButton
- MouseSelect6
  Qt::LeftButton + Qt::AltButton + Qt::ShiftButton

See also:
  initMousePattern()

Definition at line 79 of file qwt_event_pattern.h.

enum QwtEventPattern::KeyPatternCode

Symbolic keyboard input codes.

Default initialization:

- KeySelect1
  Qt::Key_Return
- KeySelect2
  Qt::Key_Space
- KeyAbort
  Qt::Key_Escape

- KeyLeft
  Qt::Key_Left
- KeyRight
  Qt::Key_Right
- KeyUp
  Qt::Key_Up
- KeyDown
  Qt::Key_Down

- KeyUndo
  Qt::Key_Minus
- KeyRedo
  Qt::Key_Plus
- KeyHome
  Qt::Key_Escape

Definition at line 118 of file qwt_event_pattern.h.

## Constructor & Destructor Documentation

QwtEventPattern::QwtEventPattern | ( |  | ) |

Constructor

See also:
  MousePatternCode, KeyPatternCode

Definition at line 19 of file qwt_event_pattern.cpp.

References initKeyPattern(), and initMousePattern().

QwtEventPattern::~QwtEventPattern | ( |  | ) | `[virtual]`

Destructor.

Definition at line 28 of file qwt_event_pattern.cpp.

## Member Function Documentation

void QwtEventPattern::initMousePattern | ( | int | numButtons | ) |

Set default mouse patterns, depending on the number of mouse buttons

Parameters:

  | numButtons | Number of mouse buttons ( <= 3 )

See also:
  MousePatternCode

Definition at line 38 of file qwt_event_pattern.cpp.

References setMousePattern().

Referenced by QwtEventPattern().

void QwtEventPattern::initKeyPattern | ( |  | ) |

Set default mouse patterns.

See also:
  KeyPatternCode

Definition at line 88 of file qwt_event_pattern.cpp.

References setKeyPattern().

Referenced by QwtEventPattern().

void QwtEventPattern::setMousePattern | ( | uint | pattern,
|  | int | button,
|  | int | state = `Qt::NoButton` |
| ) |  |  |

Change one mouse pattern

Parameters:

  | pattern | Index of the pattern
  | button | Button
  | state | State

See also:
  QMouseEvent

Definition at line 115 of file qwt_event_pattern.cpp.

Referenced by initMousePattern().

void QwtEventPattern::setKeyPattern | ( | uint | pattern,
|  | int | key,
|  | int | state = `Qt::NoButton` |
| ) |  |  |

Change one key pattern

Parameters:

  | pattern | Index of the pattern
  | key | Key
  | state | State

See also:
  QKeyEvent

Definition at line 133 of file qwt_event_pattern.cpp.

Referenced by initKeyPattern().

void QwtEventPattern::setMousePattern | ( | const QwtArray< MousePattern > & |  | ) |

Change the mouse event patterns.

Definition at line 143 of file qwt_event_pattern.cpp.

void QwtEventPattern::setKeyPattern | ( | const QwtArray< KeyPattern > & |  | ) |

Change the key event patterns.

Definition at line 149 of file qwt_event_pattern.cpp.

const QwtArray< QwtEventPattern::MousePattern > & QwtEventPattern::mousePattern | ( |  | ) | const

Return mouse patterns.

Definition at line 156 of file qwt_event_pattern.cpp.

const QwtArray< QwtEventPattern::KeyPattern > & QwtEventPattern::keyPattern | ( |  | ) | const

Return key patterns.

Definition at line 163 of file qwt_event_pattern.cpp.

QwtArray< QwtEventPattern::MousePattern > & QwtEventPattern::mousePattern | ( |  | ) |

Return ,ouse patterns.

Definition at line 169 of file qwt_event_pattern.cpp.

QwtArray< QwtEventPattern::KeyPattern > & QwtEventPattern::keyPattern | ( |  | ) |

Return Key patterns.

Definition at line 175 of file qwt_event_pattern.cpp.

bool QwtEventPattern::mouseMatch | ( | uint | pattern,
|  | const QMouseEvent * | e |
| ) |  |  | const

Compare a mouse event with an event pattern.

A mouse event matches the pattern when both have the same button value and in the state value the same key flags(Qt::KeyButtonMask) are set.

Parameters:

  | pattern | Index of the event pattern
  | e | Mouse event

Returns:
  true if matches

See also:
  keyMatch()

Definition at line 193 of file qwt_event_pattern.cpp.

Referenced by QwtPickerPolygonMachine::transition(), QwtPickerDragRectMachine::transition(), QwtPickerClickRectMachine::transition(), QwtPickerDragPointMachine::transition(), QwtPickerClickPointMachine::transition(), and QwtPlotZoomer::widgetMouseReleaseEvent().

bool QwtEventPattern::keyMatch | ( | uint | pattern,
|  | const QKeyEvent * | e |
| ) |  |  | const

Compare a key event with an event pattern.

A key event matches the pattern when both have the same key value and in the state value the same key flags (Qt::KeyButtonMask) are set.

Parameters:

  | pattern | Index of the event pattern
  | e | Key event

Returns:
  true if matches

See also:
  mouseMatch()

Definition at line 248 of file qwt_event_pattern.cpp.

Referenced by QwtPickerPolygonMachine::transition(), QwtPickerDragRectMachine::transition(), QwtPickerClickRectMachine::transition(), QwtPickerDragPointMachine::transition(), QwtPickerClickPointMachine::transition(), QwtPlotZoomer::widgetKeyPressEvent(), and QwtPicker::widgetKeyPressEvent().

bool QwtEventPattern::mouseMatch | ( | const MousePattern & | pattern,
|  | const QMouseEvent * | e |
| ) |  |  | const`[protected, virtual]`

Compare a mouse event with an event pattern.

A mouse event matches the pattern when both have the same button value and in the state value the same key flags(Qt::KeyButtonMask) are set.

Parameters:

  | pattern | Mouse event pattern
  | e | Mouse event

Returns:
  true if matches

See also:
  keyMatch()

Definition at line 217 of file qwt_event_pattern.cpp.

References QwtEventPattern::MousePattern::button, and QwtEventPattern::MousePattern::state.

bool QwtEventPattern::keyMatch | ( | const KeyPattern & | pattern,
|  | const QKeyEvent * | e |
| ) |  |  | const`[protected, virtual]`

Compare a key event with an event pattern.

A key event matches the pattern when both have the same key value and in the state value the same key flags (Qt::KeyButtonMask) are set.

Parameters:

  | pattern | Key event pattern
  | e | Key event

Returns:
  true if matches

See also:
  mouseMatch()

Definition at line 272 of file qwt_event_pattern.cpp.

References QwtEventPattern::KeyPattern::key, and QwtEventPattern::KeyPattern::state.