/*----------------------------------------------------------------------
 *       Class:  AmayaTransformEvtHandler
 *      Method:  OnMouseDown
 * Description:  handle mouse button down events
 -----------------------------------------------------------------------*/
void AmayaTransformEvtHandler::OnMouseDown( wxMouseEvent& event )
{
  if (IsFinish())
    return;

  ButtonDown = true;
  lastX = mouse_x;
  lastY = mouse_y;
  switch(type)
    {
    case 2:
      /* Rotation: is the user clicking on the center ? */
      if (IsNear(cx2, cy2))
        type = 3;

      hasBeenRotated = false;
      break;

    case 1:
      /* Scaling: is the user clicking on an arrow ? */
      if (IsNear((left2+right2)/2, top2))
        type = 9;
      else if (IsNear((left2+right2)/2, bottom2))
        type = 10;
      else if (IsNear(left2, (top2+bottom2)/2))
        type = 11;
      else if (IsNear(right2, (top2+bottom2)/2))
        type = 12;
      else  if (IsNear(left2, top2))
        type = 13;
      else if (IsNear(right2, top2))
        type = 14;
      else if (IsNear(right2, bottom2))
        type = 15;
      else if (IsNear(left2, bottom2))
        type = 16;
      else Finished = true;

      /* Clear the arrows */
      DrawScalingArrows();
      break;

    case 4:
      /* Skewing: is the user clicking on an arrow ? */

      if (IsNear((left2+right2)/2, top2))
        type = 5;
      else if (IsNear((left2+right2)/2, bottom2))
        type = 6;
      else if (IsNear(left2, (top2+bottom2)/2))
        type = 7;
      else if (IsNear(right2, (top2+bottom2)/2))
        type = 8;
      else Finished = true;

      /* Clear the arrows */
      DrawSkewingArrows();
      break;
    }
}
void CImportPatchDlg::OnBnClickedOk()
{
	m_PathList.Clear();
	this->UpdateData();

	SaveSplitterPos();

	if(IsFinish())
	{
		this->OnOK();
		return;
	}

	m_ctrlTabCtrl.SetActiveTab(1);

	EnableInputCtrl(false);
	InterlockedExchange(&m_bThreadRunning, TRUE);
	InterlockedExchange(&this->m_bExitThread, FALSE);
	if ( (m_LoadingThread=AfxBeginThread(ThreadEntry, this)) ==NULL)
	{
		InterlockedExchange(&m_bThreadRunning, FALSE);
		CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
	}

}
void CImportPatchDlg::UpdateOkCancelText()
{
	if (this->m_bThreadRunning && !IsFinish())
	{
		this->GetDlgItem(IDOK)->EnableWindow(FALSE);
		this->GetDlgItem(IDCANCEL)->SetWindowText(_T("A&bort"));
	}
	else if (!IsFinish())
	{
		this->GetDlgItem(IDOK)->EnableWindow(TRUE);
	}
	else
	{
		this->GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
		this->GetDlgItem(IDOK)->SetWindowText(_T("&OK"));
	}
}
void CImportPatchDlg::UpdateOkCancelText()
{
	if (this->m_bThreadRunning && !IsFinish())
	{
		this->GetDlgItem(IDOK)->EnableWindow(FALSE);
		this->GetDlgItem(IDCANCEL)->SetWindowText(CString(MAKEINTRESOURCE(IDS_ABORTBUTTON)));
	}
	else if (!IsFinish())
	{
		this->GetDlgItem(IDOK)->EnableWindow(TRUE);
	}
	else
	{
		this->GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
		this->GetDlgItem(IDOK)->SetWindowText(CString(MAKEINTRESOURCE(IDS_OKBUTTON)));
	}
}
	void InternalBuffer::Update( uint32_t bytes )
	{
		assert( !IsFinish() );

		auto& buf_	= ImpUPtr_->Buffer_;
		auto& off_	= ImpUPtr_->Offset_;

		assert(off_+bytes <= buf_.size());

		off_ += bytes;
	}
