示例#1
0
void QXipIvWidget::mouseMoveEvent(QMouseEvent* event)
{
	QWidget* pWidget = parentWidget()->parentWidget();

//    qDebug() << "QXipIvWidget::mouseMoveEvent";

	bool onResizeBorder = false;

	//if (!event->buttons())
	//{
	//	if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
	//	{
	//		if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
	//		{
	//			if ((event->pos().x() > (this->width() - 10)) && (event->pos().y() > (this->height() - 10)))
	//			{
	//				setCursor(Qt::SizeFDiagCursor);
	//				onResizeBorder = true;
	//			}
	//			else if (event->pos().x() > (this->width() - 10))
	//			{
	//				setCursor(Qt::SizeHorCursor);
	//				onResizeBorder = true;
	//			}
	//			else if (event->pos().y() > (this->height() - 10))
	//			{
	//				setCursor(Qt::SizeVerCursor);
	//				onResizeBorder = true;
	//			}
	//		}
	//	}
	//}

	switch (m_mouseMode)
	{
	case RESIZE_NONE:
		if (!onResizeBorder)
		{
			event->accept();

			SbTime time;
			time.setToTimeOfDay();
			SoLocation2Event e;
			e.setTime(time);
			if (event->modifiers() & Qt::ShiftModifier)
				e.setShiftDown(TRUE);
			if (event->modifiers() & Qt::ControlModifier)
				e.setCtrlDown(TRUE);
			e.setPosition(SbVec2s(event->pos().x(), m_height - event->pos().y()));
			if (m_sceneManager->processEvent(&e))
			{
				processDelayQueue();
				updateCursor(true);
			}
			else
			{
				updateCursor(false);
			}
		} break;
	case RESIZE_WIDTH:
		{
			pWidget->resize(mapTo(pWidget, event->pos()).x() + 3, pWidget->size().height());
			event->accept();
		} break;
	case RESIZE_HEIGHT:
		{
			pWidget->resize(pWidget->size().width(), mapTo(pWidget, event->pos()).y() + 3);
			event->accept();
		} break;
	case RESIZE_CORNER:
		{
			pWidget->resize(mapTo(pWidget, event->pos()).x() + 3, mapTo(pWidget, event->pos()).y() + 3);
			event->accept();
		} break;
	}
}
void QCtkXipSGWidget::mouseMoveEvent(QMouseEvent *event)
{
  bool onResizeBorder = false;

  if (!event->buttons())
  {
    if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
    {
      if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
      {
        if ((event->pos().x() > (this->width() - 10)) && (event->pos().y() > (this->height() - 10)))
        {
          setCursor(Qt::SizeFDiagCursor);
          onResizeBorder = true;
        }
        else if (event->pos().x() > (this->width() - 10))
        {
          setCursor(Qt::SizeHorCursor);
          onResizeBorder = true;
        }
        else if (event->pos().y() > (this->height() - 10))
        {
          setCursor(Qt::SizeVerCursor);
          onResizeBorder = true;
        }
      }
    }
  }

  event->accept();

  SbTime time;
  time.setToTimeOfDay();

  // get mouse delta field
  //SoSFBool *deltaField = (SoSFBool *) SoDB::getGlobalField("MOUSE_DELTA_MODE");
  //if ( deltaField && deltaField->getValue() )
  //{


  if (mSceneManager && mIsSceneManagerActive) 
  {
    SbTime time;
    time.setToTimeOfDay();
    //SoLocation2Event event;
    //event.setTime(time);
    //if (event->modifiers() & Qt::ShiftModifier) 
    // event.setShiftDown(TRUE);
    //if (event->modifiers() & Qt::ControlModifier) 
    // event.setCtrlDown(TRUE);
    SbVec2s pos = SbVec2s(event->pos().x(),event->pos().y());
    //SbVec2s delta =  pos - mOldPos;
    //delta[1] = -delta[1];

    mOldPos = pos;
    SoLocation2Event e;
    e.setTime(time);
    if (event->modifiers() & Qt::ShiftModifier)
      e.setShiftDown(TRUE);
    if (event->modifiers() & Qt::ControlModifier)
      e.setCtrlDown(TRUE);

    e.setPosition(SbVec2s(event->pos().x(), mHeight - event->pos().y()));
    if (mSceneManager->processEvent(&e))
    {
      //processDelayQueue();
      //repaint();
      updateCursor(true);
    }
    else
    {
      updateCursor(false);
    }
  }


}