layevent.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:16k
源码类别:

Symbian

开发平台:

Visual C++

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