void WindowAttributesPickle::LoadAttributes()
{
    wxPoint pos = GetWindowPos(m_name, wxDefaultPosition);
    wxSize size = GetWindowSize(m_name, m_default_size);
    m_window->SetSize(pos.x, pos.y, size.GetWidth(), size.GetHeight());
#ifndef __WXMAC__
    m_window->Maximize(GetWindowMaximized(m_name));
#endif
}
Beispiel #2
0
// Initialize the 'renderer_' member. No other members have been initialized at
// this point.
bool Game::InitializeRenderer() {
#ifdef __ANDROID__
  vec2i window_size = GetWindowSize();
  if (fplbase::IsTvDevice()) {
    window_size = vec2i(kAndroidTvMaxScreenWidth, kAndroidTvMaxScreenHeight);
  }
#else
  vec2i window_size(1200, 800);
#endif  // __ANDROID__
  if (!renderer_.Initialize(window_size, GetConfig().window_title()->c_str())) {
    LogError("Renderer initialization error: %s\n",
             renderer_.last_error().c_str());
    return false;
  }

#ifdef __ANDROID__
  // Restart the app if HW scaler setting failed.
  auto retry = fplbase::LoadPreference("HWScalerRetry", 0);
  const auto kMaxRetry = 3;
  auto current_window_size = fplbase::AndroidGetScalerResolution();
  if (current_window_size.x() != window_size.x() ||
      current_window_size.y() != window_size.y()) {
    if (retry < kMaxRetry) {
      LogError("Restarting application.");
      fplbase::SavePreference("HWScalerRetry", retry + 1);
      fplbase::RelaunchApplication();
      return false;
    }
    // The HW may not support the API. Fallback to native resolution pass until
    // the API success next time.
  } else {
    // HW scaler setting was success. Clear retry counter.
    fplbase::SavePreference("HWScalerRetry", 0);
  }
#endif  // __ANDROID__

  renderer_.set_color(mathfu::kOnes4f);
  // Initialize the first frame as black.
  renderer_.ClearFrameBuffer(mathfu::kZeros4f);

#ifdef ANDROID_HMD
  vec2i size = fplbase::AndroidGetScalerResolution();
  const vec2i viewport_size =
      size.x() && size.y() ? size : renderer_.window_size();
  fplbase::InitializeUndistortFramebuffer(viewport_size.x(), viewport_size.y());
#endif  // ANDROID_HMD

#if ZOOSHI_OVERDRAW_DEBUG
  renderer_.SetBlendMode(BlendMode::kBlendModeAdd);
  renderer_.force_blend_mode() = BlendMode::kBlendModeAdd;
  renderer_.override_pixel_shader() =
      "void main() { gl_FragColor = vec4(0.2, 0.2, 0.2, 1); }";
#endif  // ZOOSHI_OVERDRAW_DEBUG

  return true;
}
Beispiel #3
0
bool GLWindow::DisplayWindow(int _width, int _height)
{
	GetWindowSize();

	if ( !CreateContextGL() ) return false;

	PrintProtocolVersion();

	return true;
}
bool cdxCDynamicControlsManager::StretchWindow(CWnd & rWnd, int iAddPcnt)
{
	ASSERT(::IsWindow(rWnd.m_hWnd));

	CSize	szDelta	=	GetWindowSize(rWnd);

	szDelta.cx	=	(szDelta.cx * iAddPcnt) / 100;
	szDelta.cy	=	(szDelta.cy * iAddPcnt) / 100;

	return StretchWindow(rWnd,szDelta);
}
Beispiel #5
0
///////////////////////////////////////////////////////////////////////////////
/// CConnection::HandleResend
/// @description: After being called, this method sends up WINDOWSIZE messages
///   to retry delievery.
/// @pre: Initialized CConnection.
/// @post: Upto WINDOWSIZE messages are rewritten to the channel.
///////////////////////////////////////////////////////////////////////////////
void CConnection::HandleResend()
{
    Logger::Debug << __PRETTY_FUNCTION__ << std::endl;
    SlidingWindow<QueueItem>::iterator sit;
    sit = m_queue.begin();   
 
    for(unsigned int i=0; sit != m_queue.end() && i < GetWindowSize(); i++,sit++ )
    {
        GetSocket().get_io_service().post(
        boost::bind(&CConnection::HandleSend, this,(*sit).second));
    }
}
int wxSplitWindow::OnSashPositionChanging (int newSashPosition) {
    // If within UNSPLIT_THRESHOLD from edge, set to edge to cause closure.
    //? TODO fix constant value
    const int UNSPLIT_THRESHOLD = 4;

    // first of all, check if OnSashPositionChange() doesn't forbid this change
    if (!OnSashPositionChange (newSashPosition)) return -1; // it does

    // Obtain relevant window dimension for bottom / right threshold check
    int size = GetWindowSize();

    bool unsplit_scenario = false;
    if (m_permitUnsplitAlways || m_minimumPaneSize == 0) {

        // Do edge detection if unsplit premitted
        if (newSashPosition <= UNSPLIT_THRESHOLD) {
            // threshold top / left check
            newSashPosition = 0;
            unsplit_scenario = true;
        }
        if (newSashPosition >= size - UNSPLIT_THRESHOLD) {
            // threshold bottom/right check
            newSashPosition = size;
            unsplit_scenario = true;
        }
    }

    if (!unsplit_scenario) {
        // If resultant pane would be too small, enlarge it
        newSashPosition = AdjustSashPosition (newSashPosition);
    }

    // If the result is out of bounds it means minimum size is too big,
    // so split window in half as best compromise.
    if (newSashPosition < 0 || newSashPosition > size) newSashPosition = size / 2;

    // now let the event handler have it
    // TODO: shouldn't we do it before the adjustments above so as to ensure
    //       that the sash position is always reasonable?
    wxSplitWindowEvent event(wxEVT_COMMAND_SPLITWINDOW_SASH_POS_CHANGING, this);
    event.m_data.pos = newSashPosition;

    if (!DoSendEvent(event)) {
        // the event handler vetoed the change
        newSashPosition = -1;
    }else{
        // it could have been changed by it
        newSashPosition = event.GetSashPosition();
    }

    return newSashPosition;
}
Beispiel #7
0
///////////////////////////////////////////////////////////////////////////////
/// CConnection::Send
/// @description: Given a message and wether or not it should be sequenced,
///   write that message to the channel.
/// @pre: The CConnection object is initialized.
/// @post: If the window is in not full, the message will have been written to
///   to the channel. Before being sent the message has been signed with the
///   UUID, source hostname and sequence number (if it is being sequenced).
///   If the message is being sequenced  and the window is not already full,
///   the timeout timer is cancelled and reset.
/// @param p_mesg: A CMessage to write to the channel.
/// @param sequence: if true, the message will be sequenced and reliably
///   delievered in order. Otherwise it is immediately fired and forgotten.
///   this is mostly meant for use with ACKs. True by default.
///////////////////////////////////////////////////////////////////////////////
void CConnection::Send(CMessage p_mesg, bool sequence)
{
    Logger::Debug << __PRETTY_FUNCTION__ << std::endl;

    //Make a call to the dispatcher to sign the messages
    //With a bunch of shiny stuff.
    ptree x = static_cast<ptree>(p_mesg);
    unsigned int msgseq;

    //m_dispatch.HandleWrite(x);  

    CMessage outmsg(x);

    // Sign the message with the hostname, uuid, and squencenumber
    if(sequence == true)
    {
        if(m_synched == false)
        {
            m_synched = true;
            SendSYN();
        }
        msgseq = m_outsequenceno;
        outmsg.SetSequenceNumber(msgseq);
        m_outsequenceno = (m_outsequenceno+1) % GetSequenceModulo();
    }
    outmsg.SetSourceUUID(GetConnectionManager().GetUUID()); 
    outmsg.SetSourceHostname(GetConnectionManager().GetHostname());

    if(sequence == true)
    {
        // If it isn't squenced then don't put it in the queue.
        m_queue.Push( QueueItem(msgseq,outmsg) );
    }
    // Before, we would put it into a queue to be sent later, now we are going
    // to immediately write it to channel.

    if(m_queue.size() <= GetWindowSize() || sequence == false)
    {
        // Only try to write to the socket if the window isn't already full.
        // Or it is an unsequenced message
        
        HandleSend(outmsg);
        if(sequence == true)
        {
            m_timeout.cancel();
            m_timeout.expires_from_now(boost::posix_time::milliseconds(1000));
            m_timeout.async_wait(boost::bind(&CConnection::Resend,this,
                boost::asio::placeholders::error));
        }
    }
}
Beispiel #8
0
bool GLWindow::DisplayWindow(int _width, int _height)
{
	GetWindowSize();

	if (!CreateVisual()) return false;

	// connect the glx-context to the window
	CreateContextGL();
	glXMakeCurrent(glDisplay, glWindow, context);

	GetGLXVersion();

	return true;
}
Beispiel #9
0
void MyApp::DrawConfig()
{
	int lineStart(LINE_START);
	int lineStep(LINE_STEP);

	//! 显示地图信息
	DrawString(0, lineStart, CLR_WHITE, "-------Config Info-------");
	lineStart += lineStep;

	int w,h;
	GetWindowSize(w,h);
	int infoHeight = h-lineStart-LINE_BOTTOM;
	if(infoHeight < lineStep)
		return;

	const FvRobotCfg::Items& kItems = FvRobotCfg::Instance().GetItems();
	if(kItems.empty())
		return;

	int iItemsPerPage = infoHeight / lineStep;
	int iPages = (kItems.size() + iItemsPerPage-1) / iItemsPerPage;
	if(m_iInfoPage4Config >= iPages)
		m_iInfoPage4Config = iPages-1;

	int iStart = m_iInfoPage4Config*iItemsPerPage;
	int i = iStart;
	for(; i<iStart+iItemsPerPage && i<(int)kItems.size(); ++i)
	{
		DrawString(0, lineStart, CLR_WHITE, kItems[i].GetValueStr().c_str());
		lineStart += lineStep;
	}

	if(m_iInfoPage4Config==0 && m_iInfoPage4Config<iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page Down-------");
		lineStart += lineStep;
	}
	else if(0<m_iInfoPage4Config && m_iInfoPage4Config<iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page UP/Down-------");
		lineStart += lineStep;
	}
	else if(0<m_iInfoPage4Config && m_iInfoPage4Config==iPages-1)
	{
		DrawString(0, lineStart, CLR_WHITE, "-------Press Page UP-------");
		lineStart += lineStep;
	}
}
// Remove the specified (or second) window from the view
// Doesn't actually delete the window.
bool wxSplitWindow::Unsplit(wxWindow *toRemove) {
    if (!IsSplit() || toRemove == NULL) return false;

    if (toRemove == m_windowOne) {
        DoSetSashPosition (0);
    }else if (toRemove == m_windowTwo) {
        DoSetSashPosition (GetWindowSize());
    }else{
        wxFAIL_MSG(wxT("splitter: attempt to remove a non-existent window"));
        return false;
    }

    OnUnsplit (toRemove);
    SizeWindows();
    return true;
}
Beispiel #11
0
bool CSensorDataFilter::Filter(double &dfVal)
{
	//add the value to our store of data
	//like a stack, we add to the top
	m_Data.push_front(dfVal);

	//do we have enough data to scan the window?
	if( m_Data.size() < GetWindowSize() )
		return false;

	//mind the max size
	if( m_Data.size() > GetDataSize() )
		m_Data.pop_back();


	return FilterData(dfVal);
}
Beispiel #12
0
bool GLWindow::DisplayWindow(int _width, int _height)
{
	backbuffer.w = _width;
	backbuffer.h = _height;

	if (!CreateVisual()) return false;

	/* create a color map */
	attr.colormap = XCreateColormap(glDisplay, RootWindow(glDisplay, vi->screen),
						   vi->visual, AllocNone);
	attr.border_pixel = 0;
    attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
        StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
        EnterWindowMask | LeaveWindowMask | FocusChangeMask ;

    // Create a window at the last position/size
    glWindow = XCreateWindow(glDisplay, RootWindow(glDisplay, vi->screen),
            conf.x , conf.y , _width, _height, 0, vi->depth, InputOutput, vi->visual,
            CWBorderPixel | CWColormap | CWEventMask,
            &attr);

    /* Allow to kill properly the window */
    Atom wmDelete = XInternAtom(glDisplay, "WM_DELETE_WINDOW", True);
    XSetWMProtocols(glDisplay, glWindow, &wmDelete, 1);

    // Set icon name
    XSetIconName(glDisplay, glWindow, "ZZogl-pg");

    // Draw the window
    XMapRaised(glDisplay, glWindow);
    XSync(glDisplay, false);

	// connect the glx-context to the window
	CreateContextGL();
	glXMakeCurrent(glDisplay, glWindow, context);
	
	GetGLXVersion();

    // Always start in window mode
	fullScreen = 0;
    GetWindowSize();

	return true;
}
Beispiel #13
0
HWND ChildWindow(char* Text,LPSTR url ){

	int w = 400;
	int h = 170;
	
	if(IsThemeActive()) h += 8;
	RECT rc = {0,0,w,h};

	outdata = Text;
	outurl = url;

	InitApp(NULL,ChildProc,_T("Child"));

	/////
#if DXLIBFLAG
	int dx,dy,wx,wy;
	GetWindowSize(&dx,&dy);
	GetWindowPosition(&wx,&wy);
	/////

	HWND hWndChild = CreateWindow(
			_T("Child"),_T("ついーと"),
			WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
			//表示位置
			3+wx+(dx-w)/2,22+wy+(dy-h)/2,
			//( GetSystemMetrics( SM_CXSCREEN ) - rc.right-rc.left ) / 2, (GetSystemMetrics( SM_CYSCREEN ) - rc.bottom-rc.top ) / 2,
			w,h,NULL,NULL,NULL,NULL);
#else
	HWND hWndChild = CreateWindow(
			_T("Child"),_T("ついーと"),
			WS_VISIBLE|WS_CAPTION|WS_SYSMENU,
			//表示位置
			( GetSystemMetrics( SM_CXSCREEN ) - rc.right-rc.left ) / 2, (GetSystemMetrics( SM_CYSCREEN ) - rc.bottom-rc.top ) / 2,
			w,h,NULL,NULL,NULL,NULL);
#endif

	hWnd = hWndChild;

	ShowWindow(hWndChild, SW_SHOW);
	UpdateWindow(hWndChild);

	return hWndChild;
}
Beispiel #14
0
bool GLWindow::DisplayWindow(int _width, int _height)
{
	backbuffer.w = _width;
	backbuffer.h = _height;

	NativeWindow = XCreateSimpleWindow(NativeDisplay, DefaultRootWindow(NativeDisplay), conf.x, conf.y, backbuffer.w, backbuffer.h, 0, 0, 0);

    // Draw the window
    XMapRaised(NativeDisplay, NativeWindow);
    XSync(NativeDisplay, false);

	if ( !CreateContextGL() ) return false;

	PrintProtocolVersion();

    GetWindowSize();

	return true;
}
STDMETHODIMP CInternalPropertyPage::GetPageInfo(PROPPAGEINFO* pPageInfo)
{
    CAutoLock cAutoLock(this);

    CheckPointer(pPageInfo, E_POINTER);

    LPOLESTR pszTitle;
    HRESULT hr = AMGetWideString(CStringW(GetWindowTitle()), &pszTitle);
    if (FAILED(hr)) {
        return hr;
    }

    pPageInfo->cb = sizeof(PROPPAGEINFO);
    pPageInfo->pszTitle = pszTitle;
    pPageInfo->pszDocString = nullptr;
    pPageInfo->pszHelpFile = nullptr;
    pPageInfo->dwHelpContext = 0;
    pPageInfo->size = GetWindowSize();

    return S_OK;
}
Beispiel #16
0
plChecksum::plChecksum(unsigned int bufsize, const char* buffer)
{
    unsigned int wndsz = GetWindowSize(),i = 0;
    fSum = 0;

    const char* bufferAbsEnd = buffer + bufsize;
    const char* bufferEnvenEnd = buffer + bufsize - (bufsize % wndsz);

    while (buffer < bufferEnvenEnd)
    {
        fSum += hsToLE32(*((SumStorage*)buffer));
        buffer += wndsz;
    }

    SumStorage last = 0;
    while (buffer < bufferAbsEnd)
    {
        ((char*)&last)[i % wndsz] = *buffer;
        buffer++;
    }
    fSum+= hsToLE32(last);
}
Beispiel #17
0
int wxSplitterWindow::AdjustSashPosition(int sashPos) const
{
    int window_size = GetWindowSize();

    wxWindow *win;

    win = GetWindow1();
    if ( win )
    {
        // the window shouldn't be smaller than its own minimal size nor
        // smaller than the minimual pane size specified for this splitter
        int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
                                                      : win->GetMinHeight();

        if ( minSize == -1 || m_minimumPaneSize > minSize )
            minSize = m_minimumPaneSize;

        minSize += GetBorderSize();

        if ( sashPos < minSize )
            sashPos = minSize;
    }

    win = GetWindow2();
    if ( win )
    {
        int minSize = m_splitMode == wxSPLIT_VERTICAL ? win->GetMinWidth()
                                                      : win->GetMinHeight();

        if ( minSize == -1 || m_minimumPaneSize > minSize )
            minSize = m_minimumPaneSize;

        int maxSize = window_size - minSize - GetBorderSize() - GetSashSize();
        if ( sashPos > maxSize )
            sashPos = maxSize;
    }

    return sashPos;
}
Beispiel #18
0
int main()
{
  Stream *graph;
  word	 x, y;

  if (!InitGraphics(NULL, NULL))
     exit(1);

  graph = OpenGraph(NULL, 100, 100, 50, 200, WS_OVERLAPPEDWINDOW, SW_SHOWNA);
  if (graph == Null(Stream))
     exit(1);

  GetWindowSize(graph, &x, &y);

  SetFillAttr(graph, BLUE, H_CROSS);
  FillRect(graph, 0, 0, x - 5, y - 5, BLUE);	/* fill rect in blue */
  FLUSH();
  sleep(2);
  FillRect(graph, 0, 0, x - 10 , y - 10, RED);   		/* fill window in red */
  FLUSH();
  sleep(2);
  FillRect(graph, 0, 0, x - 15, y - 15, GREEN);	/* fill rect in green */
  FLUSH();
  sleep(2);
  FillRect(graph, 0, 0, x -20 , y - 20 , YELLOW);		/* fill window in yellow */
  FLUSH();
  sleep(2);
  FillRect(graph, 0, 0, x - 25, y - 25, RGB(127, 127, 127));  /* fill rect in gray */ 
  FLUSH();
  sleep(2);
  FillRect(graph, 0, 0, x - 30 , y - 30, RGB(0, 127, 255));  /* fill window in light blue */
  FLUSH();
  sleep(2);
  CloseGraph(graph);
  TidyGraphics();
  exit(0);
}
/**
 * Toggle fullscreen using the internal GameEngine Variable
 */