Exemple #6
0
void CBoxManMain::WinOrNot(void)
{
	if (IsFinish())
	{
		m_pBoxManWnd->Invalidate(FALSE);
		m_SoundState=SOUND_STATE_VICTORY;
		BoxManPlaySound();
		AfxMessageBox("恭喜!\n您已通过该关!");
		//Sleep(1000);
		DispatchMsg(113);
	}
}
Exemple #7
0
void cParticle::Update( float fDeltaTime )
{
	cSprite::Update(fDeltaTime);

	m_fPassedTime += fDeltaTime;

	if(IsFinish())
	{
		if(m_pDelegate)
			m_pDelegate->OnDead(this);
		return;
	}

	float t = m_fPassedTime / m_fLifespan;
	
	//if(t > 1.0f) t = 1.0f;
	// color
	D3DXCOLOR c = (1.0f - t) * m_stStartColor + t * m_stFinishColor;

	DWORD dwA = 255 * c.a;
	if(dwA > 255) dwA = 255;

	DWORD dwR = 255 * c.r;
	if(dwR > 255) dwR = 255;

	DWORD dwG = 255 * c.g;
	if(dwG > 255) dwG = 255;

	DWORD dwB = 255 * c.b;
	if(dwB > 255) dwB = 255;

	m_dwColor = D3DCOLOR_ARGB(dwA, dwR, dwG, dwB);
	
	// position
	m_vFinishPosition = m_vStartPosition + m_fLifespan * m_vDirection * m_fSpeed;
	D3DXVec3Lerp(&m_vPosition, &m_vStartPosition, &m_vFinishPosition, t);
	
	// scale
	float s = (1.0f - t) * m_fStartSize + t * m_fFinishSize;
	m_vScale.x = m_vScale.y = s;
}
Exemple #8
0
void cParticle::Render()
{
	if(IsFinish())
	{
		return;
	}
	
	if(m_pTexture)
	{
		m_pSprite->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);
		g_pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
		g_pD3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);

		g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);

		m_pSprite->SetTransform(&m_mTransform);
		m_pSprite->Draw(m_pTexture->GetTexture(), &m_rc, &m_vCenter, NULL, m_dwColor);
		m_pSprite->End();
	}

	cNode::Render();
}
/*----------------------------------------------------------------------
 *       Class:  AmayaEditShapeEvtHandler
 *      Method:  OnMouseMove
 * Description:  handle mouse move events
 -----------------------------------------------------------------------*/
void AmayaEditShapeEvtHandler::OnMouseMove( wxMouseEvent& event )
{
#define RATIO_EQUILATERAL sqrt((float)3)/2.

  ThotBool same_size;
  int      rx, ry, lx, ly, x, y;
  int      x1, y1, x2, y2, dx, dy;
  float    ratio = 0.;

  if (IsFinish())
    return;
  /* DELTA is the sensitivity toward mouse moves. */
#define DELTA 0

  /* Update the current mouse coordinates */
  mouse_x = event.GetX();
  mouse_y = event.GetY();
  if (!buttonDown)
    {
      lastX = mouse_x;
      lastY = mouse_y;
      buttonDown = true;
    }

  if ((abs(mouse_x -lastX) + abs(mouse_y - lastY) > DELTA))
    {
      x1 = lastX;
      y1 = lastY;
      x2 = mouse_x;
      y2 = mouse_y;
      MouseCoordinatesToSVG (document, pFrame, x0, y0, width, height,
                             inverse, TRUE, NULL,
                             &x1, &y1, FALSE);
      MouseCoordinatesToSVG (document, pFrame, x0, y0, width, height,
                             inverse, TRUE, NULL,
                             &x2, &y2, FALSE);

      dx = x2 - x1;
      dy = y2 - y1;

      /*               lx
       *         <------------->
       *                       
       *       (x,y)------O-rx-.    ^
       *         |             |    |
       *         |             ry   |
       *         |             |    |
       *         |             O    |    
       *         |             |    |    
       *         |             |    |ly    
       *         |             |    |    
       *         |             |    |    
       *         |             |    |    
       *         |             |    |    
       *         .-------------.    v
       */


      lx = box->BxW;
      ly = box->BxH;
      x = x_org;
      y = y_org;

      /*                                   9 = Rx handle       */
      /*                                  /                    */
      /*            1-------------2------O------3              */
      /*            |                           O              */
      /*            |                           |\             */
      /*            8                           4 \            */
      /*            |                           |  10 = Ry     */
      /*            |                           |       Handle */
      /*            7-------------6-------------5              */

      switch(shape)
        {
        case 1: /* square */
        case 2: /* Parallelogram */
        case 3: /* Trapezium */
        case 'C': /* rectangle */
        case 'a': /* circle */
        case 'c': /* ellipse */
        case 'L': /* diamond */
        case 4: /* Equilateral triangle (ly = lx*R) */
        case 5: /* Isosceles triangle */
        case 6: /* Rectangle triangle */
        case 7: /* square */
        case 8: /* rectangle */
          if (shape == 1 || shape == 'C') /* square and rectangle with rounded corner */
            {
              rx = box->BxRx;
              ry = box->BxRy;
              if (rx != -1 && ry == -1)
                ry = rx;
              else if (rx == -1 && ry != -1)
                rx = ry;
            }
          else if (shape == 2) /* parallelogram */
            rx = box->BxRx;
          else if (shape == 3) /* trapezium */
            {
              rx = box->BxRx;
              ry = box->BxRy;
            }

          if (1 <= point && point <= 8)
            {
              same_size = (shape == 1 || shape == 7 || shape == 'a');
              if (same_size)ratio = 1.;
            }
          else
            same_size = (box->BxRx == -1 || box->BxRy == -1);

          if (shape == 4)
            ratio = RATIO_EQUILATERAL;

          if (shape == 6 && point == 5)
            {
              /* The point is actually the middle of the hypot */
              dx *= 2;
              dy *= 2;
            }

          switch(point)
            {
            case 1:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, -1, ratio);
              break;
	      
            case 2:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, 0, -1, ratio);
              break;
	      
            case 3:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, -1, ratio);
              break;

            case 4:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, 0, ratio);
              break;
	      
            case 5:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, +1, ratio);
              break;
	      
            case 6:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, 0, +1, ratio);
              break;
	      
            case 7:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, +1, ratio);
              break;
	      
            case 8:
              apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, 0, ratio);
              break;
	      
            case 9:
              // change the arc size
              if (shape == 1 || shape == 'C') /* Square Rectangle */
                {
                  rx -= dx;
                  if (rx > lx/2)
                    rx = lx/2;
                  if (same_size)
                    {
                      if (rx > ly/2)
                        rx = ly/2;
                      ry = rx;
                    }
                }
              else if (shape == 2) /* Parallelogram */
                rx += dx;
              break;
	      
            case 10:
              // change the arc size
              if (shape == 1 || shape == 'C') /* Square Rectangle */
                {
                  ry += dy;
                  if (ry > ly/2)
                    ry = ly/2;
                  if (same_size || Angle_ratio)
                    {
                      if (ry > lx/2)
                        ry = lx/2;
                      rx = ry;
                    }
                }
              else if (shape == 2) /* Parallelogram */
                rx -= dx;
              break;
            }
	  
          if (lx < 0){lx = 0; x = x_org;}
          if (ly < 0){ly = 0; y = y_org;}
          if (shape == 1 || shape == 'C') /* Square Rectangle */
            {
              if (rx > lx/2)
                rx = lx/2;
              if (ry > ly/2)
                ry = ly/2;
	      
              if (box->BxRx != -1)
                box->BxRx = rx;
              if (box->BxRy != -1)
                box->BxRy = ry;
            }
          else if (shape == 2) /* Parallelogram */
            {
              if (rx < 0)rx = 0;
              if (rx > lx)rx = lx;
              box->BxRx = rx;
            }
          else if (shape == 3) /* Trapezium */
            {
              if (x+abs(rx) > x+lx-abs(ry))
                {
                  box->BxRx = (rx < 0 ? -1 : 1)*(lx/2);
                  box->BxRy = (ry < 0 ? -1 : 1)*(lx/2);
                }
              else
                {
                  box->BxRx = rx;
                  box->BxRy = ry;
                }
            }
          break;

        default:
          break;
        }
      
      if (shape != 1 && shape != 'C' && shape != 'a' && shape != 'c' &&
          shape != 'g' && shape != 7 && shape != 8)
        {
          TtaAppendMatrixTransform (document, el, 1, 0, 0, 1, x - x_org, y - y_org);
          box->BxXOrg = 0;
          box->BxYOrg = 0;
        }
      else if (point != 9 && point != 10)
        {
          box->BxXOrg = x;
          box->BxYOrg = y;
        }
      x_org = x;
      y_org = y;
      box->BxW = lx;
      box->BxH = ly;
      box->BxWidth = lx;
      box->BxHeight = ly;
      e_box->BxW = lx;
      e_box->BxH = ly;
      e_box->BxWidth = lx;
      e_box->BxHeight = ly;
      /* Redisplay the GRAPHICS leaf */
      RedisplayLeaf ((PtrElement) leaf, document, 0);

      /* Update the previous mouse coordinates */
      lastX = mouse_x;
      lastY = mouse_y;

      *hasBeenEdited = TRUE;
    }
}
/*----------------------------------------------------------------------
 *       Class:  AmayaTransformEvtHandler
 *      Method:  OnMouseUp
 * Description:  handle mouse button up events
 -----------------------------------------------------------------------*/
