📄 macsite.cpp
字号:
CHXMacSite::_GetSystemSizeOfSliders(INT32* pWidth, INT32* pHeight)
{
if (pWidth) *pWidth = SCROLL_BAR_WIDTH;
if (pHeight) *pHeight = SCROLL_BAR_WIDTH;
}
/************************************************************************
* Method:
* CHXMacSite::_IsWindowVisible
*/
BOOL
CHXMacSite::_IsWindowVisible()
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::ShowMacControl
*/
void
CHXMacSite::ShowMacControl(ControlHandle theControl, BOOL bShow)
{
if (theControl)
{
if (bShow)
{
::ShowControl(theControl);
}
else
{
::HideControl(theControl);
}
}
}
/************************************************************************
* Method:
* CHXMacSite::SetMacControlRectangle
*/
void
CHXMacSite::SetMacControlRectangle(ControlHandle theControl,
INT32 left, INT32 top, INT32 right, INT32 bottom )
{
if (theControl)
{
::SizeControl(theControl, right-left, bottom-top);
::MoveControl(theControl, left, top);
}
}
void
CHXMacSite::SetMacControlRange(ControlHandle theControl, INT32 controlMax)
{
if (theControl)
{
// XXX bobclark
// Important note: The MacOS scroll bars only use 16-bit integers,
// while the Core uses 32-bit integers here. If 16 bits isn't enough,
// we'll have to do a lot more work by hand, like storing the "real"
// value in a separate variable, and scaling from 16-bit to 32-bit
// values whenever the scroll bar's thumb is dragged. For clicking on
// the scroll bar's arrows or paging around, we could compute that
// directly using the long but we'd need to scale it back to a short
// so the scroll bar would correctly reflect its approximation of the
// value.
// I don't think this will be an issue, since we're scrolling around
// a site, and a site that's more than 32000 pixels wide is ludicrous.
HX_ASSERT(controlMax >= 0 && controlMax < 32000);
SetControlMinimum(theControl, 0);
SetControlMaximum(theControl, (short)controlMax);
}
}
/************************************************************************
* Method:
* CHXMacSite::_ShowXSlider
*/
void
CHXMacSite::_ShowXSlider(BOOL bShow)
{
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);
ShowMacControl(m_hHScrollBar, bShow);
SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v);
}
/************************************************************************
* Method:
* CHXMacSite::_MoveXSlider
*/
void
CHXMacSite::_MoveXSlider(INT32 left, INT32 top, INT32 right, INT32 bottom, BOOL bRedraw)
{
// xxxbobclark do nothing right now
}
/************************************************************************
* Method:
* CHXMacSite::_ShowYSlider
*/
void
CHXMacSite::_ShowYSlider(BOOL bShow)
{
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);
ShowMacControl(m_hVScrollBar, bShow);
SetOriginAndMaintainClipRgn(oldOrigin.h, oldOrigin.v);
}
/************************************************************************
* Method:
* CHXMacSite::_MoveYSlider
*/
void
CHXMacSite::_MoveYSlider(INT32 left, INT32 top, INT32 right, INT32 bottom, BOOL bRedraw)
{
// xxxbobclark don't do anything right now
}
/************************************************************************
* Method:
* CHXMacSite::_DoesXSliderExist
*/
BOOL
CHXMacSite::_DoesXSliderExist()
{
if (m_hHScrollBar) return TRUE;
return FALSE;
}
/************************************************************************
* Method:
* CHXMacSite::_GetContainingWindow
*/
void*
CHXMacSite::_GetContainingWindow()
{
if (m_pParentSite) return m_pParentSite->_GetContainingWindow();
return NULL;
}
/************************************************************************
* Method:
* CHXMacSite::_GetCursorPos
*/
void
CHXMacSite::_GetCursorPos(HXxPoint* pPoint)
{
// this will return in global coordinates. (???)
HX_ASSERT(_AtSystemTime());
if (!_AtSystemTime()) return;
HX_ASSERT(pPoint);
if (!pPoint) return;
Point pt;
::GetMouse(&pt);
// pt is in local coordinates
::LocalToGlobal(&pt);
pPoint->x = pt.h;
pPoint->y = pt.v;
}
/************************************************************************
* Method:
* CHXMacSite::_MapPointToOSWindow
*/
void
CHXMacSite::_MapPointToOSWindow(HXxPoint* pPt, void** pWindowHandle)
{
}
/************************************************************************
* Method:
* CHXMacSite::_GetWindowWithCursor
*/
void*
CHXMacSite::_GetWindowWithCursor()
{
return NULL;
}
/************************************************************************
* Method:
* CHXMacSite::_ReInitPrimarySurface
*/
void
CHXMacSite::_ReInitPrimarySurface()
{
}
/************************************************************************
* Method:
* CHXMacSite::_MoveWindow
*/
BOOL
CHXMacSite::_MoveWindow(void* window, INT32 X, INT32 Y, INT32 nWidth, INT32 nHeight, BOOL bRepaint)
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::_UpdateWindow
*/
BOOL
CHXMacSite::_UpdateWindow(void* hWnd)
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::_ShowWindow
*/
BOOL
CHXMacSite::_ShowWindow(void* hWnd, INT32 nCmdShow)
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::_SetWindowPos
*/
BOOL
CHXMacSite::_SetWindowPos(void* hWnd, void* hWndInsertAfter, INT32 X, INT32 Y, INT32 cx, INT32 cy, INT32 uFlags)
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::_SetWindowRgn
*/
BOOL
CHXMacSite::_SetWindowRgn(void* hWnd, HXREGION* hRgn, BOOL bRedraw)
{
return TRUE;
}
/************************************************************************
* Method:
* CHXMacSite::_SetFocus
*/
void
CHXMacSite::_SetFocus(void* pWindow)
{
}
/************************************************************************
* Method:
* CHXMacSite::GetMacContentAreaOffset
*/
void
CHXMacSite::GetMacContentAreaOffset(REF(HXxPoint)offset)
{
offset.x = m_topleft.x;
offset.y = m_topleft.y;
HXxWindow* pWindow = GetWindow();
if (pWindow)
{
offset.x += pWindow->x;
offset.y += pWindow->y;
}
return;
}
#pragma export on
extern "C" void MacSiteHandleAllEvents(HXxEvent* pEvent)
{
CHXMacSite::_HandleAllOSEvents(pEvent);
}
#pragma export off
/************************************************************************
* Callback implementation
*/
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback ctor
*/
CHXMacSite::MacSiteRedrawCallback::MacSiteRedrawCallback(CHXMacSite* pMacSite)
: m_lRefCount(0)
, m_ulMacSiteRedrawCallbackPendingID(0)
, m_pMacSite(pMacSite)
{
}
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback dtor
*/
CHXMacSite::MacSiteRedrawCallback::~MacSiteRedrawCallback()
{
}
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback::QueryInterface
*/
STDMETHODIMP
CHXMacSite::MacSiteRedrawCallback::QueryInterface(REFIID riid, void** ppvObj)
{
if (IsEqualIID(riid, IID_IHXCallback))
{
AddRef();
*ppvObj = (IHXCallback*)this;
return HXR_OK;
}
else if (IsEqualIID(riid, IID_IUnknown))
{
AddRef();
*ppvObj = this;
return HXR_OK;
}
*ppvObj = NULL;
return HXR_NOINTERFACE;
}
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback::AddRef
*/
STDMETHODIMP_(ULONG32)
CHXMacSite::MacSiteRedrawCallback::AddRef()
{
return InterlockedIncrement( &m_lRefCount );
}
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback::Release
*/
STDMETHODIMP_(ULONG32)
CHXMacSite::MacSiteRedrawCallback::Release()
{
if ( InterlockedDecrement( &m_lRefCount ) > 0 )
{
return m_lRefCount;
}
delete this;
return 0;
}
/************************************************************************
* Method:
* CHXMacSite::MacSiteRedrawCallback::Func
*/
STDMETHODIMP
CHXMacSite::MacSiteRedrawCallback::Func()
{
m_pMacSite->_TLSLock();
m_ulMacSiteRedrawCallbackPendingID = NULL;
m_pMacSite->ForceRedraw();
m_pMacSite->_TLSUnlock();
return HXR_OK;
}
#ifdef THREADS_SUPPORTED
#ifdef USE_CARBON_TIMER
/************************************************************************
* Method:
* CHXMacSite::Redraw(something)Timer
*/
/*static*/
#ifdef _MAC_MACHO
void CHXMacSite::RedrawCFTimer(CFRunLoopTimerRef, CHXMacSite* pMacSite)
#else
void CHXMacSite::RedrawCarbonTimer(EventLoopTimerRef, CHXMacSite* pMacSite)
#endif
{
// XXXMEH
MLOG_BLT(NULL,
"%lu\t----macsite.cpp--- RedrawCarbonTimer()\n",
HX_GET_BETTERTICKCOUNT());
HX_ASSERT( pMacSite );
HX_ASSERT(IsMacInCooperativeThread());
if (pMacSite->m_pIHXCoreMutex) pMacSite->m_pIHXCoreMutex->LockCoreMutex();
// this huge block of code is adapted from the base site's implementation of
// InternalScheduleUpgrade, where it needs to match up an IHXPlayer with this
// site. In this case, we're protecting ourselves against rug-pulling, i.e.
// if a stream has ended and stuff has been deleted, it's still possible (due
// to the Carbon Timer's behavior of delaying redraws) that there's a pending
// ForceRedraw() that wants to happen. If there's no player for this site, or
// if the player is done, then we'll omit the blit.
// On a one-gigahertz processor, this checking function is taking
// between 20 and 30 microseconds; it may be worthwhile to save the
// player in a member variable.
bool bPlayerStillRunning = false;
IHXPreferences* pPreferences = NULL;
IHXBuffer* pBuffer = NULL;
IHXClientEngine* pClientEngine = NULL;
if (HXR_OK == pMacSite->m_pContext->QueryInterface(IID_IHXClientEngine, (void**)&pClientEngine))
{
UINT16 nPlayerCount = pClientEngine->GetPlayerCount();
IUnknown* pUnknown = NULL;
if (nPlayerCount == 1)
{
// wow, this was easy -- this is the only player then.
pClientEngine->GetPlayer(0, pUnknown);
}
else
{
IHXSite* pThisSite = NULL;
pMacSite->QueryInterface(IID_IHXSite, (void**)&pThisSite);
HX_ASSERT(pThisSite);
UINT16 index;
for (index = 0; index < nPlayerCount; index++)
{
IHXSiteManager2* pSiteMgr2 = NULL;
IUnknown* pUnknownPlayer = NULL;
pClientEngine->GetPlayer(index, pUnknownPlayer);
HX_ASSERT(pUnknownPlayer);
pUnknownPlayer->QueryInterface(IID_IHXSiteManager2, (void**)&pSiteMgr2);
if (pSiteMgr2)
{
UINT32 nNumSites;
pSiteMgr2->GetNum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -