basesite.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:209k
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: RCSL 1.0/RPSL 1.0
- *
- * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
- *
- * The contents of this file, and the files included with this file, are
- * subject to the current version of the RealNetworks Public Source License
- * Version 1.0 (the "RPSL") available at
- * http://www.helixcommunity.org/content/rpsl unless you have licensed
- * the file under the RealNetworks Community Source License Version 1.0
- * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
- * in which case the RCSL will apply. You may also obtain the license terms
- * directly from RealNetworks. You may not use this file except in
- * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
- * applicable to this file, the RCSL. Please see the applicable RPSL or
- * RCSL for the rights, obligations and limitations governing use of the
- * contents of the file.
- *
- * This file is part of the Helix DNA Technology. RealNetworks is the
- * developer of the Original Code and owns the copyrights in the portions
- * it created.
- *
- * This file, and the files included with this file, is distributed and made
- * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- *
- * Technology Compatibility Kit Test Suite(s) Location:
- * http://www.helixcommunity.org/content/tck
- *
- * Contributor(s):
- *
- * ***** END LICENSE BLOCK ***** */
- #include <stdlib.h> //for atof
- #include "hxcom.h"
- #include "hxtypes.h"
- #include "hxwintyp.h"
- #include "ihxpckts.h"
- #include "hxwin.h"
- #include "hxengin.h"
- #include "hxsite2.h"
- #include "hxevent.h"
- #include "hxcomm.h"
- #include "hxassert.h"
- #include "hxthread.h"
- #include "hxvsurf.h"
- #include "basesite.h"
- #include "basesurf.h"
- #include "baseroot.h"
- #ifdef _WINDOWS
- #include "winroot.h" //must be included before colormap.h
- #endif
- #include "colormap.h"
- #if defined(_UNIX) && !defined(_MAC_UNIX)
- #include "X11/Xlib.h"
- #include "X11/keysym.h"
- #include "unixsite.h"
- #include "hxiids.h"
- #include "hxcmenu.h"
- #endif
- #include "sitetext.h"
- //#include "hxwinver.h"
- #include "ihxpckts.h"
- #include "hxprefs.h"
- #include "hxtick.h"
- #include "hxcore.h"
- #include "hxupgrd.h"
- #include "addupcol.h"
- #include "mmx_util.h"
- #ifdef _WINDOWS
- #include "winsite.h"
- #endif
- #if defined(_MACINTOSH) || defined(_MAC_UNIX)
- //#include "../dcondev/dcon.h"
- #include "platform/mac/macsite.h"
- #endif
- #if defined(_UNIX) && !defined(_MAC_UNIX)
- #include "unixsite.h"
- #endif
- #include "hxheap.h"
- #include "colormap.h"
- #include "drawline.h"
- #include "hxvimlog.h"
- #include "sitefact.h"
- #if defined(HELIX_FEATURE_PREFERENCES)
- #include "hxprefs.h"
- #include "hxprefutil.h"
- #endif /* HELIX_FEATURE_PREFERENCES */
- #ifdef _DEBUG
- #undef HX_THIS_FILE
- static const char HX_THIS_FILE[] = __FILE__;
- #endif
- //XXXgfw just to clean up the code. We still *REALLY* need to clean
- //this up.
- #ifdef _WIN32
- #define GETBITMAPCOLOR(x) GetBitmapColor( (LPBITMAPINFO)(x) )
- #else
- #define GETBITMAPCOLOR(x) GetBitmapColor( (HXBitmapInfo*)(x))
- #endif
- #ifdef _WIN32
- #define GETBITMAPPITCH(x) GetBitmapPitch( (LPBITMAPINFO)(x) )
- #else
- #define GETBITMAPPITCH(x) GetBitmapPitch( (HXBitmapInfo*)(x))
- #endif
- /*
- * Full Screen Preferences Information
- */
- #define MODE_SEPERATOR "|"
- #define MODE_DESRIPTION_SEPS "xX"
- #define REGKEY_TESTED "Tested"
- #define REGKEY_BLT_TIME "BltTime"
- #define REGKEY_PASS "Passed"
- #define DIRECT_DRAW_DLL "ddraw.dll"
- #define REGKEY_FULLSCREEN_DATA "FullScreenData"
- #define REGKEY_FULLSCREEN_AVAILIABLE_MODES "AvailiableModes"
- #define REGKEY_FULLSCREEN_TEST_MODES "TestModes"
- #define REGKEY_FULLSCREEN_PREFERED_MODE "PreferedMode"
- #define REGKEY_NEW_FULLSCREEN_CODE "NewFullScreen"
- #define REGKEY_FULLSCREEN_NEW_STRING_FORMAT "NewStringFormat"
- #define REGKEY_DO_NOT_SETUP_DD "DoNotSetupDD"
- #define TEST_THRESHOLD 30
- #define REGKEY_FULLSCREEN_POSTAGE_STAMP "PostageStamp"
- #define TEST_LENGTH 6000
- #define NUM_OF_TEST_ITTERATIONS 2000
- #define MOVING_TIMEOUT 200 // Milliseconds
- BOOL CHXBaseSite::zm_bInFullScreenTest = FALSE;
- extern tranType z_TransitionTable[];
- extern INT32 z_nNumberTransitionTypes;
- //Out global list of YUV sites.
- CHXSimpleList CHXBaseSite::zm_YUVSiteList;
- //#define DEBUG_LINKING
- /************************************************************************
- * Method:
- * Constructor
- */
- CHXBaseSite::CHXBaseSite(IUnknown* pContext, IUnknown* pUnkOuter, INT32 lZorder)
- : m_lRefCount(0)
- , zm_pColorAcc(NULL)
- , m_bIsChildWindow(FALSE)
- , m_pValues(0)
- , m_pUser(0)
- , m_pParentSite(0)
- , m_pVideoSurface(0)
- , m_pCCF(0)
- , m_pWatcher(0)
- , m_pContext(pContext)
- , m_pUnkOuter(pUnkOuter)
- , m_lZOrder(lZorder)
- , m_bIsVisible(TRUE)
- , m_bInDestructor(FALSE)
- , m_pRootSurface(NULL)
- , m_CallbackHandle(0)
- , m_ScrollSiteCallbackHandle(0)
- , m_pMouseInSite(0)
- , m_pScheduler(0)
- , m_bRecomputeClipScheduled(FALSE)
- , m_bForceRedrawNeeded(FALSE)
- , m_bInFullScreen(FALSE)
- , m_bSettingDisplayMode(FALSE)
- , m_bRepaintScheduled(FALSE)
- , m_bDisableForceRedraw(FALSE)
- , m_bProcessRepaint(FALSE)
- , m_bAboutToBlt(FALSE)
- , m_fSharpness(DEF_SHARPNESS)
- , m_fHue(DEF_HUE)
- , m_fSaturation(DEF_SATURATION)
- , m_fContrast(DEF_CONTRAST)
- , m_fBrightness(DEF_BRIGHTNESS)
- , m_XSliderPos(0)
- , m_YSliderPos(0)
- , m_XSliderRange(0)
- , m_YSliderRange(0)
- , m_pTopLevelSite(0)
- , m_pFocusSite(0)
- , m_pStatusText(0)
- , m_nStatusTextExpireTime(0)
- , m_pCallback(0)
- , m_pScrollSiteCallback(0)
- , m_bWasTopMost(FALSE)
- , m_bDoNotGenerateWMPPaint(FALSE)
- , m_bSetCaptureOn(FALSE)
- , m_pCaptureUser(0)
- , m_pLastUser(0)
- , m_bModeSharpness(FALSE)
- , m_nLastMoveTime(0)
- , m_bAttachWindowPending(FALSE)
- , m_bDetachWndMsgPending(FALSE)
- , m_nOldBitsPerPixel(0)
- , m_nOldHorzRes(0)
- , m_nOldVertRes(0)
- , m_Region(NULL)
- , m_RegionForMouse(NULL)
- , m_RegionWithoutChildren(NULL)
- , m_nTransitionState(0)
- , m_lBltEntryCount(0)
- , m_bRegionIsValid(FALSE)
- , m_bTransitionReversed(FALSE)
- , m_bTransitionTranIn(TRUE)
- , m_nTransitionVertRepeat(1)
- , m_nTransitionHorzRepeat(1)
- , m_nTransitionBorderWidth(0)
- , m_ulTransitionBorderColor(0)
- , m_ulTransitionFadeColor(0)
- , m_bTransitionBlendBorder(FALSE)
- , m_bTransitionCoordinated(FALSE)
- , m_bTransitionCoordTranIsParentClip(FALSE)
- , m_bWindowCreatedByCreate(FALSE)
- , m_pWindow(NULL)
- , m_bSiteNeverBlts(FALSE)
- , m_bCalledComputeClipFromTransition(FALSE)
- , m_nEventSensitivity(SENSITIVITY_NOT_SET)
- , m_nDelayFillBorders(0)
- , m_bUsingList(FALSE)
- , m_bCompositionLocked(FALSE)
- , m_bCompositionMode(FALSE)
- , m_bScheduleUpgrade(FALSE)
- , m_bVideoUnderTransition(FALSE)
- , m_bInForceRedraw(FALSE)
- , m_bSiteRefresh(FALSE)
- , m_bMoving(FALSE)
- , m_bTestWindowing(FALSE)
- , m_nWindowColor(0)
- , m_bPostageStamp(FALSE)
- , m_bBltHasBeenCalled(FALSE)
- , m_pKeyBoardFocusUser(NULL)
- , m_nTLSMutexLockCount(0)
- , m_ulTLSMutexOwningThread(0)
- , m_pDirtyRegion(NULL)
- , m_bUserWantsSubRects(FALSE)
- , m_bSiteScalingInfo(FALSE)
- , m_bScrollingSite(FALSE)
- {
- m_fpTransitionEffect = z_TransitionTable[0].m_pSubTypes[0].m_fpTranFunction;
- //If we are not being aggregated then just point the outer unkown
- //to ourselves....
- if( pUnkOuter == NULL )
- {
- m_pUnkOuter = (IUnknown*)(SiteNonDelegatingUnknown*) this;
- }
- // addref the context
- if( m_pContext )
- {
- m_pContext->AddRef();
- // get the CCF
- m_pContext->QueryInterface(IID_IHXCommonClassFactory,
- (void**)&m_pCCF);
- }
- HX_ASSERT( m_pCCF );
- if( m_pCCF )
- {
- m_pCCF->CreateInstance(CLSID_IHXValues, (void**)&m_pValues);
- HX_ASSERT(m_pValues);
- }
- if( m_pContext )
- {
- m_pContext->QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler);
- }
- HX_ASSERT(m_pScheduler);
- #if defined(THREADS_SUPPORTED) || defined(_UNIX_THREADS_SUPPORTED)
- HXMutex::MakeMutex(m_pMutex);
- HXThread::MakeThread(m_pDummyThread);
- #else
- HXMutex::MakeStubMutex(m_pMutex);
- HXThread::MakeStubThread(m_pDummyThread);
- #endif
- m_pVideoSurface = CBaseSurface::Create(m_pContext, this);
- m_pVideoSurface->AddRef();
- memset(&m_TopLevelWindow, 0, sizeof(HXxWindow));
- memset(&m_topleft, 0, sizeof(HXxPoint));
- memset(&m_position, 0, sizeof(HXxPoint));
- memset(&m_positionOrig, 0, sizeof(HXxPoint));
- memset(&m_CreateWindowPos, 0, sizeof(HXxPoint));
- memset(&m_size, 0, sizeof(HXxPoint));
- memset(&m_screenOffset, 0, sizeof(HXxPoint));
- m_pWindow = NULL;
- memset(&m_rectOldClientRect, 0, sizeof(HXxRect));
- memset(&m_rcFocusRect, 0, sizeof(m_rcFocusRect));
- m_pTopLevelSite = this;
- m_bIsChildWindow = TRUE;
- CreateColorAccess(m_pContext);
- m_pCallback = new BaseSiteCallback(this);
- IHXPreferences* pPreferences = NULL;
- IHXBuffer* pBuffer = NULL;
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))
- {
- ReadPrefBOOL(pPreferences, "TestWindowing", m_bTestWindowing);
- }
- HX_RELEASE(pPreferences);
- //Create our dirty rect region.
- m_pDirtyRegion = HXCreateRegion();
- #ifdef _CHECK_CREATE
- {
- #ifdef _WINDOWS
- FILE* f1 = fopen("c:\create.txt", "a+"); /* Flawfinder: ignore */
- #elif defined(_UNIX)
- FILE* f1 = fopen("/tmp/create.txt", "a+"); /* Flawfinder: ignore */
- #endif
- if( f1 )
- {
- fprintf(f1, "%p Constructor: %pn", GetCurrentThreadId(), this);
- fclose(f1);
- }
- }
- #endif
- }
- /************************************************************************
- * Method:
- * Destructor
- */
- CHXBaseSite::~CHXBaseSite()
- {
- HX_DELETE(m_pMutex);
- HX_DELETE(m_pDummyThread);
- m_bInDestructor = TRUE;
- //Focus
- if(m_pTopLevelSite->GetFocusSite() == this)
- {
- m_pTopLevelSite->SetFocusSite(NULL);
- }
- //Clean up the color access functions
- HX_DELETE(zm_pColorAcc);
- //Cleanup Mouse oversupport
- if (m_pTopLevelSite->m_pMouseInSite == this)
- {
- m_pTopLevelSite->m_pMouseInSite = NULL;
- }
- //Cleanup all remaining callbacks
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- HX_DELETE(m_pCallback);
- if (m_ScrollSiteCallbackHandle)
- {
- m_pScheduler->Remove(m_ScrollSiteCallbackHandle);
- m_ScrollSiteCallbackHandle = 0;
- }
- HX_DELETE(m_pScrollSiteCallback);
- //Clean up all child sites
- while(m_ChildrenMap.GetCount())
- {
- IHXSite* pSite = NULL;
- pSite = (IHXSite*) (m_ChildrenMap.Begin()).get_key();
- DestroyChild(pSite);
- }
- m_ChildrenInZOrder.RemoveAll();
- //clean up passive site watchers
- while(m_PassiveSiteWatchers.GetCount())
- {
- IHXPassiveSiteWatcher* pWatcher =
- (IHXPassiveSiteWatcher*)m_PassiveSiteWatchers.GetHead();
- HX_RELEASE(pWatcher);
- m_PassiveSiteWatchers.RemoveHead();
- }
- //Check and see if we are in the YUV Site list. If so, remove ourselves.
- LISTPOSITION pPos = zm_YUVSiteList.Find(this);
- if(pPos)
- {
- zm_YUVSiteList.RemoveAt(pPos);
- }
- _EmptyBlenderList();
- _EmptyNotifierList();
- //Remove all pending tasks.
- if (m_pTopLevelSite)
- m_pTopLevelSite->RemovePendingTasks(this);
- // release intefaces
- HX_RELEASE(m_pCCF);
- HX_RELEASE(m_pScheduler);
- HX_RELEASE(m_pContext);
- HX_RELEASE(m_pValues);
- HX_RELEASE(m_pVideoSurface);
- HX_RELEASE(m_pRootSurface);
- if(m_pTopLevelSite != this)
- HX_RELEASE(m_pTopLevelSite);
- HXDestroyRegion(m_Region);
- m_Region=NULL;
- HXDestroyRegion(m_RegionForMouse);
- m_RegionForMouse=NULL;
- HXDestroyRegion(m_RegionWithoutChildren);
- m_RegionWithoutChildren = NULL;
- HXDestroyRegion(m_pDirtyRegion);
- m_pDirtyRegion = NULL;
- }
- /************************************************************************
- * Method:
- * CHXBaseSite::SetParentSite
- */
- void
- CHXBaseSite::SetParentSite(CHXBaseSite* pParentSite)
- {
- m_pParentSite = pParentSite;
- }
- /************************************************************************
- * Method:
- * CHXBaseSite::SetTopLevelSite
- */
- void
- CHXBaseSite::SetTopLevelSite(CHXBaseSite* pTop)
- {
- if (m_pTopLevelSite != this)
- {
- HX_RELEASE(m_pTopLevelSite);
- }
- m_pTopLevelSite = pTop;
- if (m_pTopLevelSite && m_pTopLevelSite != this)
- m_pTopLevelSite->AddRef();
- }
- /************************************************************************
- * Method:
- * IUnknown::QueryInterface
- */
- STDMETHODIMP CHXBaseSite::QueryInterface(REFIID riid, void** ppvObj)
- {
- return m_pUnkOuter->QueryInterface(riid,ppvObj);
- }
- /************************************************************************
- * Method:
- * IUnknown::AddRef
- */
- STDMETHODIMP_(ULONG32) CHXBaseSite::AddRef()
- {
- return m_pUnkOuter->AddRef();
- }
- /************************************************************************
- * Method:
- * IUnknown::Release
- */
- STDMETHODIMP_(ULONG32) CHXBaseSite::Release()
- {
- return m_pUnkOuter->Release();
- }
- /************************************************************************
- * Method:
- * IUnknown::QueryInterface
- */
- STDMETHODIMP CHXBaseSite::SiteNonDelegatingQueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = (IUnknown*)(IHXSite*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSite))
- {
- AddRef();
- *ppvObj = (IHXSite*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSite2))
- {
- AddRef();
- *ppvObj = (IHXSite2*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXInterruptSafe))
- {
- AddRef();
- *ppvObj = (IHXInterruptSafe*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSiteWindowless))
- {
- AddRef();
- *ppvObj = (IHXSiteWindowless*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSiteWindowed))
- {
- AddRef();
- *ppvObj = (IHXSiteWindowed*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXStatusMessage))
- {
- AddRef();
- *ppvObj = (IHXStatusMessage*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSiteFullScreen))
- {
- AddRef();
- *ppvObj = (IHXSiteFullScreen*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXVideoControl))
- {
- AddRef();
- *ppvObj = (IHXVideoControl*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSiteTransition))
- {
- AddRef();
- *ppvObj = (IHXSiteTransition*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSiteComposition))
- {
- AddRef();
- *ppvObj = (IHXSiteComposition*)this;
- return HXR_OK;
- }
- else if (m_pValues &&
- m_pValues->QueryInterface(riid, ppvObj) == HXR_OK)
- {
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXKeyBoardFocus))
- {
- AddRef();
- *ppvObj = (IHXKeyBoardFocus*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXDrawFocus))
- {
- AddRef();
- *ppvObj = (IHXDrawFocus*)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXSubRectSite))
- {
- AddRef();
- *ppvObj = (IHXSubRectSite*)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- /************************************************************************
- * Method:
- * IUnknown::AddRef
- */
- STDMETHODIMP_(ULONG32) CHXBaseSite::SiteNonDelegatingAddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- /************************************************************************
- * Method:
- * IUnknown::Release
- */
- STDMETHODIMP_(ULONG32) CHXBaseSite::SiteNonDelegatingRelease()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /************************************************************************
- * Method:
- * IHXSite::AttachUser
- */
- STDMETHODIMP CHXBaseSite::AttachUser(IHXSiteUser* /*IN*/ pUser)
- {
- if (m_pUser) return HXR_UNEXPECTED;
- #ifndef _DEBUG_WINDOWED_SITES
- if (m_pParentSite && pUser->NeedsWindowedSites())
- {
- _NeedWindowedSite();
- }
- #endif
- m_pUser = pUser;
- m_pUser->AddRef();
- //if (!m_pTopLevelSite->m_pKeyBoardFocusUser && m_pTopLevelSite->m_pUser)
- //{
- // m_pTopLevelSite->m_pKeyBoardFocusUser = m_pTopLevelSite->m_pUser;
- // m_pTopLevelSite->m_pKeyBoardFocusUser->AddRef();
- //}
- m_pUser->AttachSite(this);
- if (m_bAttachWindowPending)
- {
- m_bAttachWindowPending = FALSE;
- m_bDetachWndMsgPending = TRUE;
- // send HX_ATTACH_WINDOW msg to the renderers
- void * lpParam1 = NULL;
- void * lpParam2 = NULL;
- HXxEvent event = {HX_ATTACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
- m_pUser->HandleEvent(&event);
- }
- /* XXXRA
- * Mac one does scale to full screen and also forces and update message
- * should not need it!
- */
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::DetachUser
- */
- STDMETHODIMP CHXBaseSite::DetachUser()
- {
- if (!m_pUser) return HXR_UNEXPECTED;
- /*
- * SetCapture
- */
- if (m_pTopLevelSite->m_pLastUser == m_pUser)
- {
- m_pTopLevelSite->m_pLastUser = NULL;
- }
- if (m_pTopLevelSite->m_pCaptureUser == m_pUser)
- {
- m_pTopLevelSite->m_pCaptureUser= NULL;
- m_bSetCaptureOn = FALSE;
- }
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- if (m_ScrollSiteCallbackHandle)
- {
- m_pScheduler->Remove(m_ScrollSiteCallbackHandle);
- m_ScrollSiteCallbackHandle = 0;
- }
- if (m_pUser && m_bDetachWndMsgPending)
- {
- // send HX_DETACH_WINDOW msg to the renderers
- void * lpParam1 = NULL;
- void * lpParam2 = NULL;
- HXxEvent event = {HX_DETACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
- m_bDetachWndMsgPending = FALSE;
- m_pUser->HandleEvent(&event);
- }
- AddRef();
- if (HXR_OK == m_pUser->DetachSite())
- {
- if (m_pTopLevelSite->m_pKeyBoardFocusUser == m_pUser)
- HX_RELEASE(m_pTopLevelSite->m_pKeyBoardFocusUser);
- HX_RELEASE(m_pUser);
- }
- Release();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::GetUser
- */
- STDMETHODIMP CHXBaseSite::GetUser(REF(IHXSiteUser*) /*OUT*/ pUser)
- {
- if (!m_pUser) return HXR_UNEXPECTED;
- pUser = m_pUser;
- pUser->AddRef();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::CreateChild
- */
- STDMETHODIMP CHXBaseSite::CreateChild(REF(IHXSite*) /*OUT*/ pChildSite)
- {
- _TLSLock();
- HRESULT result = HXR_OK;
- // Create an instance of CHXBaseSite, let it know it's in child
- // window mode.
- CHXBaseSite* pChildSiteWindowless = CHXBaseSite::CreateSite(m_pContext, NULL, m_ChildrenMap.GetCount());
- pChildSiteWindowless->AddRef();
- pChildSiteWindowless->SetParentSite(this);
- pChildSiteWindowless->SetTopLevelSite(m_pTopLevelSite);
- pChildSiteWindowless->SetRootSurface(m_pRootSurface);
- pChildSiteWindowless->SetParentWindow(&m_TopLevelWindow);
- #ifdef _WIN32
- //this is to give the windows sites a chance to hook themselves
- //into wm_move madness.
- CHXWinSite* pSiteIt = (CHXWinSite*)pChildSiteWindowless;
- pSiteIt->HookParents();
- #endif
- // Get the IHXSite interface from the child to return to the
- // outside world.
- pChildSiteWindowless->QueryInterface(IID_IHXSite, (void**)&pChildSite);
- // Store the CHXBaseSite in a list of child windows, always keep
- //a reference to it. ExSiteInfo does an AddRef in constructor
- m_ChildrenMap.SetAt(pChildSite, pChildSiteWindowless);
- pChildSite->AddRef();
- //Now add the child into or ZOrder sorted list.
- m_ChildrenInZOrder.AddTail( (void*)pChildSiteWindowless );
- //Set the child's origin
- pChildSiteWindowless->SetOrigin(&m_topleft);
- if(m_pTopLevelSite)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- HXxWindow* pWindow = GetWindow();
- //XXXgfw this focus code is disabled for the beamer release.
- //SafeSetFocus(pWindow);
- _TLSUnlock();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::DestroyChild
- */
- STDMETHODIMP CHXBaseSite::DestroyChild(IHXSite* /*IN*/ pChildSite)
- {
- // Avoid dead-lock in vidsurf2
- LockBlitters();
- FlushSurfaces();
- _TLSLock();
- //Check and see if we are in the YUV Site list. If so, remove ourselves.
- LISTPOSITION pPos = zm_YUVSiteList.Find(this);
- if(pPos)
- {
- zm_YUVSiteList.RemoveAt(pPos);
- }
- //Verify that the site is actually a child site and find its
- //position in the list in the event that it is a child.
- HX_RESULT retVal = HXR_FAIL;
- CHXBaseSite* pChildSiteWindowless=NULL;
- if (m_ChildrenMap.Lookup(pChildSite, (void*&) pChildSiteWindowless))
- {
- m_ChildrenMap.RemoveKey(pChildSite);
- pChildSiteWindowless->Destroy();
- pChildSiteWindowless->SetParentSite(NULL);
- //Remove it from our child z-order list.
- LISTPOSITION pos,posNext = m_ChildrenInZOrder.GetHeadPosition();
- while (posNext)
- {
- pos = posNext;
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(posNext);
- if( pSite == pChildSiteWindowless )
- {
- m_ChildrenInZOrder.RemoveAt(pos);
- while (posNext)
- {
- pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(posNext);
- INT32 zOrder;
- pSite->GetZOrder(zOrder);
- pSite->SetInternalZOrder(zOrder - 1);
- }
- break;
- }
- }
- HX_RELEASE(pChildSite);
- HX_RELEASE(pChildSiteWindowless);
- retVal = HXR_OK;
- }
- HX_ASSERT( m_ChildrenInZOrder.GetCount() == m_ChildrenMap.GetCount() );
- if (m_pTopLevelSite==this)
- {
- m_pTopLevelSite->RecomputeClip();
- }
- else
- {
- if (m_pTopLevelSite)
- {
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- }
- }
- _TLSUnlock();
- UnlockBlitters();
- return retVal;
- }
- /************************************************************************
- * Method:
- * IHXSite::AttachWatcher
- */
- STDMETHODIMP CHXBaseSite::AttachWatcher(IHXSiteWatcher* /*IN*/ pWatcher)
- {
- if (m_pWatcher) return HXR_UNEXPECTED;
- m_pWatcher = pWatcher;
- if (m_pWatcher)
- {
- m_pWatcher->AddRef();
- m_pWatcher->AttachSite(this);
- }
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::DetachWatcher
- */
- STDMETHODIMP CHXBaseSite::DetachWatcher()
- {
- if (!m_pWatcher) return HXR_UNEXPECTED;
- m_pWatcher->DetachSite();
- HX_RELEASE(m_pWatcher);
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::SetSize
- */
- STDMETHODIMP CHXBaseSite::SetSize(HXxSize size)
- {
- HX_RESULT ret = HXR_OK;
- _TLSLock();
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- ret = _SafeSetSize(size);
- _TLSUnlock();
- return ret;
- }
- PendingTask* pPendingTask = new PendingTask( ONSETSIZE,
- this,
- (void*)size.cx,
- (void*)size.cy,
- (void*)NULL,
- (void*)NULL,
- (void*)NULL,
- (void*)NULL
- );
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- _TLSUnlock();
- return TRUE;
- }
- /************************************************************************
- * Method:
- * IHXSite::SetSize
- */
- HX_RESULT CHXBaseSite::_SafeSetSize(HXxSize size)
- {
- _TLSLock();
- HRESULT hres = HXR_OK;
- CHXSimpleList::Iterator i;
- size.cx = size.cx<0?0:size.cx;
- size.cy = size.cy<0?0:size.cy;
- //Fix up sizes for full screen. Some renderes, MPEG, will get very
- //late setsize calls. If we get a setsize call after we have gone
- //to fullscreen, we need to readjust our full screen window.
- if( IsFullScreen() && this==m_pTopLevelSite )
- {
- double stretchRatio = 0;
- double xRatio = 0;
- double yRatio = 0;
- UINT16 newBitsPerPixel = 0;
- UINT16 nHozRes = 0;
- UINT16 nVertRes = 0;
- _GetDeviceCaps(NULL, newBitsPerPixel, nHozRes, nVertRes);
- if(m_bPostageStamp)
- {
- if( m_windowSize.cx*2 <= nHozRes &&
- m_windowSize.cy*2 <= nVertRes)
- {
- xRatio = yRatio = 2.0;
- }
- else
- {
- xRatio = yRatio = 1.0;
- }
- }
- else
- {
- xRatio = (double)nHozRes / (double)size.cx ;
- yRatio = (double)nVertRes / (double)size.cy ;
- }
- if (xRatio<yRatio)
- stretchRatio = xRatio;
- else
- stretchRatio = yRatio;
- if( m_bPostageStamp )
- {
- size.cx = (int) ((double) m_windowSize.cx * stretchRatio + 0.5);
- size.cy = (int) ((double) m_windowSize.cy * stretchRatio + 0.5);
- }
- else
- {
- size.cx = (int) ((double) size.cx * stretchRatio + 0.5);
- size.cy = (int) ((double) size.cy * stretchRatio + 0.5);
- }
- #if !defined(_UNIX) || defined(_MAC_UNIX)
- m_screenOffset.x = (nHozRes - size.cx)/2;
- m_screenOffset.y = (nVertRes - size.cy)/2;
- #endif
- }
- //before we do anything, we give the SiteWatcher a chance to
- //influence this operation.
- if (m_pWatcher)
- {
- hres = m_pWatcher->ChangingSize(m_size, size);
- }
- //Get rid of our last alpha blend region as it is the wrong size
- //now....
- HX_FREE( m_pVideoSurface->m_pucLastImage );
- if (HXR_OK == hres )
- {
- //We must invalidate our rect.....
- HXxRect pTmp = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp, TRUE );
- m_size = size;
- // iterate child site list
- for(i=m_PassiveSiteWatchers.Begin(); i!= m_PassiveSiteWatchers.End(); ++i)
- {
- ((IHXPassiveSiteWatcher*) *i)->SizeChanged(&m_size);
- }
- if( m_pWindow && m_pWindow->window &&
- (m_pTopLevelSite!=this || m_bWindowCreatedByCreate ) )
- {
- _SetSize(size);
- }
- //Handle scrolling..
- if( m_pValues )
- {
- ULONG32 bScroll = FALSE;
- m_pValues->GetPropertyULONG32("ScrollingSite", bScroll);
- if (bScroll)
- {
- SetXSliderRange(size.cx);
- SetYSliderRange(size.cy);
- m_bScrollingSite = TRUE;
- }
- }
- //We must invalidate our rect after the resize also..
- HXxRect pTmp2 = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp2, TRUE );
- }
- if (this == m_pTopLevelSite && m_pStatusText)
- {
- m_pStatusText->ParentChangedSize();
- }
- if (m_pTopLevelSite==this)
- {
- m_pTopLevelSite->RecomputeClip();
- }
- else
- {
- if(m_pTopLevelSite)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- }
- if( this == m_pTopLevelSite && m_pStatusText )
- {
- m_pStatusText->ParentChangedSize();
- }
- //XXXgfw Don't know where to really do this work. It must be after
- //the site is created and smil can set these values but before we
- //handle events.
- //Get sensitivity setting for mouse clicks. Only do this
- //once per site on the first event. If 'sensitivity'
- //isn't set by then too bad.
- if( m_nEventSensitivity==SENSITIVITY_NOT_SET )
- {
- //opaque is the default set by the W3C working group.
- m_nEventSensitivity = SENSITIVITY_OPAQUE;
- if( m_pValues )
- {
- IHXBuffer* pBuf = NULL;
- m_pValues->GetPropertyCString( "sensitivity", pBuf );
- if( pBuf )
- {
- const char* pszBuff = (const char*)pBuf->GetBuffer();
- if( pszBuff)
- {
- //m_nEventSensitivity is in alpha values [0,255]
- if( strcmp( pszBuff, "transparent" )==0 )
- {
- m_nEventSensitivity = SENSITIVITY_TRANSPARENT;
- }
- else if( strcmp( pszBuff, "opaque" )==0 )
- {
- m_nEventSensitivity = SENSITIVITY_OPAQUE;
- }
- else
- {
- double sen = ::atof( pszBuff );
- if( sen < 0 )
- sen = 0;
- if( sen > 100 )
- sen = 100;
- //Scale percentages to [0,255]
- m_nEventSensitivity = 255-(int)(sen*255.0/100.0+0.5);
- }
- }
- HX_RELEASE(pBuf);
- }
- }
- }
- _TLSUnlock();
- return hres;
- }
- /************************************************************************
- * Method:
- * IHXSite::SetPosition
- */
- STDMETHODIMP CHXBaseSite::SetPosition(HXxPoint position)
- {
- HX_RESULT ret = HXR_OK;
- _TLSLock();
- if (_AtSystemTime())
- {
- m_pTopLevelSite->ExecutePendingTasks();
- ret = _SafeSetPosition(position);
- _TLSUnlock();
- return ret;
- }
- PendingTask* pPendingTask = new PendingTask(ONSETPOSITION,
- this, (void*) position.x,
- (void*) position.y,
- (void*) NULL,
- (void*) NULL,
- (void*) NULL,
- (void*) NULL);
- m_pTopLevelSite->m_PendingTaskList.AddTail((void*) pPendingTask);
- m_pTopLevelSite->ScheduleCallback(MOUSE, 0);
- _TLSUnlock();
- return TRUE;
- }
- HX_RESULT CHXBaseSite::_SafeSetPosition(HXxPoint position)
- {
- _TLSLock();
- HRESULT hres = HXR_OK;
- CHXSimpleList::Iterator i;
- CHXMapPtrToPtr::Iterator j;
- //Before we do anything, we give the SiteWatcher a chance to
- //influence this operation.
- if (m_pWatcher)
- {
- hres = m_pWatcher->ChangingPosition(m_position, position);
- }
- #if defined(_MACINTOSH) || defined(_MAC_UNIX)
- if (this == m_pTopLevelSite)
- {
- // xxxbobclark
- // For the Mac, the top-level site is moved by adjusting
- // its HXxWindow's x and y values. If we go ahead and
- // change m_position, it can screw up situations like the
- // embedded player where it DOES call SetPosition on the
- // top-level site to move it in its window.
- _TLSUnlock();
- return HXR_OK;
- }
- #endif
- if (HXR_OK == hres)
- {
- //Damage The old position....
- HXxRect pTmp = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp, TRUE );
- if(!m_bWindowCreatedByCreate )
- {
- // if we've created the window we don't want to move the site
- // just the window
- m_position = position;
- m_positionOrig = m_position;
- }
- //fixup our top left
- ResetOrigin();
- //iterate passive site watcher list
- for(i=m_PassiveSiteWatchers.Begin(); i!= m_PassiveSiteWatchers.End(); ++i)
- {
- ((IHXPassiveSiteWatcher*) *i)->PositionChanged(&m_position);
- }
- if( m_pWindow &&
- m_pWindow->window &&
- (m_pTopLevelSite!=this || m_bWindowCreatedByCreate )
- )
- {
- m_CreateWindowPos = position;
- _SetPosition(position);
- }
- }
- //We must first remove our old dirty region because we moved and
- //we could get negative offsets...
- HXxRect pTmp2 = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp2, TRUE );
- if (m_pTopLevelSite==this)
- {
- m_pTopLevelSite->RecomputeClip();
- }
- else
- {
- if (m_pTopLevelSite)
- {
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- }
- }
- m_pVideoSurface->UpdateDestRect();
- _TLSUnlock();
- return hres;
- }
- /************************************************************************
- * Method:
- * IHXSite::GetSize
- */
- STDMETHODIMP CHXBaseSite::GetSize(REF(HXxSize) size)
- {
- size = m_size;
- //XXXgfw what???????? why change it after assignment???
- // m_pValues->GetPropertyULONG32("MediaSizeX", (ULONG32&) ttt.cx);
- // m_pValues->GetPropertyULONG32("MediaSizeY", (ULONG32&) ttt.cy);
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite::GetPosition
- */
- STDMETHODIMP CHXBaseSite::GetPosition(REF(HXxPoint) position)
- {
- position = m_position;
- return HXR_OK;
- }
- //
- // CHXBaseSite::DamageRect()
- //
- // All incoming coordinates are SITE relative...
- //
- STDMETHODIMP CHXBaseSite::DamageRect(HXxRect rect)
- {
- #if defined(_MACINTOSH) || defined(_MAC_UNIX)
- _TLSLock();
- #endif
- HXRECTANGLE rectTmp;
- HXxPoint* pOrigin = GetOrigin();
- //Crop
- if( rect.left < 0 )
- rect.left = 0;
- if( rect.top < 0 )
- rect.top = 0;
- if( rect.right > m_size.cx )
- rect.right = m_size.cx;
- if( rect.bottom > m_size.cy )
- rect.bottom = m_size.cy;
- //Translate rect to window coordinates.
- rect.left += pOrigin->x;
- rect.right += pOrigin->x;
- rect.top += pOrigin->y;
- rect.bottom += pOrigin->y;
- rectTmp.x = (short)rect.left;
- rectTmp.y = (short)rect.top;
- rectTmp.width = (short)(rect.right-rect.left);
- rectTmp.height = (short)(rect.bottom-rect.top);
- HXUnionRectWithRegion( &rectTmp, m_pDirtyRegion, m_pDirtyRegion);
- //Do OS specific stuff here.
- _DamageRect(rect);
- #if defined(_MACINTOSH) || defined(_MAC_UNIX)
- _TLSUnlock();
- #endif
- return HXR_OK;
- }
- //This is the same as DamageRect except that the coordinates are in
- //Window relative coords and we don't do the OS specific stuff (like
- //no invalidateRect.
- void CHXBaseSite::DamageRectWindowRel(HXxRect rect)
- {
- HXxPoint* pPosition = GetOrigin();
- //Crop
- HXREGION* pReg = HXCreateRectRegion( rect.left,
- rect.top,
- rect.right-rect.left,
- rect.bottom-rect.top
- );
- //Find out what part intersects us.
- HXREGION* pTemp = Transition( pPosition->x, pPosition->y,
- pPosition->x + m_size.cx,
- pPosition->y + m_size.cy
- );
- HXIntersectRegion( pTemp, pReg, pReg );
- if( !HXEmptyRegion(pReg) )
- {
- HXUnionRegion( pReg, m_pDirtyRegion, m_pDirtyRegion);
- // We must call _DamageRect to give windows a chance to see if
- // we are occluded by a drop down menu. If we are, then we
- // have to invalidate the OS rect so Windows does not do a
- // save under.
- HXxRect rectTmp =
- {pTemp->extents.x1, pTemp->extents.y1, pTemp->extents.x2, pTemp->extents.y2};
- _DamageRect(rectTmp);
- }
- HXDestroyRegion( pReg );
- HXDestroyRegion( pTemp );
- }
- /************************************************************************
- * Method:
- * IHXSite::DamageRegion
- */
- STDMETHODIMP CHXBaseSite::DamageRegion(HXxRegion region)
- {
- HX_ASSERT( "Depricated method, do not use. Use the new damage region." == NULL );
- //This was never used and it was not defined what a HXxRegion was.
- //So, we just have to invalidate the whole site.
- //Users should use the new damage region that takes the cross platform
- //region that actually works.
- HXxRect rect;
- HXREGION* reg = (HXREGION*)region;
- rect.left = 0;
- rect.top = 0;
- rect.right = m_size.cx;
- rect.bottom = m_size.cy;
- return DamageRect( rect );
- }
- // Method:
- // IHXSite::ForceRedraw
- STDMETHODIMP CHXBaseSite::ForceRedraw()
- {
- HXxEvent event;
- HXxWindow* hxxWin = GetWindow();
- if( IsCompositionLocked() && m_pVideoSurface->m_nBltMode!=HX_OVERLAY_BLT )
- {
- return HXR_OK;
- }
- // make sure we have a visible window event though this should be
- // computed from the list of rects.
- if (!_ShouldEnterForceRedraw())
- {
- return HXR_OK;
- }
- _TLSLock();
- AddRef();
- memset(&m_UpdateBltStatsRect, 0, sizeof(m_UpdateBltStatsRect));
- if(m_pTopLevelSite->m_bDisableForceRedraw)
- {
- m_pTopLevelSite->m_bDisableForceRedraw = TRUE;
- }
- else
- {
- BOOL bDoIt =
- ((m_bIsVisible && m_pUser && m_Region && !HXEmptyRegion(m_Region)) ||
- (m_AlphaBlendNotifiers.GetCount()!=0 || m_AlphaBlendSites.GetCount()!=0));
- if( bDoIt )
- {
- AboutToBlt();
- event.handled = 0;
- if( m_bUserWantsSubRects )
- {
- if( !HXEmptyRegion(m_pDirtyRegion) )
- {
- HXxExposeInfo exposeInfo;
- HXxBoxRegion dirtRegion;
- //Construct a dirty rect that is relative to the
- //site's topleft corner.
- HXREGION* pTmpReg = HXCreateRegion();
- HXUnionRegion( pTmpReg, m_pDirtyRegion, pTmpReg );
- HXOffsetRegion( pTmpReg, -m_topleft.x, -m_topleft.y );
- // adjust for scrolling; essentially turning off
- // subrect blitting while scrolling
- if (GetXSliderPos() || GetYSliderPos())
- {
- HXREGION* pMe = HXCreateRectRegion( 0,
- 0,
- m_size.cx,
- m_size.cy
- );
- HXUnionRegion(pMe, pTmpReg, pTmpReg);
- HXDestroyRegion(pMe);
- }
- //Set up the cross platform region.
- dirtRegion.numRects = pTmpReg->numRects;
- dirtRegion.rects = pTmpReg->rects;
- exposeInfo.extents.left = pTmpReg->extents.x1;
- exposeInfo.extents.right = pTmpReg->extents.x2;
- exposeInfo.extents.top = pTmpReg->extents.y1;
- exposeInfo.extents.bottom = pTmpReg->extents.y2;
- exposeInfo.pRegion = & dirtRegion;
- exposeInfo.pWindow = GetWindow();
- exposeInfo.pParam1 = NULL;
- exposeInfo.pParam2 = NULL;
- event.event = HX_SURFACE_UPDATE2;
- event.window = hxxWin?hxxWin->window : NULL;
- event.param1 = m_pVideoSurface;
- event.param2 = &exposeInfo;
- event.result = 0;
- event.handled = 0;
- // Clear the dirty region
- HXZeroOutRegion( m_pDirtyRegion );
- if( m_pUser )
- {
- if (!m_bDoNotGenerateWMPPaint)
- {
- m_bInForceRedraw = m_bSiteRefresh;
- m_pUser->HandleEvent(&event);
- m_bInForceRedraw = FALSE;
- }
- }
- HXDestroyRegion( pTmpReg );
- }
- }
- else
- {
- //XXXgfw OK, this is screwed up. Windows renders want a rectangle in
- //XXXgfw param2 while the unix renderers want a Window there. To clean this
- //XXXgfw up we need to clean up and unify the renderers.....
- #if defined(_UNIX) && !defined(_MAC_UNIX)
- event.event = HX_SURFACE_UPDATE;
- event.window = hxxWin?hxxWin->window : NULL;
- event.param1 = m_pVideoSurface;
- event.param2 = GetWindow();
- event.result = 0;
- event.handled = 0;
- #else
- event.event = HX_SURFACE_UPDATE;
- event.window = m_pWindow? m_pWindow->window : NULL;
- event.param1 = m_pVideoSurface;
- event.param2 = NULL;
- event.result = 0;
- event.handled = 0;
- #endif
- // Clear the dirty region
- HXZeroOutRegion( m_pDirtyRegion );
- if( m_pUser )
- {
- if (!m_bDoNotGenerateWMPPaint)
- {
- // Distinguishes between a new frame and a repaint of a prior frame
- m_bInForceRedraw = m_bSiteRefresh;
- m_pUser->HandleEvent(&event);
- m_bInForceRedraw = FALSE;
- }
- }
- }
- // If blt has never been called, then blt black to the
- // background. Do not do this if we are a windowed
- // renderer.
- if (!event.handled && !m_bBltHasBeenCalled
- && !m_pWindow && m_pVideoSurface->m_nBltMode!=HX_OVERLAY_BLT )
- {
- // Get the current size of the site The source rect is
- // just a 1 by 1 black pixel that gets stretched to
- // fit the destination
- HXxRect rDestRect = { 0, 0, m_size.cx, m_size.cy};
- HXxRect rSrcRect = { 0, 0, 1, 1};
- HXBitmapInfoHeader bih;
- memset(&bih, 0, sizeof(HXBitmapInfoHeader));
- bih.biSize = sizeof(HXBitmapInfoHeader);
- bih.biWidth = 1;
- bih.biHeight = 1;
- bih.biPlanes = 1;
- bih.biBitCount = 32;
- bih.biCompression = HX_RGB;
- UCHAR pBuffer[4] = { 0,0,0,0 };
- m_pVideoSurface->Blt(pBuffer,
- &bih,
- rDestRect,
- rSrcRect);
- m_bBltHasBeenCalled = FALSE;
- }
- //Stupid Windowed renderers!
- if(!m_bDoNotGenerateWMPPaint &&
- !event.handled &&
- m_pWindow &&
- m_pWindow->window )
- {
- _SendOSUpdateMessage();
- }
- }
- m_pVideoSurface->UpdateBltStats(&m_UpdateBltStatsRect);
- }
- _TLSUnlock();
- _ExitForceRedraw();
- Release();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite2::UpdateSiteWindow
- *
- * Not used on Windows platform
- */
- STDMETHODIMP CHXBaseSite::UpdateSiteWindow
- (
- HXxWindow* /*IN*/ pWindow
- )
- {
- return HXR_NOTIMPL;
- }
- /************************************************************************
- * Method:
- * IHXSite2::ShowSite
- */
- STDMETHODIMP CHXBaseSite::ShowSite(BOOL bShow)
- {
- _TLSLock();
- if(m_bIsVisible != bShow)
- {
- m_bIsVisible = bShow;
- //Invalidate the rect....
- HXxRect pTmp = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp, TRUE );
- if( this == m_pTopLevelSite )
- {
- RecomputeClip();
- }
- else
- {
- if(m_pTopLevelSite)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- }
- }
- _ShowSite(bShow);
- SizeSliders();
- _TLSUnlock();
- return HXR_OK;
- }
- void CHXBaseSite::_ForceRedrawAll()
- {
- if( (IsSiteVisible() && m_Region && !HXEmptyRegion(m_Region)) ||
- (m_AlphaBlendSites.GetCount()||m_AlphaBlendNotifiers.GetCount() )
- )
- {
- // HXREGION* pReg = NULL;
- // if( pDirtyRect)
- // {
- // pReg = HXCreateRectRegion( pDirtyRect->left,
- // pDirtyRect->top,
- // pDirtyRect->right-pDirtyRect->left,
- // pDirtyRect->bottom-pDirtyRect->top );
- // HXIntersectRegion( m_Region, pReg, pReg );
- // HXUnionRegion( m_pDirtyRegion, pReg, m_pDirtyRegion );
- // HXDestroyRegion( pReg );
- // }
- // else
- // {
- // HXUnionRegion( m_pDirtyRegion, m_Region, m_pDirtyRegion );
- // }
- InternalForceRedraw();
- }
- //Now do all the children in z-order
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->_ForceRedrawAll();
- }
- }
- BOOL CHXBaseSite::_CheckForVisibleChild()
- {
- BOOL retVal = FALSE;
- if( m_bIsVisible && !m_bSiteNeverBlts )
- {
- retVal = TRUE;
- }
- else
- {
- LISTPOSITION pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- if( pSite->_CheckForVisibleChild() )
- {
- retVal = TRUE;
- break;
- }
- }
- }
- return retVal;
- }
- /************************************************************************
- * Method:
- * IHXSite2::IsSiteVisible
- */
- STDMETHODIMP_(BOOL) CHXBaseSite::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;
- }
- /************************************************************************
- * Method:
- * IHXSite2::UpdateZOrder
- * This method updates the Z order of its child sites since one of its
- * child sites' Z order is being updated.
- */
- void
- CHXBaseSite::UpdateZOrder( CHXBaseSite* pUpdatedChildSite, INT32 lOldZOrder, 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;
- CHXBaseSite* pSite = (CHXBaseSite*)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++);
- }
- HX_ASSERT((newZOrder == m_ChildrenInZOrder.GetCount()) &&
- (m_ChildrenInZOrder.GetCount() == m_ChildrenMap.GetCount()));
- }
- /************************************************************************
- * Method:
- * IHXSite2::SetZOrder
- */
- STDMETHODIMP CHXBaseSite::SetZOrder(INT32 lZOrder)
- {
- if(!m_pParentSite)
- {
- return HXR_UNEXPECTED;
- }
- _TLSLock();
- 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, m_lZOrder, lZOrder);
- //Invalidate the rect....
- if( m_pTopLevelSite )
- {
- HXxRect pTmp = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &pTmp, TRUE );
- }
- }
- if( this == m_pTopLevelSite)
- {
- RecomputeClip();
- }
- else
- {
- if (m_pTopLevelSite)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- }
- _TLSUnlock();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite2::GetZOrder
- */
- STDMETHODIMP CHXBaseSite::GetZOrder(REF(INT32) lZOrder)
- {
- lZOrder = m_lZOrder;
- HX_ASSERT(m_lZOrder> -1 && m_lZOrder< 2000);
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite2::MoveSiteToTop
- */
- STDMETHODIMP CHXBaseSite::MoveSiteToTop()
- {
- SetZOrder(-1); //-1 means the top.
- return HXR_OK;
- }
- //IHXSubRectSite::GetSubRectVideoSurface()
- STDMETHODIMP CHXBaseSite::GetSubRectVideoSurface( REF(IHXSubRectVideoSurface*) pSurface )
- {
- HX_RESULT res = HXR_FAIL;
- if (m_pVideoSurface)
- {
- res = m_pVideoSurface->QueryInterface(IID_IHXSubRectVideoSurface,
- (void**)&pSurface);
- }
- return res;
- }
- /************************************************************************
- * Method:
- * IHXSite2::GetVideoSurface
- */
- STDMETHODIMP CHXBaseSite::GetVideoSurface(REF(IHXVideoSurface*) pSurface)
- {
- HX_RESULT res = HXR_FAIL;
- if (m_pVideoSurface)
- {
- res = m_pVideoSurface->QueryInterface(IID_IHXVideoSurface,
- (void**)&pSurface);
- }
- return res;
- }
- /************************************************************************
- * Method:
- * IHXSite2::GetNumberOfChildSites
- */
- STDMETHODIMP_(UINT32) CHXBaseSite::GetNumberOfChildSites()
- {
- HX_ASSERT( m_ChildrenInZOrder.GetCount() == m_ChildrenMap.GetCount() );
- return (UINT32)m_ChildrenMap.GetCount();
- }
- /************************************************************************
- * Method:
- * IHXSite2::AddPassiveSiteWatcher
- */
- STDMETHODIMP CHXBaseSite::AddPassiveSiteWatcher(IHXPassiveSiteWatcher* pWatcher)
- {
- pWatcher->AddRef();
- m_PassiveSiteWatchers.AddTail(pWatcher);
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSite2::RemovePassiveSiteWatcher
- */
- STDMETHODIMP CHXBaseSite::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;
- }
- #if defined(_DEBUG) && !defined(_MACINTOSH) && !defined(_MAC_UNIX)
- void _PrintKeyboardEventInfo(HXxEvent* pEvent )
- {
- char szBuff[256]; /* Flawfinder: ignore */
- if( pEvent->event == HX_CHAR )
- _DumpString( "HX_CHAR " );
- if( pEvent->event == HX_KEY_DOWN )
- _DumpString( "HX_KEY_DOWN " );
- if( pEvent->event == HX_KEY_UP )
- _DumpString( "HX_KEY_UP " );
- if( ((UINT32)pEvent->param2)&HX_VIRTUAL_KEY_MASK )
- {
- _DumpString( " key: " );
- switch((UINT32)pEvent->param1 )
- {
- case HX_VK_LBUTTON :
- _DumpString( "HX_VK_LBUTTON ");
- break;
- case HX_VK_RBUTTON :
- _DumpString( "HX_VK_RBUTTON ");
- break;
- case HX_VK_CANCEL :
- _DumpString( "HX_VK_CANCEL ");
- break;
- case HX_VK_MBUTTON :
- _DumpString( "HX_VK_MBUTTON ");
- break;
- case HX_VK_BACK :
- _DumpString( "HX_VK_BACK ");
- break;
- case HX_VK_TAB :
- _DumpString( "HX_VK_TAB ");
- break;
- case HX_VK_CLEAR :
- _DumpString( "HX_VK_CLEAR ");
- break;
- case HX_VK_RETURN :
- _DumpString( "HX_VK_RETURN ");
- break;
- case HX_VK_SHIFT :
- _DumpString( "HX_VK_SHIFT ");
- break;
- case HX_VK_CONTROL :
- _DumpString( "HX_VK_CONTROL ");
- break;
- case HX_VK_MENU :
- _DumpString( "HX_VK_MENU ");
- break;
- case HX_VK_PAUSE :
- _DumpString( "HX_VK_PAUSE ");
- break;
- case HX_VK_CAPITAL :
- _DumpString( "HX_VK_CAPITAL ");
- break;
- case HX_VK_ESCAPE :
- _DumpString( "HX_VK_ESCAPE ");
- break;
- case HX_VK_SPACE :
- _DumpString( "HX_VK_SPACE ");
- break;
- case HX_VK_PRIOR :
- _DumpString( "HX_VK_PRIOR ");
- break;
- case HX_VK_NEXT :
- _DumpString( "HX_VK_NEXT ");
- break;
- case HX_VK_END :
- _DumpString( "HX_VK_END ");
- break;
- case HX_VK_HOME :
- _DumpString( "HX_VK_HOME ");
- break;
- case HX_VK_LEFT :
- _DumpString( "HX_VK_LEFT ");
- break;
- case HX_VK_UP :
- _DumpString( "HX_VK_UP ");
- break;
- case HX_VK_RIGHT :
- _DumpString( "HX_VK_RIGHT ");
- break;
- case HX_VK_DOWN :
- _DumpString( "HX_VK_DOWN ");
- break;
- case HX_VK_SELECT :
- _DumpString( "HX_VK_SELECT ");
- break;
- case HX_VK_EXECUTE :
- _DumpString( "HX_VK_EXECUTE ");
- break;
- case HX_VK_SNAPSHOT :
- _DumpString( "HX_VK_SNAPSHOT ");
- break;
- case HX_VK_INSERT :
- _DumpString( "HX_VK_INSERT ");
- break;
- case HX_VK_DELETE :
- _DumpString( "HX_VK_DELETE ");
- break;
- case HX_VK_HELP :
- _DumpString( "HX_VK_HELP ");
- break;
- case HX_VK_LWIN :
- _DumpString( "HX_VK_LWIN ");
- break;
- case HX_VK_RWIN :
- _DumpString( "HX_VK_RWIN ");
- break;
- case HX_VK_APPS :
- _DumpString( "HX_VK_APPS ");
- break;
- case HX_VK_NUMPAD0 :
- _DumpString( "HX_VK_NUMPAD0 ");
- break;
- case HX_VK_NUMPAD1 :
- _DumpString( "HX_VK_NUMPAD1 ");
- break;
- case HX_VK_NUMPAD2 :
- _DumpString( "HX_VK_NUMPAD2 ");
- break;
- case HX_VK_NUMPAD3 :
- _DumpString( "HX_VK_NUMPAD3 ");
- break;
- case HX_VK_NUMPAD4 :
- _DumpString( "HX_VK_NUMPAD4 ");
- break;
- case HX_VK_NUMPAD5 :
- _DumpString( "HX_VK_NUMPAD5 ");
- break;
- case HX_VK_NUMPAD6 :
- _DumpString( "HX_VK_NUMPAD6 ");
- break;
- case HX_VK_NUMPAD7 :
- _DumpString( "HX_VK_NUMPAD7 ");
- break;
- case HX_VK_NUMPAD8 :
- _DumpString( "HX_VK_NUMPAD8 ");
- break;
- case HX_VK_NUMPAD9 :
- _DumpString( "HX_VK_NUMPAD9 ");
- break;
- case HX_VK_MULTIPLY :
- _DumpString( "HX_VK_MULTIPLY ");
- break;
- case HX_VK_ADD :
- _DumpString( "HX_VK_ADD ");
- break;
- case HX_VK_SEPARATOR :
- _DumpString( "HX_VK_SEPARATOR ");
- break;
- case HX_VK_SUBTRACT :
- _DumpString( "HX_VK_SUBTRACT ");
- break;
- case HX_VK_DECIMAL :
- _DumpString( "HX_VK_DECIMAL ");
- break;
- case HX_VK_DIVIDE :
- _DumpString( "HX_VK_DIVIDE ");
- break;
- case HX_VK_F1 :
- _DumpString( "HX_VK_F1 ");
- break;
- case HX_VK_F2 :
- _DumpString( "HX_VK_F2 ");
- break;
- case HX_VK_F3 :
- _DumpString( "HX_VK_F3 ");
- break;
- case HX_VK_F4 :
- _DumpString( "HX_VK_F4 ");
- break;
- case HX_VK_F5 :
- _DumpString( "HX_VK_F5 ");
- break;
- case HX_VK_F6 :
- _DumpString( "HX_VK_F6 ");
- break;
- case HX_VK_F7 :
- _DumpString( "HX_VK_F7 ");
- break;
- case HX_VK_F8 :
- _DumpString( "HX_VK_F8 ");
- break;
- case HX_VK_F9 :
- _DumpString( "HX_VK_F9 ");
- break;
- case HX_VK_F10 :
- _DumpString( "HX_VK_F10 ");
- break;
- case HX_VK_F11 :
- _DumpString( "HX_VK_F11 ");
- break;
- case HX_VK_F12 :
- _DumpString( "HX_VK_F12 ");
- break;
- case HX_VK_F13 :
- _DumpString( "HX_VK_F13 ");
- break;
- case HX_VK_F14 :
- _DumpString( "HX_VK_F14 ");
- break;
- case HX_VK_F15 :
- _DumpString( "HX_VK_F15 ");
- break;
- case HX_VK_F16 :
- _DumpString( "HX_VK_F16 ");
- break;
- case HX_VK_F17 :
- _DumpString( "HX_VK_F17 ");
- break;
- case HX_VK_F18 :
- _DumpString( "HX_VK_F18 ");
- break;
- case HX_VK_F19 :
- _DumpString( "HX_VK_F19 ");
- break;
- case HX_VK_F20 :
- _DumpString( "HX_VK_F20 ");
- break;
- case HX_VK_F21 :
- _DumpString( "HX_VK_F21 ");
- break;
- case HX_VK_F22 :
- _DumpString( "HX_VK_F22 ");
- break;
- case HX_VK_F23 :
- _DumpString( "HX_VK_F23 ");
- break;
- case HX_VK_F24 :
- _DumpString( "HX_VK_F24 ");
- break;
- case HX_VK_NUMLOCK :
- _DumpString( "HX_VK_NUMLOCK ");
- break;
- case HX_VK_SCROLL :
- _DumpString( "HX_VK_SCROLL ");
- break;
- default:
- _DumpString( " !! UNKOWN VIRTUAL !! " );
- }
- }
- else
- {
- sprintf( szBuff, " key: "%c" (%d) ", pEvent->param1, pEvent->param1 ); /* Flawfinder: ignore */
- _DumpString( szBuff );
- }
- sprintf( szBuff, "scancode: %d flags: ", ((UINT32)pEvent->param2)&0x000000ff ); /* Flawfinder: ignore */
- _DumpString( szBuff );
- if( (UINT32)pEvent->param2 & HX_VIRTUAL_KEY_MASK )
- _DumpString( "VirtualKey " );
- if( (UINT32)pEvent->param2 & HX_EXTENDED_KEY_MASK )
- _DumpString( "ExtendedKey " );
- if( (UINT32)pEvent->param2 & HX_SHIFT_MASK )
- _DumpString( "ShiftKey " );
- if( (UINT32)pEvent->param2 & HX_CTRL_MASK )
- _DumpString( "ControlKey " );
- if( (UINT32)pEvent->param2 & HX_ALT_MASK )
- _DumpString( "AltKey " );
- if( (UINT32)pEvent->param2 & HX_CAPS_LOCK_MASK )
- _DumpString( "CapsLock " );
- if( (UINT32)pEvent->param2 & HX_NUM_LOCK_MASK )
- _DumpString( "NumLock " );
- if( (UINT32)pEvent->param2 & HX_SCROLL_LOCK_MASK )
- _DumpString( "ScrollLock " );
- _DumpString( "n" );
- }
- #endif
- CHXBaseSite* CHXBaseSite::_GetSiteFromPixel(HXxPoint& point)
- {
- CHXBaseSite* pRet = this;
- if( ( m_bSiteNeverBlts ||
- m_nEventSensitivity == SENSITIVITY_TRANSPARENT ||
- ( m_pVideoSurface &&
- m_pVideoSurface->IsPixelTransparent(point, m_nEventSensitivity)
- )
- ) &&
- !(m_nEventSensitivity == SENSITIVITY_OPAQUE )
- )
- {
- //Now go through all the alphablend regions and see who this
- //pixel belongs to.
- CHXMapPtrToPtr::Iterator i = m_AlphaBlendSites.Begin();
- for( ; i!=m_AlphaBlendSites.End() ; ++i)
- {
- CHXBaseSite* pSite = (CHXBaseSite*) i.get_key();
- HXREGION* pRegion = (HXREGION*)*i;
- if( HXPointInRegion( pRegion, point.x, point.y ) )
- {
- pRet=pSite->_GetSiteFromPixel(point);
- break;
- }
- }
- //If we are transparent here we MUST be blending with someone.
- HX_ASSERT( this!=pRet);
- }
- return pRet;
- }
- /************************************************************************
- * Method:
- * IHXSiteWindowless::EventOccurred
- */
- STDMETHODIMP CHXBaseSite::EventOccurred(HXxEvent* /*IN*/ pEvent)
- {
- HX_RESULT hr = HXR_OK;
- CHXMapPtrToPtr::Iterator i;
- HXxEvent event;
- if( NULL == pEvent )
- {
- return HXR_OK;
- }
- memcpy(&event, pEvent, sizeof(HXxEvent)); /* Flawfinder: ignore */
- AddRef();
- if(!_HandleOSEvents(pEvent) && !_ConvertToHXEvent(pEvent) )
- {
- if( _ConvertToHXEvent(pEvent))
- {
- Release();
- return hr;
- }
- switch((ULONG32)pEvent->event)
- {
- case HX_KEY_UP:
- case HX_KEY_DOWN:
- #if defined(_DEBUG) && 0
- _PrintKeyboardEventInfo(pEvent);
- #endif
- // Always send <CR> and <TAB> to the top level site for smil
- #if !defined(_MACINTOSH) && !defined(_MAC_UNIX) // XXXSEH: Is this the correct solution?
- if (HX_VK_TAB == (int)pEvent->param1 || HX_VK_RETURN == (int)pEvent->param1)
- #else
- if (0)
- #endif
- m_pTopLevelSite->m_pUser->HandleEvent(pEvent);
- // Send keyboard messages to the user that has focus
- else if (m_pTopLevelSite->m_pKeyBoardFocusUser)
- m_pTopLevelSite->m_pKeyBoardFocusUser->HandleEvent(pEvent);
- else if (m_pUser)
- m_pUser->HandleEvent(pEvent);
- break;
- case HX_CHAR:
- #if defined(_DEBUG) && 0
- _PrintKeyboardEventInfo(pEvent);
- #endif
- // Always send <CR> and <TAB> to the top level site for smil
- #if !defined(_MACINTOSH) && !defined(_MAC_UNIX) // XXXSEH: Is this the correct solution?
- if (HX_VK_TAB == (int)pEvent->param1 || HX_VK_RETURN == (int)pEvent->param1)
- #else
- if (0)
- #endif
- m_pTopLevelSite->m_pUser->HandleEvent(pEvent);
- // Send keyboard messages to the user that has focus
- else if (m_pTopLevelSite->m_pKeyBoardFocusUser)
- m_pTopLevelSite->m_pKeyBoardFocusUser->HandleEvent(pEvent);
- else if (m_pUser)
- m_pUser->HandleEvent(pEvent);
- break;
- case HX_SET_FOCUS:
- case HX_LOSE_FOCUS:
- if (m_pUser)
- m_pUser->HandleEvent(pEvent);
- break;
- case HX_SET_STATUS:
- case HX_SET_CURSOR:
- if (m_pUser)
- m_pUser->HandleEvent(pEvent);
- break;
- case HX_MOUSE_LEAVE:
- case HX_MOUSE_ENTER:
- {
- HXxEvent tempEvent;
- memcpy( &tempEvent, pEvent, sizeof( HXxEvent ) ); /* Flawfinder: ignore */
- if (m_pUser)
- m_pUser->HandleEvent(pEvent);
- //Also send a set status and set cursor to the user.
- tempEvent.event = HX_SET_CURSOR;
- if (m_pUser)
- m_pUser->HandleEvent(&tempEvent);
- tempEvent.event = HX_SET_STATUS;
- tempEvent.handled = FALSE;
- if (m_pUser)
- m_pUser->HandleEvent(&tempEvent);
- }
- break;
- case HX_PRIMARY_BUTTON_UP:
- case HX_PRIMARY_BUTTON_DOWN:
- case HX_CONTEXT_BUTTON_UP:
- case HX_CONTEXT_BUTTON_DOWN:
- case HX_MOUSE_MOVE:
- case HX_PRIMARY_DBLCLK:
- case HX_CONTEXT_DBLCLK:
- case HX_THIRD_DBLCLK:
- {
- HXxPoint point = *((HXxPoint*)pEvent->param1);
- HX_ASSERT( m_nEventSensitivity != SENSITIVITY_NOT_SET || m_pWindow);
- #if defined(_DEBUG) && 0
- //XXXgfw just so I can set break points.
- if( pEvent->event == HX_PRIMARY_BUTTON_DOWN )
- {
- int MasterSlaveFlipFlop=1;
- }
- #endif
- // check to see if this message is within my bounding box.
- if( m_RegionWithoutChildren &&
- ::HXPointInRegion( m_RegionWithoutChildren, point.x, point.y))
- {
- // ok check to see it is within our clipping area
- if (::HXPointInRegion(m_RegionForMouse, point.x, point.y) )
- {
- //Get the site under the point that isn't transparent.
- CHXBaseSite* pRealSite = this;
- pRealSite = _GetSiteFromPixel(point);
- pRealSite->_HandleMouseEvent(pEvent);
- #if defined(_UNIX) && !defined(_MAC_UNIX)
- // for unix only, post context menu if the event is unhandled
- if (!pEvent->handled && pEvent->event == HX_CONTEXT_BUTTON_DOWN)
- {
- IHXClientEngineMapper* pCleng = NULL;
- if (m_pContext)
- {
- m_pContext->QueryInterface(IID_IHXClientEngineMapper,
- (void**)&pCleng);
- if (pCleng)
- {
- IUnknown* pUnknown = NULL;
- if (HXR_OK != pCleng->GetPlayerBySite(this, pUnknown))
- {
- // check our children
- CHXMapPtrToPtr::Iterator i = m_ChildrenMap.Begin();
- for ( ; i != m_ChildrenMap.End(); ++i)
- {
- CHXBaseSite* pSite = (CHXBaseSite*) *i;
- if (HXR_OK == pCleng->GetPlayerBySite(pSite, pUnknown))
- break;
- }
- }
- if (pUnknown)
- {
- IHXContextMenu *pContextMenu = NULL;
- pUnknown->QueryInterface(IID_IHXContextMenu, (void**)&pContextMenu);
- HX_RELEASE(pUnknown);
- if (pContextMenu)
- {
- pContextMenu->InitContextMenu("Contextual Menu");
- pContextMenu->ShowMenu(NULL, point);
- HX_RELEASE(pContextMenu);
- }
- }
- HX_RELEASE(pCleng);
- }
- }
- }
- #endif
- }
- else
- {
- INT32 handledCount = 0;
- INT32 mapCount = 0;
- LISTPOSITION pos = NULL;
- // try send this to all of our children
- mapchanged2:
- mapCount = m_ChildrenInZOrder.GetCount();
- pos = m_ChildrenInZOrder.GetHeadPosition();
- while(pos)
- {
- CHXBaseSite* pSite = (CHXBaseSite*)m_ChildrenInZOrder.GetNext(pos);
- pSite->EventOccurred(pEvent);
- if (pEvent->handled)
- {
- break;
- }
- handledCount+=pEvent->handled;
- pEvent->handled=0;
- if (m_ChildrenInZOrder.GetCount() != mapCount)
- {
- goto mapchanged2;
- }
- }
- if (handledCount)
- {
- pEvent->handled = 1;
- }
- HX_ASSERT(handledCount<2);
- }
- }
- break;
- }
- default:
- #if defined(_DEBUG) && 0
- _DumpString("CHXBaseSite::EventOccurred Unkown event type........n");
- #endif
- break;
- }
- }
- event.handled = pEvent->handled;
- event.result = pEvent->result;
- memcpy( pEvent, &event, sizeof( event ) ); /* Flawfinder: ignore */
- Release();
- return hr;
- }
- void CHXBaseSite::_HandleMouseEvent(HXxEvent* pEvent)
- {
- HXxEvent event;
- memcpy( &event, pEvent, sizeof(event) ); /* Flawfinder: ignore */
- HXxPoint point = *((HXxPoint*)pEvent->param1);
- m_pTopLevelSite->m_pLastUser = m_pUser;
- //If this is a click then this is the site with "focus"
- if (pEvent->event == HX_PRIMARY_BUTTON_DOWN)
- {
- m_pTopLevelSite->SetFocusSite(this);
- HXxWindow* pTempwindow = GetWindow();
- if(pTempwindow && pTempwindow->window)
- {
- SafeSetFocus(pTempwindow);
- }
- // Keyboard focus must change to match the site focus
- if (m_pTopLevelSite->m_pKeyBoardFocusUser &&
- m_pTopLevelSite->m_pKeyBoardFocusUser != m_pUser)
- {
- HXxEvent focusEvent;
- memcpy(&focusEvent, pEvent, sizeof(focusEvent)); /* Flawfinder: ignore */
- focusEvent.handled = FALSE;
- focusEvent.event = HX_SET_FOCUS;
- EventOccurred(&focusEvent);
- if (focusEvent.handled)
- SetKeyboardFocus(m_pUser);
- else
- SetKeyboardFocus(m_pTopLevelSite->m_pUser);
- }
- }
- // translate point and send it off to our user
- float xf = 0.0;
- float yf = 0.0;
- if( m_pParentSite )
- {
- int dX = (m_size.cx-m_pParentSite->m_size.cx);
- int dY = (m_size.cy-m_pParentSite->m_size.cy);
- if( dX && dY )
- {
- xf = (float)GetXSliderPos()/(float)(dX);
- yf = (float)GetYSliderPos()/(float)(dY);
- }
- }
- point.x = point.x - (short)((m_topleft.x - GetXSliderPos()) + GetSliderWidth()*xf);
- point.y = point.y - (short)((m_topleft.y - GetYSliderPos()) + GetSliderHeight()*yf);
- memcpy(&event, pEvent, sizeof(HXxEvent)); /* Flawfinder: ignore */
- event.param1 = &point;
- // hey do we think that we are the window with the mouse?
- CHXBaseSite* pTopLevelSite = m_pTopLevelSite;
- if (pTopLevelSite->m_pMouseInSite != this)
- {
- if (pTopLevelSite->m_pMouseInSite)
- {
- HXxPoint oobPoint;
- oobPoint.x = -1;
- oobPoint.y = -1;
- HXxEvent Outevent = { HX_MOUSE_LEAVE,
- m_pWindow ? m_pWindow->window : NULL,
- (void*)&oobPoint,
- 0, 0,
- FALSE };
- pTopLevelSite->m_pMouseInSite->EventOccurred(&Outevent);
- }
- //Generate a mouse enter message
- pTopLevelSite->m_pMouseInSite = this;
- HXxEvent tempevent = {HX_MOUSE_ENTER,
- m_pWindow ? m_pWindow->window : NULL,
- (void*)&point,
- 0, 0,
- FALSE};
- if (m_pUser)
- {
- m_pUser->HandleEvent(&tempevent);
- }
- // hey, have we started the mouseleave generator?
- pTopLevelSite->ScheduleCallback(MOUSE, 100);
- }
- // we have already called HandleEvent on the
- // original user in HandleWndProc
- if(pEvent->window != (m_pWindow ? m_pWindow->window : NULL))
- {
- _GenerateOSEvent(&event, pEvent);
- }
- //Send out the HX_SET_CURSOR and HX_SET_STATUS *after*
- //the mouse leave/enter messages. These are sent out for
- //all mouse move messages.
- if( pEvent->event==HX_MOUSE_MOVE && m_pUser )
- {
- HXxEvent stTmpEvent;
- memcpy( &stTmpEvent, pEvent, sizeof( HXxEvent ) ); /* Flawfinder: ignore */
- //Set Cursor....
- stTmpEvent.event = HX_SET_CURSOR;
- stTmpEvent.handled = FALSE;
- m_pUser->HandleEvent(&stTmpEvent);
- //Set Status....
- stTmpEvent.event = HX_SET_STATUS;
- stTmpEvent.handled = FALSE;
- m_pUser->HandleEvent(&stTmpEvent);
- }
- //ALWAYS send the RMA MOUSE messages... Needed for
- //hyperlinks to work in SMIL since the native
- //message is handled by...say...the Flash
- //renderer... and SMIL only understands the RMA
- //mouse messages.
- if(m_pUser)
- {
- m_pUser->HandleEvent(&event);
- pEvent->handled |= event.handled;
- }
- #if !defined(_UNIX) || defined(_MAC_UNIX)
- //XXXgfw We should change the realtext renderer to use
- //HX_SET_CURSOR and HX_SET_STATUS instead and then
- //just get rid of this....
- // and now for the real text renderer we will
- // check to see if this was a mouse move
- // message. If so we will give the user a
- // WM_SETCURSOR
- if (m_pUser && pEvent->event == HX_MOUSE_MOVE)
- {
- _GenerateSetCursorEvent();
- }
- #endif
- }
- /************************************************************************
- * Method:
- * IHXSiteWindowless::GetParentWindow
- */
- STDMETHODIMP_(HXxWindow*) CHXBaseSite::GetParentWindow()
- {
- if (m_pWindow && m_pWindow->window)
- {
- return m_pWindow;
- }
- else
- {
- if(m_pParentSite)
- {
- return m_pParentSite->GetParentWindow();
- }
- else
- {
- return NULL;
- }
- }
- }
- /************************************************************************
- * Method:
- * CHXBaseSite::GetTopLevelSite
- */
- CHXBaseSite*
- CHXBaseSite::GetTopLevelSite()
- {
- if (!m_pParentSite)
- {
- return this;
- }
- else
- {
- return m_pParentSite->GetTopLevelSite();
- }
- }
- CHXBaseSite*
- CHXBaseSite::GetContainingCHXBaseSite()
- {
- if (m_pWindow && m_pWindow->window)
- {
- return this;
- }
- else
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetContainingCHXBaseSite();
- }
- }
- return NULL;
- }
- /************************************************************************
- * Method:
- * CHXBaseSite::AttachWindow
- */
- STDMETHODIMP CHXBaseSite::AttachWindow(HXxWindow* pWindow)
- {
- if (m_pWindow && m_pWindow->window) return HXR_UNEXPECTED;
- _TLSLock();
- if (!m_pParentSite)
- {
- memcpy(&m_TopLevelWindow, pWindow, sizeof(HXxWindow)); /* Flawfinder: ignore */
- }
- m_pWindow = pWindow;
- if (!m_pRootSurface && !m_pParentSite)
- {
- m_pRootSurface = CBaseRootSurface::Create(m_pContext, this);
- m_pRootSurface->AddRef();
- }
- _AttachWindow();
- if (!m_pParentSite)
- {
- _GetDeviceCaps(NULL, m_nOldBitsPerPixel, m_nOldHorzRes, m_nOldVertRes);
- m_pRootSurface->AddRef();
- SetRootSurface(m_pRootSurface);
- m_pRootSurface->Release();
- SetParentWindow(&m_TopLevelWindow);
- }
- if (m_pUser)
- {
- m_bAttachWindowPending = FALSE;
- m_bDetachWndMsgPending = TRUE;
- // send HX_ATTACH_WINDOW msg to the renderers
- void * lpParam1 = NULL;
- void * lpParam2 = NULL;
- HXxEvent event = {HX_ATTACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
- m_pUser->HandleEvent(&event);
- }
- else
- {
- m_bAttachWindowPending = TRUE;
- }
- //XXXgfw This focus code is disabled for the Beamer release.
- // if (!m_pParentSite)
- // {
- // SafeSetFocus(m_pWindow);
- // }
- _TLSUnlock();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSiteWindowed::DetachWindow
- */
- STDMETHODIMP CHXBaseSite::DetachWindow()
- {
- if (!m_pWindow || !m_pWindow->window) return HXR_UNEXPECTED;
- if (m_pVideoSurface)
- {
- m_pVideoSurface->EndOptimizedBlt();
- }
-
- // Avoid dead-lock in vidsurf2
- LockBlitters();
- FlushSurfaces();
- _TLSLock();
- if (m_pUser && m_bDetachWndMsgPending)
- {
- // send HX_DETACH_WINDOW msg to the renderers
- void * lpParam1 = NULL;
- void * lpParam2 = NULL;
- HXxEvent event = {HX_DETACH_WINDOW, m_pWindow ? m_pWindow->window : NULL, lpParam1, lpParam2, 0, 0};
- m_bDetachWndMsgPending = FALSE;
- m_pUser->HandleEvent(&event);
- }
- //Status text
- if (m_pStatusText)
- {
- m_pStatusText->Destroy();
- #ifdef _WINDOWS
- HX_DELETE(m_pStatusText);
- #else
- HX_RELEASE(m_pStatusText);
- #endif
- HX_DELETE(m_pStatusText);
- }
- _DestroySliders();
- // let the OS specific site do its cleanup.
- _DetachWindow();
- m_pWindow = NULL;
- DestroySurfaces();
- HX_RELEASE(m_pRootSurface);
- if (m_pTopLevelSite)
- m_pTopLevelSite->RemovePendingTasks(this);
- SetRootSurface(NULL);
- SetParentWindow(NULL);
- if (m_pTopLevelSite == this)
- {
- if (m_CallbackHandle)
- {
- m_pScheduler->Remove(m_CallbackHandle);
- m_CallbackHandle = 0;
- }
- if (m_ScrollSiteCallbackHandle)
- {
- m_pScheduler->Remove(m_ScrollSiteCallbackHandle);
- m_ScrollSiteCallbackHandle = 0;
- }
- }
- _TLSUnlock();
- UnlockBlitters();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * IHXSiteWindowed::Create
- */
- STDMETHODIMP CHXBaseSite::Create(void* ParentWindow, UINT32 style)
- {
- HRESULT retVal = HXR_OK;
- if( m_pWindow && m_pWindow->window )
- {
- //We already have one.
- return HXR_FAIL;
- }
- _TLSLock();
- void* hWnd = _Create(ParentWindow, style);
- if (!hWnd)
- {
- retVal = HXR_FAIL;
- }
- else
- {
- HXxWindow* pWindow = new HXxWindow;
- memset(pWindow,0,sizeof(HXxWindow));
- pWindow->window = hWnd;
- if( this == m_pTopLevelSite )
- {
- //This flags tells us if Create was used to make the window
- //or not. We use this in SetSize and SetPosition so that we
- //never resize or move the TLCs window. But, in TLC that call
- //create, like testplay, we need to do the move and resize
- //for them.
- m_bWindowCreatedByCreate = TRUE;
- }
- //This way we always pass through attach window.
- AttachWindow(pWindow);
- }
- _TLSUnlock();
- return retVal;
- }
- /************************************************************************
- * Method:
- * IHXSiteWindowed::Destroy
- */
- STDMETHODIMP CHXBaseSite::Destroy()
- {
- //This could be the site that owns the overlay even though
- //it doesn't have a window. Give it a chance to clean up
- //here...
- if( m_pVideoSurface )
- {
- m_pVideoSurface->EndOptimizedBlt();
- }
- _DestroySliders();
- if(!m_pWindow || !m_pWindow->window)
- {
- return HXR_UNEXPECTED;
- }
- _TLSLock();
- HXxWindow tempWindow;
- memcpy( &tempWindow, m_pWindow, sizeof( HXxWindow ) ); /* Flawfinder: ignore */
- DetachWindow();
- _Destroy(&tempWindow);
- m_pWindow = NULL;
- if (m_pTopLevelSite && m_pTopLevelSite != this)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- _TLSUnlock();
- return HXR_OK;
- }
- STDMETHODIMP_(HXxWindow*) CHXBaseSite::GetWindow()
- {
- return GetParentWindow();
- }
- /************************************************************************
- * Method:
- * IHXSite2::SetCursor
- */
- STDMETHODIMP CHXBaseSite::SetCursor(HXxCursor cursor, REF(HXxCursor) oldCursor)
- {
- return HXR_NOTIMPL;
- }
- /************************************************************************
- * Method:
- * IHXCallback::Func
- */
- STDMETHODIMP CHXBaseSite::Func(void)
- {
- _TLSLock();
- m_CallbackHandle = 0;
- AddRef();
- ExecutePendingTasks();
- if (m_bRecomputeClipScheduled)
- {
- m_bDisableForceRedraw = TRUE;
- m_bRecomputeClipScheduled = FALSE;
- RecomputeClip();
- m_bDisableForceRedraw = FALSE;
- _ForceRedrawAll();
- m_bForceRedrawNeeded = FALSE;
- m_bCalledComputeClipFromTransition = FALSE;
- FillColorKey();
- }
- if (m_bProcessRepaint)
- {
- _ForceRedrawAll();
- m_bProcessRepaint = FALSE;
- }
- if( m_bForceRedrawNeeded )
- {
- _ForceRedrawAll();
- m_bForceRedrawNeeded = FALSE;
- FillColorKey();
- }
- //The preferable fix is during WM_PAINT, if in full screen, to call
- //FillBorders. However, we are currently generating quite a number
- //of spurious WM_PAINT callbacks and this would further degrade
- //performance. If some day we reduce the number of spurious
- //WM_PAINT callbacks then this code (which is hookey) should be
- //placed in * the WM_PAINT handler (too many handlers in that
- //sentence).
- if (m_nDelayFillBorders)
- {
- m_nDelayFillBorders--;
- m_pRootSurface->FillBorders();
- }
- if (m_nStatusTextExpireTime)
- {
- if (m_pStatusText && (HX_GET_TICKCOUNT() - m_nStatusTextExpireTime > 100))
- {
- if (m_pStatusText)
- {
- m_pStatusText->SetStatusText(NULL);
- if (IsFullScreen())
- {
- m_pRootSurface->FillBorders();
- }
- }
- m_nStatusTextExpireTime = 0;
- }
- }
- if (m_nLastMoveTime)
- {
- if (HX_GET_TICKCOUNT() - m_nLastMoveTime > MOVING_TIMEOUT)
- {
- SiteNotMoving();
- m_nLastMoveTime = 0;
- }
- }
- if (m_bScheduleUpgrade)
- {
- ScheduleUpgrade();
- }
- #ifdef _DEBUG_WINDOWED_SITES
- DrawAllSites();
- #endif
- //TEST TEST TEST TEST XXXgfw
- // SetCompositionMode(1);
- // UnlockComposition();
- // BltComposition();
- // LockComposition();
- // ScheduleCallback(MOUSE, 45);
- //TEST TEST TEST TEST XXXgfw
- ScheduleCallback(MOUSE, 100);
- #if !defined(_UNIX) && !defined(_MACINTOSH)
- //XXXgfw this whole section of code should go away when we add
- // HX_SET_CURSOR and HX_SET_STATUS messages....
- //We don't need this in UNIX because we have EnterNotify and
- //LeaveNotify events that the OS supplies. This will be
- //handled in the OS specific class.
- // xxxbobclark The mac site call generate mouse leave message.
- if (_AtSystemTime())
- {
- GenerateMouseLeaveMessage();
- }
- #endif
- Release();
- _TLSUnlock();
- return HXR_OK;
- }
- /************************************************************************
- * Method:
- * SetStatus
- */
- STDMETHODIMP CHXBaseSite::SetStatus(const char* pText)
- {
- if (this != m_pTopLevelSite)
- {
- m_pTopLevelSite->SetStatus(pText);
- }
- /*
- * if we get a zero length string we will remove the Status Text
- * in 100 milliseconds.
- */
- _TLSLock();
- if (!pText || !*pText)
- {
- m_nStatusTextExpireTime = HX_GET_TICKCOUNT();
- ScheduleCallback(MOUSE, 100);
- _TLSUnlock();
- return HXR_OK;
- }
- m_nStatusTextExpireTime = 0;
- if (!m_pStatusText)
- {
- m_pStatusText = new CHXSiteStatusText();
- //XXXgfw We need to make this interface cross platform.
- #ifdef _WINDOWS
- m_pStatusText->Create( GetWindow()->window );
- #else
- m_pStatusText->AddRef();
- m_pStatusText->Create( this );
- #endif
- m_pStatusText->ParentChangedSize();
- }
- m_pStatusText->SetStatusText(pText);
- _TLSUnlock();
- return HXR_OK;
- }
- HXxPoint
- CHXBaseSite::GetScreenOffset()
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetScreenOffset();
- }
- return m_screenOffset;
- }
- STDMETHODIMP CHXBaseSite::EnterFullScreen()
- {
- IHXPreferences* pPreferences = NULL;
- HX_RESULT ret = HXR_OK;
- //Check to see if we are in postage stamp mode.
- m_bPostageStamp = FALSE;
- if (HXR_OK == m_pContext->QueryInterface(IID_IHXPreferences,(void**)&pPreferences))
- {
- IHXBuffer* pBuffer = NULL;
- char szBuffer[255]; /* Flawfinder: ignore */
- strcpy(szBuffer, REGKEY_FULLSCREEN_DATA); /* Flawfinder: ignore */
- strcat(szBuffer, "\"); /* Flawfinder: ignore */
- strcat(szBuffer, REGKEY_FULLSCREEN_POSTAGE_STAMP); /* Flawfinder: ignore */
- ReadPrefBOOL(pPreferences, szBuffer, m_bPostageStamp);
- }
- if (m_pParentSite)
- {
- return m_pParentSite->EnterFullScreen();
- }
- if (IsFullScreen())
- {
- return HXR_OK;
- }
- _TLSLock();
- ret = _EnterFullScreen();
- _TLSUnlock();
- return ret;
- }
- STDMETHODIMP CHXBaseSite::ExitFullScreen()
- {
- HX_RESULT ret = HXR_OK;
- if (m_pParentSite)
- {
- return m_pParentSite->ExitFullScreen();
- }
- if( !m_bInFullScreen )
- {
- return HXR_OK;
- }
- // Avoid dead-lock in vidsurf2
- LockBlitters();
- FlushSurfaces();
- _TLSLock();
- ret = _ExitFullScreen();
- _TLSUnlock();
- UnlockBlitters();
- return ret;
- }
- STDMETHODIMP CHXBaseSite::TestFullScreen(void* hTestBitmap,const char* pszStatusText)
- {
- return _TestFullScreen(hTestBitmap, pszStatusText);
- }
- STDMETHODIMP_(BOOL) CHXBaseSite::IsFullScreen()
- {
- if (m_pParentSite)
- {
- return m_pParentSite->IsFullScreen();
- }
- return m_bInFullScreen;
- }
- STDMETHODIMP CHXBaseSite::Initialize (IHXValues* pParams)
- {
- INT32 transitionType = 0;
- INT32 transitionSubType = 0;
- BOOL bFoundType = FALSE;
- BOOL bFoundSubType = FALSE;
- IHXBuffer* pPropertyValue = NULL;
- pParams->GetPropertyCString("type", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- char* pString;
- pString = (char*)pPropertyValue->GetBuffer();
- if (pString)
- {
- for(int i = 0; i < z_nNumberTransitionTypes; ++i)
- {
- tranType* pStruct;
- pStruct = &z_TransitionTable[i];
- if (pStruct->m_pName)
- {
- if (!strcmp(pStruct->m_pName, pString))
- {
- bFoundType = TRUE;
- transitionType = i;
- break;
- }
- }
- }
- }
- }
- HX_RELEASE(pPropertyValue);
- pParams->GetPropertyCString("subType", (IHXBuffer*&)pPropertyValue);
- if (bFoundType && pPropertyValue)
- {
- char* pString;
- pString = (char*)pPropertyValue->GetBuffer();
- if (pString)
- {
- for(int i = 0; i < z_TransitionTable[transitionType].m_nNum; ++i)
- {
- tranStruct* pStruct;
- pStruct = &z_TransitionTable[transitionType].m_pSubTypes[i];
- if (pStruct->m_pTranName)
- {
- if (!strcmp(pStruct->m_pTranName, pString))
- {
- bFoundSubType = TRUE;
- transitionSubType = i;
- break;
- }
- }
- }
- }
- }
- HX_RELEASE(pPropertyValue);
- pParams->GetPropertyCString("reverse", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_bTransitionReversed = (::atoi((const char *)pPropertyValue->GetBuffer())==1);
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("TranIn", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_bTransitionTranIn = (::atoi((const char *)pPropertyValue->GetBuffer())==1);
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("VerticalRepeat", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_nTransitionVertRepeat = ::atoi((const char *)pPropertyValue->GetBuffer());
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("HorizontalRepeat", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_nTransitionHorzRepeat = ::atoi((const char *)pPropertyValue->GetBuffer());
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("BorderWidth", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_nTransitionBorderWidth = ::atoi((const char *)pPropertyValue->GetBuffer());
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("BorderColor", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_ulTransitionBorderColor = ::atoi((const char *)pPropertyValue->GetBuffer());
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("FadeColor", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_ulTransitionFadeColor = ::atoi((const char *)pPropertyValue->GetBuffer());
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("BlendBorder", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_bTransitionBlendBorder = (::atoi((const char *)pPropertyValue->GetBuffer())==1);
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("Coordinated", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- m_bTransitionCoordinated = (::atoi((const char *)pPropertyValue->GetBuffer())==1);
- HX_RELEASE(pPropertyValue);
- }
- pParams->GetPropertyCString("ClipBoundary", (IHXBuffer*&)pPropertyValue);
- if (pPropertyValue)
- {
- const char* pszType = (const char*)pPropertyValue->GetBuffer();
- BOOL bIsParent = TRUE;
- if( pszType && strlen( pszType ) )
- {
- bIsParent = pszType[0]=='p' || pszType[0]=='P';
- }
- m_bTransitionCoordTranIsParentClip = bIsParent;
- HX_RELEASE(pPropertyValue);
- }
- if (bFoundSubType && bFoundType)
- {
- m_fpTransitionEffect =
- z_TransitionTable[transitionType].m_pSubTypes[transitionSubType].m_fpTranFunction;
- m_nTransitionState = 0;
- return HXR_OK;
- }
- else
- {
- return HXR_FAIL;
- }
- }
- STDMETHODIMP CHXBaseSite::SetPercentage (UINT32 nThousandnthsComplete)
- {
- _TLSLock();
- if( nThousandnthsComplete != (UINT32)m_nTransitionState )
- {
- m_nTransitionState = nThousandnthsComplete;
- // We need to invalidate the rect first before we may
- // update m_topleft and m_postion. This would happen
- // if we are doing some sort of slideWipe transition.
- // The first rect will be the "old" position of a
- // slideWipe. If we are not using some sort of
- // slideWipe, then the rect won't change and we
- // won't damage again.
- HXxRect cTmp = { m_topleft.x,
- m_topleft.y,
- m_topleft.x+m_size.cx,
- m_topleft.y+m_size.cy};
- m_pTopLevelSite->_RecursiveDamageRect( &cTmp, TRUE );
- int completeness = m_nTransitionState;
- if(m_bTransitionReversed)
- completeness = 1000 - completeness;
- if( m_fpTransitionEffect == SlideFromLeft )
- {
- m_position.x = m_positionOrig.x -
- ((INT32)(m_size.cx - (double(m_size.cx)/1000.0)*(double)completeness));
- ResetOrigin();
- }
- else if( m_fpTransitionEffect == SlideFromTop )
- {
- m_position.y = m_positionOrig.y -
- ((INT32)(m_size.cy - (double(m_size.cy)/1000.0)*(double)completeness));
- ResetOrigin();
- }
- else if( m_fpTransitionEffect == SlideFromRight )
- {
- m_position.x = m_positionOrig.x +
- ((INT32)(m_size.cx - (double(m_size.cx)/1000.0)*(double)completeness));
- ResetOrigin();
- }
- else if( m_fpTransitionEffect == SlideFromBottom )
- {
- m_position.y = m_positionOrig.y +
- ((INT32)(m_size.cy - (double(m_size.cy)/1000.0)*(double)completeness));
- ResetOrigin();
- }
- // Did we change the rect? If so, then damage with
- // the new rect
- if (cTmp.left != m_topleft.x ||
- cTmp.top != m_topleft.y ||
- cTmp.right != m_topleft.x + m_size.cx ||
- cTmp.bottom != m_topleft.y + m_size.cy)
- {
- // Invalidate the changed rect
- cTmp.left = m_topleft.x;
- cTmp.top = m_topleft.y;
- cTmp.right = m_topleft.x + m_size.cx;
- cTmp.bottom = m_topleft.y + m_size.cy;
- m_pTopLevelSite->_RecursiveDamageRect(&cTmp, TRUE);
- }
- if( this==m_pTopLevelSite)
- {
- m_pTopLevelSite->RecomputeClip();
- }
- else
- {
- if(m_pTopLevelSite)
- m_pTopLevelSite->ScheduleCallback(CLIP, 0);
- m_pTopLevelSite->m_bCalledComputeClipFromTransition = TRUE;
- }
- }
- _TLSUnlock();
- return HXR_OK;
- }
- /*
- * IHXVideoControls methods
- */
- STDMETHODIMP_(float) CHXBaseSite::GetBrightness(void)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetBrightness();
- }
- return m_fBrightness;
- }
- STDMETHODIMP CHXBaseSite::SetBrightness(float brightness)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetBrightness(brightness);
- }
- m_fBrightness = brightness;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP_(float) CHXBaseSite::GetContrast(void)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetContrast();
- }
- return m_fContrast;
- }
- STDMETHODIMP CHXBaseSite::SetContrast(float contrast)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetContrast(contrast);
- }
- m_fContrast = contrast;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP_(float) CHXBaseSite::GetSaturation(void)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetSaturation();
- }
- return m_fSaturation;
- }
- STDMETHODIMP CHXBaseSite::SetSaturation(float saturation)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetSaturation(saturation);
- }
- m_fSaturation = saturation;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP_(float) CHXBaseSite::GetHue(void)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetHue();
- }
- return m_fHue;
- }
- STDMETHODIMP CHXBaseSite::SetHue(float hue)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetHue(hue);
- }
- m_fHue = hue;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP_(float) CHXBaseSite::GetSharpness(void)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->GetSharpness();
- }
- return m_fSharpness;
- }
- STDMETHODIMP CHXBaseSite::SetSharpness(float sharpness)
- {
- if (m_pParentSite)
- {
- return m_pParentSite->SetSharpness(sharpness);
- }
- m_fSharpness = sharpness;
- ScheduleCallback(REPAINT, 0);
- return HXR_OK;
- }
- STDMETHODIMP CHXBaseSite::SetModeSharpness(UINT16 dFlag)
- {
- m_bModeSharpness = dFlag;
- return HXR_OK;
- }
- STDMETHODIMP_(BOOL) CHXBaseSite::IsInterruptSafe()
- {
- return TRUE;
- }
- STDMETHODIMP CHXBaseSite::SetKeyboardFocus(IHXSiteUser* pSiteUser)
- {
- #ifdef FUTURE_WORKING_FOCUS
- if (m_pTopLevelSite->m_pKeyBoardFocusUser)
- {
- HXxEvent event = {HX_LOSE_FOCUS, m_pWindow ? m_pWindow->window : NULL, NULL, NULL, 0, 0};
- m_pTopLevelSite->m_pKeyBoardFocusUser->HandleEvent(&event);
- m_pTopLevelSite->m_pKeyBoardFocusUser->Release();
- m_pTopLevelSite->m_pKeyBoardFocusUser = NULL;