Esempio n. 1
0
   LRESULT CALLBACK Splitter::ProcessMessage(UINT message, WPARAM wParam, LPARAM lParam)
   {
      switch(message) {
      case WM_SIZE:
         Size(LOWORD(lParam), HIWORD(lParam));
         return 0;
      case WM_PAINT:
         Paint();
         return 0;
      case WM_LBUTTONDOWN:
         LButtonDown(MAKEPOINTS(lParam));
         return 0;
      case WM_LBUTTONUP:
         LButtonUp(MAKEPOINTS(lParam));
         return 0;
      case WM_MOUSEMOVE:
         if(wParam & MK_LBUTTON)
            LButtonDrag(MAKEPOINTS(lParam));
         return 0;
      case WM_CAPTURECHANGED:
         CaptureChanged();
         return 0;
      }

      return Window::ProcessMessage(message, wParam, lParam);
   }
void CDrawLine::DblLButtonDown(CDPoint p,CDPoint s)
{
	// Second line..
	LButtonDown(p,s);

	// .. and end
	RButtonDown(p,s);
}
void CDrawLine::LButtonUp(CDPoint p)
{
	// Only do this if this is the first
	// m_segment we have placed...
	if (has_placed)
	{
		return;
	}

	// If the user has made a significant movement,
	// then consider this a placement....
	double offset_x = m_point_a.x - m_point_b.x;
	double offset_y = m_point_a.y - m_point_b.y;

	if (offset_x < 0)
	{
		offset_x = -offset_x;
	}
	if (offset_y < 0)
	{
		offset_y = -offset_y;
	}

	if (offset_x > 10 || offset_y > 10)
	{
		// Ok, we can place
		if (!m_segment && !is_stuck)
		{
			// First line
			LButtonDown(p,p);
		}
		// Second line..
		LButtonDown(p,p);

		// .. and end
		RButtonDown(p,p);
	}
	else
	{
		has_placed = TRUE;
	}
}
Esempio n. 4
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_CREATE:
			//初始化
			Init(hWnd, wParam, lParam);
			break;
		case WM_PAINT:
			//绘制
			Render(hWnd);
			break;
		case WM_KEYDOWN:
			//键盘按下事件
			if (GameStart) KeyDown(hWnd, wParam, lParam);
			break;
		case WM_KEYUP:
			//键盘松开事件
			if (GameStart && m_hero.alive) KeyUp(hWnd, wParam, lParam);
			break;
		case WM_MOUSEMOVE:
			//鼠标移动事件
			MouseMove(hWnd, wParam, lParam);
			break;
		case WM_LBUTTONDOWN:
			//左鼠标事件
			LeftKeyDown = TRUE;
			LButtonDown(hWnd, wParam, lParam);
			break;
		case WM_LBUTTONUP:
			LeftKeyDown = FALSE;
			LButtonUp(hWnd, wParam, lParam);
			break;
		case WM_TIMER:
			//定时器事件
			TimerUpdate(hWnd, wParam, lParam);
			break;
		case WM_DESTROY:
			PostQuitMessage(0);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
			break;
	}
	return 0;
}
void CDrawSquare::LButtonUp(CDPoint p)
{
    // If the user has made a significant movement,
    // then consider this a placement....
    double offset_x = m_point_a.x - m_point_b.x;
    double offset_y = m_point_a.y - m_point_b.y;

    if (offset_x < 0)
    {
        offset_x = -offset_x;
    }
    if (offset_y < 0)
    {
        offset_y = -offset_y;
    }

    if (offset_x > 10 || offset_y > 10)
    {
        // Second line..
        LButtonDown(p,p);
    }
}
Esempio n. 6
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_CREATE:
		//初始化
		Init(hWnd, wParam, lParam);
		break;
	case WM_PAINT:
		//绘制
		Render(hWnd);
		break;
	case WM_KEYDOWN:
		//键盘按下事件
		KeyDown(hWnd, wParam, lParam);
		break;
	case WM_KEYUP:
		//键盘松开事件
		KeyUp(hWnd, wParam, lParam);
		break;
	case WM_LBUTTONDOWN:
		//左鼠标事件
		LButtonDown(hWnd, wParam, lParam);
		break;
	case WM_TIMER:
		//定时器事件
		TimerUpdate(hWnd, wParam, lParam);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