void GameEngine::ToggleFullScreen()
{
    logger.Log("Toggle Fullscreen");
    if( ! m_bFullscreen )
    {
        m_bFullscreen = true;

        // We store this so that if they toggle back out of fullscreen
        // We can resize the window from the crazy resolution that the window
        // will end up as
        GetWindowSize(&m_iWindowW, &m_iWindowH);

        logger.Log("Window size is currently h = " + std::to_string(m_iWindowW) + " w = " + std::to_string(m_iWindowH));
        if( SDL_SetWindowFullscreen(m_cWindow, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0 )
        {
            logger.Log("Fullscreen successfully initialized");
        }
        else
        {
            logger.LogError("Turning Fullscreen On failed with error " + std::string(SDL_GetError()));
        }
    }
    else
    {
        m_bFullscreen = false;
        if( SDL_SetWindowFullscreen(m_cWindow, SDL_FALSE) == 0 )
        {
            logger.Log("Fullscreen successfully turned off");
        }
        else
        {
            logger.LogError("Turning Fullscreen off failed or was already off with error " +  std::string(SDL_GetError()));
        }

        ResizeWindow(m_iWindowW, m_iWindowH);
    }
}
/// <summary>
/// This method will construct all the member classes and enumerate all the sensors
/// </summary>
void CMainWindow::InitializeResource()
{
    // Set the dialog icon
    NuiViewer::SetIcon(m_hWnd);

    // Set window minimum track size
    m_minTrackWidth = GetWindowSize(m_hWnd).cx;

    // Load url string
    LoadStringW(GetModuleHandle(0), IDS_MOREINFOURL, m_moreInfoLinkUrl, MaxStringChars);

    // Set text font style
    SendMessageW(GetHandle(IDC_CONNECTEDDEVICESTEXT), WM_SETFONT, (WPARAM)LargeTextFont, 0);
    SendMessageW(GetHandle(IDC_REQUIREDSENSORTEXT), WM_SETFONT, (WPARAM)LargeTextFont, 0);
    SendMessageW(GetHandle(IDC_STATUSTEXT), WM_SETFONT, (WPARAM)LargeTextFont, 0);

    // Set the logo picture
    HBITMAP hLogoImage = nullptr;
    EnsureImageLoaded(hLogoImage, IDB_LOGO);
    SendMessageW(GetHandle(IDC_LOGOPICTURE), STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hLogoImage);

    // Create sensor list instance
    m_pSensorListControl = new SensorListControl(GetHandle(IDC_KINECTSENSORLIST));

    // Create status log list instance
    m_pStatusLogListControl = new StatusLogListControl(GetHandle(IDC_STATUSLOGLIST));

    // Create kinect window manager instance
    m_pKinectWindowMgr = new KinectWindowManager(m_hWnd);

    // Construct all the sensors
    EnumerateSensors();

    // Upate layout and show/hide status
    UpdateLayoutAndShowStatus();
}
Beispiel #21
0
void MyApp::Draw()
{
	if(!FvRobotMainApp::pInstance())
		return;

	//! 修改窗口大小
	if(m_iResetWindowSize)
	{
		int w,h;
		GetWindowSize(w, h);

		if(m_iResetWindowSize & 0x1)
			w = FvRobotCfg::Instance().GetWindowSizeWidth();
		if(m_iResetWindowSize & 0x2)
			h = FvRobotCfg::Instance().GetWindowSizeHeight();

		SetWindowSize(w, h);
		m_iResetWindowSize = 0;
	}

	if(m_iShowMode == 0)
	{
		if(FvRobotCfg::Instance().GetSingleMode())
			DrawSingleMode();
		else
			DrawGlobalMode();
	}
	else if(m_iShowMode == 1)
	{
		DrawHelp();
	}
	else
	{
		DrawConfig();
	}
}
Beispiel #22
0
	int RetRotMainLoop()
	{
		isStarted = true;

		HWND hWnd;
		WNDCLASSEXA winc;
		MSG msg;
		HINSTANCE hInstance = GetModuleHandle(NULL);

		g_pixSz = Settings.initialPixelSize;
		g_fullScr = Settings.initialFullScrMode;

		ImmDisableIME((DWORD)-1);

		winc.cbSize = sizeof(WNDCLASSEX);
		winc.style = CS_HREDRAW | CS_VREDRAW;
		winc.lpfnWndProc = WndProc;
		winc.cbClsExtra = 0;
		winc.cbWndExtra = 0;
		winc.hInstance = hInstance;
		winc.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(Settings.icon), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
		winc.hIconSm = NULL;
		winc.hCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
		winc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_MENU));
		winc.lpszMenuName = NULL;
		winc.lpszClassName = "MAIN";

		if (!RegisterClassExA(&winc)) {
			return 0;
		}

		SIZE sz = GetWindowSize();

		if (Settings.WndMenu != NULL)
		{
			hWndMenu = Settings.WndMenu;
		}
		else
		{
			hWndMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(Settings.WndMenuID));
		}

		hWnd = CreateWindowA(
			"MAIN",
			Settings.title,
			g_fullScr ? WS_FULLSCRMODE : (Settings.ScreenOnly ? WS_WINDOWMODE_NOFRAME : WS_WINDOWMODE),
			g_fullScr ? 0 : CW_USEDEFAULT,
			g_fullScr ? 0 : CW_USEDEFAULT,
			sz.cx,
			sz.cy,
			NULL,
			hWndMenu != NULL ? hWndMenu : NULL,
			hInstance,
			NULL
			);

		if (hWnd == NULL) {
			return 0;
		}

		FpsControl fc;

		do {
			if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
				BOOL ret = GetMessage(&msg, NULL, 0, 0);
				if (ret == 0 || ret == -1) {
					break;
				}
				DispatchMessage(&msg);
			}
			else
			{
				Sleep(1);
			}
		} while (msg.message != WM_QUIT);

		isStarted = false;

		return (int)msg.wParam;
	}
