layevent.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:15k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. // system
  36. #include <time.h>
  37. // include
  38. #include "hxtypes.h"
  39. #include "hxwintyp.h"
  40. #include "smiltype.h"
  41. #include "hxcom.h"
  42. #include "hxwin.h"
  43. #include "hxxml.h"
  44. #include "hxengin.h"
  45. #include "hxcore.h"
  46. #include "hxclsnk.h"
  47. #include "hxgroup.h"
  48. #include "hxvport.h"
  49. #include "ihxpckts.h"
  50. #include "hxsite2.h"
  51. #include "hxerror.h"
  52. #include "hxmmrkr.h" // smldoc.h   dependency
  53. #include "hxinter.h" // smldoc.h   dependency
  54. #include "hxstrutl.h"
  55. // containers:
  56. #include "hxstring.h"
  57. #include "hxslist.h"
  58. #include "hxmap.h"
  59. // misc:
  60. #include "hxwinver.h"
  61. #include "hxtick.h"
  62. // xmllib
  63. #include "hxxmlprs.h"
  64. // smlrendr
  65. #include "smlelem.h"
  66. #include "smlparse.h"
  67. #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
  68. #include "animattr.h"
  69. #include "animsand.h"
  70. #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
  71. #include "evnthook.h"
  72. #include "siteuser.h"
  73. #include "layout.h"
  74. #include "passivsw.h"
  75. #include "smlrtype.h"
  76. #include "smldoc.h"
  77. #include "layevent.h"
  78. // pndebug
  79. #include "smlrmlog.h"
  80. #include "hxheap.h"
  81. #ifdef _DEBUG
  82. #undef HX_THIS_FILE
  83. static const char HX_THIS_FILE[] = __FILE__;
  84. #endif
  85. const char* const CSmilLayoutEvent::m_pszEventTypeName[] = {"ShowSite",
  86.                                                             "HideSite",
  87.                                                             "BeginTransition",
  88.                                                             "EndTransition",
  89. #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
  90.                                                       "Animate",
  91. #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */
  92.                                                       "Unknown"};
  93. CSmilLayoutEvent::CSmilLayoutEvent(UINT16 uGroupIndex, 
  94.                                    UINT32 ulEventTime,
  95.                                    BOOL   bIgnorEvent) :
  96.     m_uGroupIndex(uGroupIndex),
  97.     m_ulEventTime(ulEventTime),
  98.     m_bOnlyHideSite(FALSE),
  99.     m_bIgnorEvent(bIgnorEvent)
  100. {
  101. }
  102. CSmilLayoutEvent::~CSmilLayoutEvent()
  103. {
  104. }
  105. const char* CSmilLayoutEvent::getEventTypeName()
  106. {
  107.     return (const char*) m_pszEventTypeName[m_type];
  108. }
  109. CSmilShowSiteEvent::CSmilShowSiteEvent(UINT16                 uGroupIndex,
  110.                                        UINT32                 ulEventTime,
  111.                                        IHXSite*              pSite,
  112.                                        IHXSite*              pRegionSite,
  113.                                        BOOL                   bShowSite,
  114.                                        BOOL                   bIgnorEvent,
  115.                                        CSmilDocumentRenderer* pDoc,
  116.                                        const char*            pszMediaID,
  117.                                        const char*            pszRegionID,
  118.                                        ShowBackground         eShowBackground) :
  119.     CSmilLayoutEvent(uGroupIndex, ulEventTime, bIgnorEvent),
  120.     m_bShowSite(bShowSite),
  121.     m_pRegionSite(pRegionSite),
  122.     m_pSite(pSite),
  123.     m_pDoc(pDoc),
  124.     m_MediaID(pszMediaID),
  125.     m_RegionID(pszRegionID),
  126.     m_eShowBackground(eShowBackground),
  127.     m_pErrorMessages(NULL)
  128. {
  129.     if (m_pSite)
  130.     {
  131.         m_pSite->AddRef();
  132.     }
  133.     if (m_pRegionSite)
  134.     {
  135.         m_pRegionSite->AddRef();
  136.     }
  137.     if (bShowSite)
  138.     {
  139.         m_type = eShowSite;
  140.     }
  141.     else
  142.     {
  143.         m_type = eHideSite;
  144.     }
  145.     if (m_pDoc)
  146.     {
  147.         m_pDoc->AddRef();
  148.         m_pDoc->getErrorInterface(m_pErrorMessages);
  149.     }
  150. }
  151. CSmilShowSiteEvent::~CSmilShowSiteEvent()
  152. {
  153.     HX_RELEASE(m_pRegionSite);
  154.     HX_RELEASE(m_pSite);
  155.     HX_RELEASE(m_pDoc);
  156.     HX_RELEASE(m_pErrorMessages);
  157. }
  158. HX_RESULT CSmilShowSiteEvent::handleEvent(UINT32 ulTime)
  159. {
  160.     MLOG_EVENT(m_pErrorMessages, 
  161.                "CSmilShowSiteEvent::handleEvent(%lu)ntm_type=%snt"
  162.                "m_ulEventTime=%luntm_uGroupIndex=%unt"
  163.                "m_bOnlyHideSite=%luntm_bIgnorEvent=%luntm_MediaID=%snt"
  164.                "m_RegionID=%snttick=%lun",
  165.                ulTime, (m_type == eShowSite ? "SHOW" : "HIDE"), m_ulEventTime,
  166.                m_uGroupIndex, m_bOnlyHideSite, m_bIgnorEvent,
  167.                (const char*) m_MediaID, (const char*) m_RegionID,
  168.                HX_GET_BETTERTICKCOUNT());
  169.     HX_RESULT retVal = HXR_OK;
  170.     if (!m_bIgnorEvent)
  171.     {
  172.         if (m_bShowSite)
  173.         {
  174.             // if showing, then first show the site before the region site
  175.             // to prevent the flash when the region site is shown before the
  176.             // site.
  177.             CSmilDocumentRenderer::showSite(m_pSite, m_bShowSite);
  178.             if (!m_bOnlyHideSite)
  179.             {
  180.                 CSmilDocumentRenderer::showSite(m_pRegionSite, m_bShowSite);
  181.             }
  182.             // If we need to, change the media override parameters before
  183.             // we show the site
  184.             if (m_pDoc)
  185.             {
  186.                 m_pDoc->processMediaRegionOverrides(m_RegionID, m_MediaID, TRUE, ulTime);
  187.             }
  188.         }
  189.         else
  190.         {
  191.             if (m_pDoc)
  192.             {
  193.                 m_pDoc->processMediaRegionOverrides(m_RegionID, m_MediaID, FALSE, ulTime);
  194.             }
  195.             // if hiding, then first hide the region so it's a one-step
  196.             // process visually.
  197.             if (!m_bOnlyHideSite &&
  198.                 m_eShowBackground == ShowBackgroundWhenActive)
  199.             {
  200.                 CSmilDocumentRenderer::showSite(m_pRegionSite, m_bShowSite);
  201.             }
  202.             CSmilDocumentRenderer::showSite(m_pSite, m_bShowSite);
  203.         }
  204.     }
  205.     else
  206.     {
  207.         // We won't show or hide any sites, but we still
  208.         // need to execute the media region overrides
  209.         if (m_pDoc)
  210.         {
  211.             m_pDoc->processMediaRegionOverrides(m_RegionID, m_MediaID, m_bShowSite, ulTime);
  212.         }
  213.     }
  214.     return retVal;
  215. }
  216. IHXSite* CSmilShowSiteEvent::getRegionSite()
  217. {
  218.     return m_pRegionSite;
  219. }
  220. IHXSite* CSmilShowSiteEvent::getRendererSite()
  221. {
  222.     return m_pSite;
  223. }
  224. BOOL CSmilShowSiteEvent::getShowSite()
  225. {
  226.     return m_bShowSite;
  227. }
  228. const char* CSmilShowSiteEvent::getMediaID()
  229. {
  230.     return (const char*) m_MediaID;
  231. }
  232. const char* CSmilShowSiteEvent::getRegionID()
  233. {
  234.     return (const char*) m_RegionID;
  235. }
  236. #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS)
  237. CSmilTransitionEvent::CSmilTransitionEvent(UINT32                 ulEventTime,
  238.                                            SMILPlayToAssoc*       pAssoc,
  239.                                            SMILSiteInfo*          pSiteInfo,
  240.                                            BOOL                   bBeginTransition,
  241.                                            CSmilDocumentRenderer* pRenderer) :
  242.     CSmilLayoutEvent(pAssoc->m_uGroupIndex, ulEventTime, FALSE)
  243. {
  244.     m_pDocRenderer = pRenderer;
  245.     m_pPlayToAssoc = pAssoc;
  246.     m_pSiteInfo    = pSiteInfo;
  247.     m_pSite        = NULL;
  248.     if (m_pDocRenderer)
  249.     {
  250.         m_pDocRenderer->AddRef();
  251.     }
  252.     if (bBeginTransition)
  253.     {
  254.         m_type = eBeginTransition;
  255.     }
  256.     else
  257.     {
  258.         m_type = eEndTransition;
  259.     }
  260. }
  261. CSmilTransitionEvent::CSmilTransitionEvent(UINT32                 ulEventTime,
  262.                                            SMILPlayToAssoc*       pAssoc,
  263.                                            IHXSite*              pSite,
  264.                                            BOOL                   bBeginTransition,
  265.                                            CSmilDocumentRenderer* pRenderer) :
  266.     CSmilLayoutEvent(pAssoc->m_uGroupIndex, ulEventTime, FALSE)
  267. {
  268.     m_pDocRenderer = pRenderer;
  269.     m_pPlayToAssoc = pAssoc;
  270.     m_pSiteInfo    = NULL;
  271.     m_pSite        = pSite;
  272.     if (m_pDocRenderer)
  273.     {
  274.         m_pDocRenderer->AddRef();
  275.     }
  276.     if (m_pSite)
  277.     {
  278.         m_pSite->AddRef();
  279.     }
  280.     if (bBeginTransition)
  281.     {
  282.         m_type = eBeginTransition;
  283.     }
  284.     else
  285.     {
  286.         m_type = eEndTransition;
  287.     }
  288. }
  289. CSmilTransitionEvent::~CSmilTransitionEvent()
  290. {
  291.     HX_RELEASE(m_pDocRenderer);
  292.     HX_RELEASE(m_pSite);
  293. }
  294. HX_RESULT CSmilTransitionEvent::handleEvent(UINT32 ulTime)
  295. {
  296.     MLOG_EVENT(NULL,
  297.                "CSmilTransitionEvent::handleEvent(%lu)nt"
  298.                "m_ulEventTime=%luntm_uGroupIndex=%unttick=%lun",
  299.                ulTime, m_ulEventTime, m_uGroupIndex,
  300.                HX_GET_BETTERTICKCOUNT());
  301.     HX_RESULT retVal = HXR_FAIL;
  302.     if (m_pDocRenderer && m_pPlayToAssoc)
  303.     {
  304.         CSmilTransitionInfo* pInfo = NULL;
  305.         if (m_type == eBeginTransition)
  306.         {
  307.             pInfo = m_pDocRenderer->getTransition(m_pPlayToAssoc->m_beginTransition);
  308.         }
  309.         else
  310.         {
  311.             pInfo = m_pDocRenderer->getTransition(m_pPlayToAssoc->m_endTransition);
  312.         }
  313.         if (pInfo)
  314.         {
  315.             if (m_pSiteInfo || m_pSite)
  316.             {
  317.                 retVal = m_pDocRenderer->startTransition(m_ulEventTime, pInfo, m_pSiteInfo,
  318.                                                          m_pPlayToAssoc, m_pSite, ulTime,
  319.                                                          m_type == eBeginTransition);
  320.             }
  321.         }
  322.     }
  323.     return retVal;
  324. }
  325. IHXSite* CSmilTransitionEvent::getRegionSite()
  326. {
  327.     return m_pSiteInfo ? m_pSiteInfo->m_pRegionSite   : NULL;
  328. }
  329. IHXSite* CSmilTransitionEvent::getRendererSite()
  330. {
  331.     return m_pSiteInfo ? m_pSiteInfo->m_pRendererSite : m_pSite;
  332. }
  333. #endif /* #if defined(HELIX_FEATURE_SMIL2_TRANSITIONS) */
  334. #if defined(HELIX_FEATURE_SMIL2_ANIMATION)
  335. CSmilAnimateEvent::CSmilAnimateEvent(UINT16                 uGroupIndex,
  336.                                      UINT32                 ulEventTime,
  337.                                      BOOL                   bIgnorEvent,
  338.                                      CSmilAnimateElement*   pElement,
  339.                                      CSmilDocumentRenderer* pDocRenderer,
  340.                                      CSmilParser*           pParser)
  341.     : CSmilLayoutEvent(uGroupIndex, ulEventTime, bIgnorEvent)
  342. {
  343.     m_type             = eAnimate;
  344.     m_pElement         = pElement;
  345.     m_pDocRenderer     = pDocRenderer;
  346.     m_pSmilParser      = pParser;
  347.     m_bEventBasedBegin = (pElement ? pElement->hasEventBasedBeginTime() : FALSE);
  348.     m_bHandled         = FALSE;
  349. }
  350. CSmilAnimateEvent::CSmilAnimateEvent(const CSmilAnimateEvent& rEvent)
  351.     : CSmilLayoutEvent(rEvent.m_pElement->m_pNode->m_nGroup,
  352.                        rEvent.m_ulEventTime,
  353.                        rEvent.m_bIgnorEvent)
  354. {
  355.     m_type             = eAnimate;
  356.     m_pElement         = rEvent.m_pElement;
  357.     m_pDocRenderer     = rEvent.m_pDocRenderer;
  358.     m_pSmilParser      = rEvent.m_pSmilParser;
  359.     m_bEventBasedBegin = (m_pElement ? m_pElement->hasEventBasedBeginTime() : FALSE);
  360. }
  361. CSmilAnimateEvent::~CSmilAnimateEvent()
  362. {
  363. }
  364. HX_RESULT CSmilAnimateEvent::handleEvent(UINT32 ulTime)
  365. {
  366.     MLOG_EVENT(NULL,
  367.                "CSmilAnimateEvent::handleEvent(%lu)ntm_ulEventTime=%lunt"
  368.                "m_uGroupIndex=%untid=%snttargetElement=%snt"
  369.                "attributeName=%lunttick=%lun",
  370.                ulTime, m_ulEventTime, m_uGroupIndex,
  371.                (m_pElement && m_pElement->m_pNode ?
  372.                 (const char*) m_pElement->m_pNode->m_id : "NULL"),
  373.                (m_pElement && m_pElement->m_pTargetElementID ?
  374.                 (const char*) *m_pElement->m_pTargetElementID : "NULL"),
  375.                (m_pElement ? m_pElement->m_ucAttributeName : 0),
  376.                HX_GET_BETTERTICKCOUNT());
  377.     HX_RESULT retVal = HXR_OK;
  378.     if (m_pElement && m_pElement->m_pNode &&
  379.         !m_pElement->m_bCancelAnimation)
  380.     {
  381.         // Create the sandwich layer. If this is an
  382.         // animateMotion, then we need to create two
  383.         // layers, otherwise one
  384.         if (m_pElement->m_pNode->m_tag == SMILAnimateMotion)
  385.         {
  386.             CAnimationSandwichLayer* pLayerLeft =
  387.                 new CAnimationSandwichLayer(m_pElement, kAttrNameLeft, m_pSmilParser);
  388.             if (pLayerLeft)
  389.             {
  390.                 CAnimationSandwichLayer* pLayerTop =
  391.                     new CAnimationSandwichLayer(m_pElement, kAttrNameTop, m_pSmilParser);
  392.                 if (pLayerTop)
  393.                 {
  394.                     retVal = m_pDocRenderer->addAnimation(pLayerLeft);
  395.                     if (SUCCEEDED(retVal))
  396.                     {
  397.                         retVal = m_pDocRenderer->addAnimation(pLayerTop);
  398.                     }
  399.                 }
  400.                 else
  401.                 {
  402.                     retVal = HXR_OUTOFMEMORY;
  403.                 }
  404.             }
  405.             else
  406.             {
  407.                 retVal = HXR_OUTOFMEMORY;
  408.             }
  409.         }
  410.         else
  411.         {
  412.             CAnimationSandwichLayer* pLayer =
  413.                 new CAnimationSandwichLayer(m_pElement, m_pElement->m_ucAttributeName, m_pSmilParser);
  414.             if (pLayer)
  415.             {
  416.                 retVal = m_pDocRenderer->addAnimation(pLayer);
  417.             }
  418.             else
  419.             {
  420.                 retVal = HXR_OUTOFMEMORY;
  421.             }
  422.         }
  423.     }
  424.     return retVal;
  425. }
  426. IHXSite* CSmilAnimateEvent::getRegionSite()
  427. {
  428.     return NULL;
  429. }
  430. IHXSite* CSmilAnimateEvent::getRendererSite()
  431. {
  432.     return NULL;
  433. }
  434. BOOL CSmilAnimateEvent::isSameElement(CSmilAnimateElement* pAnim)
  435. {
  436.     BOOL bRet = FALSE;
  437.     if (pAnim && m_pElement &&
  438.         pAnim == m_pElement)
  439.     {
  440.         bRet = TRUE;
  441.     }
  442.     return bRet;
  443. }
  444. #endif /* #if defined(HELIX_FEATURE_SMIL2_ANIMATION) */