Example #1
0
bool CLocalGUI::ProcessMessage ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // If we have the focus, we handle the message
    if ( InputGoesToGUI () )
    {
        // Pass the message to the GUI manager
		// ACHTUNG: fix the CEGUI ones!
        switch ( uMsg )
        {
			case WM_MOUSEWHEEL:
                if ( GET_WHEEL_DELTA_WPARAM ( wParam ) > 0 )  
				    pGUI->ProcessMouseInput ( CGUI_MI_MOUSEWHEEL, 1, NULL );
                else
                    pGUI->ProcessMouseInput ( CGUI_MI_MOUSEWHEEL, 0, NULL );
				return true;

            case WM_MOUSEMOVE:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEPOS, LOWORD ( lParam ), HIWORD ( lParam ) );
                return true;

            case WM_LBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, LeftButton );
                return true;

            case WM_RBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, RightButton );
                return true;

            case WM_MBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, MiddleButton );
                return true;

            case WM_LBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, LeftButton );
                return true;

            case WM_RBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, RightButton );
                return true;

			case WM_MBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, MiddleButton );
                return true;
#ifdef WM_XBUTTONDOWN
			case WM_XBUTTONDOWN:
				pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, X1Button );
				return true;

			case WM_XBUTTONUP:
				pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, X1Button );
				return true;
#endif
            case WM_KEYDOWN:
            {
                DWORD dwTemp = TranslateScanCodeToGUIKey ( wParam );
                if ( dwTemp > 0 )
                {
                    pGUI->ProcessKeyboardInput ( dwTemp, true );
                    return true;
                }

                return true;
            }

            case WM_KEYUP:
            {
                DWORD dwTemp = TranslateScanCodeToGUIKey ( wParam );
                if ( dwTemp > 0 )
                {
                    pGUI->ProcessKeyboardInput ( dwTemp, false );
                }

                return false;
            }

            case WM_CHAR:
                pGUI->ProcessCharacter ( wParam );
                return true;
        }
    }

    // Test - Use PageUp and PageDown to scroll chat box
    switch ( uMsg )
    {
        case WM_KEYDOWN:
        {
            if ( wParam == VK_PRIOR )
            {
                if ( m_pChat )
                    m_pChat->ScrollUp ();

                if ( m_pDebugView )
                    m_pDebugView->ScrollUp ();
            }
            else
            if ( wParam == VK_NEXT )
            {
                if ( m_pChat )
                    m_pChat->ScrollDown ();

                if ( m_pDebugView )
                    m_pDebugView->ScrollDown ();
            }
        }
    }


    // The event wasn't handled
    return false;
}
Example #2
0
bool CLocalGUI::ProcessMessage ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    CGUI* pGUI = CCore::GetSingleton ().GetGUI ();

    // If we have the focus, we handle the message
    if ( InputGoesToGUI () )
    {
        // Pass the message to the GUI manager
        // ACHTUNG: fix the CEGUI ones!
        switch ( uMsg )
        {
            case WM_MOUSEWHEEL:
                if ( GET_WHEEL_DELTA_WPARAM ( wParam ) > 0 )  
                    pGUI->ProcessMouseInput ( CGUI_MI_MOUSEWHEEL, 1, NULL );
                else
                    pGUI->ProcessMouseInput ( CGUI_MI_MOUSEWHEEL, 0, NULL );
                return true;

            case WM_MOUSEMOVE:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEPOS, LOWORD ( lParam ), HIWORD ( lParam ) );
                return true;

            case WM_LBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, LeftButton );
                return true;

            case WM_RBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, RightButton );
                return true;

            case WM_MBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, MiddleButton );
                return true;

            case WM_LBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, LeftButton );
                return true;

            case WM_RBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, RightButton );
                return true;

            case WM_MBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, MiddleButton );
                return true;
#ifdef WM_XBUTTONDOWN
            case WM_XBUTTONDOWN:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEDOWN, 0, 0, X1Button );
                return true;

            case WM_XBUTTONUP:
                pGUI->ProcessMouseInput ( CGUI_MI_MOUSEUP, 0, 0, X1Button );
                return true;
#endif
            case WM_KEYDOWN:
            {
                DWORD dwTemp = TranslateScanCodeToGUIKey ( wParam );
                if ( dwTemp > 0 )
                {
                    pGUI->ProcessKeyboardInput ( dwTemp, true );
                    return true;
                }

                return true;
            }

            case WM_KEYUP:
            {
                DWORD dwTemp = TranslateScanCodeToGUIKey ( wParam );
                if ( dwTemp > 0 )
                {
                    pGUI->ProcessKeyboardInput ( dwTemp, false );
                }

                return false;
            }

            case WM_IME_COMPOSITION:
            {
                if ( lParam & GCS_RESULTSTR )
                {
                    HIMC himc = ImmGetContext ( hwnd );

                    // Get composition result
                    ushort buffer[256];
                    LONG numBytes = ImmGetCompositionStringW ( himc, GCS_RESULTSTR, buffer, sizeof ( buffer ) - 2 );
                    int iNumCharacters = numBytes / sizeof ( ushort );

                    // Erase output from previous composition state
                    for ( int i = 0 ; i < m_uiActiveCompositionSize ; i++ )
                    {
                        pGUI->ProcessCharacter ( '\x08' );
                        pGUI->ProcessKeyboardInput ( 14, true );
                    }

                    // Output composition result
                    for ( int i = 0 ; i < iNumCharacters ; i++ )
                        if ( buffer[i] )
                            pGUI->ProcessCharacter ( buffer[i] );

                    ImmReleaseContext ( hwnd, himc );

                    m_uiActiveCompositionSize = 0;
                }
                else if( lParam & GCS_COMPSTR ) 
                {
                    HIMC himc = ImmGetContext ( hwnd );

                    // Get composition state
                    ushort buffer[256];
                    LONG numBytes = ImmGetCompositionStringW ( himc, GCS_COMPSTR, buffer, sizeof ( buffer ) - 2 );
                    int iNumCharacters = numBytes / sizeof ( ushort );

                    // Erase output from previous composition state
                    for ( int i = 0 ; i < m_uiActiveCompositionSize ; i++ )
                    {
                        pGUI->ProcessCharacter ( '\x08' );
                        pGUI->ProcessKeyboardInput ( 14, true );
                    }

                    // Output new composition state
                    for ( int i = 0 ; i < iNumCharacters ; i++ )
                        if ( buffer[i] )
                            pGUI->ProcessCharacter ( buffer[i] );

                    ImmReleaseContext ( hwnd, himc );

                    m_uiActiveCompositionSize = iNumCharacters;
                }
            }
            break;

            case WM_IME_CHAR:
                return true;
            case WM_IME_KEYDOWN:
            {
                // Handle space/return seperately in this case
                if ( wParam == VK_SPACE   )
                    pGUI->ProcessCharacter ( MapVirtualKey( wParam, MAPVK_VK_TO_CHAR ) );

                DWORD dwTemp = TranslateScanCodeToGUIKey ( wParam );
                if ( dwTemp > 0 )
                    pGUI->ProcessKeyboardInput ( dwTemp, true );
            }
            break;

            case WM_CHAR:
            {
                pGUI->ProcessCharacter ( wParam );
                return true;
            }
            break;
        }
    }

    // The event wasn't handled
    return false;
}