Esempio n. 1
0
int32 SQRScrollBar::Create( const WndCreateParam& param )
{
	WndCreateParam newParam = param;
	newParam.uStyle |= WS_CHILD;
	if( FAILED( SQRWnd::Create( newParam ) ) )
		return GERROR;

	CFRect rt;
	CFRect rt1,rt2,rt3;
	GetWndRect( rt );
	CFRect rtWnd = rt;

	float PressW;
	if( GetStyle()&SS_HSCROLL )
	{
		PressW = min( rtWnd.Height(), rtWnd.Width() / 3 );
		rt1 = CFRect( 0, 0, PressW, rtWnd.Height() );
		rt2 = CFRect( rtWnd.Width() - PressW, 0, rtWnd.Width(), rtWnd.Height() );
		rt3 = rt1;
		rt3.left = rt1.right;
		rt3.right = rt3.left + rt1.Width();	
	}
	else
	{
		PressW = min( rtWnd.Width(), rtWnd.Height() / 3 );
		rt1 = CFRect( 0, 0, rtWnd.Width(), PressW );
		rt2 = CFRect( 0, rtWnd.Height() - PressW, rtWnd.Width(), rtWnd.Height() );
		rt3 = rt1;
		rt3.top = rt1.bottom;
		rt3.bottom = rt3.top + rt1.Height();	
	}

	WndCreateParam childParam;
	childParam.x = rt1.left;
	childParam.y = rt1.top;
	childParam.width = rt1.Width();
	childParam.height = rt1.Height();
	childParam.pParentWnd = this;
	childParam.font_size = 12;
	m_pPressButton1->Create( childParam );
	m_pPressButton1->SetMouseWheel(true);
	childParam.x = rt2.left;
	childParam.y = rt2.top;
	childParam.width = rt2.Width();
	childParam.height = rt2.Height();
	m_pPressButton2->Create( childParam );
	m_pPressButton2->SetMouseWheel(true);
	childParam.x = rt3.left;
	childParam.y = rt3.top;
	childParam.width = rt3.Width();
	childParam.height = rt3.Height();
	m_pScrollBar->Create( childParam );
	m_pScrollBar->SetMouseWheel(true);
	//m_pScrollBar->ShowWnd(false);
	if( GetStyle()&SS_HSCROLL )
	{
		m_pPressButton1->SetLockFlag( LOCK_LEFT|LOCK_TOP|LOCK_BOTTOM );
		m_pPressButton2->SetLockFlag( LOCK_RIGHT|LOCK_TOP|LOCK_BOTTOM);
		m_pScrollBar->SetLockFlag(LOCK_LEFT|LOCK_RIGHT|LOCK_TOP|LOCK_BOTTOM);
	}
	else
	{
		m_pPressButton1->SetLockFlag( LOCK_TOP|LOCK_LEFT|LOCK_RIGHT );
		m_pPressButton2->SetLockFlag( LOCK_BOTTOM|LOCK_LEFT|LOCK_RIGHT );
		m_pScrollBar->SetLockFlag(LOCK_TOP|LOCK_BOTTOM|LOCK_LEFT|LOCK_RIGHT);
	}

	m_fRange		= 100;
	m_fPageSize = 10;
	m_fCurPos	= 0;

	RefreshThumbState();
	SetMouseWheel(true);
	return 0;
}
Esempio n. 2
0
void OUGUIObject::UpdateSelf(float fDeltaTime, float fMX, float fMY)
{
    /** 如果鼠标不在HGE窗口内 */
    //if(!m_pHGE->Input_IsMouseOver()) return;

    bool bLButton = m_pHGE->Input_GetKeyState(HGEK_LBUTTON);
    bool bRButton = m_pHGE->Input_GetKeyState(HGEK_RBUTTON);
    bool bMButton = m_pHGE->Input_GetKeyState(HGEK_MBUTTON);
    int nWheel = m_pHGE->Input_GetMouseWheel();

    OnUpdate(fDeltaTime, fMX, fMY);

    /** 若控件不可用 */
    if(!GetEnableMode()) return;
    if(!GetShowMode()) return;

    /** 若有鼠标捕获的控件 */
    if(OUGUIObject::m_pMouseCaptureControl &&
        OUGUIObject::m_pMouseCaptureControl != this &&
        !IsParent(OUGUIObject::m_pMouseCaptureControl))
    {
        return;
    }

    /** 若有模式窗口 */
    if(OUGUIObject::m_pModalControl &&
        OUGUIObject::m_pModalControl != this &&
        !IsParent(OUGUIObject::m_pModalControl))
    {
        return;
    }

    /** 若有控件在激活状态下 */
    if(OUGUIObject::m_pActiveControl &&
        OUGUIObject::m_pActiveControl != this)
    {
        return;
    }
    
    /** 如果鼠标没有被按下,则检测是不是OnEnter */
    if(!bLButton && OnCheckCollision(fMX, fMY))
    {
        //SetMouseEnter(OnCheckCollision(fMX, fMY));
        SetMouseEnter(true);
    }
    /** 如果鼠标抬起,则检测是不是OnLeave */
    else
    if(!bLButton && !OnCheckCollision(fMX, fMY) && GetMouseEnter())
    {
        SetMouseEnter(false);

        this->m_bMouseLButton = false;
        this->m_bMouseMButton = false;
        this->m_bMouseRButton = false;
        this->m_nMouseWheel = 0;
       
        if(OUGUIObject::GetActiveControl() == this)
        {
            OUGUIObject::SetActiveControl(NULL);
        }

        return;
    }

    if(GetMouseEnter() || OUGUIObject::GetMouseCaptureControl() == this)
    {
        SetMousePos(fMX, fMY);
        SetMouseLButton(bLButton);
        SetMouseRButton(bRButton);
        SetMouseMButton(bMButton);
        SetMouseWheel(nWheel);

        /** 键盘响应 */
        for(int i = 0; i < 256; i++)
        {
            if(i == HGEK_LBUTTON) continue;
            if(i == HGEK_RBUTTON) continue;
            if(i == HGEK_MBUTTON) continue;

            if(m_pHGE->Input_KeyDown(i)) OnKeyDown(i);
            else
            if(m_pHGE->Input_KeyUp(i)) OnKeyUp(i);
        }

        OnIdle();
    }
    else
    {
        /** 清空状态 */
        SetMouseLButton(false);
        SetMouseRButton(false);
        SetMouseMButton(false);
        SetMouseWheel(nWheel);
    }
}
Esempio n. 3
0
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static POINT ptLastMousePosit;
	static POINT ptCurrentMousePosit;

	DKey = false;

    switch(msg)
    {
		case WM_KEYDOWN:
        {
            switch(wParam)
            {
                case VK_ESCAPE:
					if (DC)
					{
						ServerDisconnect();
						DC = false;
					}
                    break;

				case 'A':
					SetKeyboard(1, true);
					break;

				case 'D':
					SetKeyboard(4, true);
					break;

				case 'S':
					SetKeyboard(19, true);
					break;

				case 'W':
					SetKeyboard(23, true);
					break;
            }
        }
        break;

		case WM_RBUTTONDOWN:
        {
            ptLastMousePosit.x = ptCurrentMousePosit.x = LOWORD(lParam);
            ptLastMousePosit.y = ptCurrentMousePosit.y = HIWORD(lParam);
            SetMouseClick(1, true);
        }
        break;

        case WM_RBUTTONUP:
        {
            SetMouseClick(1, false);
        }
        break;

		case WM_LBUTTONDOWN:
        {
			SetMouseClick(0, true);
        }
        break;

        case WM_LBUTTONUP:
        {
			SetMouseClick(0, false);
        }
        break;

		case WM_MOUSEMOVE:			//Remember that it only works if the mouse is moved
        {
            ptCurrentMousePosit.x = LOWORD(lParam);
            ptCurrentMousePosit.y = HIWORD(lParam);

            ChangeX = (ptCurrentMousePosit.x - ptLastMousePosit.x);
            ChangeY = (ptCurrentMousePosit.y - ptLastMousePosit.y);

			SetMouseChange(ChangeX, ChangeY);

            ptLastMousePosit.x = ptCurrentMousePosit.x;
            ptLastMousePosit.y = ptCurrentMousePosit.y;
        }
        break;

		case WM_MOUSEWHEEL:
		{
			SetMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
		}
		break;

		 case WM_DESTROY:
		{
            PostQuitMessage(0);
            return 0;
		}

		case WM_CLOSE:
        {
            PostQuitMessage(0);
			return 0;
        }
    }

	return DefWindowProc( hWnd, msg, wParam, lParam );
}