bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) { #ifndef __WXOSX_IPHONE__ if (mode == wxDefaultVideoMode) { CGRestorePermanentDisplayConfiguration(); return true; } #endif boolean_t bExactMatch; CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate( m_id, (size_t)mode.GetDepth(), (size_t)mode.GetWidth(), (size_t)mode.GetHeight(), (double)mode.GetRefresh(), &bExactMatch ); bool bOK = bExactMatch; if (bOK) bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr; return bOK; }
static bool wxCreateMGL_WM(const wxVideoMode& displayMode) { int mode; int refresh = MGL_DEFAULT_REFRESH; #if wxUSE_SYSTEM_OPTIONS if ( wxSystemOptions::HasOption(wxT("mgl.screen-refresh")) ) refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh")); #endif mode = MGL_findMode(displayMode.GetWidth(), displayMode.GetHeight(), displayMode.GetDepth()); if ( mode == -1 ) { wxLogError(_("Mode %ix%i-%i not available."), displayMode.GetWidth(), displayMode.GetHeight(), displayMode.GetDepth()); return false; } g_displayDC = new MGLDisplayDC(mode, 1, refresh); if ( !g_displayDC->isValid() ) { delete g_displayDC; g_displayDC = NULL; return false; } g_winMng = MGL_wmCreate(g_displayDC->getDC()); if (!g_winMng) return false; return true; }
bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) { // Changing to default mode (wxDefaultVideoMode) doesn't // work because we don't have access to the system's 'scrn' // resource which holds the user's mode which the system // will return to after this app is done boolean_t bExactMatch; CFDictionaryRef theCGMode = CGDisplayBestModeForParametersAndRefreshRate( m_id, (size_t)mode.GetDepth(), (size_t)mode.GetWidth(), (size_t)mode.GetHeight(), (double)mode.GetRefresh(), &bExactMatch ); bool bOK = bExactMatch; if (bOK) bOK = CGDisplaySwitchToMode( m_id, theCGMode ) == CGDisplayNoErr; return bOK; }
bool wxApp::SetDisplayMode(const wxVideoMode& mode) { if ( !mode.IsOk() ) { return false; } if ( g_displayDC != NULL ) { // FIXME_MGL -- we currently don't allow to switch video mode // more than once. This can hopefully be changed... wxFAIL_MSG(wxT("Can't change display mode after intialization!")); return false; } if ( !wxCreateMGL_WM(mode) ) return false; gs_rootWindow = new wxRootWindow; m_displayMode = mode; return true; }
void Add(const wxVideoMode& mode) { if ( mode.Matches(m_modeMatch) ) m_modes.Add(mode); }
bool wxDisplayImplMultimon::ChangeMode(const wxVideoMode& mode) { // prepare ChangeDisplaySettingsEx() parameters DEVMODE dm; DEVMODE *pDevMode; int flags; if ( mode == wxDefaultVideoMode ) { // reset the video mode to default pDevMode = NULL; flags = 0; } else // change to the given mode { wxCHECK_MSG( mode.GetWidth() && mode.GetHeight(), false, wxT("at least the width and height must be specified") ); wxZeroMemory(dm); dm.dmSize = sizeof(dm); dm.dmDriverExtra = 0; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; dm.dmPelsWidth = mode.GetWidth(); dm.dmPelsHeight = mode.GetHeight(); if ( mode.GetDepth() ) { dm.dmFields |= DM_BITSPERPEL; dm.dmBitsPerPel = mode.GetDepth(); } if ( mode.GetRefresh() ) { dm.dmFields |= DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = mode.GetRefresh(); } pDevMode = &dm; #ifdef __WXWINCE__ flags = 0; #else // !__WXWINCE__ flags = CDS_FULLSCREEN; #endif // __WXWINCE__/!__WXWINCE__ } // get pointer to the function dynamically // // we're only called from the main thread, so it's ok to use static // variable static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx = NULL; if ( !pfnChangeDisplaySettingsEx ) { wxDynamicLibrary dllDisplay(displayDllName, wxDL_VERBATIM | wxDL_QUIET); if ( dllDisplay.IsLoaded() ) { wxDL_INIT_FUNC_AW(pfn, ChangeDisplaySettingsEx, dllDisplay); } //else: huh, no this DLL must always be present, what's going on?? #ifndef __WXWINCE__ if ( !pfnChangeDisplaySettingsEx ) { // we must be under Win95 and so there is no multiple monitors // support anyhow pfnChangeDisplaySettingsEx = ChangeDisplaySettingsExForWin95; } #endif // !__WXWINCE__ } // do change the mode switch ( pfnChangeDisplaySettingsEx ( GetName().wx_str(), // display name pDevMode, // dev mode or NULL to reset NULL, // reserved flags, NULL // pointer to video parameters (not used) ) ) { case DISP_CHANGE_SUCCESSFUL: // ok { // If we have a top-level, full-screen frame, emulate // the DirectX behavior and resize it. This makes this // API quite a bit easier to use. wxWindow *winTop = wxTheApp->GetTopWindow(); wxFrame *frameTop = wxDynamicCast(winTop, wxFrame); if (frameTop && frameTop->IsFullScreen()) { wxVideoMode current = GetCurrentMode(); frameTop->SetClientSize(current.GetWidth(), current.GetHeight()); } } return true; case DISP_CHANGE_BADMODE: // don't complain about this, this is the only "expected" error break; default: wxFAIL_MSG( wxT("unexpected ChangeDisplaySettingsEx() return value") ); } return false; }
bool wxDisplayMSW::ChangeMode(const wxVideoMode& mode) { // prepare ChangeDisplaySettingsEx() parameters DEVMODE dm; DEVMODE *pDevMode; int flags; if ( mode == wxDefaultVideoMode ) { // reset the video mode to default pDevMode = NULL; flags = 0; } else // change to the given mode { wxCHECK_MSG( mode.GetWidth() && mode.GetHeight(), false, wxT("at least the width and height must be specified") ); wxZeroMemory(dm); dm.dmSize = sizeof(dm); dm.dmDriverExtra = 0; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; dm.dmPelsWidth = mode.GetWidth(); dm.dmPelsHeight = mode.GetHeight(); if ( mode.GetDepth() ) { dm.dmFields |= DM_BITSPERPEL; dm.dmBitsPerPel = mode.GetDepth(); } if ( mode.GetRefresh() ) { dm.dmFields |= DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = mode.GetRefresh(); } pDevMode = &dm; flags = CDS_FULLSCREEN; } // do change the mode switch ( ::ChangeDisplaySettingsEx ( GetName().t_str(), // display name pDevMode, // dev mode or NULL to reset NULL, // reserved flags, NULL // pointer to video parameters (not used) ) ) { case DISP_CHANGE_SUCCESSFUL: // ok { // If we have a top-level, full-screen frame, emulate // the DirectX behaviour and resize it. This makes this // API quite a bit easier to use. wxWindow *winTop = wxTheApp->GetTopWindow(); wxFrame *frameTop = wxDynamicCast(winTop, wxFrame); if (frameTop && frameTop->IsFullScreen()) { wxVideoMode current = GetCurrentMode(); frameTop->SetClientSize(current.GetWidth(), current.GetHeight()); } } return true; case DISP_CHANGE_BADMODE: // don't complain about this, this is the only "expected" error break; default: wxFAIL_MSG( wxT("unexpected ChangeDisplaySettingsEx() return value") ); } return false; }