/* * 功能: * 构造函数,初始化有限状态机并run之。 * 参数: * 无 * 返回值: * 无 */ EnglishInput::EnglishInput(QWidget *parent) : QWidget(parent) , p_centerWidget(NULL) , m_currentWidth(0) , m_currentHeight(0) , p_textEdit(NULL) , p_lineEdit(NULL) , p_groupABC(NULL) , m_inputStr("") , m_upLatter(false) , m_latterStatus(true) , m_objID(0) { setWindowsSize(); setDefaultStyleSheet(); }
LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { BOOL bProcessed = FALSE; switch (message) { case WM_LBUTTONDOWN: #if(_MSC_VER >= 1600) // Don't process message generated by Windows Touch if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break; #endif /* #if(_MSC_VER >= 1600) */ #ifdef Hunter m_measureRect = true; m_mouse1x = (short)LOWORD(lParam) / m_fFrameZoomFactor; m_mouse1y = (short)HIWORD(lParam) / m_fFrameZoomFactor; #endif // Hunter if (m_pDelegate && MK_LBUTTON == wParam) { POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)}; CCPoint pt(point.x, point.y); pt.x /= m_fFrameZoomFactor; pt.y /= m_fFrameZoomFactor; CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y); if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp)) { m_bCaptured = true; SetCapture(m_hWnd); int id = 0; handleTouchesBegin(1, &id, &pt.x, &pt.y); } } break; case WM_MOUSEMOVE: #if(_MSC_VER >= 1600) // Don't process message generated by Windows Touch if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break; #endif /* #if(_MSC_VER >= 1600) */ if (MK_LBUTTON == wParam && m_bCaptured) { POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)}; CCPoint pt(point.x, point.y); int id = 0; pt.x /= m_fFrameZoomFactor; pt.y /= m_fFrameZoomFactor; handleTouchesMove(1, &id, &pt.x, &pt.y); } #ifdef Hunter { POINT point22 = {(short)LOWORD(lParam), (short)HIWORD(lParam)}; int m2x = 0, m2y = 0, m1x = 0, m1y = 0; m1x = point22.x / m_fFrameZoomFactor; m1y = point22.y / m_fFrameZoomFactor; if (m_measureRect) { m2x = point22.x / m_fFrameZoomFactor; m2y = point22.y / m_fFrameZoomFactor; } if(m2x != m_mouse2x || m1x != m_mouse1x || m1y != m_mouse1y || m_mouse2y != m2y) { m_mouse2x = m2x; m_mouse2y = m2y; if(!m_measureRect) { m_mouse1x = m1x; m_mouse1y = m1y; } updateStatusMessage(); } } #endif // Hunter break; case WM_LBUTTONUP: #if(_MSC_VER >= 1600) // Don't process message generated by Windows Touch if (m_bSupportTouch && (s_pfGetMessageExtraInfoFunction() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) break; #endif /* #if(_MSC_VER >= 1600) */ #ifdef Hunter m_measureRect = false; #endif // Hunter if (m_bCaptured) { POINT point = {(short)LOWORD(lParam), (short)HIWORD(lParam)}; CCPoint pt(point.x, point.y); int id = 0; pt.x /= m_fFrameZoomFactor; pt.y /= m_fFrameZoomFactor; handleTouchesEnd(1, &id, &pt.x, &pt.y); ReleaseCapture(); m_bCaptured = false; } break; #if(_MSC_VER >= 1600) case WM_TOUCH: { BOOL bHandled = FALSE; UINT cInputs = LOWORD(wParam); PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs]; if (pInputs) { if (s_pfGetTouchInputInfoFunction((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))) { for (UINT i=0; i < cInputs; i++) { TOUCHINPUT ti = pInputs[i]; POINT input; input.x = TOUCH_COORD_TO_PIXEL(ti.x); input.y = TOUCH_COORD_TO_PIXEL(ti.y); ScreenToClient(m_hWnd, &input); CCPoint pt(input.x, input.y); CCPoint tmp = ccp(pt.x, m_obScreenSize.height - pt.y); if (m_obViewPortRect.equals(CCRectZero) || m_obViewPortRect.containsPoint(tmp)) { pt.x /= m_fFrameZoomFactor; pt.y /= m_fFrameZoomFactor; if (ti.dwFlags & TOUCHEVENTF_DOWN) handleTouchesBegin(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y); else if (ti.dwFlags & TOUCHEVENTF_MOVE) handleTouchesMove(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y); else if (ti.dwFlags & TOUCHEVENTF_UP) handleTouchesEnd(1, reinterpret_cast<int*>(&ti.dwID), &pt.x, &pt.y); } } bHandled = TRUE; } delete [] pInputs; } if (bHandled) { s_pfCloseTouchInputHandleFunction((HTOUCHINPUT)lParam); } } break; #endif /* #if(_MSC_VER >= 1600) */ case WM_SIZE: #ifndef GCParticleEditor switch (wParam) { case SIZE_RESTORED: CCApplication::sharedApplication()->applicationWillEnterForeground(); break; case SIZE_MINIMIZED: CCApplication::sharedApplication()->applicationDidEnterBackground(); break; } #endif break; case WM_KEYDOWN: if (wParam == VK_F1 || wParam == VK_F2) { CCDirector* pDirector = CCDirector::sharedDirector(); if (GetKeyState(VK_LSHIFT) < 0 || GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0) pDirector->getKeypadDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked); } else if (wParam == VK_ESCAPE) { CCDirector::sharedDirector()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked); } #ifdef Hunter else { CCDirector::sharedDirector()->getKeypadDispatcher()->win32KeyboardMSG(message, wParam); } #endif // Hunter if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } break; #ifdef Hunter case WM_SYSKEYDOWN: { DWORD dwFlags = (DWORD)lParam; if(0x20000000 & dwFlags) { if(wParam == VK_RETURN) { CCLOG("wParam is %d", wParam); CCLOG("lParam is %d", lParam); DWORD info = GetWindowLong(m_hWnd, GWL_STYLE); if((info & WS_POPUP) > 0) { setWindowsSize(true, 1136, 640); } else { setWindowsSize(false, 1136, 640); } } } } break; #endif case WM_KEYUP: #ifdef Hunter CCDirector::sharedDirector()->getKeypadDispatcher()->win32KeyboardMSG(message, wParam); #endif // Hunter if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } break; case WM_CHAR: { if (wParam < 0x20) { if (VK_BACK == wParam) { CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward(); } else if (VK_RETURN == wParam) { CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1); } else if (VK_TAB == wParam) { // tab input } else if (VK_ESCAPE == wParam) { // ESC input //CCDirector::sharedDirector()->end(); } } else if (wParam < 128) { // ascii char CCIMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&wParam, 1); } else { char szUtf8[8] = {0}; int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL); CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen); } if ( m_lpfnAccelerometerKeyHook!=NULL ) { (*m_lpfnAccelerometerKeyHook)( message,wParam,lParam ); } } break; case WM_PAINT: PAINTSTRUCT ps; BeginPaint(m_hWnd, &ps); EndPaint(m_hWnd, &ps); break; case WM_CLOSE: CCDirector::sharedDirector()->end(); break; case WM_DESTROY: destroyGL(); PostQuitMessage(0); break; default: if (m_wndproc) { m_wndproc(message, wParam, lParam, &bProcessed); if (bProcessed) break; } return DefWindowProc(m_hWnd, message, wParam, lParam); } if (m_wndproc && !bProcessed) { m_wndproc(message, wParam, lParam, &bProcessed); } return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int cmdShow) { MSG message; //메세지 (윈도우) WNDCLASS wndClass; //윈도우 구조체 _hInstance = hInstance; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hInstance = hInstance; wndClass.lpfnWndProc = (WNDPROC)WndProc; wndClass.lpszClassName = WINNAME; wndClass.lpszMenuName = NULL; wndClass.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wndClass); _hWnd = CreateWindow( WINNAME, WINNAME, WS_OVERLAPPEDWINDOW, WINSTARTX, WINSTARTY, WINSIZEX, WINSIZEY, NULL, (HMENU)NULL, hInstance, NULL); setWindowsSize(WINSTARTX, WINSTARTY, WINSIZEX, WINSIZEY); ShowWindow(_hWnd, cmdShow); //메세지 처리 루프문 if (FAILED(_pg.init())) { return 0; //꺼버려라 } //GetMessage : 메시지가 발생해야 그제서야 처리한다 //PeekMessage : 메세지 여부와 상관없이 메시지 처리를 계속 하고있다 /* while (GetMessage(&message, 0, 0, 0)) { TranslateMessage(&message); //키보드 입력하는 순간에 입력키 전달 메시지 DispatchMessage(&message); //실제로 윈도우로 메시지를 전송해주는 역할 } */ while (true) { if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { if (message.message == WM_QUIT) break; TranslateMessage(&message); DispatchMessage(&message); } else { TIMEMANAGER->update(60.0f); _pg.update(); _pg.render(); } } //KillTimer _pg.release(); UnregisterClass(WINNAME, hInstance); return message.wParam; }