void OCC_2dView::OnLButtonUp(UINT nFlags, CPoint point) 
{
  // TODO: Add your message handler code here and/or call default
  if ( nFlags & CASCADESHORTCUTKEY ) 
  {
    return;
  }
  else // if ( Ctrl )
  {
    switch (myCurrentMode)
    {
    case CurAction2d_Nothing :
      if (point.x == myXmin && point.y == myYmin)
      { // no offset between down and up --> selectEvent
        myXmax=point.x;  
        myYmax=point.y;
        if (nFlags & MULTISELECTIONKEY )
          MultiInputEvent2D(point.x,point.y);
        else
          InputEvent2D     (point.x,point.y);
      } else
      {
        DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
        myXmax=point.x;  
        myYmax=point.y;
        if (nFlags & MULTISELECTIONKEY)
          MultiDragEvent2D(point.x,point.y,1);
        else
          DragEvent2D(point.x,point.y,1);
      }
      break;
    case CurAction2d_DynamicZooming :
      // 
      myCurrentMode = CurAction2d_Nothing;
      break;
    case CurAction2d_WindowZooming :
      myXmax=point.x;     myYmax=point.y;
      DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
      if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
        // Test if the zoom window is greater than a minimale window.
      {
        // Do the zoom window between Pmin and Pmax
        myV2dView->WindowFit(myXmin,myYmin,myXmax,myYmax);  
      }  
      myCurrentMode = CurAction2d_Nothing;
      break;
    case CurAction2d_DynamicPanning :
      myCurrentMode = CurAction2d_Nothing;
      break;
    case CurAction2d_GlobalPanning :
      myV2dView->Place(point.x,point.y,myCurZoom); 
      myCurrentMode = CurAction2d_Nothing;
      break;
    default :
      Standard_Failure::Raise(" incompatible Current Mode ");
      break;
    } //switch (myCurrentMode)
  } //	else // if ( CASCADESHORTCUTKEY )	
}
void Button::DrawButton( int screenWidth, int screenHeight, int fullscreen, float sfxVolume ) {
	float offset  = 0;
	if ( !fullscreen )
		offset    = 40;
	float tMouseX = (float)GetMouseX();
	float tMouseY = screenHeight - GetMouseY() - offset;

	if ( tMouseX > mXPos && tMouseX < mXPos + mWidth * mScale && 
		 tMouseY > mYPos && tMouseY < mYPos + mHeight * mScale ) {

		glBindTexture( GL_TEXTURE_2D, mHoverTexture->GetTextureId() );
		if ( !mHoverPlayed ) {
			irrklang::ISound *tSFX = mAudioManager->play2D( mHoverSFX.c_str(), false, true );
			tSFX->setVolume( sfxVolume );
			tSFX->setIsPaused( false );
			mHoverPlayed = true;
		}
	} else {
		glBindTexture( GL_TEXTURE_2D, mTexture->GetTextureId() );
		mHoverPlayed = false;
	}
		
	DrawRectangle2D( mXPos, mYPos, mXPos + mWidth * mScale, mYPos + mHeight * mScale );
}
void OCC_2dView::OnMouseMove(UINT nFlags, CPoint point) 
{
  //   ============================  LEFT BUTTON =======================
  if ( (nFlags & MK_LBUTTON) &! (nFlags & MK_RBUTTON) ) // Left + Right is specific
  {
    if ( nFlags & CASCADESHORTCUTKEY ) 
    {
      // move with MB1 and CASCADESHORTCUTKEY : on the dynamic zooming  
      // Do the zoom in function of mouse's coordinates  
      myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
      // save the current mouse coordinate in min 
      myXmax = point.x; 
      myYmax = point.y;	
    }
    else // if ( CASCADESHORTCUTKEY )
    {
      switch (myCurrentMode)
      {
      case CurAction2d_Nothing :
        myXmax = point.x;     myYmax = point.y;	
        DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False);
        DragEvent2D(myXmax,myYmax,0);  
        DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True);
        break;
      case CurAction2d_DynamicZooming :
        myV2dView->Zoom(myXmax,myYmax,point.x,point.y);
        // save the current mouse coordinate in min \n";
        myXmax=point.x;  myYmax=point.y;
        break;
      case CurAction2d_WindowZooming :
        myXmax = point.x; myYmax = point.y;	
        DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
        DrawRectangle2D(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
        break;
      case CurAction2d_DynamicPanning :
        myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
        myXmax = point.x; myYmax = point.y;	
        break;
      case CurAction2d_GlobalPanning : // nothing           
        break;
      default :
        Standard_Failure::Raise(" incompatible Current Mode ");
        break;
      }//  switch (myCurrentMode)
    }// if ( nFlags & CASCADESHORTCUTKEY )  else 
  } else //   if ( nFlags & MK_LBUTTON) 
    //   ============================  MIDDLE BUTTON =======================
    if ( nFlags & MK_MBUTTON)
    {
      if ( nFlags & CASCADESHORTCUTKEY ) 
      {
        myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
        myXmax = point.x; myYmax = point.y;	

      }
    } else //  if ( nFlags & MK_MBUTTON)
      //   ============================  RIGHT BUTTON =======================
      if ( (nFlags & MK_RBUTTON) &! (nFlags & MK_LBUTTON) ) // Left + Right is specific
      {
      }else //if ( nFlags & MK_RBUTTON)
        if ( (nFlags & MK_RBUTTON) && (nFlags & MK_LBUTTON) )
        {
          // in case of Left + Right : same as Middle
          if ( nFlags & CASCADESHORTCUTKEY ) 
          {
            myV2dView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
            myXmax = point.x; myYmax = point.y;	
          }
        }else //if ( nFlags & MK_RBUTTON)&& (nFlags & MK_LBUTTON) 
          //   ============================  NO BUTTON =======================
        {  // No buttons 
          myXmax = point.x; myYmax = point.y;	
          if (nFlags & MULTISELECTIONKEY)
            MultiMoveEvent2D(point.x,point.y);
          else
            MoveEvent2D(point.x,point.y);
        }
}
void iGraphics::draw_rectangle (int x1, int y1, int x2, int y2)
{
	DrawRectangle2D (x1, invert (y1), x2, invert (y2));
};