camerauis/activepalette/Src/ActivePalette2Tooltip.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 Tooltip*
       
    15 */
       
    16 
       
    17 
       
    18 /**
       
    19  * @file ActivePalette2Tooltip.cpp
       
    20  * Active Palette Tooltip
       
    21  */
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <activepalette2observer.h>
       
    25 #include <fbs.h>
       
    26 #include <bitstd.h>
       
    27 #include <AknsDrawUtils.h>
       
    28 #include <AknsControlContext.h>
       
    29 #include <AknsBasicBackgroundControlContext.h> 
       
    30 #include <AknUtils.h>
       
    31 
       
    32 #include "ActivePalette2Tooltip.h"
       
    33 #include "ActivePalette2Logger.h"
       
    34 #include "ActivePalette2Utils.h"
       
    35 #include "ActivePalette2Model.h"
       
    36 #include "ActivePalette2Cfg.h"
       
    37 #include "ActivePalette2BasicUI.h"
       
    38 #include "ActivePalette2Styler.h"
       
    39 
       
    40 
       
    41 // ================= MEMBER FUNCTIONS =======================
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CActivePalette2Tooltip::NewL()
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48  CActivePalette2Tooltip* CActivePalette2Tooltip::NewL(const CActivePalette2BasicUI* aParent,
       
    49 													CActivePalette2Model* aModel,
       
    50 													CActivePalette2Styler* aStyler)
       
    51     {
       
    52 	CActivePalette2Tooltip * self = new (ELeave) 
       
    53 		CActivePalette2Tooltip(aModel, aStyler);
       
    54 				
       
    55 	CleanupStack::PushL(self);
       
    56 	self->ConstructL(aParent);
       
    57 	CleanupStack::Pop(self);
       
    58 	return self;
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CActivePalette2Tooltip::CActivePalette2Tooltip()
       
    63 // C++ constructor
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CActivePalette2Tooltip::CActivePalette2Tooltip(
       
    67     CActivePalette2Model* aModel,
       
    68     CActivePalette2Styler* aStyler)
       
    69 :   CCoeControl(),
       
    70     iAnchor(TPoint(0,0)),
       
    71     iModel(aModel),
       
    72     iStyler(aStyler)
       
    73     {
       
    74     // No implementation required
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CActivePalette2Tooltip::ConstructL()
       
    79 // Symbian 2nd phase construction
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CActivePalette2Tooltip::ConstructL(const CActivePalette2BasicUI* aParent)
       
    83     {
       
    84 
       
    85     iParent = aParent;
       
    86 
       
    87 	if(aParent)
       
    88 	    {
       
    89 	    SetContainerWindowL(*aParent);
       
    90 	    }
       
    91 
       
    92 	// finally
       
    93 	MakeVisible(EFalse);	
       
    94 	ActivateL();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CActivePalette2Tooltip::~CActivePalette2Tooltip()
       
    99 // Destructor
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CActivePalette2Tooltip::~CActivePalette2Tooltip()
       
   103     {
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CActivePalette2Tooltip::Draw()
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CActivePalette2Tooltip::Draw(const TRect& /*aRect*/) const
       
   111     {
       
   112     if ( !iRenderGc && iModel->ShowTooltip() )
       
   113         {
       
   114     	ProduceTooltipToScreen(EFalse);
       
   115     	}
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CActivePalette2Tooltip::ProduceTooltipToScreen()
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CActivePalette2Tooltip::ProduceTooltipToScreen(TBool aActivateGc) const
       
   123     {
       
   124     // Redraw background
       
   125     TRect redrawRect;
       
   126     TRect tooltipRect(TooltipRect());
       
   127     
       
   128     if ( iModel->ShowTooltip() )
       
   129         {
       
   130         redrawRect = tooltipRect;
       
   131 
       
   132         if ( iRenderedRect.Width() > 0 )
       
   133             {
       
   134             redrawRect.BoundingRect(iRenderedRect);
       
   135             }
       
   136         }
       
   137     else
       
   138         {
       
   139         redrawRect = iRenderedRect;
       
   140         }
       
   141         
       
   142     if ( !iRenderGc && aActivateGc )
       
   143         {
       
   144         Window().Invalidate(redrawRect);
       
   145     	ActivateGc();
       
   146     	Window().BeginRedraw(redrawRect);
       
   147         }
       
   148     
       
   149     // Draw in the background
       
   150     if ( iParent && iParent->APObserver() )
       
   151         {
       
   152         if ( redrawRect.Size().iHeight > 0 && redrawRect.Size().iWidth > 0 )
       
   153             {
       
   154             iParent->APObserver()->Redraw(redrawRect);
       
   155             }
       
   156         }
       
   157 
       
   158     if ( iModel->ShowTooltip() )
       
   159         {
       
   160         if ( iRenderGc )
       
   161             {
       
   162         	iStyler->BlitTooltip(iRenderGc, tooltipRect.iTl,
       
   163         	                     TRect(TPoint(0,0),TPoint(tooltipRect.Width(), tooltipRect.Height())));
       
   164             }
       
   165         else
       
   166             {    
       
   167             iStyler->BlitTooltip(&SystemGc(), tooltipRect.iTl,
       
   168                                  TRect(TPoint(0,0),TPoint(tooltipRect.Width(), tooltipRect.Height())));
       
   169         	}
       
   170         }
       
   171             	
       
   172     if ( !iRenderGc && aActivateGc )
       
   173         {
       
   174     	Window().EndRedraw();
       
   175     	DeactivateGc();	
       
   176         }
       
   177 
       
   178     if ( iModel->ShowTooltip() )
       
   179         {
       
   180         iRenderedRect = tooltipRect;
       
   181         }
       
   182     else
       
   183         {
       
   184         iRenderedRect = TRect(0,0,0,0);
       
   185         }
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CActivePalette2Tooltip::TooltipUpdated()
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 TInt CActivePalette2Tooltip::TooltipUpdated()
       
   193     {
       
   194     return iStyler->DrawTooltip(iModel->TooltipText());
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CActivePalette2Tooltip::TooltipAnimated()
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 void CActivePalette2Tooltip::TooltipAnimated()
       
   202     {
       
   203     ProduceTooltipToScreen(ETrue);
       
   204 
       
   205     if ( !iRenderGc )
       
   206         {                	
       
   207     	SetRect(TooltipRect());
       
   208     	}
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CActivePalette2Tooltip::TooltipRect()
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 TRect CActivePalette2Tooltip::TooltipRect() const
       
   216     {
       
   217     TInt yPos = iAnchor.iY + iStyler->TootipYOffset(iModel->TooltipScreenPosition());
       
   218     return TRect(TPoint(iAnchor.iX - ((iStyler->TooltipSize().iWidth * iModel->TooltipCurrentFrame()) / iModel->TooltipTotalFrames()),
       
   219                             yPos),
       
   220                    TPoint(iAnchor.iX,
       
   221                             yPos + iStyler->TooltipSize().iHeight));
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CActivePalette2Tooltip::SetAnchor()
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 void CActivePalette2Tooltip::SetAnchor(TPoint aAnchor)
       
   229     {
       
   230     iAnchor = aAnchor;
       
   231     }
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 // CActivePalette2Tooltip::SetGc()
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CActivePalette2Tooltip::SetGc(CBitmapContext* aGc)
       
   238     {
       
   239     iRenderGc = aGc;
       
   240     MakeVisible(!aGc);
       
   241     }
       
   242     
       
   243 
       
   244 // End of File