示例#1
0
文件: player.cpp 项目: iegor/kdesktop
void Player::tickerTimeout()
{
	position = mEngine->position();
	mLength = mEngine->length();

	handleButtons();

	if(mEngine->state() == KMediaPlayer::Player::Stop && unfinished)
	{
		if(mLooping)
		{
			play();
		}
		else
		{
			stop();
			emit finished();
		}
	}
	else if(mEngine->state() != KMediaPlayer::Player::Stop)
	{
		emit timeout();
		unfinished = true;
	}

}
示例#2
0
void handleTick(uint16_t ms)
{
  onTickClock(ms); //clock always is udated regardless its mode
  switch(sCurrentMode)
  {
  case ModeStopWatch:
      onTickStopwatch(ms);
      break;
  case ModeCountDown:
      onTickCountdown(ms);
      break;
  }
  handleButtons();
  updateDisplay();
}
void HydroponicsUI::CheckForScreenTouch()
{
  if (myTouch.dataAvailable())
    {
      switch(whichScreen)
      {
        case MAIN_SCREEN:
        {
          handleButtons( iMainScreen->handleScreen() );
          break;
        }
         case ABOUT_SCREEN:
        {
          handleButtons( iAboutScreen->handleScreen() );
          break;
        }
          case SETUP_SCREEN:
        {
          handleButtons( iSetupScreen->handleScreen() );
          break;
        }
         case PH_SCREEN:
        {

          handleButtons( ipHScreen->handleScreen() );
          limitInfo.maxPHLevel = ipHScreen->getMax();
          limitInfo.minPHLevel = ipHScreen->getMin();
          break;
        }
          case EC_SCREEN:
        {

          handleButtons( iECScreen->handleScreen() );
          limitInfo.maxECLevel = iECScreen->getMax();
          limitInfo.minECLevel = iECScreen->getMin();
          break;
        }
          case AIR_SCREEN:
        {
        	handleButtons( iAirScreen->handleScreen() );
        	limitInfo.maxAirTemp = iAirScreen->getMax();
        	limitInfo.minAirTemp = iAirScreen->getMin();
        	limitInfo.airUnits = iAirScreen->getUnits();
          break;
        }
          case WATER_SCREEN:
        {
        	handleButtons( iWaterScreen->handleScreen() );
        	limitInfo.maxWaterTemp = iWaterScreen->getMax();
        	limitInfo.minWaterTemp = iWaterScreen->getMin();
          break;
        }
          case PLUGS_SCREEN:
        {
        	handleButtons( iPlugScreen->handleScreen() );
          break;
        }
          case CLOCK_SCREEN:
        {
        	handleButtons( iTimeScreen->handleScreen() );
          break;
        }
         case CALLIBRATE_EC_SCREEN:
        {
           Serial.println("handle EC Cal Screen();  \n");
           handleButtons( iECCalibrateScreen->handleScreen() );
           break;
        }
         case CALLIBRATE_PH_SCREEN:
        {
           Serial.println("handle PH Cal Screen();  \n");
           handleButtons( iPhCalibrateScreen->handleScreen() );
           break;
        }
         case PLUGS_SETTINGS_SCREEN:
        {
           Serial.println("handle Plug Settings Screen();  \n");
           handleButtons( iPlugSettingsScreen->handleScreen() );
           break;
        }
         case PUMP_SCREEN:
          {
          handleButtons( iPumpScreen->handleScreen() );
          break;
          }
         case PUMP_DURATION_SCREEN:
          {
          handleButtons( iPumpDurationScreen->handleScreen() );
          break;
          }
        default: //If Error, Just go back to main.
        {
        	Serial.println("ERROR :::: handleMainScreen();  \n");
        	handleButtons( iMainScreen->handleScreen() );
          break;
        }
        
      }
    }  
}
示例#4
0
void handleEvents()
{
	sf::Event Event;
	const sf::Input& Input = App->GetInput();
	bool shiftDown = Input.IsKeyDown(sf::Key::LShift) || Input.IsKeyDown(sf::Key::RShift);
	while (App->GetEvent(Event))
	{
		// Close window : exit
		if (Event.Type == sf::Event::Closed)
			App->Close();
		//
		// Escape key : exit
		if (Event.Type == sf::Event::KeyPressed)
		{
			if(Event.Key.Code == sf::Key::Escape)
				App->Close();
			else if(Event.Key.Code == sf::Key::Delete)
				deleteShape();
			else if(Event.Key.Code == sf::Key::Up && selected != 0)
			{
				Shape* s = findShape(selected);
				switch(colorM)
				{
					case COLOR_R:
						s->color[0] = ffmin(1.0, s->color[0]+0.05); break;
					case COLOR_G:
						s->color[1] = ffmin(1.0, s->color[1]+0.05); break;
					case COLOR_B:
						s->color[2] = ffmin(1.0, s->color[2]+0.05); break;
				}	
			}
			else if(Event.Key.Code == sf::Key::Down && selected != 0)
			{
				Shape* s = findShape(selected);
				switch(colorM)
				{
					case COLOR_R:
						s->color[0] = ffmax(0.0, s->color[0]-0.05); break;
					case COLOR_G:
						s->color[1] = ffmax(0.0, s->color[1]-0.05); break;
					case COLOR_B:
						s->color[2] = ffmax(0.0, s->color[2]-0.05); break;
				}	
			}
		}

		// Resize event : adjust viewport
		if (Event.Type == sf::Event::Resized)
		{
			glViewport(0, 0, Event.Size.Width, Event.Size.Height);
			currentRes[0] = Event.Size.Width;
			currentRes[1] = Event.Size.Height;	
			update_perspective();
		}

		if (Event.Type == sf::Event::MouseButtonPressed)
		{	
			lastPos[0] = Event.MouseButton.X;
			lastPos[1] = Event.MouseButton.Y;
			float x = Event.MouseButton.X;
			float y = currentRes[1]-Event.MouseButton.Y;
			if(Event.MouseButton.Button == sf::Mouse::Left)
			{
				if(!handleButtons(x,y))
				{
					handleSelection(Event.MouseButton.X, Event.MouseButton.Y);
				}
			}

			if(Event.MouseButton.Button == sf::Mouse::Left && !shiftDown)
			{
				buttonDown[0] = 1;
			}
			if(Event.MouseButton.Button == sf::Mouse::Right)
				buttonDown[1] = 1;
			if(Event.MouseButton.Button == sf::Mouse::Middle)
				buttonDown[2] = 1;
			if(Event.MouseButton.Button == sf::Mouse::Left && shiftDown)
				buttonDown[2] = 1;
		}

		if (Event.Type == sf::Event::MouseButtonReleased)
		{
			if(Event.MouseButton.Button == sf::Mouse::Left && !shiftDown)
				buttonDown[0] = 0;
			if(Event.MouseButton.Button == sf::Mouse::Right)
				buttonDown[1] = 0;
			if(Event.MouseButton.Button == sf::Mouse::Middle)
				buttonDown[2] = 0;
			if(Event.MouseButton.Button == sf::Mouse::Left && shiftDown)
				buttonDown[2] = 0;
		}

		if (Event.Type == sf::Event::MouseMoved && (buttonDown[0] || buttonDown[1] || buttonDown[2]) )
		{
			int x = Event.MouseMove.X;
			int y = Event.MouseMove.Y;
			if(selected == 0)
			{
				if(buttonDown[0])
					camera.trackball_rotate(lastPos[0], lastPos[1], x, y, currentRes[0], currentRes[1]);
				if(buttonDown[1])
					camera.trackball_translate(lastPos[0], lastPos[1], x, y);
				if(buttonDown[2])
					camera.trackball_translate_z(lastPos[0], lastPos[1], x, y);
			}
			else
			{
				Shape* s = findShape(selected);
				float diff = (x-lastPos[0])-(y-lastPos[1]);
				vec3 v;
				switch(axisM)
				{
					case X_AXIS:
						v = vec3(diff,0.0,0.0); break;
					case Y_AXIS:
						v = vec3(0.0,diff,0.0); break;
					case Z_AXIS:
						v = vec3(0.0,0.0,diff); break;
				}
				switch(transM)
				{
					case TRANS_TRANSLATION:
						s->trans.trans += v*0.01; break;
					case TRANS_ROTATION:
						s->rot.trans += v*0.1; break;
					case TRANS_SCALE:
						s->scale.trans += v*0.01; break;
				}
			}
			lastPos[0] = x;
			lastPos[1] = y;
		}
	}
}
BOOL NextBarDlg::OCommand(ULONG msg, MPARAM mp1, MPARAM mp2)
{
 switch(msg) {
    case WM_INITDLG:
       centerDlg();
       Title.inherit(hwnd);
       Program.inherit(hwnd);
       Path.inherit(hwnd);
       Parms.inherit(hwnd);
       Icon.inherit(hwnd);
       Settings.inherit(hwnd);
       Settings.setFont("8.Helv");
       setProgram2Dialog();
       if (actualButton)
         WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE, 
                    MPFROMP(actualButton->pIco->hptr), NULL);
       break;

    case WM_CONTROL:
       handleButtons(mp1);
       break; 

    case DM_DRAGOVER:
     {
      PDRAGINFO  pdinfo = (PDRAGINFO) mp1;
      PDRAGITEM  pditem = NULL;

      DrgAccessDraginfo(pdinfo);
      pditem = DrgQueryDragitemPtr(pdinfo, 0);
      if (DrgVerifyRMF(pditem, "DRM_OS2FILE", NULL))
       {
        DrgFreeDraginfo (pdinfo) ;
        return(TRUE);
       }
      else
       {
        DrgFreeDraginfo (pdinfo) ;
        return(FALSE);
       }
     }

   case DM_DROP: {
     PDRAGINFO       pDragInfo;              /* Pointer to DRAGINFO structure */
     PDRAGITEM       pDragItem;              /* Pointer to DRAGITEM structure */
     CHAR            Buffer[CCHMAXPATH];
     CHAR            ObjectType[CCHMAXPATH];
     PSZ             pszBuffer;
     OString         tmpBuf; 

     pDragInfo = (PDRAGINFO)mp1;
     if(DrgAccessDraginfo(pDragInfo)==FALSE) break;
     pDragItem = DrgQueryDragitemPtr(pDragInfo, 0);
     DrgQueryStrName(pDragItem->hstrRMF, sizeof(ObjectType), ObjectType);
     if(!strstr(ObjectType, "<DRM_OBJECT, DRF_OBJECT>"))
      { // this is not a WPS object
       DrgQueryStrName(pDragItem->hstrContainerName, sizeof(Buffer), Buffer);
       pszBuffer = ((PSZ) Buffer)+strlen(Buffer);
       DrgQueryStrName(pDragItem->hstrSourceName, sizeof(Buffer)-strlen(pszBuffer), pszBuffer);
       tmpBuf << Buffer;
       strupr(tmpBuf);
       if (strstr(tmpBuf, ".ICO")) {
          hps = WinGetPS(WinWindowFromID(hwnd, NHX_ICONFIELD));
          GpiCreateLogColorTable(hps, LCOL_RESET, LCOLF_RGB, 0L, 0L, NULL);
          WinQueryWindowRect(WinWindowFromID(hwnd, NHX_ICONFIELD), &rcl);
          GpiSetColor(hps, SYSCLR_DIALOGBACKGROUND);
          GpiBox(hps, DRO_FILL, (PPOINTL) &rcl.xRight, 0L, 0L);
          WinReleasePS(hps);
          if (actualButton->pIco) 
            delete actualButton->pIco;
          try {
            actualButton->pIco = new OIcon(Buffer); }
          catch(...) {
            delete actualButton->pIco;
            actualButton->pIco = new OIcon(); }
          WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE, 
                     MPFROMP(actualButton->pIco->hptr), NULL);
          WinSetDlgItemText(hwnd, NHX_ICON, Buffer); }
       else if ((!strstr(tmpBuf, ".EXE")) &&  (!strstr(tmpBuf, ".COM")) &&
                (!strstr(tmpBuf, ".BAT")) &&  (!strstr(tmpBuf, ".CMD")))
          install2Dialog(Buffer, TRUE);
       else
          install2Dialog(Buffer, FALSE);
      }
     else {
       DrgQueryStrName(pDragItem->hstrSourceName, sizeof(Buffer), Buffer);
       install2Dialog(Buffer, TRUE); }
    break; }

    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1)) 
       {
        case NHX_SAVE:
          setDialog2Program();
          if (isCreation)
             WinPostMsg(nxh->toolbar->hwnd, WM_TOOLBAR_RESET, NULL, NULL);
          else
             WinPostMsg(nxh->toolbar->hwnd, WM_SAVE_BUTTONS, NULL, NULL);
          event = NULL;
          WinPostMsg(hwnd, WM_CLOSE, NULL, NULL);
          break;

        case NHX_CANCEL:
          WinSendMsg(hwnd, WM_CLOSE, NULL, NULL);
          break;

        case NHX_LOAD:
          loadProgram();
          break;
       }
      break;

    case WM_HELP:
       nxh->toolbar->helpRequest(PANEL_CFGS);
       break;

    case WM_CLOSE:
       WinSendMsg(WinWindowFromID(hwnd, NHX_ICONFIELD), SM_SETHANDLE,
                  MPFROMP(NULLHANDLE), NULL);
       if (isCreation)
         WinPostMsg(nxh->toolbar->hwnd, WM_CFG_CANCELED, MPFROMP(event), NULL);
       delete this;
       break;

    default:
       return(FALSE); }
 return(TRUE);
#ifdef __BORLANDC__
  #pragma warn -par
#endif
}