Exemplo n.º 1
0
void TWindow::handleEvent(TEvent &event) {
   TRect  limits;
   TPoint min, max;

   TGroup::handleEvent(event);
   if (event.what== evCommand)
      switch (event.message.command) {
         case  cmResize:
            if ((flags & (wfMove | wfGrow)) != 0) {
               limits = owner->getExtent();
               sizeLimits(min, max);
               dragView(event, dragMode | (flags & (wfMove | wfGrow)),
                        limits, min, max);
               clearEvent(event);
            }
            break;
         case  cmClose:
            if ((flags & wfClose) != 0 &&
               (event.message.infoPtr == 0 || event.message.infoPtr == this))
            {
               clearEvent(event);
               if ((state & sfModal) == 0)
                  close();
               else {
                  event.what = evCommand;
                  event.message.command = cmCancel;
                  putEvent(event);
                  clearEvent(event);
               }
            }
            break;
         case  cmZoom:
            if ((flags & wfZoom) != 0 &&
               (event.message.infoPtr == 0 || event.message.infoPtr == this))
            {
               zoom();
               clearEvent(event);
            }
            break;
      }
   else if (event.what == evKeyDown)
      switch (event.keyDown.keyCode) {
         case  kbTab:
            focusNext(False);
            clearEvent(event);
            break;
         case  kbShiftTab:
            focusNext(True);
            clearEvent(event);
            break;
      }
   else if (event.what == evBroadcast &&
            event.message.command == cmSelectWindowNum &&
            event.message.infoInt == number &&
            (options & ofSelectable) != 0
           ) {
      select();
      clearEvent(event);
   }
}
Exemplo n.º 2
0
bool StelMovementMgr::handleMouseMoves(int x, int y, Qt::MouseButtons)
{
	// Turn if the mouse is at the edge of the screen unless config asks otherwise
	if (flagEnableMoveAtScreenEdge)
	{
		if (x <= 1)
		{
			turnLeft(1);
			isMouseMovingHoriz = true;
		}
		else if (x >= core->getProjection2d()->getViewportWidth() - 2)
		{
			turnRight(1);
			isMouseMovingHoriz = true;
		}
		else if (isMouseMovingHoriz)
		{
			turnLeft(0);
			isMouseMovingHoriz = false;
		}

		if (y <= 1)
		{
			turnUp(1);
			isMouseMovingVert = true;
		}
		else if (y >= core->getProjection2d()->getViewportHeight() - 2)
		{
			turnDown(1);
			isMouseMovingVert = true;
		}
		else if (isMouseMovingVert)
		{
			turnUp(0);
			isMouseMovingVert = false;
		}
	}

	// We can hardly use the mouse exactly enough to go to the zenith/pole. Any mouse motion can safely reset the simplified up vector.
	setViewUpVector(Vec3d(0., 0., 1.));

	if (isDragging && flagEnableMouseNavigation)
	{
		if (hasDragged || (std::sqrt((float)((x-previousX)*(x-previousX) +(y-previousY)*(y-previousY)))>dragTriggerDistance))
		{
			hasDragged = true;
			setFlagTracking(false);
			dragView(previousX, previousY, x, y);
			previousX = x;
			previousY = y;
			return true;
		}
	}
	return false;
}