idlehomescreen/xmluirendering/uiengine/src/xnwidgetextensionadapter.cpp
branchRCL_3
changeset 34 d05a55b217df
parent 30 b8fae6b8a148
child 38 79311d856354
equal deleted inserted replaced
30:b8fae6b8a148 34:d05a55b217df
    17 #include <e32base.h>
    17 #include <e32base.h>
    18 #include <e32const.h>
    18 #include <e32const.h>
    19 #include <coecntrl.h>
    19 #include <coecntrl.h>
    20 #include <coemain.h>
    20 #include <coemain.h>
    21 #include <AknUtils.h>
    21 #include <AknUtils.h>
       
    22 #include <gfxtranseffect/gfxtranseffect.h>
       
    23 #include <akntransitionutils.h>
    22 
    24 
    23 // User includes
    25 // User includes
    24 #include "xnwidgetextensionadapter.h"
    26 #include "xnwidgetextensionadapter.h"
    25 #include "xncontroladapter.h"
    27 #include "xncontroladapter.h"
    26 
       
    27 #include "xncomponentnodeimpl.h"
    28 #include "xncomponentnodeimpl.h"
    28 #include "xncomponent.h"
    29 #include "xncomponent.h"
    29 
       
    30 #include "xnuiengine.h"
    30 #include "xnuiengine.h"
    31 #include "xnhittest.h"
       
    32 
    31 
    33 #include "xnnode.h"
    32 #include "xnnode.h"
    34 #include "xnnodepluginif.h"
    33 #include "xnnodepluginif.h"
    35 #include "xnviewnodeimpl.h"
    34 #include "xnviewnodeimpl.h"
    36 #include "xnnodepluginif.h"
    35 #include "xnnodepluginif.h"
    44 #include "xnappuiadapter.h"
    43 #include "xnappuiadapter.h"
    45 #include "xnviewmanager.h"
    44 #include "xnviewmanager.h"
    46 #include "xnviewdata.h"
    45 #include "xnviewdata.h"
    47 #include "xnplugindata.h"
    46 #include "xnplugindata.h"
    48 
    47 
    49 #include <gfxtranseffect/gfxtranseffect.h>
       
    50 #include <akntransitionutils.h>
       
    51 
       
    52 // Constants
    48 // Constants
    53 _LIT8( KPopup, "popup" );
    49 _LIT8( KPopup, "popup" );
    54 _LIT8( KPositionHint, "_s60-position-hint" );
    50 _LIT8( KPositionHint, "_s60-position-hint" );
    55 _LIT8( KWidgetNodeName, "widget" );
    51 _LIT8( KWidgetNodeName, "widget" );
    56 _LIT8( KParentIdName, "parentid" );
    52 _LIT8( KParentIdName, "parentid" );
   213             }
   209             }
   214         }
   210         }
   215     
   211     
   216     if ( aVisible && iPopup )
   212     if ( aVisible && iPopup )
   217         {        
   213         {        
   218         // read position-hint property and set-up its variable
   214         ChangePopupPosition();
   219         CXnProperty* positionHintProp = NULL;
   215         }
   220         TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
   216     
   221                    
       
   222         if ( positionHintProp )
       
   223             {
       
   224             const TDesC8& displayHintVal = positionHintProp->StringValue();
       
   225                     
       
   226             if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
       
   227                 {
       
   228                 iPositionHint = EAboveLeft;
       
   229                 }
       
   230             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
       
   231                 {
       
   232                 iPositionHint = EAboveRight;
       
   233                 }
       
   234             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
       
   235                 {
       
   236                 iPositionHint = EBelowLeft;
       
   237                 }
       
   238             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
       
   239                 {
       
   240                 iPositionHint = EBelowRight;
       
   241                 }
       
   242             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
       
   243                 {
       
   244                 iPositionHint = ERight;
       
   245                 }
       
   246             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
       
   247                 {
       
   248                 iPositionHint = ELeft;
       
   249                 }
       
   250             else 
       
   251                 {
       
   252                  // if the value if of unknown type, use default one
       
   253                  if ( AknLayoutUtils::LayoutMirrored() )
       
   254                      {
       
   255                      iPositionHint = EAboveRight;
       
   256                      }
       
   257                      else
       
   258                      {
       
   259                      iPositionHint = EAboveLeft; 
       
   260                      }
       
   261                  }
       
   262         
       
   263             if ( iPositionHint != ENone )
       
   264                 {    
       
   265                 // the popup is going visible and position-hind is available
       
   266                 // calculate its position
       
   267                 CalculatePosition();
       
   268                 }
       
   269             }        
       
   270         }
       
   271 
       
   272     TBool effectStarted = EFalse;
   217     TBool effectStarted = EFalse;
   273     if ( iAppUiAdapter->IsForeground() )
   218     if ( iAppUiAdapter->IsForeground() )
   274         {
   219         {
   275         if ( aVisible )
   220         if ( aVisible )
   276             {
   221             {
   371 // 
   316 // 
   372 // -----------------------------------------------------------------------------
   317 // -----------------------------------------------------------------------------
   373 //    
   318 //    
   374 void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const
   319 void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const
   375     {
   320     {
       
   321     SystemGc().Clear( aRect );
   376     CXnControlAdapter::Draw( aRect );
   322     CXnControlAdapter::Draw( aRect );
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CXnWidgetExtensionAdapter::DoHandlePropertyChangeL
       
   327 // 
       
   328 // -----------------------------------------------------------------------------
       
   329 //    
       
   330 void CXnWidgetExtensionAdapter::DoHandlePropertyChangeL( CXnProperty* /*aProperty*/ )
       
   331     {
       
   332     if( iNode.Node().IsLaidOut() && IsVisible() )
       
   333         {
       
   334         ChangePopupPosition();
       
   335         }
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CXnWidgetExtensionAdapter::ChangePopupPosition
       
   340 // 
       
   341 // -----------------------------------------------------------------------------
       
   342 // 
       
   343 void CXnWidgetExtensionAdapter::ChangePopupPosition()
       
   344     {
       
   345     if ( iPopup )
       
   346         { 
       
   347         // read position-hint property and set-up its variable
       
   348         CXnProperty* positionHintProp = NULL;
       
   349         TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) );
       
   350                    
       
   351         if ( positionHintProp )
       
   352             {
       
   353             const TDesC8& displayHintVal = positionHintProp->StringValue();
       
   354                     
       
   355             if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft )
       
   356                 {
       
   357                 iPositionHint = EAboveLeft;
       
   358                 }
       
   359             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight )
       
   360                 {
       
   361                 iPositionHint = EAboveRight;
       
   362                 }
       
   363             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft )
       
   364                 {
       
   365                 iPositionHint = EBelowLeft;
       
   366                 }
       
   367             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight )
       
   368                 {
       
   369                 iPositionHint = EBelowRight;
       
   370                 }
       
   371             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight )
       
   372                 {
       
   373                 iPositionHint = ERight;
       
   374                 }
       
   375             else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft )
       
   376                 {
       
   377                 iPositionHint = ELeft;
       
   378                 }
       
   379             else 
       
   380                 {
       
   381                  // if the value if of unknown type, use default one
       
   382                  if ( AknLayoutUtils::LayoutMirrored() )
       
   383                      {
       
   384                      iPositionHint = EAboveRight;
       
   385                      }
       
   386                      else
       
   387                      {
       
   388                      iPositionHint = EAboveLeft; 
       
   389                      }
       
   390                  }
       
   391         
       
   392             if ( iPositionHint != ENone )
       
   393                 {    
       
   394                 // the popup is going visible and position-hind is available
       
   395                 // calculate its position
       
   396                 CalculatePosition();
       
   397                 }
       
   398             }        
       
   399         }
   377     }
   400     }
   378 
   401 
   379 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   380 // CalculatePosition
   403 // CalculatePosition
   381 // This is used only for popup element with position hint
   404 // This is used only for popup element with position hint
   383 void CXnWidgetExtensionAdapter::CalculatePosition() 
   406 void CXnWidgetExtensionAdapter::CalculatePosition() 
   384     {
   407     {
   385     // widget's rectangle
   408     // widget's rectangle
   386     TRect controlRect;
   409     TRect controlRect;
   387 
   410 
   388     // get popup's window size
   411     // get popup's size.
   389     TRect popupRect = this->Rect();
   412     TSize popupSize = iNode.BorderRect().Size();
   390 
   413 
   391     TRect clientRect = static_cast<CEikAppUi&>( *iAppUiAdapter ).ClientRect();
   414     TRect clientRect = static_cast<CEikAppUi&>( *iAppUiAdapter ).ClientRect();
   392 
   415 
   393     // get entire screen except control pane
   416     // get entire screen except control pane
   394     TRect contentRect( 0, 0, clientRect.iBr.iX, clientRect.iBr.iY ); 
   417     TRect contentRect( 0, 0, clientRect.iBr.iX, clientRect.iBr.iY ); 
   432         
   455         
   433         case EAboveLeft:
   456         case EAboveLeft:
   434             
   457             
   435             // if this position does not fit the screen,
   458             // if this position does not fit the screen,
   436             // and if below left is more suitable, use it
   459             // and if below left is more suitable, use it
   437             if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove )
   460             if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove )
   438                 {
   461                 {
   439                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   462                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   440                               TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
   463                               TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
   441                 }
   464                 }
   442             else
   465             else
   443                 {
   466                 {
   444                 // use the above-left position
   467                 // use the above-left position
   445                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), 
   468                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), 
   446                               TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
   469                               TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
   447                 
   470                 
   448                 }
   471                 }
   449             break;
   472             break;
   450             
   473             
   451         case EAboveRight:
   474         case EAboveRight:
   452             
   475             
   453             // if this position does not fit the screen,
   476             // if this position does not fit the screen,
   454             // and if below right is more suitable, use it
   477             // and if below right is more suitable, use it
   455             if ( spaceAbove < popupRect.Height() && spaceBelow > spaceAbove )
   478             if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove )
   456                 {
   479                 {
   457                 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), 
   480                 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), 
   458                               TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
   481                               TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
   459                 }
   482                 }
   460             else
   483             else
   461                 {
   484                 {
   462                 // use the above-right position
   485                 // use the above-right position
   463                 rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), 
   486                 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), 
   464                               TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );
   487                               TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );
   465                 }
   488                 }
   466             break;
   489             break;
   467             
   490             
   468         case EBelowLeft:
   491         case EBelowLeft:
   469             
   492             
   470             // if this position does not fit the screen,
   493             // if this position does not fit the screen,
   471             // and if above left is more suitable, use it
   494             // and if above left is more suitable, use it
   472             if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove )
   495             if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove )
   473                 {
   496                 {
   474                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), 
   497                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), 
   475                               TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
   498                               TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
   476                 }
   499                 }
   477             else
   500             else
   478                 {
   501                 {
   479                 // use the below-left position
   502                 // use the below-left position
   480                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   503                 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   481                               TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
   504                               TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
   482                 }
   505                 }
   483             break;
   506             break;
   484 
   507 
   485         case EBelowRight:
   508         case EBelowRight:
   486 
   509 
   487               // if this position does not fit the screen,
   510               // if this position does not fit the screen,
   488               // and if above right is more suitable, use it
   511               // and if above right is more suitable, use it
   489               if ( spaceBelow < popupRect.Height() && spaceBelow < spaceAbove )
   512               if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove )
   490                   {
   513                   {
   491                   rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), 
   514                   rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), 
   492                                 TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );
   515                                 TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );
   493                   }
   516                   }
   494               else
   517               else
   495                   {
   518                   {
   496                   // use the below-right position
   519                   // use the below-right position
   497                   rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), 
   520                   rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), 
   498                                 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
   521                                 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
   499                   }
   522                   }
   500             break;
   523             break;
   501 
   524 
   502         case ERight:
   525         case ERight:
   503 
   526 
   504             // if this position does not fit the screen,
   527             // if this position does not fit the screen,
   505             // and if left or above-left is more suitable, use it
   528             // and if left or above-left is more suitable, use it
   506             if ( spaceRight < popupRect.Width() )
   529             if ( spaceRight < popupSize.iWidth )
   507                 {
   530                 {
   508                 // use the left position if the space is big enough
   531                 // use the left position if the space is big enough
   509                 if ( spaceLeft >= popupRect.Width() )
   532                 if ( spaceLeft >= popupSize.iWidth )
   510                     {
   533                     {
   511                     // use left position
   534                     // use left position
   512                     rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ), 
   535                     rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), 
   513                                   TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) );
   536                                   TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) );
   514                     }
   537                     }
   515                 else if ( spaceAbove >= popupRect.Height() )
   538                 else if ( spaceAbove >= popupSize.iHeight )
   516                     {
   539                     {
   517                     // use the above-right position
   540                     // use the above-right position
   518                     rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iTl.iY - popupRect.Height() ), 
   541                     rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), 
   519                                   TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );  
   542                                   TPoint( controlRect.iBr.iX,  controlRect.iTl.iY ) );  
   520                     }
   543                     }
   521                 else
   544                 else
   522                     {
   545                     {
   523                     // use the below-right position
   546                     // use the below-right position
   524                     rect = TRect( TPoint( controlRect.iBr.iX - popupRect.Width(), controlRect.iBr.iY ), 
   547                     rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), 
   525                                   TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupRect.Height() ) );
   548                                   TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) );
   526                     }
   549                     }
   527                 }
   550                 }
   528             else
   551             else
   529                 {
   552                 {
   530                 // use the right position
   553                 // use the right position
   531                 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), 
   554                 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), 
   532                               TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) );
   555                               TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) );
   533                 }
   556                 }
   534                 
   557                 
   535             break;
   558             break;
   536             
   559             
   537         case ELeft:
   560         case ELeft:
   538             
   561             
   539             // if this position does not fit the screen,
   562             // if this position does not fit the screen,
   540             // and if right is more suitable, use it
   563             // and if right is more suitable, use it
   541             if ( spaceLeft < popupRect.Width() )
   564             if ( spaceLeft < popupSize.iWidth )
   542                 {
   565                 {
   543                 // use the right position, if it the space is big enough
   566                 // use the right position, if it the space is big enough
   544                 if ( spaceRight >= popupRect.Width() )
   567                 if ( spaceRight >= popupSize.iWidth )
   545                     {    
   568                     {    
   546                     rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), 
   569                     rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), 
   547                                   TPoint( controlRect.iBr.iX + popupRect.Width(), controlRect.iTl.iY + popupRect.Height() ) );
   570                                   TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) );
   548                     }
   571                     }
   549                 else if ( spaceAbove >= popupRect.Height() )
   572                 else if ( spaceAbove >= popupSize.iHeight )
   550                     {
   573                     {
   551                     // use the above-left position
   574                     // use the above-left position
   552                     rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupRect.Height() ), 
   575                     rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), 
   553                                   TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iTl.iY ) );
   576                                   TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) );
   554                     }
   577                     }
   555                 else
   578                 else
   556                     {
   579                     {
   557                     // use the below-left position
   580                     // use the below-left position
   558                     rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   581                     rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), 
   559                                   TPoint( controlRect.iTl.iX + popupRect.Width(), controlRect.iBr.iY + popupRect.Height() ) );
   582                                   TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) );
   560                     }
   583                     }
   561                 }
   584                 }
   562             else
   585             else
   563                 {
   586                 {
   564                 // use the left position  
   587                 // use the left position  
   565                 rect = TRect( TPoint( controlRect.iTl.iX - popupRect.Width(), controlRect.iTl.iY ), 
   588                 rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), 
   566                               TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupRect.Height() ) );
   589                               TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) );
   567                 }
   590                 }
   568             break;
   591             break;
   569         default:
   592         default:
   570             break;
   593             break;
   571         }
   594         }