idlehomescreen/xmluirendering/uiengine/src/xnwidgetextensionadapter.cpp
changeset 5 c743ef5928ba
parent 2 08c6ee43b396
child 9 f966699dea19
child 20 636d517f67e6
equal deleted inserted replaced
4:4d54b72983ae 5:c743ef5928ba
   104     // we have to decide which one of them is the recent one    
   104     // we have to decide which one of them is the recent one    
   105  
   105  
   106     CXnType* typeInfo = iNode.Node().Type();
   106     CXnType* typeInfo = iNode.Node().Type();
   107     const TDesC8& type = typeInfo->Type();
   107     const TDesC8& type = typeInfo->Type();
   108 
   108 
   109     if ( type == KPopUpText )
   109     if ( ( type != KPopUpText ) &&
   110         {
   110          ( Window().SetTransparencyAlphaChannel() == KErrNone ) )
   111         // popup element does not capture pointer events
   111         {
   112         SetPointerCapture( ETrue );      
   112         Window().SetBackgroundColor( ~0 );     
   113         }
       
   114     else
       
   115         {
       
   116         // widget extension node
       
   117         SetPointerCapture( ETrue );
       
   118         if ( Window().SetTransparencyAlphaChannel() == KErrNone )
       
   119             {
       
   120             Window().SetBackgroundColor( ~0 );
       
   121             }     
       
   122         }
   113         }
   123     iUiEngine = iNode.Node().UiEngine();
   114     iUiEngine = iNode.Node().UiEngine();
   124     CXnControlAdapter::ConstructL( iNode );
   115     CXnControlAdapter::ConstructL( iNode );
   125     EnableDragEvents();   
   116     EnableDragEvents();   
   126 
   117 
   140     if ( visible == aVisible )
   131     if ( visible == aVisible )
   141         {
   132         {
   142         return;
   133         return;
   143         }
   134         }
   144 
   135 
       
   136     SetPointerCapture( aVisible );
       
   137     
   145     CXnPluginData& plugin( 
   138     CXnPluginData& plugin( 
   146             iAppUiAdapter->ViewManager().ActiveViewData().Plugin( &iNode.Node() ) );
   139             iAppUiAdapter->ViewManager().ActiveViewData().Plugin( &iNode.Node() ) );
   147 
   140 
   148     plugin.SetIsDisplayingPopup( aVisible, &iNode.Node() );
   141     plugin.SetIsDisplayingPopup( aVisible, &iNode.Node() );
   149     
   142     
   150     if ( aVisible )
   143     CXnType* typeInfo = iNode.Node().Type();
   151         {
   144     const TDesC8& type = typeInfo->Type();
       
   145 
       
   146     if ( type != KPopUpText )
       
   147         {
       
   148         DrawableWindow()->FadeBehind( aVisible );
       
   149         }
       
   150     
       
   151     if ( aVisible && type == KPopUpText )
       
   152         {        
       
   153         // read position-hint property and set-up its variable
       
   154         CXnProperty* positionHintProp = NULL;
       
   155         TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
       
   156                    
       
   157         if ( positionHintProp )
       
   158             {
       
   159             const TDesC8& displayHintVal = positionHintProp->StringValue();
       
   160                     
       
   161             if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
       
   162                 {
       
   163                 iPositionHint = EAboveLeft;
       
   164                 }
       
   165             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
       
   166                 {
       
   167                 iPositionHint = EAboveRight;
       
   168                 }
       
   169             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
       
   170                 {
       
   171                 iPositionHint = EBelowLeft;
       
   172                 }
       
   173             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
       
   174                 {
       
   175                 iPositionHint = EBelowRight;
       
   176                 }
       
   177             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
       
   178                 {
       
   179                 iPositionHint = ERight;
       
   180                 }
       
   181             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
       
   182                 {
       
   183                 iPositionHint = ELeft;
       
   184                 }
       
   185             else 
       
   186                 {
       
   187                  // if the value if of unknown type, use default one
       
   188                  if ( AknLayoutUtils::LayoutMirrored() )
       
   189                      {
       
   190                      iPositionHint = EAboveRight;
       
   191                      }
       
   192                      else
       
   193                      {
       
   194                      iPositionHint = EAboveLeft; 
       
   195                      }
       
   196                  }
   152         
   197         
   153         CXnType* typeInfo = iNode.Node().Type();
   198             if ( iPositionHint != ENone )
   154         const TDesC8& type = typeInfo->Type();
   199                 {    
   155 
   200                 // the popup is going visible and position-hind is available
   156         if ( type == KPopUpText )
   201                 // calculate its position
   157             {            
   202                 CalculatePosition();
   158             // read position-hint property and set-up its variable
   203                 }
   159             CXnProperty* positionHintProp = NULL;
   204             }        
   160             TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
   205         }
   161                        
   206 
   162             if ( positionHintProp )
       
   163                 {
       
   164                 const TDesC8& displayHintVal = positionHintProp->StringValue();
       
   165                         
       
   166                 if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
       
   167                     {
       
   168                     iPositionHint = EAboveLeft;
       
   169                     }
       
   170                 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
       
   171                     {
       
   172                     iPositionHint = EAboveRight;
       
   173                     }
       
   174                 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
       
   175                     {
       
   176                     iPositionHint = EBelowLeft;
       
   177                     }
       
   178                 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
       
   179                     {
       
   180                     iPositionHint = EBelowRight;
       
   181                     }
       
   182                 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
       
   183                     {
       
   184                     iPositionHint = ERight;
       
   185                     }
       
   186                 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
       
   187                     {
       
   188                     iPositionHint = ELeft;
       
   189                     }
       
   190                 else 
       
   191                     {
       
   192                      // if the value if of unknown type, use default one
       
   193                      if ( AknLayoutUtils::LayoutMirrored() )
       
   194                          {
       
   195                          iPositionHint = EAboveRight;
       
   196                          }
       
   197                          else
       
   198                          {
       
   199                          iPositionHint = EAboveLeft; 
       
   200                          }
       
   201                      }
       
   202             
       
   203                 if ( iPositionHint != ENone )
       
   204                     {    
       
   205                     // the popup is going visible and position-hind is available
       
   206                     // calculate its position
       
   207                     CalculatePosition();
       
   208                     }
       
   209                 }
       
   210             }       
       
   211         DrawableWindow()->FadeBehind( ETrue );
       
   212         }
       
   213     else
       
   214         {
       
   215         DrawableWindow()->FadeBehind( EFalse );
       
   216         }
       
   217     CCoeControl::MakeVisible( aVisible );            
   207     CCoeControl::MakeVisible( aVisible );            
   218     }
   208     }
   219 
   209 
   220 // -----------------------------------------------------------------------------
   210 // -----------------------------------------------------------------------------
   221 // CXnWidgetExtensionAdapter::HandlePointerEventL
   211 // CXnWidgetExtensionAdapter::HandlePointerEventL
   253                 {                
   243                 {                
   254                 const TDesC8& parentIdVal = parentIdProp->StringValue();
   244                 const TDesC8& parentIdVal = parentIdProp->StringValue();
   255                 CXnNode* parentN(iUiEngine->FindNodeByIdL( parentIdVal,
   245                 CXnNode* parentN(iUiEngine->FindNodeByIdL( parentIdVal,
   256                         iNode.Node().Namespace() ) );
   246                         iNode.Node().Namespace() ) );
   257                 
   247                 
   258                 TRect clientRect =
   248                 if ( parentN )
   259                         static_cast<CEikAppUi&> ( *iAppUiAdapter ).ClientRect();
       
   260                 TRect parentRect = parentN->Rect();
       
   261                 parentRect.Move( clientRect.iTl );
       
   262                 
       
   263                 if ( !parentRect.Contains( aPointerEvent.iParentPosition ) )
       
   264                     {
   249                     {
   265                     // tap was neither in popup nor in its parent -
   250                     TRect clientRect =
   266                     // we can close it
   251                             static_cast<CEikAppUi&> ( *iAppUiAdapter ).ClientRect();
   267                     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   252                     TRect parentRect = parentN->Rect();
       
   253                     parentRect.Move( clientRect.iTl );
       
   254                     
       
   255                     if ( !parentRect.Contains( aPointerEvent.iParentPosition ) )
   268                         {
   256                         {
   269                         CXnDomStringPool* sp =
   257                         // tap was neither in popup nor in its parent -
   270                             iNode.Node().DomNode()->StringPool();
   258                         // we can close it
   271                         CXnProperty* prop = CXnProperty::NewL( KDisplay, KNone,
   259                         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   272                         CXnDomPropertyValue::EString, *sp );
   260                             {
   273                         CleanupStack::PushL( prop );
   261                             CXnDomStringPool* sp =
   274                         iNode.Node().SetPropertyL( prop );
   262                                 iNode.Node().DomNode()->StringPool();
   275                         CleanupStack::Pop( prop );
   263                             CXnProperty* prop = CXnProperty::NewL( KDisplay, KNone,
       
   264                             CXnDomPropertyValue::EString, *sp );
       
   265                             CleanupStack::PushL( prop );
       
   266                             iNode.Node().SetPropertyL( prop );
       
   267                             CleanupStack::Pop( prop );
       
   268                             return;
       
   269                             }
       
   270                         }
       
   271                     else
       
   272                         {
       
   273                         // tap was made inside of popup parent
       
   274                         // we pass the event to it after
       
   275                         // recalculating the taping point
       
   276                         TPointerEvent newPointerEvent;
       
   277                         newPointerEvent.Copy( aPointerEvent );
       
   278                         newPointerEvent.iPosition = TPoint(
       
   279                                  aPointerEvent.iParentPosition - clientRect.iTl );
       
   280                         parentN->Control()->HandlePointerEventL( newPointerEvent );
   276                         return;
   281                         return;
   277                         }
   282                         }
   278                     }
       
   279                 else
       
   280                     {
       
   281                     // tap was made inside of popup parent
       
   282                     // we pass the event to it after
       
   283                     // recalculating the taping point
       
   284                     TPointerEvent newPointerEvent;
       
   285                     newPointerEvent.Copy( aPointerEvent );
       
   286                     newPointerEvent.iPosition = TPoint(
       
   287                              aPointerEvent.iParentPosition - clientRect.iTl );
       
   288                     parentN->Control()->HandlePointerEventL( newPointerEvent );
       
   289                     return;
       
   290                     }
   283                     }
   291                 }
   284                 }
   292             }
   285             }
   293         }
   286         }
   294     
   287