📄 macsite.cpp
字号:
GDHandle aGD = ::GetMainDevice(); // Check the UseOverlay preference here, since _OverlayAvailable() doesn't update its // value on Preference changes. BOOL bDoScreenResSwitch = FALSE; IHXPreferences* pPreferences = NULL; if (m_pContext && (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences, (void**)&pPreferences))) { IHXBuffer* pBuffer = NULL; if (pPreferences->ReadPref("UseOverlay", pBuffer) == HXR_OK) { bDoScreenResSwitch = ::atoi((char*)pBuffer->GetBuffer()) != 1; } HX_RELEASE(pBuffer); } HX_RELEASE(pPreferences); if (!bDoScreenResSwitch) { // if an overlay exists then let's assume we don't have // to switch resolutions. desiredWidth = (**aGD).gdRect.right - (**aGD).gdRect.left; desiredHeight = (**aGD).gdRect.bottom - (**aGD).gdRect.top; } else { desiredWidth = m_size.cx; desiredHeight = m_size.cy; } ::BeginFullScreen( &zm_pRememberFullScreenInformation, ::GetMainDevice(), &desiredWidth, &desiredHeight, nil, nil, fullScreenAllowEvents ); _DestroySliders(); CMacRootSurface::VisRgnChangedCallback(); GDHandle mainGD = ::GetMainDevice(); Rect bounds = (**mainGD).gdRect; if (m_pHXxFullScreenWindow && m_pHXxFullScreenWindow->window) { WindowPtr w = (WindowPtr)m_pHXxFullScreenWindow->window; ::ShowWindow(w); ::SizeWindow(w, bounds.right-bounds.left, bounds.bottom-bounds.top, true); ::MoveWindow(w, bounds.left, bounds.top, true); HXxPoint newPosition; newPosition.x = bounds.left; newPosition.y = bounds.top; HXxSize newSize; newSize.cx = bounds.right-bounds.left; newSize.cy = bounds.bottom-bounds.top; double theXZoomFactor = (double)newSize.cx / (double)m_pWindow->width; double theYZoomFactor = (double)newSize.cy / (double)m_pWindow->height; if (theXZoomFactor < theYZoomFactor) { theYZoomFactor = theXZoomFactor; newSize.cy = (long)((double)m_pWindow->height * theYZoomFactor); newPosition.y += ((bounds.bottom-bounds.top)-newSize.cy)/2; } else { theXZoomFactor = theYZoomFactor; newSize.cx = (long)((double)m_pWindow->width * theXZoomFactor); newPosition.x += ((bounds.right-bounds.left)-newSize.cx)/2; } m_fStretchMultiple = theXZoomFactor; m_pHXxFullScreenWindow->x = newPosition.x; m_pHXxFullScreenWindow->y = newPosition.y; m_pHXxFullScreenWindow->width = newSize.cx; m_pHXxFullScreenWindow->height = newSize.cy; m_pHXxFullScreenWindow->clipRect.left = newPosition.x; m_pHXxFullScreenWindow->clipRect.top = newPosition.y; m_pHXxFullScreenWindow->clipRect.right = newPosition.x + newSize.cx; m_pHXxFullScreenWindow->clipRect.bottom = newPosition.y + newSize.cy; #if defined(_CARBON) || defined(_MAC_UNIX) ::SetPort( GetWindowPort( (WindowPtr)m_pHXxFullScreenWindow->window ) );#else ::SetPort((WindowPtr)m_pHXxFullScreenWindow->window);#endif RGBColor holdRGB; RGBColor theRGB = {0x0000, 0x0000, 0x0000}; ::GetBackColor(&holdRGB); ::RGBBackColor(&theRGB); ::EraseRect(&bounds); ::RGBBackColor(&holdRGB); if (m_bInternalResizeOnFullscreen) { GetSize(m_RememberNonFullscreenSize); GetPosition(m_RememberNonFullscreenPosition); m_pTopLevelSite->m_bDisableForceRedraw = TRUE; SetSize(newSize); m_pTopLevelSite->m_bDisableForceRedraw = FALSE; SetPosition(newPosition); } else { _ScaleFullScreen(m_pWindow); } SetOriginAndMaintainClipRgn(-m_pHXxFullScreenWindow->x, -m_pHXxFullScreenWindow->y); } m_bInFullScreen = TRUE; } return HXR_OK;}/************************************************************************ * Method: * CHXMacSite::_ExitFullScreen */HX_RESULTCHXMacSite::_ExitFullScreen(){ CMacRootSurface::VisRgnChangedCallback(); if (m_pTopLevelSite == this) { m_bInFullScreen = FALSE; _DestroySliders(); if (m_pHXxFullScreenWindow && m_pHXxFullScreenWindow->window) { WindowPtr w = (WindowPtr)m_pHXxFullScreenWindow->window; GrafPtr savePort; ::GetPort(&savePort); ::SetPort(::GetWindowPort(w)); // we need to restore the origin for the next time we may // enter fullscreen mode. xxxbobclark SetOriginAndMaintainClipRgn(0,0); ::HideWindow(w); ::SetPort(savePort); } if (!m_bInternalResizeOnFullscreen) { HXxSize fullscreenSize; fullscreenSize.cx = m_pHXxFullScreenWindow->width; fullscreenSize.cy = m_pHXxFullScreenWindow->height; HXxSize nonfullscreenSize; nonfullscreenSize.cx = (long)((double)fullscreenSize.cx / m_fStretchMultiple); nonfullscreenSize.cy = (long)((double)fullscreenSize.cy / m_fStretchMultiple); if (m_pWatcher) { HRESULT hres = m_pWatcher->ChangingSize(fullscreenSize, nonfullscreenSize); } } ::EndFullScreen(zm_pRememberFullScreenInformation, nil); } if (CMacSurface::zm_pOverlaySurface == (CMacSurface*)m_pVideoSurface) { CMacSurface::CleanUpOverlay(); CMacSurface::zm_pOverlaySurface = nil; } zm_bFullScreenActive = FALSE; if (m_pTopLevelSite == this) { if (m_bInternalResizeOnFullscreen) { m_pTopLevelSite->m_bDisableForceRedraw = TRUE; SetSize(m_RememberNonFullscreenSize); m_pTopLevelSite->m_bDisableForceRedraw = FALSE; SetPosition(m_RememberNonFullscreenPosition); } } return HXR_OK;}/************************************************************************ * Method: * CHXMacSite::_TestFullScreen */HX_RESULTCHXMacSite::_TestFullScreen(void* hTestBitmap, const char* pszStatusText){ return HXR_OK;}/************************************************************************ * Method: * CHXMacSite::_TryCreateXSlider */voidCHXMacSite::_TryCreateXSlider(){ if (!IsSiteVisible()) { return; } HXxWindow* pWindow = GetWindow(); if (!pWindow || !pWindow->window) { return; } WindowPtr w = (WindowPtr)pWindow->window; GrafPtr savePort; ::GetPort(&savePort); ::SetPort(::GetWindowPort(w)); Point oldOrigin; Rect portRect; ::GetPortBounds(::GetWindowPort(w), &portRect); oldOrigin.h = portRect.left; oldOrigin.v = portRect.top; SetOriginAndMaintainClipRgn(0,0); // scroll bar maintenance requires origin at 0,0. HXxPoint offset = {0,0}; GetMacContentAreaOffset(offset); HXxPoint position; HXxSize size; HX_ASSERT(GetParentSite()); if (GetParentSite()) { GetParentSite()->GetSize(size); position.x = 0; position.y = 0; } Rect controlRect; controlRect.left = position.x + offset.x; controlRect.top = position.y + offset.y + size.cy - SCROLL_BAR_WIDTH; controlRect.right = controlRect.left + size.cx; controlRect.bottom = controlRect.top + SCROLL_BAR_WIDTH; if (m_hHScrollBar && ::GetControlOwner(m_hHScrollBar) != w) { ::DisposeControl(m_hHScrollBar); m_hHScrollBar = NULL; m_XSliderPos = 0; } if (m_hHScrollBar) { // if it already exists, then we may simply need to // move it... Rect oldControlRect; ::GetControlBounds(m_hHScrollBar, &oldControlRect); if (!::EqualRect(&oldControlRect, &controlRect)) { ::SetControlBounds(m_hHScrollBar, &controlRect); ::InvalWindowRect(w, &oldControlRect); } } else { ::CreateScrollBarControl(w, &controlRect, 0, 0, 2, 1, false, NULL, &m_hHScrollBar); ::SetControlReference(m_hHScrollBar, 0); } // invaling the rect seems to ameliorate this problem where extra scrollbars // were being spuriously displayed. ::InvalWindowRect(w, &controlRect); SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v); ::SetPort(savePort);}/************************************************************************ * Method: * CHXMacSite::_SetXSliderValues */voidCHXMacSite::_SetXSliderValues(INT32 range, INT32 pageSize){ HXxWindow* pWindow = GetWindow(); if (!pWindow || !pWindow->window) { return; } WindowPtr w = (WindowPtr)pWindow->window; Point oldOrigin; Rect portRect; ::GetPortBounds(::GetWindowPort(w), &portRect); oldOrigin.h = portRect.left; oldOrigin.v = portRect.top; SetOriginAndMaintainClipRgn(0,0); ::SetControl32BitMinimum(m_hHScrollBar, 0); ::SetControl32BitMaximum(m_hHScrollBar, range - pageSize); ::SetControlViewSize(m_hHScrollBar, pageSize); ::SetControl32BitValue(m_hHScrollBar, m_XSliderPos); m_nHorizPageSize = pageSize / 2; SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v); SetMacControlRange(m_hHScrollBar, range); m_nHorizPageSize = pageSize;}/************************************************************************ * Method: * CHXMacSite::_TryCreateYSlider */voidCHXMacSite::_TryCreateYSlider(){ if (!IsSiteVisible()) { return; } HXxWindow* pWindow = GetWindow(); if (!pWindow || !pWindow->window) { return; } WindowPtr w = (WindowPtr)pWindow->window; GrafPtr savePort; ::GetPort(&savePort); ::SetPort(::GetWindowPort(w)); Point oldOrigin; Rect portRect; ::GetPortBounds(::GetWindowPort(w), &portRect); oldOrigin.h = portRect.left; oldOrigin.v = portRect.top; HXxPoint offset = {0,0}; GetMacContentAreaOffset(offset); SetOriginAndMaintainClipRgn(0,0); HXxPoint position; HXxSize size; HX_ASSERT(GetParentSite()); if (GetParentSite()) { GetParentSite()->GetSize(size); position.x = 0; position.y = 0; } Rect controlRect; controlRect.left = position.x + offset.x + size.cx - SCROLL_BAR_WIDTH; controlRect.top = position.y + offset.y; controlRect.right = controlRect.left + SCROLL_BAR_WIDTH; controlRect.bottom = controlRect.top + size.cy; if (_DoesXSliderExist()) { controlRect.bottom -= SCROLL_BAR_WIDTH; // ensure that both scroll bars don't overlap at the bottom right corner } if (m_hVScrollBar && ::GetControlOwner(m_hVScrollBar) != w) { ::DisposeControl(m_hVScrollBar); m_hVScrollBar = NULL; m_YSliderPos = 0; } if (m_hVScrollBar) { Rect oldControlRect; ::GetControlBounds(m_hVScrollBar, &oldControlRect); if (!::EqualRect(&oldControlRect, &controlRect)) { ::SetControlBounds(m_hVScrollBar, &controlRect); ::InvalWindowRect(w, &oldControlRect); } } else { ::CreateScrollBarControl(w, &controlRect, 0, 0, 2, 1, false, NULL, &m_hVScrollBar); ::SetControlReference(m_hVScrollBar, 0); } ::InvalWindowRect(w, &controlRect); SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v); ::SetPort(savePort);}/************************************************************************ * Method: * CHXMacSite::_SetYSliderValues */voidCHXMacSite::_SetYSliderValues(INT32 range, INT32 pageSize){ HXxWindow* pWindow = GetWindow(); if (!pWindow || !pWindow->window) { return; } WindowPtr w = (WindowPtr)pWindow->window; Point oldOrigin; Rect portRect; ::GetPortBounds(::GetWindowPort(w), &portRect); oldOrigin.h = portRect.left; oldOrigin.v = portRect.top; SetOriginAndMaintainClipRgn(0,0); ::SetControl32BitMinimum(m_hVScrollBar, 0); ::SetControl32BitMaximum(m_hVScrollBar, range-pageSize); ::SetControlViewSize(m_hVScrollBar, pageSize); ::SetControl32BitValue(m_hVScrollBar, m_YSliderPos); m_nVertPageSize = pageSize / 2; SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v);}/************************************************************************ * Method: * CHXMacSite::_GetSystemSizeOfSliders */voidCHXMacSite::_GetSystemSizeOfSliders(INT32* pWidth, INT32* pHeight){ if (pWidth) *pWidth = SCROLL_BAR_WIDTH; if (pHeight) *pHeight = SCROLL_BAR_WIDTH;}/************************************************************************ * Method: * CHXMacSite::_IsWindowVisible */BOOLCHXMacSite::_IsWindowVisible(){ return TRUE;}/************************************************************************ * Method: * CHXMacSite::ShowMacControl */voidCHXMacSite::ShowMacControl(ControlHandle theControl, BOOL bShow){ if (theControl) { if (bShow) { ::ShowControl(theControl); } else { ::HideControl(theControl); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -