示例#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;
}
示例#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() );
}
示例#3
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;
}