Example #1
0
void Game::EventKeyPress(WPARAM wParam, LPARAM lParam)
{
	//Toggle full screen mode when escape is pressed
	if( wParam == VK_ESCAPE )
		enableFullScreenMode(md3dPP.Windowed);

	gMyGameWorld->KeyPress(wParam);
}
void MainWindow::initUI()
{
    setWindowTitle("Maliit test application");
    m_grid_row = 0;

    QHBoxLayout *buttons = new QHBoxLayout;
    buttons->addWidget(m_start_server);
    buttons->addWidget(m_rotate_keyboard);
    // Clicking the button will steal focus from the text edit, thus hiding
    // the virtual keyboard:
    buttons->addWidget(new QPushButton("Dismiss input method"));

    m_grid->addLayout(buttons, m_grid_row, 1);
    ++m_grid_row;

    // multi line:
    QLabel *label = 0;
    QTextEdit *entry = 0;

    m_grid->addWidget(label = new QLabel("multi line"), m_grid_row, 0);
    m_grid->addWidget(entry = new QTextEdit, m_grid_row, 1);
    ++m_grid_row;

    label->setToolTip("Qt::ImhNone");
    entry->setInputMethodHints(Qt::ImhNone);
    entry->installEventFilter(this);

    // single line, emulating content types via Qt::InputMethodHints:
    insertIntoGrid("single line", Qt::ImhNone,
                   "Qt::ImhNone");
    insertIntoGrid("password", Qt::ImhHiddenText|Qt::ImhNoPredictiveText,
                   "Qt::ImhHiddenText|Qt::ImhNoPredictiveText");
    insertIntoGrid("numbers only", Qt::ImhFormattedNumbersOnly,
                   "Qt::ImhFormattedNumbersOnly");
    insertIntoGrid("dialer input", Qt::ImhDialableCharactersOnly,
                   "Qt::ImhDialableCharactersOnly");
    insertIntoGrid("symbol view", Qt::ImhPreferNumbers,
                   "Qt::ImhPreferNumbers");
    insertIntoGrid("e-mail", Qt::ImhEmailCharactersOnly,
                   "Qt::ImhEmailCharactersOnly");
    insertIntoGrid("website", Qt::ImhUrlCharactersOnly,
                   "Qt::ImhUrlCharactersOnly");

    // Don't want other buttons to steal focus:
    m_start_server->setFocusPolicy(Qt::NoFocus);
    m_rotate_keyboard->setFocusPolicy(Qt::NoFocus);

    QPushButton *close_app = new QPushButton("Close application");
    m_grid->addWidget(close_app, m_grid_row, 1);
    ++m_grid_row;

    connect(close_app, SIGNAL(clicked()),
            this,     SLOT(close()));

    setCentralWidget(new QWidget);
    centralWidget()->setLayout(m_grid);

    if (enableFullScreenMode()) {
        showFullScreen();
    } else {
        show();
    }
}
Example #3
0
LRESULT D3DApp::msgProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
	// Is the application in a minimized or maximized state?
	static bool minOrMaxed = false;

	RECT clientRect = {0, 0, 0, 0};
	switch( msg )
	{

		// WM_ACTIVE is sent when the window is activated or deactivated.
		// We pause the game when the main window is deactivated and 
		// unpause it when it becomes active.
	case WM_ACTIVATE:
		/*if( LOWORD(wParam) == WA_INACTIVE )
			mAppPaused = true;
		else
			mAppPaused = false;*/
		return 0;


		// WM_SIZE is sent when the user resizes the window.  
	case WM_SIZE:
		if( md3dDevice )
		{
			md3dPP.BackBufferWidth  = LOWORD(lParam);
			md3dPP.BackBufferHeight = HIWORD(lParam);

			if( wParam == SIZE_MINIMIZED )
			{
				mAppPaused = true;
				minOrMaxed = true;
			}
			else if( wParam == SIZE_MAXIMIZED )
			{
				mAppPaused = false;
				minOrMaxed = true;
				onLostDevice();
				HR(md3dDevice->Reset(&md3dPP));
				onResetDevice();
			}
			// Restored is any resize that is not a minimize or maximize.
			// For example, restoring the window to its default size
			// after a minimize or maximize, or from dragging the resize
			// bars.
			else if( wParam == SIZE_RESTORED )
			{
				mAppPaused = false;

				// Are we restoring from a mimimized or maximized state, 
				// and are in windowed mode?  Do not execute this code if 
				// we are restoring to full screen mode.
				if( minOrMaxed && md3dPP.Windowed )
				{
					onLostDevice();
					HR(md3dDevice->Reset(&md3dPP));
					onResetDevice();
				}
				else
				{
					// No, which implies the user is resizing by dragging
					// the resize bars.  However, we do not reset the device
					// here because as the user continuously drags the resize
					// bars, a stream of WM_SIZE messages is sent to the window,
					// and it would be pointless (and slow) to reset for each
					// WM_SIZE message received from dragging the resize bars.
					// So instead, we reset after the user is done resizing the
					// window and releases the resize bars, which sends a
					// WM_EXITSIZEMOVE message.
				}
				minOrMaxed = false;
			}
		}
		return 0;


		// WM_EXITSIZEMOVE is sent when the user releases the resize bars.
		// Here we reset everything based on the new window dimensions.
	case WM_EXITSIZEMOVE:
		GetClientRect(mhMainWnd, &clientRect);
		md3dPP.BackBufferWidth  = clientRect.right;
		md3dPP.BackBufferHeight = clientRect.bottom;
		onLostDevice();
		HR(md3dDevice->Reset(&md3dPP));
		onResetDevice();

		return 0;

		// WM_CLOSE is sent when the user presses the 'X' button in the
		// caption bar menu.
	case WM_CLOSE:
		/*SLogOut logOut;
		gNetClient->SendPacket(&logOut);*/
		shutdownComponents();
		DestroyWindow(mhMainWnd);
		return 0;
	

		// WM_DESTROY is sent when the window is being destroyed.
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

	case WM_KEYDOWN:
		if( wParam == VK_ESCAPE )
			enableFullScreenMode(false);
		else if( wParam == 'F' )
			enableFullScreenMode(true);
		return 0;
	}
	return DefWindowProc(mhMainWnd, msg, wParam, lParam);
}