Beispiel #23
0
	void SetScreenMode(
		int PixelSize,
		bool FullScreen)
	{
		if (!g_fullScr)
		{
			GetWindowRect(hWindow, &WndRect);
		}
		if (FullScreen)
		{
			scrPosFull = D3DXVECTOR3(
				(float)(((DisplaySize.cx / 2) - (PixelSize * Settings.screenWidth) / 2) / PixelSize),
				(float)(((DisplaySize.cy / 2) - (PixelSize * Settings.screenHeight) / 2) / PixelSize),
				0.0f);

			if (!g_fullScr)
			{
				SetWindowLongPtr(hWindow, GWL_STYLE, WS_FULLSCRMODE | WS_VISIBLE);

				if (Settings.ScreenOnly)
				{
					SetWindowRgn(hWindow, NULL, FALSE);

					if (hRectRgn)
					{
						DeleteObject(hRectRgn);
					}
				}

				if (hWndMenu != NULL)
				{
					hWndMenu = GetMenu(hWindow);
					SetMenu(hWindow, NULL);
				}
			}
		}
		else
		{
			RECT rc;
			SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0);

			POINT pos;
			SIZE sz;

			sz = GetWindowSize(PixelSize);

			pos.x = WndRect.left + Settings.screenWidth * (g_pixSz - PixelSize) / 2;
			pos.y = WndRect.top + Settings.screenHeight * (g_pixSz - PixelSize) / 2;

			if (pos.x < rc.left) {
				pos.x = rc.left;
			}
			else if (pos.x + sz.cx > rc.right)
			{
				pos.x = rc.right - sz.cx;
			}

			if (pos.y < rc.top) {
				pos.y = rc.top;
			}
			else if (pos.y + sz.cy > rc.bottom)
			{
				pos.y = rc.bottom - sz.cy;
			}

			if (g_fullScr) {
				if (hWndMenu != NULL)
				{
					SetMenu(hWindow, hWndMenu);
					hWndMenu = NULL;
				}
				SetWindowLongPtr(hWindow, GWL_STYLE, (Settings.ScreenOnly ? WS_WINDOWMODE_NOFRAME : WS_WINDOWMODE) | WS_VISIBLE);
			}
			//↑↓この二つの処理を入れ替えると表示が変になる
			SetWindowPos(
				hWindow,
				HWND_NOTOPMOST,
				pos.x,
				pos.y,
				sz.cx,
				sz.cy,
				SWP_SHOWWINDOW);

			if (Settings.ScreenOnly)
			{
				hRectRgn = CreateRectRgn(0, 0, sz.cx, sz.cy);
				if (hRectRgn == NULL) {
					throw Error("リージョンの作成に失敗");
				}

				if (SetWindowRgn(hWindow, hRectRgn, FALSE) == 0)
				{
					throw Error("リージョンの設定に失敗");
				}
			}
		}

		if (!g_fullScr || !FullScreen) {
			SetD3dpp(FullScreen);
			DevReset();
		}

		g_pixSz = PixelSize;
		g_fullScr = FullScreen;
		return;
	}
