Esempio n. 1
0
/*!
  \brief Event filter

  When isEnabled() == true all events of the observed widget are filtered.
  Mouse and keyboard events are translated into widgetMouse- and widgetKey-
  and widgetWheel-events. Paint and Resize events are handled to keep 
  rubberband and tracker up to date.

  \sa event(), widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(),
      widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent()
*/
bool QwtPicker::eventFilter(QObject *o, QEvent *e)
{
    if ( o && o == parentWidget() )
    {
        switch(e->type())
        {
            case QEvent::Resize:
            {
                const QResizeEvent *re = (QResizeEvent *)e;
                if ( d_data->resizeMode == Stretch )
                    stretchSelection(re->oldSize(), re->size());

                if ( d_data->rubberBandWidget )
                    d_data->rubberBandWidget->resize(re->size());
             
                if ( d_data->trackerWidget )
                    d_data->trackerWidget->resize(re->size());
                break;
            }
            case QEvent::Leave:
                widgetLeaveEvent(e);
                break;
            case QEvent::MouseButtonPress:
                widgetMousePressEvent((QMouseEvent *)e);
                break;
            case QEvent::MouseButtonRelease:
                widgetMouseReleaseEvent((QMouseEvent *)e);
                break;
            case QEvent::MouseButtonDblClick:
                widgetMouseDoubleClickEvent((QMouseEvent *)e);
                break;
            case QEvent::MouseMove:
                widgetMouseMoveEvent((QMouseEvent *)e);
                break;
            case QEvent::KeyPress:
                widgetKeyPressEvent((QKeyEvent *)e);
                break;
            case QEvent::KeyRelease:
                widgetKeyReleaseEvent((QKeyEvent *)e);
                break;
            case QEvent::Wheel:
                widgetWheelEvent((QWheelEvent *)e);
                break;
            default:
                break;
        }
    }
    return false;
}
/*!
  \brief Event filter

  When isEnabled() the mouse events of the observed widget are filtered.

  \param object Object to be filtered
  \param event Event

  \sa widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseMoveEvent(), widgetWheelEvent(), widgetKeyPressEvent()
      widgetKeyReleaseEvent()
*/
bool QwtMagnifier::eventFilter( QObject *object, QEvent *event )
{
    if ( object && object == parent() )
    {
        switch ( event->type() )
        {
            case QEvent::MouseButtonPress:
            {
                widgetMousePressEvent( ( QMouseEvent * )event );
                break;
            }
            case QEvent::MouseMove:
            {
                widgetMouseMoveEvent( ( QMouseEvent * )event );
                break;
            }
            case QEvent::MouseButtonRelease:
            {
                widgetMouseReleaseEvent( ( QMouseEvent * )event );
                break;
            }
            case QEvent::Wheel:
            {
                widgetWheelEvent( ( QWheelEvent * )event );
                break;
            }
            case QEvent::KeyPress:
            {
                widgetKeyPressEvent( ( QKeyEvent * )event );
                break;
            }
            case QEvent::KeyRelease:
            {
                widgetKeyReleaseEvent( ( QKeyEvent * )event );
                break;
            }
            default:;
        }
    }
    return QObject::eventFilter( object, event );
}
Esempio n. 3
0
/*!
  \brief Event filter

  When isEnabled() is true all events of the observed widget are filtered.
  Mouse and keyboard events are translated into widgetMouse- and widgetKey-
  and widgetWheel-events. Paint and Resize events are handled to keep
  rubber band and tracker up to date.

  \param object Object to be filtered
  \param event Event

  \return Always false.

  \sa widgetEnterEvent(), widgetLeaveEvent(),
      widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(),
      widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent(),
      QObject::installEventFilter(), QObject::event()
*/
bool QwtPicker::eventFilter( QObject *object, QEvent *event )
{
    if ( object && object == parentWidget() )
    {
        switch ( event->type() )
        {
            case QEvent::Resize:
            {
                const QResizeEvent *re = static_cast<QResizeEvent *>( event );

                /*
                   Adding/deleting additional event filters inside of an event filter
                   is not safe dues to the implementation in Qt ( changing alist while iterating ).
                   So we create the overlays in a way, that they don't install en event filter
                   ( parent set to NULL ) and do the resizing here.
                 */
                if ( d_data->trackerOverlay )
                    d_data->trackerOverlay->resize( re->size() );

                if ( d_data->rubberBandOverlay )
                    d_data->rubberBandOverlay->resize( re->size() );

                if ( d_data->resizeMode == Stretch )
                    stretchSelection( re->oldSize(), re->size() );

                updateDisplay();
                break;
            }
            case QEvent::Enter:
            {
                widgetEnterEvent( event );
                break;
            }
            case QEvent::Leave:
            {
                widgetLeaveEvent( event );
                break;
            }
            case QEvent::MouseButtonPress:
            {
                widgetMousePressEvent( static_cast<QMouseEvent *>( event ) );
                break;
            }
            case QEvent::MouseButtonRelease:
            {
                widgetMouseReleaseEvent( static_cast<QMouseEvent *>( event ) );
                break;
            }
            case QEvent::MouseButtonDblClick:
            {
                widgetMouseDoubleClickEvent( static_cast<QMouseEvent *>( event ) );
                break;
            }
            case QEvent::MouseMove:
            {
                widgetMouseMoveEvent( static_cast<QMouseEvent *>( event ) );
                break;
            }
            case QEvent::KeyPress:
            {
                widgetKeyPressEvent( static_cast<QKeyEvent *>( event ) );
                break;
            }
            case QEvent::KeyRelease:
            {
                widgetKeyReleaseEvent( static_cast<QKeyEvent *>( event ) );
                break;
            }
            case QEvent::Wheel:
            {
                widgetWheelEvent( static_cast<QWheelEvent *>( event ) );
                break;
            }
            default:
                break;
        }
    }
    return false;
}