Exemple #1
0
    WindowHandle WindowSystem::create(uint32_t width, uint32_t height)
    {
        WindowData data;
        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE,8);
        data.sdl_window = SDL_CreateWindow(
            "",
            SDL_WINDOWPOS_UNDEFINED,
            SDL_WINDOWPOS_UNDEFINED,
            width, height,
            SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL);
        uint32_t id = SDL_GetWindowID((SDL_Window*)data.sdl_window);
        m_data.insert(std::make_pair(id,data));

        if (m_gl_context == nullptr) {
            m_gl_context = SDL_GL_CreateContext(  (SDL_Window*)data.sdl_window );
            if( m_gl_context == nullptr )
            {
                printf( "OpenGL context could not be created! SDL Error: %s\n", SDL_GetError() );
                return WindowHandle();
            }
        }

       if (m_data.size() == 1) m_main_window = id;

       return WindowHandle(id);
    }
Exemple #2
0
	//--------------------------------------------------------------------------------
	COSWindow::refType CClipboardHelper::GetOpenClipboardWindow()
	{
		_WINQ_FCONTEXT( "CClipboardHelper::GetOpenClipboardWindow" );		
		__QOR_PROTECT
		{
			CWindowHandle WindowHandle( 0, (void*)( m_User32Library.GetOpenClipboardWindow() ) );
			CWindowHandle::refType refHandle( &WindowHandle, false );
			return COSWindow::FromHandle( refHandle );
		}__QOR_ENDPROTECT
	}
Exemple #3
0
	//--------------------------------------------------------------------------------
	CClipboardViewerSession::CClipboardViewerSession( COSWindow& Wnd, int* pbResult ) : m_Wnd( Wnd ), m_User32Library( CUser32::Instance() )
	{
		_WINQ_FCONTEXT( "CClipboardViewerSession::CClipboardViewerSession" );
		__QOR_PROTECT
		{
			m_pResult = pbResult;
			CWindowHandle WindowHandle( 0, (void*)m_User32Library.SetClipboardViewer( reinterpret_cast< ::HWND >( m_Wnd.Handle()->Use() ) ) );
			CWindowHandle::refType refHandle( &WindowHandle, 0 );
			m_Next = COSWindow::FromHandle( refHandle );
		}__QOR_ENDPROTECT
	}
Exemple #4
0
/**
 * Handles window events that come from Windows.
 */
