📄 minisite.cpp
字号:
* IHXSite2::RemovePassiveSiteWatcher
*/
STDMETHODIMP CMiniBaseSite::RemovePassiveSiteWatcher(IHXPassiveSiteWatcher* pWatcher)
{
// iterate child site list
IHXPassiveSiteWatcher* pThisWatcher = NULL;
LISTPOSITION pPos = m_PassiveSiteWatchers.Find(pWatcher);
HX_RESULT retVal = HXR_FAIL;
if (pPos)
{
m_PassiveSiteWatchers.RemoveAt(pPos);
HX_RELEASE(pWatcher);
retVal = HXR_OK;
}
return retVal;
}
/************************************************************************
* Method:
* IHXSite2::SetCursor
*/
STDMETHODIMP CMiniBaseSite::SetCursor(HXxCursor cursor, REF(HXxCursor) oldCursor)
{
return HXR_NOTIMPL;
}
STDMETHODIMP CMiniBaseSite::SetZOrder(INT32 lZOrder)
{
if(!m_pParentSite)
{
return HXR_UNEXPECTED;
}
if (lZOrder == -1)
{
lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
}
if (lZOrder >= (INT32) m_pParentSite->GetNumberOfChildSites())
{
lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
}
if (m_lZOrder != lZOrder)
{
m_pParentSite->UpdateZOrder(this, lZOrder);
}
if( this == m_pTopLevelSite)
{
RecomputeClip();
}
else
{
if (m_pTopLevelSite)
m_pTopLevelSite->ScheduleCallback(CLIP, 0);
}
return HXR_OK;
}
void CMiniBaseSite::UpdateZOrder( CMiniBaseSite* pUpdatedChildSite,INT32 lNewZOrder)
{
HX_ASSERT(pUpdatedChildSite);
LISTPOSITION pos = m_ChildrenInZOrder.Find((void*)pUpdatedChildSite);
if (!pos)
{
return;
}
m_ChildrenInZOrder.RemoveAt(pos);
BOOL bHasReinsertedChild = FALSE;
INT32 zOrder = 0;
INT32 newZOrder = 0;
LISTPOSITION posNext = m_ChildrenInZOrder.GetHeadPosition();
while (posNext)
{
pos = posNext;
CMiniBaseSite* pSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(posNext);
if (!bHasReinsertedChild)
{
pSite->GetZOrder(zOrder);
if (zOrder > lNewZOrder)
{
m_ChildrenInZOrder.InsertBefore(pos, (void*)pUpdatedChildSite);
bHasReinsertedChild = TRUE;
pUpdatedChildSite->SetInternalZOrder(newZOrder++);
}
}
pSite->SetInternalZOrder(newZOrder++);
}
if (!bHasReinsertedChild)
{
m_ChildrenInZOrder.AddTail((void*)pUpdatedChildSite);
pUpdatedChildSite->SetInternalZOrder(newZOrder++);
}
}
void CMiniBaseSite::RecomputeClip()
{
// this recomputes our clipping rect.
if( ComputeSubRects() )
{
//We need to do this in Z-Order.
LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(pos);
pSite->RecomputeClip();
}
}
}
BOOL CMiniBaseSite::IsSiteVisible()
{
BOOL bIsVisible = m_bIsVisible;
if(m_pParentSite)
{
bIsVisible &= m_pParentSite->IsSiteVisible();
}
if( bIsVisible )
{
//If we are a m_bSiteNeverBlts then it doesn't matter if we are
//visible or not, we must have at least one child that is
//visible and not m_bSiteNeverBlts. Otherwise we really aren't
//visible at all. This distinction is needed because of our
//favorite logic in computesubrecs not that we have transparent
//regions.
if(!_CheckForVisibleChild())
{
bIsVisible = FALSE;
}
}
return bIsVisible;
}
BOOL CMiniBaseSite::_CheckForVisibleChild()
{
BOOL retVal = FALSE;
BOOL bSiteNeverBlts = FALSE;
IHXBuffer* pBuf=NULL;
m_pValues->GetPropertyCString( "SiteNeverBlts", pBuf );
if( pBuf )
{
bSiteNeverBlts = atoi( (const char*)pBuf->GetBuffer() )==1;
HX_RELEASE(pBuf);
}
if( m_bIsVisible && !bSiteNeverBlts )
{
retVal = TRUE;
}
else
{
LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(pos);
if( pSite->_CheckForVisibleChild() )
{
retVal = TRUE;
break;
}
}
}
return retVal;
}
BOOL CMiniBaseSite::ComputeSubRects()
{
BOOL retVal = TRUE;
HXREGION* hTemp = NULL;
HXxSize size;
HXxPoint* pPosition = NULL;
LISTPOSITION pos = NULL;
if (m_Region)
{
HXDestroyRegion(m_Region);
m_Region = NULL;
}
if (m_RegionWithoutChildren)
{
HXDestroyRegion(m_RegionWithoutChildren);
m_RegionWithoutChildren = NULL;
}
if( IsSiteVisible() )
{
m_RegionWithoutChildren = HXCreateRectRegion(m_topleft.x,
m_topleft.y,
m_size.cx,
m_size.cy
);
if (m_pParentSite)
m_pParentSite->BuildParnetClipping(m_RegionWithoutChildren,this);
// subtract all of my children from my clipping region
m_Region = HXCreateRectRegion(0,0,0,0);
HXUnionRegion(m_Region, m_RegionWithoutChildren, m_Region);
if (m_Region->numRects == 0)
{
retVal = FALSE;
}
else
{
pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pSite = (CMiniBaseSite*) m_ChildrenInZOrder.GetNext(pos);
if(pSite->IsSiteVisible())
{
pPosition = pSite->GetOrigin();
pSite->GetSize(size);
hTemp = HXCreateRectRegion( pPosition->x,
pPosition->y,
size.cx,
size.cy);
HXSubtractRegion(m_Region, hTemp, m_Region);
HXDestroyRegion(hTemp);
hTemp = NULL;
}
}
}
}
else
{
m_RegionWithoutChildren = HXCreateRectRegion(0,0,0,0);
m_Region = HXCreateRectRegion(0,0,0,0);
}
return TRUE;
}
void CMiniBaseSite::BuildParnetClipping(HXREGION* hClip, CMiniBaseSite* pChild)
{
HXREGION* hTemp = NULL;
HXxPoint* pPosition = NULL;
HXxSize size;
BOOL bFound = FALSE;
// subtract all of my children from my clipping region
LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(pos);
//Keep in mind that all sites before pChild have zorder less than
//pChild and all sites after have a higher zorder.
if( pChild == pSite )
{
bFound = TRUE;
}
if(bFound && pChild!=pSite && pSite->IsSiteVisible())
{
pSite->GetSize(size);
pPosition = pSite->GetOrigin();
hTemp = HXCreateRectRegion( pPosition->x,
pPosition->y,
size.cx,
size.cy);
HXSubtractRegion(hClip, hTemp, hClip);
HXDestroyRegion(hTemp);
hTemp=NULL;
}
}
// now handle my clipping region
hTemp = HXCreateRectRegion(m_topleft.x,
m_topleft.y,
m_size.cx,
m_size.cy);
HXIntersectRegion(hClip, hTemp, hClip);
HXDestroyRegion(hTemp);
hTemp=NULL;
if (m_pParentSite)
m_pParentSite->BuildParnetClipping(hClip,this);
}
void CMiniBaseSite::ScheduleCallback(CALLBACK_TYPE nWhichCallback,
INT32 nMilliseconds)
{
HX_ASSERT(m_pTopLevelSite == this);
if( !(m_bfCallBacks & nWhichCallback))
{
//It is not already set.
m_bfCallBacks |= nWhichCallback;
if (m_pScheduler)
{
ULONG32 now = HX_GET_TICKCOUNT();
if(m_CallbackHandle && m_ulCallbackTime>(now+nMilliseconds) )
{
m_pScheduler->Remove(m_CallbackHandle);
m_CallbackHandle = 0;
}
if( !m_CallbackHandle )
{
//Don't schedule a new one if we are already waiting.
m_CallbackHandle = m_pScheduler->RelativeEnter( this,
nMilliseconds);
m_ulCallbackTime = now+nMilliseconds;
}
}
}
}
STDMETHODIMP CMiniBaseSite::Func(void)
{
m_CallbackHandle = 0;
AddRef();
if( m_bfCallBacks & CLIP )
{
RecomputeClip();
_ForceRedrawAll();
m_bfCallBacks &= ~CLIP;
m_bfCallBacks &= ~REDRAW_ALL;
}
if (m_bfCallBacks & REPAINT)
{
_ForceRedrawAll();
m_bfCallBacks &= ~REPAINT;
}
if( m_bfCallBacks & REDRAW_ALL )
{
_ForceRedrawAll();
m_bfCallBacks &= ~REDRAW_ALL;
}
Release();
return HXR_OK;
}
void CMiniBaseSite::_ForceRedrawAll()
{
if( (IsSiteVisible() && m_Region && !HXEmptyRegion(m_Region)))
{
ForceRedraw();
}
//Now do all the children in z-order
LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(pos);
pSite->_ForceRedrawAll();
}
}
void CMiniBaseSite::ResetOrigin()
{
m_topleft.x =0;
m_topleft.y =0;
GetAbsoluteCords(m_topleft);
LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
while(pos)
{
CMiniBaseSite* pChildSite = (CMiniBaseSite*)m_ChildrenInZOrder.GetNext(pos);
pChildSite->ResetOrigin();
}
}
void CMiniBaseSite::GetAbsoluteCords(HXxPoint& point)
{
point.x += m_position.x;
point.y += m_position.y;
if (m_pParentSite)
{
m_pParentSite->GetAbsoluteCords(point);
}
}
#endif //HELIX_FEATURE_SMIL_SITE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -