Beispiel #1
0
void KSVGWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if(!m_panningPos.isNull())
    {
        m_oldPanningPos = m_oldPanningPos - (m_panningPos - event->pos());
        m_panningPos.setX(0);
        m_panningPos.setY(0);
    }

    if(event->state() & QMouseEvent::ControlButton)
        return;

    KSVG::SVGMouseEventImpl *mev = newMouseEvent(KSVG::SVGEvent::MOUSEUP_EVENT, event);

    if(part()->docImpl() && part()->docImpl()->rootElement())
        part()->docImpl()->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev);

    if(!mev->url().string().isEmpty())
    {
        QString url = mev->url().string();
        if(url.startsWith("#"))
            url.prepend(part()->docImpl()->baseUrl().prettyURL());
        emit browseURL(url);
    }

    mev->deref();
}
/* This is called when we want to pass on a mouse down event.  We
   return JNI_FALSE if something went wrong and JNI_TRUE if everything
   worked out ok. */
int handOffMouseDown(JNIEnv *env, jobject widget, int x, int y)
{
  jobject mouseEvent;        /* The event for this mouse down. */

  mouseEvent = newMouseEvent(env, widget, "MOUSE_PRESSED", 0, 0, x, y, 0, 
			     JNI_FALSE);
  if (mouseEvent == NULL) {
    return JNI_FALSE;
  }

  return handOff(env, widget, mouseEvent);
}
Beispiel #3
0
	void touchesCancel(int size, int *id, int *x, int *y, float *pressure)
	{
		for (int i = 0; i < size; ++i)
		{
			ginput_TouchEvent *touchEvent = newTouchEvent(size);
			
			touchEvent->touch.x = x[i];
			touchEvent->touch.y = y[i];
            touchEvent->touch.pressure = pressure[i];
            touchEvent->touch.touchType = 0;
			touchEvent->touch.id = id[i];
			
			for (int j = 0; j < size; ++j)
			{
				touchEvent->allTouches[j].x = x[j];
				touchEvent->allTouches[j].y = y[j];
	            touchEvent->allTouches[j].pressure = pressure[j];
	            touchEvent->allTouches[j].touchType = 0;
				touchEvent->allTouches[j].id = id[j];
			}
			
			ginput_MouseEvent *mouseEvent = NULL;
			if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0)
				mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON);

			if (mouseTouchOrder_ == 0)
			{
				if (mouseEvent)
				{
					gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this);
					deleteMouseEvent(mouseEvent);
				}
				gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this);
				deleteTouchEvent(touchEvent);
			}
			else
			{
				gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_CANCEL_EVENT, touchEvent, 0, this);
				deleteTouchEvent(touchEvent);
				if (mouseEvent)
				{
					gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this);
					deleteMouseEvent(mouseEvent);
				}
			}
		}
	}
Beispiel #4
0
	void touchBegin(int size, int *id, int *x, int *y, float *pressure, int actionIndex)
	{
		ginput_TouchEvent *touchEvent = newTouchEvent(size);
		
		touchEvent->touch.x = x[actionIndex];
		touchEvent->touch.y = y[actionIndex];
        touchEvent->touch.pressure = pressure[actionIndex];
        touchEvent->touch.touchType = 0;
		touchEvent->touch.id = id[actionIndex];
		
		for (int i = 0; i < size; ++i)
		{
			touchEvent->allTouches[i].x = x[i];
			touchEvent->allTouches[i].y = y[i];
            touchEvent->allTouches[i].pressure = pressure[i];
            touchEvent->allTouches[i].touchType = 0;
			touchEvent->allTouches[i].id = id[i];
		}
		
		
		ginput_MouseEvent *mouseEvent = NULL;
		if (isTouchToMouseEnabled_ && touchEvent->touch.id == 0)
			mouseEvent = newMouseEvent(touchEvent->touch.x, touchEvent->touch.y, GINPUT_LEFT_BUTTON);
		
		if (mouseTouchOrder_ == 0)
		{
			if (mouseEvent)
			{
				gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this);
				deleteMouseEvent(mouseEvent);
			}
			gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this);
			deleteTouchEvent(touchEvent);
		}
		else
		{
			gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_BEGIN_EVENT, touchEvent, 0, this);
			deleteTouchEvent(touchEvent);
			if (mouseEvent)
			{
				gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_DOWN_EVENT, mouseEvent, 0, this);
				deleteMouseEvent(mouseEvent);
			}
		}
	}
