svgtviewer/SvgtViewerPlugin/UIControlSrc/SvgtDecoratorControl.cpp
branchRCL_3
changeset 20 5fd161fa28b6
parent 0 632761c941a7
equal deleted inserted replaced
17:e52958d06c29 20:5fd161fa28b6
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Used to decorate the control on the navi pane
       
    15 *
       
    16 */
       
    17 
       
    18 //////////////////////////////////////////////////////////////////////////////
       
    19 //
       
    20 // -----> CSvgtDecoratorControl (implementation)
       
    21 //
       
    22 //////////////////////////////////////////////////////////////////////////////
       
    23 #include "SvgtDecoratorControl.h"
       
    24 #include <eikenv.h>
       
    25 
       
    26 #include <aknnavi.h>
       
    27 #include <AknsUtils.h>
       
    28 #include <gulicon.h>
       
    29 #include <eikspane.h>
       
    30 #include <avkon.mbg>
       
    31 #include <avkon.hrh>
       
    32 #include <eikimage.h>
       
    33 #include <eiklabel.h>
       
    34 
       
    35 _LIT(KAvkonMifFileName, "z:\\resource\\apps\\avkon2.mif");
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CSvgtDecoratorControl::CSvgtDecoratorControl
       
    39 // default constructor
       
    40 // -----------------------------------------------------------------------------
       
    41 CSvgtDecoratorControl::CSvgtDecoratorControl()
       
    42 	{
       
    43 	}
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CSvgtDecoratorControl::ConstructL
       
    47 // 2nd phase constructor
       
    48 // -----------------------------------------------------------------------------
       
    49 void CSvgtDecoratorControl::ConstructL()
       
    50 	{
       
    51 	iNaviPane = static_cast<CAknNavigationControlContainer*>
       
    52 	    ( CEikStatusPaneBase::Current()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
    53     //Create icon for drawing the pointer
       
    54     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    55     TRgb txtColor;
       
    56     AknsUtils::GetCachedColor( skin, txtColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG2 );
       
    57     
       
    58     iMutedIcon = AknsUtils::CreateGulIconL( 
       
    59             skin,
       
    60             KAknsIIDQgnIndiMupSpeakerMuted,
       
    61             KAvkonMifFileName,
       
    62             EMbmAvkonQgn_indi_speaker_muted,
       
    63             EMbmAvkonQgn_indi_speaker_muted_mask );
       
    64     
       
    65     iImg = new (ELeave) CEikImage;
       
    66     iImg->SetContainerWindowL(*this);
       
    67     iImg->SetPictureOwnedExternally(ETrue);
       
    68         
       
    69     iLabel = new (ELeave) CEikLabel;
       
    70     iLabel->SetContainerWindowL(*this);
       
    71     iLabel->SetFont(iEikonEnv->DenseFont());
       
    72     iLabel->OverrideColorL( EColorLabelText, txtColor );
       
    73     iLabel->SetTextL(KNullDesC);
       
    74     
       
    75     ShowVolumeMutedIcon(EFalse);
       
    76     TRect rt(iNaviPane->Rect().iTl, iNaviPane->Rect().Size());
       
    77 	SetRect(rt);
       
    78 	
       
    79 	ActivateL();	
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CSvgtDecoratorControl::~CSvgtDecoratorControl
       
    84 // Destructor
       
    85 // -----------------------------------------------------------------------------
       
    86 CSvgtDecoratorControl::~CSvgtDecoratorControl()
       
    87 	{
       
    88 	delete iImg;
       
    89 	delete iLabel;
       
    90 
       
    91 	delete iMutedIcon;
       
    92 	}
       
    93 
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CSvgtDecoratorControl::CountComponentControls
       
    98 // From CCoeControl
       
    99 // -----------------------------------------------------------------------------
       
   100 TInt CSvgtDecoratorControl::CountComponentControls() const
       
   101 	{
       
   102 	return ELastCtrl;
       
   103 	}
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSvgtDecoratorControl::ComponentControl
       
   107 // From CCoeControl
       
   108 // -----------------------------------------------------------------------------
       
   109 CCoeControl* CSvgtDecoratorControl::ComponentControl(TInt aIndex) const
       
   110 	{
       
   111 	CCoeControl* control = NULL;
       
   112 	switch (aIndex)
       
   113 	    {
       
   114 	    case EMuteImageCtrlId:
       
   115 	        control = static_cast<CCoeControl*>(iImg);
       
   116 	        break;
       
   117 	    case ETextCtrlId:
       
   118 	        control = static_cast<CCoeControl*>(iLabel);
       
   119 	        break;
       
   120 	    default:
       
   121 	        break;    
       
   122 	    }
       
   123 	return control;
       
   124 	}
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CSvgtDecoratorControl::SizeChanged
       
   128 // From CCoeControl
       
   129 // -----------------------------------------------------------------------------
       
   130 void CSvgtDecoratorControl::SizeChanged()
       
   131     {
       
   132 	CCoeControl::SizeChanged();
       
   133 	
       
   134 	const TInt KBitmapWidth = 40;
       
   135 	const TInt naviWidth = iNaviPane->Rect().Width();
       
   136 	const TInt naviHeight = iNaviPane->Rect().Height() ;
       
   137 
       
   138     AknIconUtils::SetSize( iMutedIcon->Bitmap(), TSize(KBitmapWidth, naviHeight));
       
   139     AknIconUtils::SetSize( iMutedIcon->Mask(), TSize(KBitmapWidth, naviHeight));
       
   140 	
       
   141 	TInt imgWidth = KBitmapWidth;
       
   142 	TInt lblWidth = naviWidth - imgWidth;
       
   143 	
       
   144 	TPoint imgPos;
       
   145 	TPoint lblPos(imgWidth, 0);
       
   146 	
       
   147 	iImg->SetExtent(imgPos, TSize(imgWidth, naviHeight));
       
   148 	iLabel->SetExtent(lblPos, TSize(lblWidth, naviHeight));
       
   149 
       
   150 	}
       
   151 	
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CSvgtDecoratorControl::Draw
       
   155 // From CCoeControl
       
   156 // -----------------------------------------------------------------------------
       
   157 void CSvgtDecoratorControl::Draw(const TRect& aRect) const
       
   158 	{
       
   159 	CEikBorderedControl::Draw(aRect);
       
   160 	}
       
   161 
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CSvgtDecoratorControl::OfferKeyEventL
       
   165 // From CCoeControl
       
   166 // -----------------------------------------------------------------------------
       
   167 TKeyResponse CSvgtDecoratorControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
   168 	{
       
   169 	return CCoeControl::OfferKeyEventL(aKeyEvent, aType);//EKeyWasNotConsumed;
       
   170 	}
       
   171 
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CSvgtDecoratorControl::SizeChanged
       
   175 // Sets the visibility of the mute icon in the navi pane.
       
   176 // -----------------------------------------------------------------------------
       
   177 void CSvgtDecoratorControl::ShowVolumeMutedIcon( TBool aVolumeMuted )
       
   178     {
       
   179     if(aVolumeMuted)
       
   180         {
       
   181         iImg->SetPicture(iMutedIcon->Bitmap(), iMutedIcon->Mask());
       
   182         }
       
   183     else
       
   184         {
       
   185         
       
   186         iImg->SetPicture(NULL, NULL);
       
   187         }    
       
   188 //    iImg->DrawDeferred()
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CSvgtDecoratorControl::SetTextL
       
   193 // Sets the progress text in the navi pane.
       
   194 // -----------------------------------------------------------------------------
       
   195 void CSvgtDecoratorControl::SetTextL( const TDesC& aText)
       
   196     {
       
   197     iLabel->SetTextL( aText );
       
   198 //    iLabel->DrawDeferred()
       
   199     }