Ejemplo n.º 1
0
bool CText::MouseMove( CMouse * pMouse, bool )
{
	CPos Pos = *GetRelPos();
	if(GetParent()) Pos = *GetParent()->GetAbsPos() + Pos;

	SetElementState( SetMouseOver( pMouse->InArea( Pos.GetX(), Pos.GetY(), GetFont()->GetStringWidth( GetFormatted().c_str() ), GetFont()->GetStringHeight() ) )?_UI("MouseOver"):_UI("Norm") );
	return 0;
}
Ejemplo n.º 2
0
void CText::Draw()
{
	if(!GetFormatted().c_str()) return;

	CPos Pos = *GetRelPos();
	if(GetParent()) Pos = *GetParent()->GetAbsPos() + Pos;
	
	GetFont()->DrawString( Pos.GetX(), Pos.GetY(), 0, pString, GetFormatted().c_str(), GetWidth() );
}
    bool test_projectVelocity()
    {
       VecDeriv vprev(numNodes);
       typename MechanicalObject::WriteVecDeriv v = dofs->writeVelocities();
       for (unsigned i=0; i<numNodes; i++){
           vprev[i] = v[i] = CPos(i,0,0);
       }
//       cerr<<"test_projectVelocity, v before = " << v << endl;
       projection->projectVelocity(core::MechanicalParams::defaultInstance(), *dofs->write(core::VecDerivId::velocity()) );
//       cerr<<"test_projectVelocity, v after = " << v << endl;

       bool succeed=true;
       typename Indices::const_iterator it = indices.begin(); // must be sorted
       for(unsigned i=0; i<numNodes; i++ )
       {
          if ((it!=indices.end()) && ( i==*it ))  // constrained particle
           {
              CPos crossprod = v[i].cross(direction); // should be parallel
              Real scal = crossprod.norm(); // null if v is ok
//              cerr<<"scal = "<< scal << endl;
              if( !Sofa_test<typename _DataTypes::Real>::isSmall(scal,100) ){
                  succeed = false;
                  ADD_FAILURE() << "Velocity of constrained particle " << i << " is wrong: " << v[i] ;
              }
               it++;
           }
           else           // unconstrained particle: check that it has not changed
           {
              CPos dv = v[i]-vprev[i];
              Real scal = dv*dv;
//              cerr<<"scal gap = "<< scal << endl;
              if( !Sofa_test<typename _DataTypes::Real>::isSmall(scal,100) ){
                  succeed = false;
                  ADD_FAILURE() << "Velocity of unconstrained particle " << i << " is wrong: " << v[i] ;
              }
           }

       }
       return succeed;
    }
Ejemplo n.º 4
0
//--------------------------------------------------------------------------------------
bool CProgressBarHorizontal::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam )
{
	if ( !CanHaveFocus () )
		return false;

	switch ( uMsg )
	{
		case WM_MOUSEMOVE:
		{
			if ( m_bPressed )
			{
				SetValue ( ValueFromPos ( pos.GetX () - m_rProgress.pos.GetX () ) );
				return true;
			}
			break;
		}

		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		{
			if ( m_rBoundingBox.InControlArea ( pos ) )
			{
				// Pressed while inside the control
				m_bPressed = true;

				if ( m_pParent )
					m_pParent->RequestControlFocus ( this );

				m_timer.Start ( PROGRESSBAR_ARROWCLICK_START );

				if ( pos.GetX () > m_rProgress.pos.GetX () + m_rProgress.size.cx )
				{
					SetValue ( m_fValue + m_fStep );
					return true;
				}

				if ( pos.GetX () < m_rProgress.pos.GetX () + m_rProgress.size.cx )
				{
					SetValue ( m_fValue - m_fStep );
					return true;
				}

				return true;
			}
			break;
		}

		case WM_LBUTTONUP:
		{
			if ( m_bPressed )
			{
				m_bPressed = false;

				if ( m_pParent )
					m_pParent->ClearControlFocus ();

				return true;
			}
			break;
		}
	}
	return false;
}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------------------
bool CTrackBarVertical::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam )
{
	if ( !CanHaveFocus () )
		return false;

	switch ( uMsg )
	{
		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
		{
			if ( m_rThumb.InControlArea ( pos ) )
			{
				// Pressed while inside the control
				m_bPressed = true;

				m_nDragOffset = pos.GetY () - m_rThumb.pos.GetY ();

				if ( m_pParent && !m_bHasFocus )
					m_pParent->RequestControlFocus ( this );

				return true;
			}

			if ( m_rBoundingBox.InControlArea ( pos ) )
			{
				m_nDragOffset = 0;

				// Pressed while inside the control
				m_bPressed = true;

				if ( m_pParent && !m_bHasFocus )
					m_pParent->RequestControlFocus ( this );

				if ( pos.GetY () > m_rThumb.pos.GetY () )
				{
					SetValue ( m_nValue + 1 );
					return true;
				}

				if ( pos.GetY () < m_rThumb.pos.GetY () )
				{
					SetValue ( m_nValue - 1 );
					return true;
				}
			}

			break;
		}

		case WM_LBUTTONUP:
		{
			if ( m_bPressed )
			{
				m_bPressed = false;
				SendEvent ( EVENT_CONTROL_SELECT, m_nValue );

				if ( m_pParent )
					m_pParent->ClearControlFocus ();

				return true;
			}
			break;
		}

		case WM_MOUSEMOVE:
		{
			if ( m_bPressed )
			{
				SetValue ( ValueFromPos ( pos.GetY () - m_rBoundingBox.pos.GetY () - m_nDragOffset ) );
				return true;
			}
			break;
		}

		case WM_MOUSEWHEEL:
		{
			int nScrollAmount = int ( ( short ) HIWORD ( wParam ) ) / WHEEL_DELTA;
			SetValue ( m_nValue - nScrollAmount );
			return true;
		}
	};

	return false;
}