Beispiel #5
0
void KSVGWidget::mousePressEvent(QMouseEvent *event)
{
    if(event->state() & QMouseEvent::ControlButton)
        return;

    if(event->button() == RightButton)
    {
        if(part() && part()->factory())
        {
            QPopupMenu *popup = static_cast<QPopupMenu *>(part()->factory()->container("popupmenu", part()));
            if(popup)
                popup->popup(event->globalPos());
        }
    }

    KSVG::SVGMouseEventImpl *mev = newMouseEvent(KSVG::SVGEvent::MOUSEDOWN_EVENT, event);

    if(part()->docImpl() && part()->docImpl()->rootElement())
        part()->docImpl()->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev);

    mev->deref();
}
Beispiel #6
0
    void mouseUp(int x, int y, int button)
    {
        ginput_MouseEvent *mouseEvent = newMouseEvent(x, y, button);

        ginput_TouchEvent *touchEvent = NULL;
        if (isMouseToTouchEnabled_)
        {
            touchEvent = newTouchEvent(1);
            touchEvent->touch.x = x;
            touchEvent->touch.y = y;
            touchEvent->touch.id = 0;
            touchEvent->allTouches[0].x = x;
            touchEvent->allTouches[0].y = y;
            touchEvent->allTouches[0].id = 0;
        }

        if (mouseTouchOrder_ == 0)
        {
            gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this);
            deleteMouseEvent(mouseEvent);
            if (touchEvent)
            {
                gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this);
                deleteTouchEvent(touchEvent);
            }

        }
        else
        {
            if (touchEvent)
            {
                gevent_EnqueueEvent(gid_, callback_s, GINPUT_TOUCH_END_EVENT, touchEvent, 0, this);
                deleteTouchEvent(touchEvent);
            }
            gevent_EnqueueEvent(gid_, callback_s, GINPUT_MOUSE_UP_EVENT, mouseEvent, 0, this);
            deleteMouseEvent(mouseEvent);
        }
    }
Beispiel #7
0
void KSVGWidget::mouseMoveEvent(QMouseEvent *event)
{
    if(event->state() & QMouseEvent::ControlButton && event->state() & QMouseEvent::LeftButton)
    {
        if(m_panningPos.isNull())
            m_panningPos = event->pos();
        else
            part()->setPanPoint(m_oldPanningPos - (m_panningPos - event->pos()));

        return;
    }
    else if(event->state() & QMouseEvent::ControlButton)
        return;

    KSVG::SVGMouseEventImpl *mev = newMouseEvent(KSVG::SVGEvent::MOUSEMOVE_EVENT, event);

    if(part()->docImpl() && part()->docImpl()->rootElement())
        part()->docImpl()->rootElement()->prepareMouseEvent(event->pos(), event->pos(), mev);

    if(mev->target() && mev->url().string().isEmpty())
    {
        KSVG::SVGElementImpl *target = const_cast<KSVG::SVGElementImpl *>(mev->target());
        KSVG::SVGStylableImpl *style = dynamic_cast<KSVG::SVGStylableImpl *>(target);

        if(!style)
        {
            setCursor(KCursor::arrowCursor());
            return;
        }

        switch(style->getCursor())
        {
        case KSVG::CURSOR_CROSSHAIR:
            setCursor(KCursor::crossCursor());
            break;
        case KSVG::CURSOR_POINTER:
            setCursor(KCursor::handCursor());
            break;
        case KSVG::CURSOR_MOVE:
            setCursor(KCursor::sizeAllCursor());
            break;
        case KSVG::CURSOR_E_RESIZE:
        case KSVG::CURSOR_W_RESIZE:
            setCursor(KCursor::sizeHorCursor());
            break;
        case KSVG::CURSOR_N_RESIZE:
        case KSVG::CURSOR_S_RESIZE:
            setCursor(KCursor::sizeVerCursor());
            break;
        case KSVG::CURSOR_NW_RESIZE:
        case KSVG::CURSOR_SE_RESIZE:
            setCursor(KCursor::sizeFDiagCursor());
            break;
        case KSVG::CURSOR_NE_RESIZE:
        case KSVG::CURSOR_SW_RESIZE:
            setCursor(KCursor::sizeBDiagCursor());
            break;
        case KSVG::CURSOR_TEXT:
            setCursor(KCursor::ibeamCursor());
            break;
        case KSVG::CURSOR_WAIT:
            setCursor(KCursor::waitCursor());
            break;
        case KSVG::CURSOR_HELP:
            setCursor(KCursor::whatsThisCursor());
            break;
        default:
            setCursor(KCursor::arrowCursor());
        }
    }
    else if(mev->url().string().isEmpty())
        setCursor(KCursor::arrowCursor());

    if(!mev->url().string().isEmpty())
        setCursor(KCursor::handCursor());

    mev->deref();
}