📄 macsite.cpp
字号:
m_pHXxFullScreenWindow->clipRect.bottom = (long)((double)pWindow->clipRect.bottom * m_fStretchMultiple);
}
}
CHXMapPtrToPtr::Iterator i = m_ChildrenMap.Begin();
for ( ; i != m_ChildrenMap.End(); ++i)
{
CHXBaseSite* pSite = (CHXBaseSite*) *i;
CHXMacSite* pMacSite = (CHXMacSite*)pSite;
pMacSite->_ScaleFullScreen(pWindow);
}
}
/************************************************************************
* Method:
* CHXMacSite::_EnterFullScreen
*/
HX_RESULT
CHXMacSite::_EnterFullScreen()
{
if (zm_bFullScreenActive)
{
return HXR_UNEXPECTED;
}
zm_bFullScreenActive = TRUE;
if (m_pTopLevelSite == this)
{
short desiredWidth, desiredHeight;
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_RESULT
CHXMacSite::_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_RESULT
CHXMacSite::_TestFullScreen(void* hTestBitmap, const char* pszStatusText)
{
return HXR_OK;
}
/************************************************************************
* Method:
* CHXMacSite::_TryCreateXSlider
*/
void
CHXMacSite::_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
*/
void
CHXMacSite::_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
*/
void
CHXMacSite::_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
*/
void
CHXMacSite::_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
*/
void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -