Exemplo n.º 1
0
void CModifiedButtonWidget::OnMouseEvent( CMouseEvent* event )
{
	// logger << event->GetButtons() << std::endl;
	switch( event->GetType() )
	{
	case types::mouse_button_down:
		
		if( event->GetButtons() & myClickableButtons ) 
		{
			mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_down" );
			myClicked = true;
			OnMouseDown( myParam );
		}

		if( myDragable && event->GetButtons() & myDragableButtons )
		{
			// mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" );
			myDragging = true;
			myDragOffset = types::point( this->GetRect().x, this->GetRect().y ) - event->GetPosition();
			IMouse::AddConstantEventListeners( this );
		}

		if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == true )
		{
			if( myDoubleClickTimer.GetTime() < double_click_time )
				OnDoubleClick( myParam );
			myDoubleClicking = false;
		}
		else if( myDoubleClickable && event->GetButtons() & myDoubleClickableButtons && myDoubleClicking == false )
		{
			myDoubleClickTimer.Reset();
			myDoubleClickTimer.Resume();
			myDoubleClicking = true;
		}
		else if ( myDoubleClickable && event->GetButtons() & !myDoubleClickableButtons )
		{
			myDoubleClicking = false;
		}



		break;

	case types::mouse_button_up:
		if( myClicked && event->GetButtons() & myClickableButtons ) 
		{
			mySpriteHandler->PlayAnimation( GetSprite(), "mouse_button_up" );
			OnClick( myParam );

			myClicked = false;
			OnMouseUp( myParam );
		}

		if( myDragable && event->GetButtons() & myDragableButtons )
		{
			// mySpriteHandler->PlayAnimation( GetSprite(), "mouse_on_drag" );
			myDragging = false;
			IMouse::RemoveConstantEventListeners( this );
			OnDragEnd();
		}

		myClicked = false;
		break;

	case types::mouse_move:

		if( myDragging )
		{
			types::point where_to = event->GetPosition() + myDragOffset;

			// Fixed 12-09-2007 by Pete
			//--------------------------------------------------------------------------
			// BUGBUG: This should be the commented line, but the signal-slot 
			// doesn't support three parameters at the current time
			// OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam );

			if( config::automatic_dragging )
				MoveBy( types::point( where_to.x - GetRect().x, where_to.y - GetRect().y ) );	

			OnDrag( where_to.x - GetRect().x, where_to.y - GetRect().y, myParam );
		}

		// myDoubleClicking = false;
		break;

	case types::mouse_over:
		{
			const std::string animation = mySelectionOn?"select_mouse_over":"mouse_over";
			mySpriteHandler->PlayAnimation( GetSprite(), animation );
			OnMouseOver( myParam );
		}
		break;

	case types::mouse_out:
		{
			const std::string animation = mySelectionOn?"select_mouse_out":"mouse_out";
			mySpriteHandler->PlayAnimation( GetSprite(), animation );
			myClicked = false;
			myDoubleClicking = false;
			OnMouseOut( myParam );
		}
		break;

	default:
		break;
	}

}
Exemplo n.º 2
0
  LRESULT cOpenGLControl::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  {
     switch (uMsg) {
        case WM_SETFOCUS:
        case WM_KILLFOCUS:
        case WM_ENABLE:
          Update();
          break;

        case WM_SIZING:
        case WM_SIZE:
          UpdateSize();
          OnSize();
          Update();
          break;

        case WM_PAINT:
          Paint();
          return FALSE;

        case WM_ERASEBKGND:
          return TRUE;

        case WM_MOUSEMOVE: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));

           if (!bMouseIn) {
              TRACKMOUSEEVENT tme;
              tme.cbSize = sizeof(TRACKMOUSEEVENT);
              tme.dwFlags = TME_LEAVE | TME_HOVER;
              tme.hwndTrack = hwnd;
              tme.dwHoverTime = HOVER_DEFAULT;
              ::TrackMouseEvent(&tme);
              OnMouseIn();
              bMouseIn = true;
           }

           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnMouseMove(x, y, modifiers);
        } break;

        case WM_MOUSELEAVE:
           if (bMouseIn) {
              OnMouseOut();
              bMouseIn = false;
           }
           break;

        case WM_MOUSEHOVER:
          if (bMouseIn) {
            const int x = int((short)LOWORD(lParam));
            const int y = int((short)HIWORD(lParam));
            cKeyModifiers modifiers;
            GetModifiersForMouseEvent(modifiers, wParam);
            OnMouseHover(x, y, modifiers);

            // Reset the track mouse event
            TRACKMOUSEEVENT tme;
            tme.cbSize = sizeof(TRACKMOUSEEVENT);
            tme.dwFlags = TME_LEAVE | TME_HOVER;
            tme.hwndTrack = hwnd;
            tme.dwHoverTime = HOVER_DEFAULT;
            ::TrackMouseEvent(&tme);
          }
          break;

        case WM_LBUTTONDOWN: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnLButtonDown(x, y, modifiers);
           break;
         }

        case WM_LBUTTONUP: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnLButtonUp(x, y, modifiers);
           break;
         }

        case WM_RBUTTONDOWN: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnRButtonDown(x, y, modifiers);
           break;
         }

        case WM_RBUTTONUP: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnRButtonUp(x, y, modifiers);
           break;
         }

        case WM_MBUTTONDOWN: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnMButtonDown(x, y, modifiers);
           break;
         }

        case WM_MBUTTONUP: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnMButtonUp(x, y, modifiers);
           break;
         }

        case WM_LBUTTONDBLCLK: {
           const int x = int((short)LOWORD(lParam));
           const int y = int((short)HIWORD(lParam));
           cKeyModifiers modifiers;
           GetModifiersForMouseEvent(modifiers, wParam);
           OnDoubleClick(x, y, modifiers);
           break;
         }

        case WM_MOUSEWHEEL: {
           POINT pt;
           pt.x = LOWORD(lParam);
           pt.y = HIWORD(lParam);
           if (::ScreenToClient(hwnd, &pt) == TRUE) {
             cKeyModifiers modifiers;
             GetModifiersForMouseEvent(modifiers, wParam);
             OnMouseWheel(pt.x, pt.y, short(HIWORD(wParam)), modifiers);
           }
           break;
         }

        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
           if ((lParam & 0x40000000) == 0) {
              cKeyEvent event;
              event.key = wParam;
              event.modifiers.bControl = ((::GetKeyState(VK_CONTROL) & 0x8000) != 0);
              event.modifiers.bAlt = ((::GetKeyState(VK_MENU) & 0x8000) != 0);
              event.modifiers.bShift = ((::GetKeyState(VK_SHIFT) & 0x8000) != 0);
              OnKeyDown(event);
           }
           break;

        case WM_KEYUP:
        case WM_SYSKEYUP:
           if ((lParam & 0x40000000) == 0) {
              cKeyEvent event;
              event.key = wParam;
              event.modifiers.bControl = ((::GetKeyState(VK_CONTROL) & 0x8000) != 0);
              event.modifiers.bAlt = ((::GetKeyState(VK_MENU) & 0x8000) != 0);
              event.modifiers.bShift = ((::GetKeyState(VK_SHIFT) & 0x8000) != 0);
              OnKeyUp(event);
           }
           break;
     }

     return DefWindowProc(hwnd, uMsg, wParam, lParam);
  }
Exemplo n.º 3
0
void AbstractObj::mouseOut()
{
    emit OnMouseOut();
}