LRESULT MainWindow::HandleMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
    HWND hWnd = WindowHandle();
    int wmId = 0, wmEvent = 0;

    switch (message)
    {
        case WM_COMMAND:
            wmId = LOWORD(wParam);
            wmEvent = HIWORD(wParam);

            // Parse the menu selections:
            switch (wmId)
            {
                case IDM_ABOUT:
                    ShowAboutBox();
                    break;
                case IDM_EXIT:
                    this->Exit();
                    break;
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;

        case WM_ACTIVATE:
            SetPaused(LOWORD(wParam) == WA_INACTIVE);
            break;

        case WM_SIZE:
            if (wParam == SIZE_MINIMIZED)
            {
                SetPaused(true);
                SetMinimized(true);
            }
            else if (wParam == SIZE_MAXIMIZED)
            {
                // Unpause if we are coming out of a minimize
                if (IsMinimized())
                {
                    SetPaused(false);
                    SetMinimized(false);
                }

                SetWindowResized(Size{ LOWORD(lParam), HIWORD(lParam) });
            }
            else
            {
                // Unpause if we are coming out of a minimize
                if (IsMinimized())
                {
                    SetPaused(false);
                    SetMinimized(false);
                }

                SetWindowResized(Size{ LOWORD(lParam), HIWORD(lParam) });
            }
            break;

        case WM_POWERBROADCAST:
            if (wParam == PBT_APMQUERYSUSPEND)
            {
                // The application is about to be suspended. We should prepare for
                // this event by saving any data and then pausing the game loop
                // until we come out of suspension
            }
            else if (wParam == PBT_APMRESUMESUSPEND)
            {
                // The application is being resumed from suspension. We should
                // reload any saved data and unpause the game loop
            }

        case WM_ENTERMENULOOP:
            // Pause while user is in menu
            SetPaused(true);
            break;

        case WM_EXITMENULOOP:
            // Unpause after user has exited menu
            SetPaused(false);
            break;

        case WM_ENTERSIZEMOVE:
            SetIsWindowResizing(true);
            SetPaused(true);
            break;

        case WM_EXITSIZEMOVE:
            SetIsWindowResizing(false);
            SetPaused(false);
            break;

        case WM_CLOSE:
            PostQuitMessage(0);
            break;

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }

    return 0;
}
bool Renderer::Init()
{
	return mImpl->Init(WindowHandle(), ScreenSizeW(), ScreenSizeH());
}
Exemple #6
0
void GWindow::Pour()
{
	bool SafeToLock = false;

	if (Wnd->IsLocked())
	{
		// I'm already locked... this could be bad if it's not me
		thread_id Thread = WindowHandle()->LockingThread();
		if (Thread != -1)
		{
			if (Thread == find_thread(NULL))
			{
				// it's all ok, I'm locking me
				SafeToLock = true;
			}
			else
			{
				// someone else is locking us
				// ok who is locking me?
				thread_info Info;
				if (get_thread_info(Thread, &Info) == B_OK)
				{
					printf("Evil locking thread: %i (%s)\n", Thread, Info.name);
				}
				else
				{
					printf("Couldn't get evil thread info\n");
				}
			}
		}
	}
	else
	{
		SafeToLock = true;
	}
	
	if (!SafeToLock)
	{
		printf("%s:%i - Not safe to lock for ::Pour.\n", __FILE__, __LINE__);
		return;
	}
	
	bool Lock = Wnd->Lock();
	Wnd->BeginViewTransaction();
	GRect r(Handle()->Frame());
	r.Offset(-r.x1, -r.y1);

	GRegion Client(r);
	GRegion Update;

	if (Menu)
	{
		GRect Mp = Menu->GetPos();
		Mp.x2 = 10000;
		Client.Subtract(&Mp);
	}

	for (GViewI *w = Children.First(); w; w = Children.Next())
	{
		GRect OldPos = w->GetPos();
		Update.Union(&OldPos);

		if (w->Pour(Client))
		{
			if (!w->Visible())
			{
				w->Visible(true);
			}

			Client.Subtract(&w->GetPos());
			Update.Subtract(&w->GetPos());
		}
		else
		{
			// non-pourable
		}
	}

	Wnd->EndViewTransaction();
	Wnd->Sync();

	// Handle()->Invalidate();
	if (Lock) Wnd->Unlock();
}
	bool ChooseWindowPushButton::winEventFilter(MSG *msg, long *result)
	{
		Q_UNUSED(result);

		if(!msg || !mSearching)
			return false;

		switch(msg->message)
		{
		case WM_LBUTTONUP:
			stopMouseCapture();
			break;

		case WM_MOUSEMOVE:
			{
				POINT screenpoint;
				GetCursorPos(&screenpoint);

				HWND window = NULL;
				HWND firstWindow = WindowFromPoint(screenpoint);
				if(firstWindow && IsWindow(firstWindow))
				{
					// try to go to child window
					if(!GetParent(firstWindow))
					{
						POINT pt;
						pt.x = screenpoint.x;
						pt.y = screenpoint.y;
						ScreenToClient(firstWindow, &pt);
						HWND childWindow = ChildWindowFromPoint(firstWindow, pt);
						if(firstWindow != childWindow)
						{
							RECT rc;
							GetWindowRect(childWindow, &rc);
							if(PtInRect(screenpoint, rc))
								// it may seem strange to check this condition after above lines
								// but try to comment it and work with MSDN main window,
								// you will hardly "find" it
								firstWindow	= childWindow;
						}
					}

					// find the best child
					if(GetParent(firstWindow))
					{
						RECT rcFirst;
						GetWindowRect(firstWindow, &rcFirst);

						// find next/prev windows in the Z-order
						bool bBestFound = false;
						HWND hOther = firstWindow;
						do
						{
							hOther	= GetNextWindow(hOther, GW_HWNDPREV);
							if(!hOther)
								break;
							RECT rcOther;
							GetWindowRect(hOther, &rcOther);
							if(PtInRect(screenpoint, rcOther) &&
								PtInRect(RectTopLeft(rcOther), rcFirst) &&
								PtInRect(RectBottomRight(rcOther), rcFirst))
							{
								firstWindow = hOther;
								bBestFound = true;
							}
						}
						while(!bBestFound);

						if(!bBestFound)
						{
							hOther = firstWindow;
							do
							{
								hOther = GetNextWindow(hOther, GW_HWNDNEXT);
								if (!hOther) break;
								RECT rcOther;
								GetWindowRect(hOther, &rcOther);
								if(PtInRect(screenpoint, rcOther) &&
									PtInRect(RectTopLeft(rcOther), rcFirst) &&
									PtInRect(RectBottomRight(rcOther), rcFirst))
								{
									firstWindow	= hOther;
									bBestFound = true;
								}
							}
							while(!bBestFound);
						}
					}

					window = firstWindow;
				}
				else
					break;

				foundWindow(WindowHandle(window));
			}
			break;
		}

		return false;
	}