A state machine for rectangle selections. More...
#include <qwt_picker_machine.h>


Public Member Functions | |
| virtual CommandList | transition (const QwtEventPattern &, const QEvent *) |
| Transition. | |
A state machine for rectangle selections.
Pressing QwtEventPattern::MouseSelect1 selects the first point, releasing it the second point. Pressing QwtEventPattern::KeySelect1 also selects the first point, a second press selects the second point and terminates the selection.
Definition at line 128 of file qwt_picker_machine.h.
| QwtPickerMachine::CommandList QwtPickerDragRectMachine::transition | ( | const QwtEventPattern & | eventPattern, |
| const QEvent * | e | ||
| ) | [virtual] |
Transition.
Implements QwtPickerMachine.
Definition at line 234 of file qwt_picker_machine.cpp.
References QwtPickerMachine::Append, QwtPickerMachine::Begin, QwtPickerMachine::End, QwtEventPattern::keyMatch(), QwtEventPattern::KeySelect1, QwtEventPattern::mouseMatch(), QwtEventPattern::MouseSelect1, QwtPickerMachine::Move, QwtPickerMachine::setState(), and QwtPickerMachine::state().
{
QwtPickerMachine::CommandList cmdList;
switch(e->type())
{
case QEvent::MouseButtonPress:
{
if ( eventPattern.mouseMatch(
QwtEventPattern::MouseSelect1, (const QMouseEvent *)e) )
{
if ( state() == 0 )
{
cmdList += Begin;
cmdList += Append;
cmdList += Append;
setState(2);
}
}
break;
}
case QEvent::MouseMove:
case QEvent::Wheel:
{
if ( state() != 0 )
cmdList += Move;
break;
}
case QEvent::MouseButtonRelease:
{
if ( state() == 2 )
{
cmdList += End;
setState(0);
}
break;
}
case QEvent::KeyPress:
{
if ( eventPattern.keyMatch(
QwtEventPattern::KeySelect1, (const QKeyEvent *)e) )
{
if ( state() == 0 )
{
cmdList += Begin;
cmdList += Append;
cmdList += Append;
setState(2);
}
else
{
cmdList += End;
setState(0);
}
}
break;
}
default:
break;
}
return cmdList;
}
1.7.2