void MaximizeState::slotIncomingPhoneCall()
{
	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin && activeWin->supportsPause()) {
		activeWin->pause();
	}
}
void MaximizeState::onExit(QEvent* event)
{
	CardWindowManagerState::onExit(event);
	CardWindow* activeWin = m_wm->activeWindow();
	m_exiting = true;

	if(false == m_wm->isLastWindowAddedModal()) {
		if (activeWin) {
                    activeWin->setMaxAndLoading(0);
			QRect r = m_wm->normalOrScreenBounds(0);
			resizeWindow(activeWin, r.width(), r.height());

			if (!activeWin->removed())
				m_wm->queueFocusAction(activeWin, false);

			SystemUiController::instance()->setDirectRenderingForWindow(SystemUiController::CARD_WINDOW_MANAGER, activeWin, false);
			activeWin->setAttachedToGroup(true);
		}

		// notify the system that we are no longer maximized
		SystemUiController::instance()->setCardWindowMaximized(false);
		SystemUiController::instance()->setMaximizedCardWindow(0);

		m_exiting = false;
		m_disableDirectRendering = 0;
	}
}
void LoadingState::animationsFinished()
{
	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin && activeWin->addedToWindowManager()) {
		m_wm->maximizeActiveWindow(!lastWindowAddedType());
	}
}
void MaximizeState::processTouchToShareTransfer(const std::string& appId)
{
    CardWindow* activeWindow = m_wm->activeWindow();
    if (activeWindow && activeWindow->appId() == appId) {
        // looks like a match, queue up an animation and minimize the app
        m_wm->queueTouchToShareAction(activeWindow);
        m_wm->minimizeActiveWindow();
    }
}
Beispiel #5
0
VOID ShowDeckOptionsDlg(HWND hwnd)
{
    INT cardBack;

    if ((cardBack = DialogBox(hInstance, MAKEINTRESOURCE(IDD_CARDBACK), hwnd, CardBackDlgProc)))
    {
        SpiderWnd.SetBackCardIdx(CARDBACK_RES_START + (cardBack - 1));
        SpiderWnd.Redraw();
    }
}
void LoadingState::onExit(QEvent* event)
{
    CardWindowManagerState::onExit(event);

	// in case we exit the Loading state during the maximizing animation
	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin && activeWin->addedToWindowManager()) {

		activeWin->stopLoadingOverlay();
	}
}
void PreparingState::windowAdded(CardWindow* win)
{
	CardWindow* activeWin = m_wm->activeWindow();
	if (win != activeWin) {
		CardWindowManagerState::windowAdded(win);
		return;
	}

	activeWin->stopLoadingOverlay();
	m_wm->maximizeActiveWindow(!lastWindowAddedType());

	if (!Settings::LunaSettings()->lunaSystemSoundAppOpen.empty())
		SoundPlayerPool::instance()->playFeedback(Settings::LunaSettings()->lunaSystemSoundAppOpen);
}
void MinimizeState::onEntry(QEvent* event)
{
	CardWindowManagerState::onEntry(event);

	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin) {
		m_wm->queueFocusAction(activeWin, false);
		QRectF boundingRect = m_wm->normalOrScreenBounds(0);
		activeWin->setBoundingRect(boundingRect.width(), boundingRect.height());
		m_wm->firstCardAlert();
	}
	SystemUiController::instance()->setCardWindowMaximized(false);
	SystemUiController::instance()->setMaximizedCardWindow(0);
}
Beispiel #9
0
VOID SaveSettings(VOID)
{
    DWORD dwDisposition;
    DWORD dwBack;
    HKEY hKey;

    if (RegCreateKeyEx(HKEY_CURRENT_USER,
                       _T("Software\\ReactOS\\Solitaire"),
                       0,
                       NULL,
                       REG_OPTION_NON_VOLATILE,
                       KEY_WRITE,
                       NULL,
                       &hKey,
                       &dwDisposition))
        return;

    RegSetValueEx(hKey,
                  _T("Options"),
                  0,
                  REG_DWORD,
                  (CONST BYTE *)&dwOptions,
                  sizeof(DWORD));

    dwBack = SolWnd.GetBackCardIdx();
    RegSetValueEx(hKey,
                  _T("Back"),
                  0,
                  REG_DWORD,
                  (CONST BYTE *)&dwBack,
                  sizeof(DWORD));

    RegCloseKey(hKey);
}
void MaximizeState::relayout(const QRectF& r, bool animate)
{
	Q_UNUSED(r);
	m_wm->maximizeActiveWindow(animate);
	QRectF boundingRect;

	CardWindow* activeWin = m_wm->activeWindow();
	if(activeWin) {
		if(WindowType::Type_ModalChildWindowCard != activeWin->type()) {
			boundingRect = m_wm->normalOrScreenBounds(activeWin);
			activeWin->setBoundingRect(boundingRect.width(), boundingRect.height());
		}
		else {
			// forward the call to the child.
			activeWin->setBoundingRect(Settings::LunaSettings()->modalWindowWidth, activeWin->boundingRect().height());

			// Notify the parent as well.
			CardWindow* parent = m_wm->modalParent();
			if(parent) {
				boundingRect = m_wm->normalOrScreenBounds(parent);
				parent->setBoundingRect(boundingRect.width(), boundingRect.height());
			}
		}
	}
}
void MaximizeState::finishMaximizingActiveWindow()
{
	// set the active windows' size to the positive space

	CardWindow* activeWin = m_wm->activeWindow();

        if(activeWin){
            activeWin->setMaxAndLoading(1);
        }
	if (activeWin && activeWin->addedToWindowManager()) {
                // allow direct rendering if no one has requested it to be disabled - Do this only if the window is NOT a modal window
		if(WindowType::Type_ModalChildWindowCard != activeWin->type()) {
			const QRect& r = m_wm->targetPositiveSpace();
            resizeWindow(activeWin, r.width(), r.height());

			if (m_disableDirectRendering == 0) {
				if(false == m_wm->isModalDismissed()) {
					SystemUiController::instance()->setDirectRenderingForWindow(SystemUiController::CARD_WINDOW_MANAGER, activeWin, true);
				}
				else {
					m_wm->setModalDismissed(false);
				}
			}
		}

		if (G_UNLIKELY(Settings::LunaSettings()->perfTesting)) {
			// NOV-97107, hook for automated performance testing
			g_message("SYSMGR PERF: STATE MAXIMIZED appid: %s, processid: %s, type: %s, time: %d",
				activeWin->appId().c_str(),
				activeWin->processId().c_str(),
				activeWin->isHost() ? "host" : "card",
				Time::curTimeMs());
		}
	}
}
void EmergencyWindowManager::fadeAnimationFinished()
{
	if(m_emergencyWindow && (m_emergencyWindow->opacity() == 1.0)) {
		// Finished fading IN
		static_cast<CardWindow*>(m_emergencyWindow)->setPaintCompositionMode(QPainter::CompositionMode_Source);

		// check to see if the window requires a specific orientation
		if(Settings::LunaSettings()->displayUiRotates) {
			CardWindow* win = static_cast<CardWindow*>(m_emergencyWindow);
			SystemUiController::instance()->setRequestedSystemOrientation(win->getCardFixedOrientation(), true, true);
		}

		SystemUiController::instance()->setDirectRenderingForWindow(SystemUiController::EMERGENCY_MODE_WINDOW_MANAGER, static_cast<CardWindow*>(m_emergencyWindow), true);
		update();
	} else if(m_emergencyWindow && (m_emergencyWindow->opacity() <= kFadedOpacity)) {

		// Finished fading OUT
		m_emergencyWindow->setParentItem(0);

		hideCornerWindows();

		update();
		SystemUiController::instance()->setEmergencyMode(false);

		if(Settings::LunaSettings()->displayUiRotates) {
			// restore fixed orientation properties for the maximized card window
			CardWindow* win = static_cast<CardWindow*>(SystemUiController::instance()->maximizedCardWindow());
			if(win)
				SystemUiController::instance()->setRequestedSystemOrientation(win->getCardFixedOrientation(), true, false);
			else
				WindowServer::instance()->setUiRotationMode(WindowServer::RotationMode_FreeRotation);
		}
		// If we had enabled full screen mode, restore normal mode again
		if (static_cast<CardWindow*>(m_emergencyWindow)->fullScreen()) {
			SystemUiController::instance()->showStatusBarAndNotificationArea();
		}

		delete m_emergencyWindow;
		m_emergencyWindow = 0;

		setVisible(false);
	}
}
void MaximizeState::onEntry(QEvent* event)
{
	CardWindowManagerState::onEntry(event);
	CardWindow* activeWin = m_wm->activeWindow();
	Q_ASSERT(activeWin != 0);

	SystemUiController::instance()->setCardWindowMaximized(true);
	SystemUiController::instance()->setMaximizedCardWindow(activeWin);

	m_wm->queueFocusAction(activeWin, true);
	activeWin->setAttachedToGroup(false);

	if(WindowType::Type_ModalChildWindowCard != activeWin->type()) {
		QRectF boundingRect = m_wm->normalOrScreenBounds(activeWin);
		activeWin->setBoundingRect(boundingRect.width(), boundingRect.height());
	}
	else {
		activeWin->setBoundingRect(Settings::LunaSettings()->modalWindowWidth, Settings::LunaSettings()->modalWindowHeight);
		//activeWin->setMaximized(true);
	}
}
// --------------------------------------------------------------------------------------------------
void PreparingState::onEntry(QEvent* event)
{
	CardWindowManagerState::onEntry(event);

	// unpack the window which we need to prepare
	CardWindow* win = 0;
	if (event->type() == QEvent::StateMachineSignal) {
		QStateMachine::SignalEvent* se = static_cast<QStateMachine::SignalEvent*>(event);
		win = se->arguments().at(0).value<CardWindow*>();

		if (win) {
			QRectF boundingRect = m_wm->normalOrScreenBounds(0);
			if(WindowType::Type_ModalChildWindowCard != win->type())
				win->setBoundingRect(boundingRect.width(), boundingRect.height());
			else {
				win->setBoundingRect(Settings::LunaSettings()->modalWindowWidth, Settings::LunaSettings()->modalWindowHeight);
			}
		}
	}

	m_wm->prepareAddWindowSibling(win);
}
void MaximizeState::positiveSpaceAboutToChange(const QRect& r, bool fullScreen)
{
	CardWindow* parent = NULL;
	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin) {
		const QRect& positiveSpace = SystemUiController::instance()->positiveSpaceBounds();
		bool expanding = positiveSpace.height() < r.height();

		if(WindowType::Type_ModalChildWindowCard == activeWin->type()) {
			// Pass on the info to the parent as well.
			parent = m_wm->modalParent();
			if(parent) {
				parent->positiveSpaceAboutToChange(r, fullScreen);
			}

			// let the child know that +ve space change is about to change.
			activeWin->positiveSpaceAboutToChange(r, fullScreen);
		}
		else {
			activeWin->positiveSpaceAboutToChange(r, fullScreen);
		}

		if (!m_exiting) {

        	// Send this out ONLY to the parent, but not the modal card.
    		if (expanding) {
    			if(WindowType::Type_ModalChildWindowCard == activeWin->type() && NULL != parent) {
    				parent->resizeEventSync(r.width(), r.height());
    			}
    			else {
    				activeWin->resizeEventSync(r.width(), r.height());
    			}
	    	}

			// adjust the maximized window if the positive space top is
    		// moving and it isn't due to exiting this state
	    	if (positiveSpace.y() != r.y()) {
		    	m_wm->maximizeActiveWindow();
    		}
        }
	}
}
void FocusState::onEntry(QEvent* event)
{
	CardWindowManagerState::onEntry(event);

	CardWindow* win = 0;
	if (event->type() == QEvent::StateMachineSignal) {
		QStateMachine::SignalEvent* se = static_cast<QStateMachine::SignalEvent*>(event);
		win = se->arguments().at(0).value<CardWindow*>();
	}

	CardGroup* activeGroup = m_wm->activeGroup();
	Q_ASSERT(activeGroup != 0);
	if (activeGroup == win->cardGroup()) {
		// update the active card within the active group and maximize it
		activeGroup->setActiveCard(win);
		m_wm->maximizeActiveWindow();
	}
	else {
		// make this card the active card in its group and focus the group
		win->cardGroup()->setActiveCard(win);
		m_wm->setActiveGroup(win->cardGroup());
		m_wm->slideAllGroups();
	}
}
void MaximizeState::focusMaximizedCardWindow(bool focus)
{
	CardWindow* activeWin = m_wm->activeWindow();

	m_disableDirectRendering = qMax((focus ? m_disableDirectRendering-1 : m_disableDirectRendering+1), 0);

   // take focus away?
    if (!focus && m_disableDirectRendering == 1) {

        // disable direct rendering so the emergency windows can render. [This is applicable ONLY if the active window is not a modal window]
    	if(activeWin->type() != WindowType::Type_ModalChildWindowCard) {
    		SystemUiController::instance()->setDirectRenderingForWindow(SystemUiController::CARD_WINDOW_MANAGER, activeWin, false);
    	}

    	// clear focus
        activeWin->aboutToFocusEvent(false);
        activeWin->queueFocusAction(false);
        activeWin->performPendingFocusAction();
    }
    else if (focus && m_disableDirectRendering == 0) {

        // make sure the active window is sized properly and re-enables
        // direct-rendering
       if (!m_wm->windowHasAnimation(activeWin)) {

            // re-enable direct rendering or just wait for any animations to finish [This is applicable ONLY if the active window is not a modal window]
        	if(activeWin->type() != WindowType::Type_ModalChildWindowCard) {
        		SystemUiController::instance()->setDirectRenderingForWindow(SystemUiController::CARD_WINDOW_MANAGER, activeWin, true);
        	}

            // refocus window
            activeWin->aboutToFocusEvent(true);
            activeWin->queueFocusAction(true);
            activeWin->performPendingFocusAction();
        } else {
            // queue refocus event for the window
        	m_wm->queueFocusAction(activeWin, true);
        }
    }
}
Beispiel #18
0
VOID LoadSettings(VOID)
{
    DWORD dwDisposition;
    DWORD dwSize;
    DWORD dwBack;
    HKEY hKey;

    if (RegCreateKeyEx(HKEY_CURRENT_USER,
                       _T("Software\\ReactOS\\Solitaire"),
                       0,
                       NULL,
                       REG_OPTION_NON_VOLATILE,
                       KEY_READ,
                       NULL,
                       &hKey,
                       &dwDisposition))
        return;

    dwSize = sizeof(DWORD);
    RegQueryValueEx(hKey,
                    _T("Options"),
                    NULL,
                    NULL,
                    (LPBYTE)&dwOptions,
                    &dwSize);

    dwSize = sizeof(DWORD);
    RegQueryValueEx(hKey,
                    _T("Back"),
                    NULL,
                    NULL,
                    (LPBYTE)&dwBack,
                    &dwSize);
    SolWnd.SetBackCardIdx(dwBack);

    RegCloseKey(hKey);
}
void MaximizeState::positiveSpaceChanged(const QRect& r)
{
	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin) {
		if(WindowType::Type_ModalChildWindowCard == activeWin->type()) {

			// Pass on the info to the parent as well.
			CardWindow* parent = m_wm->modalParent();
			if(parent) {
				parent->positiveSpaceChanged(r);
			}

			// let the child know that +ve space change is changed.
			activeWin->positiveSpaceChanged(r);
		}
		else {
			activeWin->positiveSpaceChanged(r);
		}
	}    
}
void MaximizeState::animationsFinished()
{
	finishMaximizingActiveWindow();
	QRectF boundingRect;

	CardWindow* activeWin = m_wm->activeWindow();
	if (activeWin) {
		if(WindowType::Type_ModalChildWindowCard != activeWin->type()) {
			boundingRect = m_wm->normalOrScreenBounds(activeWin);
			activeWin->setBoundingRect(boundingRect.width(), boundingRect.height());
		}
		else {
			activeWin->setBoundingRect(Settings::LunaSettings()->modalWindowWidth, Settings::LunaSettings()->modalWindowHeight);

			// Notify the parent.
			CardWindow* parent = m_wm->modalParent();
			if(parent) {
				boundingRect = m_wm->normalOrScreenBounds(parent);
				parent->setBoundingRect(boundingRect.width(), boundingRect.height());
			}
		}
	}
}
Beispiel #21
0
//
//    Forward all window messages onto the appropriate
//  class instance
//
LRESULT CALLBACK CardWindow::CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    CardWindow *cw = (CardWindow *)GetWindowLongPtr(hwnd, 0);
    return cw->WndProc(hwnd, iMsg, wParam, lParam);
}
int main(int argc, char *argv[])
{  QApplication app(argc, argv);
   CardWindow window;
   window.show();
   return app.exec();
}
Beispiel #23
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static int nWidth, nHeight;

    switch (iMsg)
    {
        case WM_CREATE:
        {
            SpiderWnd.Create(hwnd, 0, WS_CHILD | WS_VISIBLE, 0, 0, 100, 100);
            dwDifficulty = IDC_DIF_ONECOLOR;
            CreateSpider();

            SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);

            dwAppStartTime = GetTickCount();

            return 0;
        }

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;

        case WM_SIZE:
            nWidth  = LOWORD(lParam);
            nHeight = HIWORD(lParam);

            MoveWindow(SpiderWnd, 0, 0, nWidth, nHeight, TRUE);
            return 0;

        case WM_GETMINMAXINFO:
        {
            MINMAXINFO *mmi;

            mmi = (MINMAXINFO *)lParam;
            mmi->ptMinTrackSize.x = NUM_STACKS * __cardwidth + (NUM_STACKS + 3) * X_BORDER + 12; // Border left and right of 6px
            mmi->ptMinTrackSize.y = GetSystemMetrics(SM_CYCAPTION) +
                                    GetSystemMetrics(SM_CYMENU) +
                                    2 * Y_BORDER +
                                    3 * __cardheight +
                                    6 * yRowStackCardOffset;
            return 0;
        }

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDM_GAME_NEW:
                    NewGame();
                    return 0;

                case IDM_GAME_DECK:
                    ShowDeckOptionsDlg(hwnd);
                    return 0;

                case IDM_HELP_CONTENTS:
                    WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");
                    return 0;

                case IDM_HELP_ABOUT:
                    MessageBox(hwnd, MsgAbout, szAppName, MB_OK|MB_ICONINFORMATION);
                    return 0;

                case IDM_GAME_EXIT:
                    PostMessage(hwnd, WM_CLOSE, 0, 0);
                    return 0;
            }

            return 0;

        case WM_CLOSE:
            if (fGameStarted == false)
            {
                DestroyWindow(hwnd);
                return 0;
            }
            else
            {
                int ret;

                ret = MessageBox(hwnd, MsgQuit, szAppName, MB_YESNO|MB_ICONQUESTION);
                if (ret == IDYES)
                {
                    WinHelp(hwnd, szHelpPath, HELP_QUIT, 0);
                    DestroyWindow(hwnd);
                }
            }
            return 0;
    }
    return DefWindowProc (hwnd, iMsg, wParam, lParam);
}
Beispiel #24
0
//-----------------------------------------------------------------------------
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static int nWidth, nHeight, nStatusHeight;

    switch(iMsg)
    {
    case WM_CREATE:
    {
        int parts[] = { 100, -1 };
        RECT rcStatus;

        hwndStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, _T("Ready"), hwnd, 0);

        //SendMessage(hwndStatus, SB_SIMPLE, (WPARAM)TRUE, 0);

        SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
        SendMessage(hwndStatus, SB_SETTEXT, 0 | SBT_NOBORDERS, (LPARAM)"");

        SolWnd.Create(hwnd, WS_EX_CLIENTEDGE, WS_CHILD|WS_VISIBLE, 0, 0, 0, 0);

        CreateSol();

        // The status bar height is fixed and needed later in WM_SIZE and WM_GETMINMAXINFO
        // Force the window to process WM_GETMINMAXINFO again
        GetWindowRect(hwndStatus, &rcStatus);
        nStatusHeight = rcStatus.bottom - rcStatus.top;

        // Hide status bar if options say so
        if (!(dwOptions & OPTION_SHOW_STATUS))
        {
            ShowWindow(hwndStatus, SW_HIDE);
        }

        SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);

        NewGame();

        dwAppStartTime = GetTickCount();

        return 0;
    }

    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;

    case WM_SIZE:
        nWidth  = LOWORD(lParam);
        nHeight = HIWORD(lParam);

        if (dwOptions & OPTION_SHOW_STATUS)
        {
            MoveWindow(SolWnd, 0, 0, nWidth, nHeight - nStatusHeight, TRUE);
            MoveWindow(hwndStatus, 0, nHeight - nStatusHeight, nWidth, nStatusHeight, TRUE);
        }
        else
        {
            MoveWindow(SolWnd, 0, 0, nWidth, nHeight, TRUE);
        }
        //parts[0] = nWidth - 256;
        //SendMessage(hwndStatus, SB_SETPARTS, 2, (LPARAM)parts);
        return 0;

    case WM_GETMINMAXINFO:
    {
        MINMAXINFO *mmi;

        mmi = (MINMAXINFO *)lParam;
        mmi->ptMinTrackSize.x = X_BORDER + NUM_ROW_STACKS * (__cardwidth + X_ROWSTACK_BORDER) + X_BORDER;
        mmi->ptMinTrackSize.y = GetSystemMetrics(SM_CYCAPTION) +
                                GetSystemMetrics(SM_CYMENU) +
                                Y_BORDER +
                                __cardheight +
                                Y_ROWSTACK_BORDER +
                                6 * yRowStackCardOffset +
                                __cardheight +
                                Y_BORDER +
                                (dwOptions & OPTION_SHOW_STATUS ? nStatusHeight : 0);
        return 0;
    }

    case WM_COMMAND:
        switch(LOWORD(wParam))
        {
        case IDM_GAME_NEW:
            //simulate a button click on the new button..
            NewGame();
            return 0;

        case IDM_GAME_DECK:
            ShowDeckOptionsDlg(hwnd);
            return 0;

        case IDM_GAME_OPTIONS:
            ShowGameOptionsDlg(hwnd);
            return 0;

        case IDM_HELP_CONTENTS:
            WinHelp(hwnd, szHelpPath, HELP_CONTENTS, 0);//HELP_KEY, (DWORD)"How to play");
            return 0;

        case IDM_HELP_ABOUT:
            MessageBox(hwnd, MsgAbout, szAppName, MB_OK|MB_ICONINFORMATION);
            return 0;

        case IDM_GAME_EXIT:
            PostMessage(hwnd, WM_CLOSE, 0, 0);
            return 0;
        }

        return 0;

    case WM_CLOSE:
        if (fGameStarted == false)
        {
            DestroyWindow(hwnd);
            return 0;
        }
        else
        {
            int ret;

            ret = MessageBox(hwnd, MsgQuit, szAppName, MB_YESNO|MB_ICONQUESTION);
            if (ret == IDYES)
            {
                WinHelp(hwnd, szHelpPath, HELP_QUIT, 0);
                DestroyWindow(hwnd);
            }
        }
        return 0;
    }

    return DefWindowProc (hwnd, iMsg, wParam, lParam);
}