Beispiel #24
0
	SIZE GetWindowSize()
	{
		return GetWindowSize(g_pixSz);
	}
Beispiel #25
0
bool cWindow::InitWindow(const std::string& pWindowTitle) {

	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK ) != 0) {
		std::cout << "Failed to initialise SDL\n";
		exit(1);
		return false;
	}

	CalculateWindowSize();

	mWindow = SDL_CreateWindow(pWindowTitle.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, GetWindowSize().mWidth, GetWindowSize().mHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE );
	if (!mWindow) {
		std::cout << "Failed to create window\n";
		exit(1);
		return false;
	}

	mRenderer = SDL_CreateRenderer(mWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
	if (!mRenderer) {
		std::cout << "Failed to create rendered\n";
		exit(1);
		return false;
	}

	SDL_RenderSetLogicalSize(mRenderer, 366, 272);
	SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, 0);
	SetCursor();
	return true;
}
Beispiel #26
0
void SolveSpace::GetTextWindowSize(int *w, int *h)
{
    GetWindowSize(TextWnd, w, h);
}
Beispiel #27
0
void SolveSpace::GetGraphicsWindowSize(int *w, int *h)
{
    GetWindowSize(GraphicsWnd, w, h);
}
Beispiel #28
0
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{
    int x = (int)event.GetX(),
        y = (int)event.GetY();

    if (GetWindowStyle() & wxSP_NOSASH)
        return;

    // with wxSP_LIVE_UPDATE style the splitter windows are always resized
    // following the mouse movement while it drags the sash, without it we only
    // draw the sash at the new position but only resize the windows when the
    // dragging is finished
#if defined( __WXMAC__ ) && TARGET_API_MAC_OSX == 1
    bool isLive = true ;
#else
    bool isLive = (GetWindowStyleFlag() & wxSP_LIVE_UPDATE) != 0;
#endif
    if (event.LeftDown())
    {
        if ( SashHitTest(x, y) )
        {
            // Start the drag now
            m_dragMode = wxSPLIT_DRAG_DRAGGING;

            // Capture mouse and set the cursor
            CaptureMouse();
            SetResizeCursor();

            if ( !isLive )
            {
                // remember the initial sash position and draw the initial
                // shadow sash
                m_sashPositionCurrent = m_sashPosition;

                DrawSashTracker(x, y);
            }

            m_oldX = x;
            m_oldY = y;

            SetResizeCursor();
            return;
        }
    }
    else if (event.LeftUp() && m_dragMode == wxSPLIT_DRAG_DRAGGING)
    {
        // We can stop dragging now and see what we've got.
        m_dragMode = wxSPLIT_DRAG_NONE;

        // Release mouse and unset the cursor
        ReleaseMouse();
        SetCursor(* wxSTANDARD_CURSOR);

        // exit if unsplit after doubleclick
        if ( !IsSplit() )
        {
            return;
        }

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        // the position of the click doesn't exactly correspond to
        // m_sashPosition, rather it changes it by the distance by which the
        // mouse has moved
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;

        int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
        int posSashNew = OnSashPositionChanging(posSashOld + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( m_permitUnsplitAlways || m_minimumPaneSize == 0 )
        {
            // Deal with possible unsplit scenarios
            if ( posSashNew == 0 )
            {
                // We remove the first window from the view
                wxWindow *removedWindow = m_windowOne;
                m_windowOne = m_windowTwo;
                m_windowTwo = (wxWindow *) NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_UNSPLIT, this);
                event.m_data.win = removedWindow;
                (void)DoSendEvent(event);
                SetSashPositionAndNotify(0);
            }
            else if ( posSashNew == GetWindowSize() )
            {
                // We remove the second window from the view
                wxWindow *removedWindow = m_windowTwo;
                m_windowTwo = (wxWindow *) NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_UNSPLIT, this);
                event.m_data.win = removedWindow;
                (void)DoSendEvent(event);
                SetSashPositionAndNotify(0);
            }
            else
            {
                SetSashPositionAndNotify(posSashNew);
            }
        }
        else
        {
            SetSashPositionAndNotify(posSashNew);
        }

        SizeWindows();
    }  // left up && dragging
    else if ((event.Moving() || event.Leaving() || event.Entering()) && (m_dragMode == wxSPLIT_DRAG_NONE))
    {
        if ( event.Leaving() || !SashHitTest(x, y) )
            OnLeaveSash();
        else
            OnEnterSash();
    }
    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
    {
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY;
        if ( !diff )
        {
            // nothing to do, mouse didn't really move far enough
            return;
        }

        int posSashOld = isLive ? m_sashPosition : m_sashPositionCurrent;
        int posSashNew = OnSashPositionChanging(posSashOld + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( posSashNew == m_sashPosition )
            return;

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        if (m_splitMode == wxSPLIT_VERTICAL)
            x = posSashNew;
        else
            y = posSashNew;

        // Remember old positions
        m_oldX = x;
        m_oldY = y;

#ifdef __WXMSW__
        // As we captured the mouse, we may get the mouse events from outside
        // our window - for example, negative values in x, y. This has a weird
        // consequence under MSW where we use unsigned values sometimes and
        // signed ones other times: the coordinates turn as big positive
        // numbers and so the sash is drawn on the *right* side of the window
        // instead of the left (or bottom instead of top). Correct this.
        if ( (short)m_oldX < 0 )
            m_oldX = 0;
        if ( (short)m_oldY < 0 )
            m_oldY = 0;
#endif // __WXMSW__

        // Draw new one
        if ( !isLive )
        {
            m_sashPositionCurrent = posSashNew;

            DrawSashTracker(m_oldX, m_oldY);
        }
        else
        {
            DoSetSashPosition(posSashNew);
            m_needUpdating = true;
        }
    }
    else if ( event.LeftDClick() && m_windowTwo )
    {
        OnDoubleClickSash(x, y);
    }
}
Beispiel #29
0
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)
{
    int x = (int)event.GetX(),
        y = (int)event.GetY();

    if ( GetWindowStyle() & wxSP_NOSASH )
    {
        event.Skip();
        return;
    }

    bool isLive = IsLive(this);

    if (event.LeftDown())
    {
        if ( SashHitTest(x, y) )
        {
            // Start the drag now
            m_dragMode = wxSPLIT_DRAG_DRAGGING;

            // Capture mouse and set the cursor
            CaptureMouse();
            SetResizeCursor();

            if ( !isLive )
            {
                // remember the initial sash position and draw the initial
                // shadow sash
                m_sashPositionCurrent = m_sashPosition;

                m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x);
                m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y);
                DrawSashTracker(m_oldX, m_oldY);
            }

            m_ptStart = wxPoint(x,y);
            m_sashStart = m_sashPosition;
            return;
        }
    }
    else if (event.LeftUp() && m_dragMode == wxSPLIT_DRAG_DRAGGING)
    {
        // We can stop dragging now and see what we've got.
        m_dragMode = wxSPLIT_DRAG_NONE;

        // Release mouse and unset the cursor
        ReleaseMouse();
        SetCursor(* wxSTANDARD_CURSOR);

        // exit if unsplit after doubleclick
        if ( !IsSplit() )
        {
            return;
        }

        // Erase old tracker
        if ( !isLive )
        {
            DrawSashTracker(m_oldX, m_oldY);
        }

        // the position of the click doesn't exactly correspond to
        // m_sashPosition, rather it changes it by the distance by which the
        // mouse has moved
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y;

        int posSashNew = OnSashPositionChanging(m_sashStart + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( m_permitUnsplitAlways || m_minimumPaneSize == 0 )
        {
            // Deal with possible unsplit scenarios
            if ( posSashNew == 0 )
            {
                // We remove the first window from the view
                wxWindow *removedWindow = m_windowOne;
                m_windowOne = m_windowTwo;
                m_windowTwo = NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this);
                eventUnsplit.m_data.win = removedWindow;
                (void)DoSendEvent(eventUnsplit);
                SetSashPositionAndNotify(0);
            }
            else if ( posSashNew == GetWindowSize() )
            {
                // We remove the second window from the view
                wxWindow *removedWindow = m_windowTwo;
                m_windowTwo = NULL;
                OnUnsplit(removedWindow);
                wxSplitterEvent eventUnsplit(wxEVT_SPLITTER_UNSPLIT, this);
                eventUnsplit.m_data.win = removedWindow;
                (void)DoSendEvent(eventUnsplit);
                SetSashPositionAndNotify(0);
            }
            else
            {
                SetSashPositionAndNotify(posSashNew);
            }
        }
        else
        {
            SetSashPositionAndNotify(posSashNew);
        }

        SizeWindows();
    }  // left up && dragging
    else if ((event.Moving() || event.Leaving() || event.Entering()) && (m_dragMode == wxSPLIT_DRAG_NONE))
    {
        if ( event.Leaving() || !SashHitTest(x, y) )
            OnLeaveSash();
        else
            OnEnterSash();
    }
    else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING))
    {
        int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_ptStart.x : y - m_ptStart.y;

        int posSashNew = OnSashPositionChanging(m_sashStart + diff);
        if ( posSashNew == -1 )
        {
            // change not allowed
            return;
        }

        if ( !isLive )
        {
            if ( posSashNew == m_sashPositionCurrent )
                return;

            m_sashPositionCurrent = posSashNew;

            // Erase old tracker
            DrawSashTracker(m_oldX, m_oldY);

            m_oldX = (m_splitMode == wxSPLIT_VERTICAL ? m_sashPositionCurrent : x);
            m_oldY = (m_splitMode != wxSPLIT_VERTICAL ? m_sashPositionCurrent : y);

#ifdef __WXMSW__
            // As we captured the mouse, we may get the mouse events from outside
            // our window - for example, negative values in x, y. This has a weird
            // consequence under MSW where we use unsigned values sometimes and
            // signed ones other times: the coordinates turn as big positive
            // numbers and so the sash is drawn on the *right* side of the window
            // instead of the left (or bottom instead of top). Correct this.
            if ( (short)m_oldX < 0 )
                m_oldX = 0;
            if ( (short)m_oldY < 0 )
                m_oldY = 0;
#endif // __WXMSW__

            // Draw new one
            DrawSashTracker(m_oldX, m_oldY);
        }
        else
        {
            if ( posSashNew == m_sashPosition )
                return;

            DoSetSashPosition(posSashNew);

            // in live mode, the new position is the actual sash position, clear requested position!
            m_requestedSashPosition = INT_MAX;
            m_needUpdating = true;
        }
    }
    else if ( event.LeftDClick() && m_windowTwo )
    {
        OnDoubleClickSash(x, y);
    }
    else
    {
        event.Skip();
    }
}
Beispiel #30
0
void VimridViewer::Reshape()
{
	this->GlutApplication::Reshape();
	glViewport(0, 0, (GLsizei)GetWindowSize().Width, (GLsizei)GetWindowSize().Height);
}