camerauis/activepalette/Src/activepalette2tooltipfading.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Active Palette 2 Fading Tooltip implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // ===========================================================================
       
    21 // Includes
       
    22 #include <activepalette2observer.h>
       
    23 
       
    24 #include "ActivePalette2BasicUI.h"
       
    25 #include "ActivePalette2Model.h"
       
    26 #include "ActivePalette2Styler.h"
       
    27 #include "activepalette2tooltipfading.h"
       
    28 
       
    29 // ===========================================================================
       
    30 // Constants
       
    31 
       
    32 
       
    33 // ===========================================================================
       
    34 // Class implementation
       
    35 
       
    36 // static 
       
    37 CActivePalette2TooltipFading* 
       
    38 CActivePalette2TooltipFading::NewL( const CActivePalette2BasicUI*  aParent,
       
    39                                           CActivePalette2Model*  aModel,
       
    40                                           CActivePalette2Styler* aStyler )
       
    41   {
       
    42   CActivePalette2TooltipFading* self = 
       
    43       new (ELeave) CActivePalette2TooltipFading( aModel, aStyler );
       
    44         
       
    45   CleanupStack::PushL( self );
       
    46   self->ConstructL( aParent );
       
    47   CleanupStack::Pop( self );
       
    48 
       
    49   return self;
       
    50   }
       
    51 
       
    52 
       
    53 // virtual 
       
    54 CActivePalette2TooltipFading::~CActivePalette2TooltipFading()
       
    55   {
       
    56   // No new resources to free.
       
    57   }
       
    58 
       
    59  
       
    60 // virtual 
       
    61 void 
       
    62 CActivePalette2TooltipFading
       
    63 ::ProduceTooltipToScreen( TBool aActivateGc ) const
       
    64   {
       
    65   TRect redrawRect;
       
    66   TRect tooltipRect( TooltipRect() );
       
    67 
       
    68   // -------------------------------------------------------
       
    69   // Figure out redraw area needed  
       
    70   if ( iModel->ShowTooltip() )
       
    71     {
       
    72     redrawRect = tooltipRect;
       
    73 
       
    74     if ( iRenderedRect.Width() > 0 )
       
    75       {
       
    76       redrawRect.BoundingRect( iRenderedRect );
       
    77       }
       
    78     }
       
    79   else
       
    80     {
       
    81     redrawRect = iRenderedRect;
       
    82     }
       
    83         
       
    84   // -------------------------------------------------------
       
    85   // Activate system gc if needed
       
    86   if ( !iRenderGc && aActivateGc )
       
    87     {
       
    88     Window().Invalidate(redrawRect);
       
    89     ActivateGc();
       
    90     Window().BeginRedraw(redrawRect);
       
    91     }
       
    92     
       
    93   // -------------------------------------------------------
       
    94   // Draw in the background
       
    95   if ( iParent && iParent->APObserver() )
       
    96     {
       
    97     if ( redrawRect.Size().iHeight > 0 && redrawRect.Size().iWidth > 0 )
       
    98       {
       
    99       iParent->APObserver()->Redraw(redrawRect);
       
   100       }
       
   101     }
       
   102 
       
   103   // -------------------------------------------------------
       
   104   // Blit tooltip to buffer and use current opaqueness
       
   105   // value to blend the tooltip to gc.
       
   106   if ( iModel->ShowTooltip() )
       
   107     {
       
   108     CBitmapContext* context = ( iRenderGc ? iRenderGc : &SystemGc() );
       
   109     iStyler->BlitTooltip( context, 
       
   110                           tooltipRect.iTl, 
       
   111                           iModel->TooltipCurrentFrame(), 
       
   112                           iModel->TooltipTotalFrames() );
       
   113     }
       
   114               
       
   115   // -------------------------------------------------------
       
   116   // Deactivate gc if needed
       
   117   if ( !iRenderGc && aActivateGc )
       
   118     {
       
   119     Window().EndRedraw();
       
   120     DeactivateGc(); 
       
   121     }
       
   122 
       
   123   // -------------------------------------------------------
       
   124   // Determine redraw area for next round.
       
   125   if ( iModel->ShowTooltip() )
       
   126     {
       
   127     iRenderedRect = tooltipRect;
       
   128     }
       
   129   else
       
   130     {
       
   131     iRenderedRect = TRect(0,0,0,0);
       
   132     }
       
   133   // -------------------------------------------------------
       
   134   }
       
   135 
       
   136 
       
   137 
       
   138 // virtual 
       
   139 TRect 
       
   140 CActivePalette2TooltipFading::TooltipRect() const
       
   141   {
       
   142   TInt  tlX  = iAnchor.iX - iStyler->TooltipSize().iWidth;
       
   143   TInt  tlY  = iAnchor.iY + iStyler->TootipYOffset( iModel->TooltipScreenPosition() );
       
   144   TInt  brX  = iAnchor.iX;
       
   145   TInt  brY  = tlY + iStyler->TooltipSize().iHeight;
       
   146 
       
   147   return TRect( tlX, tlY, brX, brY );
       
   148   }
       
   149 
       
   150 
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CActivePalette2Tooltip::SetAnchor()
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void 
       
   157 CActivePalette2TooltipFading
       
   158 ::ConstructL( const CActivePalette2BasicUI* aParent )
       
   159   {
       
   160   CActivePalette2Tooltip::ConstructL( aParent );
       
   161   }
       
   162 
       
   163 CActivePalette2TooltipFading
       
   164 ::CActivePalette2TooltipFading( CActivePalette2Model*  aModel,
       
   165                                 CActivePalette2Styler* aStyler )
       
   166   : CActivePalette2Tooltip( aModel, aStyler )
       
   167   {
       
   168   }