phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp
branchRCL_3
changeset 57 94dc1107e8b2
parent 44 3c221667e687
equal deleted inserted replaced
44:3c221667e687 57:94dc1107e8b2
   201     {
   201     {
   202     if ( !iImage )
   202     if ( !iImage )
   203         {
   203         {
   204         return;                    
   204         return;                    
   205         }
   205         }
   206     
   206         
   207     // If bitmap is bigger than drawing area then clip from center.
   207     // If bitmap is bigger than drawing area then clip from center of the image.
   208     TRect rect;
   208     TRect rect = Rect();
   209     if ( IsFullScreenImage() )
       
   210         {
       
   211         rect = Rect();
       
   212         }
       
   213     else
       
   214         {
       
   215         rect = ImagePlacingArea();
       
   216         }
       
   217     
       
   218     iSourceRect = iImage->SizeInPixels();
   209     iSourceRect = iImage->SizeInPixels();
   219     
   210 
   220     TInt offsetX = ( iSourceRect.Width() > rect.Width() ) ? 
   211     TInt offsetX = ( iSourceRect.Width() > rect.Width() ) ? 
   221                    ((iSourceRect.Width() - rect.Width()) / 2) : 0;
   212                    ((iSourceRect.Width() - rect.Width()) / 2) : 0;
   222     TInt offsetY = ( iSourceRect.Height() > rect.Height() ) ? 
   213     TInt offsetY = ( iSourceRect.Height() > rect.Height() ) ? 
   223                    ((iSourceRect.Height() - rect.Height()) / 2) : 0;
   214                    ((iSourceRect.Height() - rect.Height()) / 2) : 0;
   224     iSourceRect.Shrink( offsetX, offsetY );    
   215     
   225     
   216     iSourceRect.Shrink( offsetX, offsetY ); 
   226     // If bitmap is smaller than drawing area then center it.
   217     
       
   218     // If bitmap is smaller than the drawing area then center the image on it.
   227     iOffset.iX = ( iSourceRect.Width() < rect.Width() ) ? 
   219     iOffset.iX = ( iSourceRect.Width() < rect.Width() ) ? 
   228                 ((rect.Width() - iSourceRect.Width()) / 2) : 0;
   220                 ((rect.Width() - iSourceRect.Width()) / 2) : 0;
   229     iOffset.iY = ( iSourceRect.Height() < rect.Height() ) ? 
   221     
   230                 ((rect.Height() - iSourceRect.Height()) / 2) : 0;
   222     iOffset.iY = 0;
   231     }
   223     
   232 
   224     // lift the image higher if needed.
       
   225     if ( iSourceRect.Height() < rect.Height() )
       
   226         {
       
   227         // check if it fits totally above the bubble
       
   228         TInt height = iImagePlacingArea.iBr.iY - iImagePlacingArea.iTl.iY;
       
   229       
       
   230         if ( iSourceRect.Height() < height )
       
   231             {
       
   232             // if it fits then center it above the bubble
       
   233             iOffset.iY = ( height - iSourceRect.Height() ) / 2;
       
   234             }
       
   235         }
       
   236     }
   233 
   237 
   234 // ---------------------------------------------------------------------------
   238 // ---------------------------------------------------------------------------
   235 // CTelBubbleCallImage::Draw
   239 // CTelBubbleCallImage::Draw
   236 // ---------------------------------------------------------------------------
   240 // ---------------------------------------------------------------------------
   237 //
   241 //
   238 EXPORT_C void CTelBubbleCallImage::Draw( const TRect& /*aRect*/ ) const
   242 EXPORT_C void CTelBubbleCallImage::Draw( const TRect& /*aRect*/ ) const
   239     {
   243     {
   240     if ( iImage ) 
   244     if ( iImage )
   241         {
   245         {
   242         CWindowGc& gc = SystemGc();
   246         CWindowGc& gc = SystemGc();
   243         const TPoint topLeft = IsFullScreenImage() ? Rect().iTl : iImagePlacingArea.iTl;
   247     
       
   248         const TPoint topLeft = Rect().iTl;
   244         const TPoint bitmapTopLeft = topLeft + iOffset;
   249         const TPoint bitmapTopLeft = topLeft + iOffset;
   245        
   250     
   246         if( iMask ) 
   251         // if we have y offset then the image wont go under the bubble in any case and so
       
   252         // no need for masking
       
   253         if ( iMask && iOffset.iY == 0 ) 
   247             {
   254             {
   248             gc.BitBltMasked( bitmapTopLeft,
   255             gc.BitBltMasked( bitmapTopLeft,
   249                              iImage, 
   256                          iImage, 
   250                              iSourceRect, 
   257                          iSourceRect, 
   251                              iMask, 
   258                          iMask, 
   252                              EFalse );
   259                          EFalse );
   253             }
   260             }
   254         else            
   261         else
   255             {
   262             {
   256             gc.BitBlt( bitmapTopLeft,
   263             gc.BitBlt( bitmapTopLeft,
   257                        iImage,
   264                    iImage,
   258                        iSourceRect );    
   265                    iSourceRect );    
   259             }
   266             }
       
   267     
   260         DrawRoundRect( gc, bitmapTopLeft, iSourceRect.Size() );
   268         DrawRoundRect( gc, bitmapTopLeft, iSourceRect.Size() );
   261         }
   269         }
   262     }
   270     }
   263 
   271 
   264 // end of file
   272 // end of file