// Main window procedure
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_PAINT:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
            
            ValidateRect( esContext->hWnd, NULL );
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 
      
	  case WM_KEYDOWN:
		  {
			  ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

			  if ( esContext && esContext->keyFunc )
				  esContext->keyFunc ( esContext, (unsigned char) wParam, true );
		  }
		  break;

	  case WM_KEYUP:
		  {
			  ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

			  if ( esContext && esContext->keyFunc )
				  esContext->keyFunc ( esContext, (unsigned char) wParam, false );
		  }
		  break;
         
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}
Exemple #2
0
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_SIZE:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            if ( esContext ) {
               esContext->width = LOWORD( lParam );
               esContext->height = HIWORD( lParam );
               InvalidateRect( esContext->hWnd, NULL, FALSE );
            }
         }

      case WM_PAINT:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
            
            if ( esContext )
              ValidateRect( esContext->hWnd, NULL );
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 
      
      case WM_CHAR:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
}
         break;
         
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   LRESULT  lRet = 1;

   switch ( uMsg )
   {
      case WM_CREATE:
         break;

      case WM_PAINT:
      {
         ESContext *esContext = ( ESContext * ) ( LONG_PTR ) GetWindowLongPtr ( hWnd, GWL_USERDATA );

         if ( esContext && esContext->drawFunc )
         {
            esContext->drawFunc ( esContext );
            eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
         }


         ValidateRect ( esContext->eglNativeWindow, NULL );
      }
      break;

      case WM_DESTROY:
         PostQuitMessage ( 0 );
         break;

      case WM_CHAR:
      {
         POINT      point;
         ESContext *esContext = ( ESContext * ) ( LONG_PTR ) GetWindowLongPtr ( hWnd, GWL_USERDATA );

         GetCursorPos ( &point );

         if ( esContext && esContext->keyFunc )
            esContext->keyFunc ( esContext, ( unsigned char ) wParam,
                                 ( int ) point.x, ( int ) point.y );
      }
      break;

      default:
         lRet = DefWindowProc ( hWnd, uMsg, wParam, lParam );
         break;
   }

   return lRet;
}
Exemple #4
0
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_PAINT:
         {
			ESContext *esContext;
			RECT rect;
			rect.bottom=0;
			rect.left=0;
			rect.right=400;
			rect.top=300;
			esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
			ValidateRect( esContext->hWnd, NULL );
			
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 
      
     case WM_CHAR:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,(int)lParam, 
		                             (int) point.x, (int) point.y );
	 }
		 break;
	  case WM_KEYUP:
		 {
			POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		  if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,0, 
		                             (int) point.x, (int) point.y );
		 }
		 
		 break;
	  case WM_KEYDOWN:
		 {
			  POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		   if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,1, 
		                             (int) point.x, (int) point.y );
		 }
         break;
	  case WM_LBUTTONDOWN:
		  {
		    POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		   if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,3, 
		                             (int) point.x, (int) point.y );
		  }
		  break;
	  case  WM_LBUTTONUP:
		  {		   
		  POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		   if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,4, 
		                             (int) point.x, (int) point.y );
		  }
		  break;
		   case WM_RBUTTONDOWN:
			   {
			POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		   if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,5, 
		                             (int) point.x, (int) point.y );
			   }
		  break;
	  case  WM_RBUTTONUP:
		  {
		    POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );
		   if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( (unsigned char) wParam,6, 
		                             (int) point.x, (int) point.y );
		  }
		  break;
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}
Exemple #5
0
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
  LRESULT  lRet = 1; 

  switch (uMsg) 
  { 
  case WM_CREATE:
    break;

  case WM_PAINT:
    {
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

      if ( esContext && esContext->drawFunc )
        esContext->drawFunc ( esContext );

      ValidateRect( esContext->hWnd, NULL );
    }
    break;

  case WM_DESTROY:
    PostQuitMessage(0);             
    break; 

    /*
  case WM_CHAR:
    {
      POINT      point;
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

      GetCursorPos( &point );

      if ( esContext && esContext->keyFunc )
        esContext->keyFunc ( esContext, (unsigned char) wParam, 
        (int) point.x, (int) point.y );
    }
    break;
    */
  case WM_KEYDOWN:
    {
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
      if(esContext && esContext->keyFunc) {
        int state = ES_KEY_DOWN;
        esContext->keyFunc(esContext, state, wParam);
      }
    }
    break;
  case WM_KEYUP:
    {
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
      if(esContext && esContext->keyFunc) {
        int state = ES_KEY_UP;
        esContext->keyFunc(esContext, state, wParam);
      }
    }
    break;
  case WM_LBUTTONDOWN:
    {
      POINT point;
      int x, y;
      RECT winRect;
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

      GetCursorPos(&point); 
      GetWindowRect(esContext->hWnd, &winRect);

      if(PtInRect(&winRect, point)) {
        x = (int)point.x - winRect.left;
        y = (int)point.y - winRect.top;
        left_pressed = 1;
        if(esContext->mouseFunc != NULL) {
          esContext->mouseFunc(ES_MOUSE_DOWN, x, y);
        }
      }
    }
		break;

	case WM_MOUSEMOVE:
    {
      if (MK_LBUTTON == wParam && left_pressed) {
        POINT point;
        int x, y;
        RECT winRect;
        ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

        GetCursorPos(&point); 
        GetWindowRect(esContext->hWnd, &winRect);

        if(PtInRect(&winRect, point)) {
          x = (int)point.x - winRect.left;
          y = (int)point.y - winRect.top;
          if(esContext->mouseFunc != NULL) {
            esContext->mouseFunc(ES_MOUSE_MOVE, x, y);
          }
        }
      }
    }
		break;

	case WM_LBUTTONUP:
    if(left_pressed) {
      POINT point;
      int x, y;
      RECT winRect;
      ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

      GetCursorPos(&point); 
      GetWindowRect(esContext->hWnd, &winRect);

      if(PtInRect(&winRect, point)) {
        x = (int)point.x - winRect.left;
        y = (int)point.y - winRect.top;
        if(esContext->mouseFunc != NULL) {
          esContext->mouseFunc(ES_MOUSE_UP, x, y);
        }
      }
      left_pressed = 0;
    }
		break;

  default: 
    lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
    break; 
  } 

  return lRet; 
}
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   static POINT mousePoint;

   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_SIZE:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            if ( esContext ) {
               esContext->width = LOWORD( lParam );
               esContext->height = HIWORD( lParam );
               InvalidateRect( esContext->hWnd, NULL, FALSE );
            }
         }

      case WM_PAINT:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
            
            if ( esContext )
              ValidateRect( esContext->hWnd, NULL );
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 

      case WM_LBUTTONDOWN:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

			mousePoint.x = GET_X_LPARAM(lParam);
			mousePoint.y = GET_Y_LPARAM(lParam);

            if ( esContext && esContext->lButtomDownFunc )
                esContext->lButtomDownFunc ( esContext, (int) mousePoint.x, (int) mousePoint.y );
         }
         break;

      case WM_LBUTTONUP:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

			point.x = GET_X_LPARAM(lParam);
			point.y = GET_Y_LPARAM(lParam);

            if ( esContext && esContext->lButtomUpFunc )
                esContext->lButtomUpFunc ( esContext, (int) point.x, (int) point.y );
         }
         break;

      case WM_MOUSEMOVE:
         {
            POINT      point;

            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );

			point.x = GET_X_LPARAM(lParam);
			point.y = GET_Y_LPARAM(lParam);

            if (wParam & MK_LBUTTON) // drag event
                if ( esContext && esContext->mouseDragFunc )
                    esContext->mouseDragFunc ( esContext, 
                                               (int) mousePoint.x, (int) mousePoint.y,
                                               (int) point.x, (int) point.y );

            mousePoint = point; // point update
         }
         break;

      case WM_CHAR:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
         }
         break;
         
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}
Exemple #7
0
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_PAINT:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
            
            ValidateRect( esContext->hWnd, NULL );
         }
         break;

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 
      
      case WM_CHAR:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
		}
         break;

	  case WM_KEYUP:
		  {
			POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFuncUp )
	            esContext->keyFuncUp ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
		  
		  }
		  break;

	  case WM_MOUSEMOVE:
		  {
			POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWL_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->mouseMoveFunc )
	            esContext->mouseMoveFunc ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
		  }
         
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}
Exemple #8
0
///
//  ESWindowProc()
//
//      Main window procedure
//
LRESULT WINAPI ESWindowProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) 
{
   LRESULT  lRet = 1; 

   switch (uMsg) 
   { 
      case WM_CREATE:
         break;

      case WM_SIZE:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWLP_USERDATA );
            if ( esContext ) {
               esContext->width = LOWORD( lParam );
               esContext->height = HIWORD( lParam );
               InvalidateRect( esContext->hWnd, NULL, FALSE );
            }
         }

      case WM_PAINT:
         {
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWLP_USERDATA );
            
            if ( esContext && esContext->drawFunc )
               esContext->drawFunc ( esContext );
            
            if ( esContext )
              ValidateRect( esContext->hWnd, NULL );
         }
         break;

		 case WM_CLOSE:
			 PostQuitMessage(0);             
         break; 

      case WM_DESTROY:
         PostQuitMessage(0);             
         break; 
      
      case WM_CHAR:
         {
            POINT      point;
            ESContext *esContext = (ESContext*)(LONG_PTR) GetWindowLongPtr ( hWnd, GWLP_USERDATA );
            
            GetCursorPos( &point );

            if ( esContext && esContext->keyFunc )
	            esContext->keyFunc ( esContext, (unsigned char) wParam, 
		                             (int) point.x, (int) point.y );
}
         break;
         


	
	case 0x020A://WM_MOUSEWHEEL:
	{

		int  zDelta = (short)HIWORD(wParam);
		int xPos = LOWORD(lParam); 
		int yPos = HIWORD(lParam); 
		zoomCamera(zDelta);
		break;
	}

	case WM_MOUSEMOVE:
		{
				int xPos = LOWORD(lParam); 
				int yPos = HIWORD(lParam); 
			mouseMotionFunc(xPos,yPos);
			break;
		}
	case WM_RBUTTONUP:
	{
			int xPos = LOWORD(lParam); 
			int yPos = HIWORD(lParam); 
			mouseFunc(2,1,xPos,yPos);
		break;
	}
	case WM_RBUTTONDOWN:
	{
			int xPos = LOWORD(lParam); 
			int yPos = HIWORD(lParam); 
			mouseFunc(2,0,xPos,yPos);
		break;
	}
	case WM_LBUTTONDOWN:
		{
				int xPos = LOWORD(lParam); 
				int yPos = HIWORD(lParam); 
			//	gDemoApplication->mouseFunc(0,0,xPos,yPos);
				mouseFunc(0,0,xPos,yPos);
			break;
		}
		case WM_LBUTTONUP:
	{
			int xPos = LOWORD(lParam); 
			int yPos = HIWORD(lParam); 
			//gDemoApplication->mouseFunc(0,1,xPos,yPos);
			mouseFunc(0,1,xPos,yPos);
		break;
	}
      default: 
         lRet = DefWindowProc (hWnd, uMsg, wParam, lParam); 
         break; 
   } 

   return lRet; 
}