Esempio n. 7
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_CREATE:
		WindowInit(hWnd, wParam, lParam);
		break;
	case WM_PAINT:
		Render(hWnd);
		break;
	case WM_KEYDOWN:
		KeyDown(hWnd, wParam, lParam);
		break;
	case WM_KEYUP:
		break;
	case WM_MOUSEMOVE:
		MouseMove(hWnd, wParam, lParam);
		break;
	case WM_LBUTTONDOWN:
		LButtonDown(hWnd, wParam, lParam);
		break;
	case WM_TOUCH:
		return TouchEvent(hWnd, message, wParam, lParam);
	case WM_TIMER:
		TimerUpdate(hWnd, wParam, lParam);
		break;
	case WM_DESTROY:
		RemoveFontResource(_T("res/font/fantiquefour.ttf"));
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
Esempio n. 8
0
// Called when the left button is double clicked
// If a card is under the pointer and it can move elsewhere then move it.
// Move onto a foundation as first choice, a populated base as second and
// an empty base as third choice.
// NB Cards in the m_pack cannot be moved in this way - they aren't in play
// yet
void Game::LButtonDblClk(wxDC& dc, int x, int y)
{
    Pile* pile = WhichPile(x, y);
    if (!pile) return;

    // Double click on m_pack is the same as left button down
    if (pile == m_pack)
    {
        LButtonDown(dc, x, y);
    }
    else
    {
        Card* card = pile->GetTopCard();

        if (card)
        {
            int i;

            // if the card is an ace then try to place it next
            // to an ace of the same suit
            if (card->GetPipValue() == 1)
            {
                for(i = 0; i < 4; i++)
                {
                    Card* m_topCard = m_foundations[i]->GetTopCard();
                    if ( m_topCard )
                    {
                        if (m_topCard->GetSuit() == card->GetSuit() &&
                            m_foundations[i + 4] != pile &&
                            m_foundations[i + 4]->GetTopCard() == 0)
                        {
                            pile->RemoveTopCard(dc);
                            m_foundations[i + 4]->AddCard(dc, card);
                            DoMove(dc, pile, m_foundations[i + 4]);
                            return;
                        }
                    }
                }
            }

            // try to place the card on a foundation
            for(i = 0; i < 8; i++)
            {
                if (m_foundations[i]->AcceptCard(card) && m_foundations[i] != pile)
                {
                    pile->RemoveTopCard(dc);
                    m_foundations[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_foundations[i]);
                    return;
                }
            }
            // try to place the card on a populated base
            for(i = 0; i < 10; i++)
            {
                if (m_bases[i]->AcceptCard(card) &&
                    m_bases[i] != pile &&
                    m_bases[i]->GetTopCard())
                {
                    pile->RemoveTopCard(dc);
                    m_bases[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_bases[i]);
                    return;
                }
            }
            // try to place the card on any base
            for(i = 0; i < 10; i++)
            {
                if (m_bases[i]->AcceptCard(card) && m_bases[i] != pile)
                {
                    pile->RemoveTopCard(dc);
                    m_bases[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_bases[i]);
                    return;
                }
            }
        }
    }
}
Esempio n. 9
0
WMSG_RESULT CUIBase::MouseMessage(MSG* pMsg)
{
    WMSG_RESULT ret = WMSG_FAIL;

    UINT16 x = LOWORD(pMsg->lParam);
    UINT16 y = HIWORD(pMsg->lParam);

    // 포커스가 있다면 먼저 처리하자
    CUIBase* pUI = CUIFocus::getSingleton()->getUI();

    switch (pMsg->message)
    {
    case WM_LBUTTONDOWN:
        {
            if (pUI)
                ret = pUI->LButtonDown(x, y);

            if (ret == WMSG_FAIL)
                ret = LButtonDown(x, y);
        }
        break;

    case WM_LBUTTONUP:
        {
            if (pUI)
                ret = pUI->LButtonUp(x, y);

            if (ret == WMSG_FAIL)
                ret = LButtonUp(x, y);
        }
        break;

    case WM_LBUTTONDBLCLK:
        {
            if (pUI)
                ret = pUI->LButtonDBLClick(x, y);

            if (ret == WMSG_FAIL)
                ret = LButtonDBLClick(x, y);
        }
        break;

    case WM_RBUTTONDOWN:
        {
            if (pUI)
                ret = pUI->RButtonDown(x, y);

            if (ret == WMSG_FAIL)
                ret = RButtonDown(x, y);
        }
        break;

    case WM_RBUTTONUP:
        {
            if (pUI)
                ret = pUI->RButtonUp(x, y);

            if (ret == WMSG_FAIL)
                ret = RButtonUp(x, y);
        }
        break;

    case WM_RBUTTONDBLCLK:
        {
            if (pUI)
                ret = pUI->RButtonDBLClick(x, y);

            if (ret == WMSG_FAIL)
                ret = RButtonDBLClick(x, y);
        }
        break;

    case WM_MOUSEMOVE:
        {
            if (pUI)
                ret = pUI->MouseMove(x, y, pMsg);

            if (ret == WMSG_FAIL)
                ret = MouseMove(x, y, pMsg);
        }
        break;

    case WM_MOUSEWHEEL:
        {
            int wheel = (short)HIWORD(pMsg->wParam);

            if (pUI)
                ret = pUI->MouseWheel(x, y, wheel);

            if (ret == WMSG_FAIL)
                ret = MouseWheel(x, y, wheel);
        }
        break;
    }

    return ret;
}
Esempio n. 10
0
// Called when the left button is double clicked
// If a card is under the pointer and it can move elsewhere then move it.
// Move onto a foundation as first choice, a populated base as second and
// an empty base as third choice.
// NB Cards in the m_pack cannot be moved in this way - they aren't in play
// yet
void Game::LButtonDblClk(wxDC& dc, int x, int y)
{
    Pile* pile = WhichPile(x, y);
    if (!pile) return;

    // Double click on m_pack is the same as left button down
    if (pile == m_pack)
    {
        LButtonDown(dc, x, y);
    }
    else
    {
        Card* card = pile->GetTopCard();

        if (card)
        {
            int i;

            // if the card is an ace then try to place it next
            // to an ace of the same suit
            if (card->GetPipValue() == 1)
            {
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
                for(i = 0; i < 4; i++)
                {
                    Card* m_topCard = m_foundations[i]->GetTopCard();
                    if ( m_topCard )
                    {
                        if (m_topCard->GetSuit() == card->GetSuit() &&
                            m_foundations[i + 4] != pile &&
                            m_foundations[i + 4]->GetTopCard() == 0)
                        {
                            pile->RemoveTopCard(dc);
                            m_foundations[i + 4]->AddCard(dc, card);
                            DoMove(dc, pile, m_foundations[i + 4]);
                            return;
                        }
                    }
                }
            }

            // try to place the card on a foundation
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            for(i = 0; i < 8; i++)
            {
                if (m_foundations[i]->AcceptCard(card) && m_foundations[i] != pile)
                {
                    pile->RemoveTopCard(dc);
                    m_foundations[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_foundations[i]);
                    return;
                }
            }
            // try to place the card on a populated base
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            for(i = 0; i < 10; i++)
            {
                if (m_bases[i]->AcceptCard(card) &&
                    m_bases[i] != pile &&
                    m_bases[i]->GetTopCard())
                {
                    pile->RemoveTopCard(dc);
                    m_bases[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_bases[i]);
                    return;
                }
            }
            // try to place the card on any base
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
            for(i = 0; i < 10; i++)
            {
                if (m_bases[i]->AcceptCard(card) && m_bases[i] != pile)
                {
                    pile->RemoveTopCard(dc);
                    m_bases[i]->AddCard(dc, card);
                    DoMove(dc, pile, m_bases[i]);
                    return;
                }
            }
        }
    }
}
Esempio n. 11
0
void CIVStatusBar::OnLButtonDown(UINT nFlags, CPoint point) 
{
	LButtonDown(nFlags, point);
}
Esempio n. 12
0
void Window::HandleMouseMove(Pos &oScreenPos)
{
    Control *pControl;
    Pos      oPos;
    Rect     oRect;

    IncUsageRef();

    if (m_bWindowMove)
    {
       Rect oActualPos;

       m_oMoveStart.x1 += (oScreenPos.x - m_oMovePos.x);
       m_oMoveStart.x2 += (oScreenPos.x - m_oMovePos.x);
       m_oMoveStart.y1 += (oScreenPos.y - m_oMovePos.y);
       m_oMoveStart.y2 += (oScreenPos.y - m_oMovePos.y);

       oActualPos = m_oMoveStart;

       if (m_iDesktopWidth > 0 && m_iDesktopHeight > 0)
       {
           if ((oActualPos.x1 >= 0 && oActualPos.x1 < iDesktopSnapAmount) || 
               (oActualPos.x1 < 0 && oActualPos.x1 > -iDesktopSnapAmount)) 
           {
               oActualPos.x2 -= oActualPos.x1;
               oActualPos.x1 = 0;           
           }
           if ((oActualPos.y1 >= 0 && oActualPos.y1 < iDesktopSnapAmount) ||
               (oActualPos.y1 < 0 && oActualPos.y1 > -iDesktopSnapAmount)) 
           {
               oActualPos.y2 -= oActualPos.y1;
               oActualPos.y1 = 0;           
           }
           if ((oActualPos.x2 < m_iDesktopWidth && 
                oActualPos.x2 >= m_iDesktopWidth - iDesktopSnapAmount) || 
               (oActualPos.x2 > m_iDesktopWidth && 
                oActualPos.x2 <= m_iDesktopWidth + iDesktopSnapAmount)) 
           {
               oActualPos.x1 += m_iDesktopWidth - oActualPos.x2;
               oActualPos.x2 = m_iDesktopWidth;           
           }
           if ((oActualPos.y2 < m_iDesktopHeight && 
                oActualPos.y2 >= m_iDesktopHeight - iDesktopSnapAmount) || 
               (oActualPos.y2 > m_iDesktopHeight && 
                oActualPos.y2 <= m_iDesktopHeight + iDesktopSnapAmount)) 
           {
               oActualPos.y1 += m_iDesktopHeight - oActualPos.y2;
               oActualPos.y2 = m_iDesktopHeight;           
           }
       }       

       m_oMovePos = oScreenPos;
       SetWindowPosition(oActualPos);
       DecUsageRef();
       
       return; 
    }

    if (m_bLButtonDown && !LButtonDown())
    {
       m_bLButtonDown = false;
       m_pMouseDownControl = NULL;
    }

    GetWindowPosition(oRect);
    oPos.x = oScreenPos.x - oRect.x1;
    oPos.y = oScreenPos.y - oRect.y1;
   
    if (m_pCaptureControl)
    {
       m_pCaptureControl->AcceptTransition(CT_MouseMove, &oPos);
       DecUsageRef();
       return;
    }

    pControl = ControlFromPos(oPos);
    if (pControl)
    {
       if (m_pMouseDownControl && m_pMouseInControl &&
           m_pMouseDownControl != pControl)
       {
           m_pMouseInControl->AcceptTransition(CT_MouseLeave);
           m_pMouseInControl = NULL;
       }    
       else
       if (m_pMouseDownControl && m_pMouseInControl == NULL &&
           m_pMouseDownControl == pControl)
       {
           m_pMouseInControl = m_pMouseDownControl;
           m_pMouseInControl->AcceptTransition(CT_MouseEnter);
           m_pMouseInControl->AcceptTransition(CT_MouseLButtonDown);
       }    
       else
       if (!m_bLButtonDown)
       {
           if (m_pMouseInControl && m_pMouseInControl != pControl)
           {
               m_pMouseInControl->AcceptTransition(CT_MouseLeave);
               m_pMouseInControl = pControl;
               m_pMouseInControl->AcceptTransition(CT_MouseEnter);
               if (m_bLButtonDown)
               {
                  m_pMouseInControl->AcceptTransition(CT_MouseLButtonDown);
               }   
           }
           else
           if (m_pMouseInControl == NULL)
           {
               m_pMouseInControl = pControl;
               m_pMouseInControl->AcceptTransition(CT_MouseEnter);
               if (m_bLButtonDown)
               {
                  m_pMouseInControl->AcceptTransition(CT_MouseLButtonDown);
               }
           }
       }

       pControl->AcceptTransition(CT_MouseMove, &oPos);
       DecUsageRef();
       return;
    }
    else
    {
       if (m_pMouseInControl)
       {
           m_pMouseInControl->AcceptTransition(CT_MouseLeave);
           m_pMouseInControl = NULL;
       }
    }
    DecUsageRef();

    return;
}