void AmayaTransformEvtHandler::OnMouseUp( wxMouseEvent& event )
{
  int   x, y;

  if (IsFinish())
    return;
  switch(type)
    {
    case 2:
      /* The user was rotating the shape */
      ButtonDown = false;
      if (!hasBeenRotated)
        {
          /* The user clicked but didn't move */
          TtaSetStatus (document, 1, "", NULL);
          Finished = true;
        }
      break;

    case 3:
      /* The user was moving the center: come back to the initial interface  */
      type = 2;
      /* Get the new coordinates in the mouse space... */
      x = cx2;
      y = cy2;
      /* ...and in the SVG canvas */
      MouseCoordinatesToSVG(document, pFrame, x0, y0, width, height,
                            inverse, TRUE, NULL,
                            &x, &y, FALSE);
      cx = (float)x;
      cy = (float)y;
      ButtonDown = false;
      break;

    case 5:
    case 6:
    case 7:
    case 8:
      /* The user was skewing the shape: come back to the initial interface */
      type = 4;
      ButtonDown = false;
      /* Redisplay the arrows */
      AmayaTransformEvtHandler::UpdatePositions();
      break;

    case 9:
    case 10:
    case 11:
    case 12:
    case 13:
    case 14:
    case 15:
    case 16:
      /* The user was scaling the shape: come back to the initial interface */
      type = 1;      
      ButtonDown = false;

      /* Redisplay the arrows */
      AmayaTransformEvtHandler::UpdatePositions();
      break;

    case 17:
      /* Translate */
      ButtonDown = false;
      break;

    default:
      TtaSetStatus (document, 1, "", NULL);
      Finished = true;
      break;
    }
}