uifw/AvKon/src/aknnoteattributes.cpp
changeset 0 2f259fa3e83a
child 51 fcdfafb36fe7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Stores attributes of note control. Since these attributes are
       
    15 *                sometimes stored by the dialog before constructing the 
       
    16 *                control, this class is the interface for passing attributes 
       
    17 *                from the dialog to the control.
       
    18 *
       
    19 */
       
    20 
       
    21 #include <barsread.h>
       
    22 #include <eikimage.h>
       
    23 #include <eiklabel.h>
       
    24 #include <eikprogi.h>
       
    25 
       
    26 #include <avkon.hrh>
       
    27 #include <avkon.mbg>
       
    28 #include <avkon.rsg>
       
    29 
       
    30 #include "AknPanic.h"
       
    31 #include "aknconsts.h"
       
    32 
       
    33 #include <aknprogresstimer.h>
       
    34 #include <AknBitmapAnimation.h>
       
    35 
       
    36 #include "aknnotecontrol.h"
       
    37 #include <aknnoteattributes.h>
       
    38 #include "akntextcontrol.h"
       
    39 
       
    40 #include <AknsFrameBackgroundControlContext.h>
       
    41 #include <AknsUtils.h>
       
    42 #include <apgicnfl.h>
       
    43 
       
    44 #include <AknsDrawUtils.h>
       
    45 #include <AknsConstants.h>
       
    46 
       
    47 #include <AknPictographInterface.h>
       
    48 #include <AknPictographDrawerInterface.h>
       
    49 
       
    50 #include <aknappui.h>
       
    51 #include <aknlayoutscalable_avkon.cdl.h>
       
    52 
       
    53 // FIXME: Experimental heuristics for finding out popup context from image/animation
       
    54 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
    55 #include <akntransitionutils.h>
       
    56 #endif
       
    57 
       
    58 /**
       
    59  * This constructor is called by the dialog
       
    60  */
       
    61 CAknNoteAttributes::CAknNoteAttributes() : iSkinIdForImage(KAknsIIDNone)
       
    62     {
       
    63     InvalidateLayout();
       
    64     }
       
    65 
       
    66 /**
       
    67  * This constructor is called by the control
       
    68  */
       
    69 CAknNoteAttributes::CAknNoteAttributes(CAknNoteControl* aControl) : iNoteControl(aControl),  
       
    70     iSkinIdForImage(KAknsIIDNone)
       
    71     {
       
    72     InvalidateLayout();
       
    73     }
       
    74 
       
    75 CAknNoteAttributes::~CAknNoteAttributes()
       
    76     {
       
    77     delete iNoteText;
       
    78     if ( iImage && iImage->IsPictureOwnedExternally() )
       
    79         {
       
    80         delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
    81         }
       
    82     delete iImage;
       
    83     
       
    84     delete iImageFile;
       
    85     
       
    86     if ( iIcon && iIcon->IsPictureOwnedExternally() )
       
    87         {
       
    88         delete ((CApaMaskedBitmap*) iIcon->Bitmap());
       
    89         }   
       
    90     delete iIcon;
       
    91 
       
    92     delete iProgressBar;
       
    93 
       
    94     delete iTimer;    
       
    95     delete iAnimation;
       
    96 
       
    97     delete iBgContext; 
       
    98     delete iBrushAndPenContext;
       
    99     }
       
   100 
       
   101 /*
       
   102 * Copy attributes of aAttributes
       
   103 * Called by dialog during prelayoutdyninit to transfer 
       
   104 * attributes stored locally. Trasfer pointer ownership
       
   105 */
       
   106 CAknNoteAttributes& CAknNoteAttributes::operator=(CAknNoteAttributes& aAttributes)
       
   107     {
       
   108     if (&aAttributes == this)
       
   109         return *this;
       
   110 
       
   111     if (aAttributes.iNoteText && iNoteText)
       
   112         *iNoteText = *aAttributes.iNoteText;
       
   113 
       
   114 #define __TRANSFER_PTR_(P1,P2)  if (P1) { delete P2; P2 = P1; P1 = NULL; } 
       
   115 
       
   116     if ( aAttributes.iImage)
       
   117         {
       
   118         if ( iImage && iImage->IsPictureOwnedExternally())
       
   119             {
       
   120             delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
   121             }
       
   122         __TRANSFER_PTR_(aAttributes.iImage,iImage);
       
   123         }
       
   124 
       
   125     if ( aAttributes.iIcon )
       
   126         {
       
   127         if ( iIcon && iIcon->IsPictureOwnedExternally() ) 
       
   128             {
       
   129             delete ((CApaMaskedBitmap*) iIcon->Bitmap());
       
   130             }
       
   131         __TRANSFER_PTR_(aAttributes.iIcon,iIcon);
       
   132         }   
       
   133 
       
   134     __TRANSFER_PTR_(aAttributes.iProgressBar,iProgressBar);
       
   135 
       
   136     __TRANSFER_PTR_(aAttributes.iTimer,iTimer);
       
   137 
       
   138     if (aAttributes.iAnimation)
       
   139         {
       
   140         iAnimationID = aAttributes.iAnimationID;
       
   141         }
       
   142 
       
   143     __TRANSFER_PTR_(aAttributes.iAnimation,iAnimation);
       
   144 
       
   145 
       
   146 #undef __TRANSFER_PTR_
       
   147     
       
   148     iFlags.iFlags |= aAttributes.iFlags.iFlags; 
       
   149 
       
   150     //Flags that are cleared via the dialog API are stored in iClearFlags
       
   151     //and are used to cancel any flags that might have been set in the 
       
   152     //resource file (API has priority over resource file)
       
   153     iFlags.iFlags &= ~(aAttributes.iClearFlags.iFlags); 
       
   154     TRAP_IGNORE(TransferToControlL());
       
   155         
       
   156     InvalidateLayout();
       
   157     return *this;
       
   158     }
       
   159 
       
   160 /**
       
   161 * Transfer CCoeControl derived classed to CAknNoteControl by calling
       
   162 * SetContainerWindowL for all CCoeControl owned classes
       
   163 */
       
   164 void CAknNoteAttributes::TransferToControlL()
       
   165     {
       
   166     if (!iNoteControl)
       
   167         return;
       
   168     
       
   169     if (iNoteText)
       
   170         {
       
   171         iNoteText->SetContainerWindowL(*iNoteControl);
       
   172         
       
   173         TCallBack cb( StaticPictographCallBack, this );
       
   174         iNoteText->SetPictographCallBackL( cb );
       
   175         }
       
   176 
       
   177     if (iAnimation)
       
   178         iAnimation->SetContainerWindowL(*iNoteControl);
       
   179     
       
   180     if (iImage)
       
   181         iImage->SetContainerWindowL(*iNoteControl);
       
   182     
       
   183     if (iIcon)
       
   184         iIcon->SetContainerWindowL(*iNoteControl);
       
   185 
       
   186     if (iProgressBar)
       
   187         iProgressBar->SetContainerWindowL(*iNoteControl);
       
   188     }
       
   189 
       
   190 void CAknNoteAttributes::TransferToControlL(CCoeControl* aControl)
       
   191     {
       
   192     if (iNoteControl && aControl)
       
   193         aControl->SetContainerWindowL(*iNoteControl);
       
   194     }
       
   195 
       
   196 
       
   197 /*
       
   198 * Construct attributes using resource file information
       
   199 * Mainly called by control during initialisation
       
   200 */ 
       
   201 void CAknNoteAttributes::ConstructFromResourceL(TResourceReader& aRes)
       
   202     {
       
   203     delete iNoteText;
       
   204     iNoteText = NULL;
       
   205 	
       
   206 	delete iImageFile;
       
   207 	iImageFile = NULL;
       
   208 
       
   209     if ( !iBrushAndPenContext && iNoteControl )
       
   210         {
       
   211         iBrushAndPenContext=CCoeBrushAndPenContext::NewL();
       
   212         iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   213         iNoteControl->SetControlContext(iBrushAndPenContext);        
       
   214         }
       
   215     iNoteText = CAknTextControl::NewL(CAknText::ENotFormatted);
       
   216     iNoteText->ConstructFromResourceL(aRes);
       
   217 
       
   218     TCallBack cb( StaticPictographCallBack, this );
       
   219     iNoteText->SetPictographCallBackL( cb );
       
   220 
       
   221     TransferToControlL(iNoteText);
       
   222     
       
   223     const TPtrC imageFile = aRes.ReadTPtrC();
       
   224     iImageFile = imageFile.AllocL();
       
   225     iImageId = aRes.ReadInt16();
       
   226     iImageMask = aRes.ReadInt16();
       
   227     
       
   228     const TPtrC iconFile = aRes.ReadTPtrC();
       
   229     const TInt iconId = aRes.ReadInt16();
       
   230     const TInt iconMask = aRes.ReadInt16();
       
   231     TInt animationId = aRes.ReadUint32();
       
   232     TInt flagIndexes = aRes.ReadInt16();
       
   233     
       
   234     TInt majorSkinIdForImage = EAknsMajorNone;
       
   235     TInt minorSkinIdForImage = EAknsMinorNone;
       
   236     
       
   237     iFlags.SetValue(flagIndexes);
       
   238        
       
   239     // Checks whether note is using AVKON_NOTE_SKINNED resource.
       
   240     if (iFlags.IsSet(ENoteWithSkinnableGraphics))
       
   241         {
       
   242         majorSkinIdForImage = aRes.ReadUint32();
       
   243         minorSkinIdForImage = aRes.ReadUint32();
       
   244         }
       
   245 
       
   246     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   247     
       
   248     if (iImageFile->CompareF(KNullDesC) != 0)
       
   249         {
       
   250         iImage = new(ELeave) CEikImage;
       
   251         
       
   252         // Check for skin icon.
       
   253         if (iFlags.IsSet(ENoteWithSkinnableGraphics))
       
   254             {
       
   255             iSkinIdForImage.Set(majorSkinIdForImage, minorSkinIdForImage);
       
   256             }
       
   257         else
       
   258             {
       
   259             iSkinIdForImage = GetSkinnedBitmapID(iImageId);
       
   260             }
       
   261 
       
   262         CFbsBitmap* bitmap = NULL;
       
   263         CFbsBitmap* mask = NULL;
       
   264        
       
   265         AknsUtils::CreateIconL(
       
   266             skin, iSkinIdForImage,
       
   267             bitmap, mask,
       
   268             *iImageFile,
       
   269             iImageId, iImageMask);
       
   270 
       
   271         iImage->SetPicture(bitmap,mask);
       
   272 
       
   273         TransferToControlL(iImage);
       
   274         
       
   275 // FIXME: Experimental heuristics for finding out popup context from image/animation
       
   276 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   277         // Check if the image file is the standard one
       
   278         if ( iImageFile->CompareF( AknIconUtils::AvkonIconFileName() ) == 0 )
       
   279             {
       
   280             switch ( iImageId )
       
   281                 {
       
   282                 case EMbmAvkonQgn_note_ok:
       
   283                     CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   284                         ( TAny* )KGfxConfirmationNoteControlUid.iUid );
       
   285                     break;
       
   286                 case EMbmAvkonQgn_note_error:
       
   287                     CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   288                         ( TAny* )KGfxErrorNoteControlUid.iUid );
       
   289                     break;
       
   290                 case EMbmAvkonQgn_note_info:
       
   291                     CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   292                         ( TAny* )KGfxInformationNoteControlUid.iUid );
       
   293                     break;
       
   294                 case EMbmAvkonQgn_note_warning:
       
   295                     CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   296                         ( TAny* )KGfxWarningNoteControlUid.iUid );
       
   297                     break;
       
   298                 case EMbmAvkonQgn_note_progress:
       
   299                     CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   300                         ( TAny* )KGfxWaitNoteControlUid.iUid );
       
   301                     break;
       
   302                 default:
       
   303                     break;
       
   304                 }
       
   305             }
       
   306 #endif      
       
   307         }
       
   308 
       
   309     if (iconFile.CompareF(KNullDesC) != 0)
       
   310         {
       
   311         iIcon = new(ELeave) CEikImage;
       
   312         TAknsItemID id = GetSkinnedBitmapID(iconId);
       
   313 
       
   314         CFbsBitmap* bitmap = NULL;
       
   315         CFbsBitmap* mask = NULL;
       
   316        
       
   317         AknsUtils::CreateIconL(
       
   318             skin, id,
       
   319             bitmap, mask,
       
   320             iconFile,
       
   321             iconId, iconMask);
       
   322          
       
   323         iIcon->SetPicture(bitmap,mask);
       
   324         
       
   325         TransferToControlL(iIcon);
       
   326         }
       
   327 
       
   328     if (animationId != 0)
       
   329         {
       
   330         if (!iAnimation)
       
   331             {// no animation previously set
       
   332             SetAnimationL(animationId);
       
   333             }
       
   334         }
       
   335         
       
   336     if ( !iBgContext)
       
   337         {
       
   338         iBgContext = CAknsFrameBackgroundControlContext::NewL( 
       
   339             KAknsIIDQsnFrPopup, TRect(0,0,1,1), TRect(0,0,1,1), ETrue);
       
   340         }
       
   341     }
       
   342 
       
   343 /**
       
   344 * Set methods here, mainly used by CAknNoteControl exported API
       
   345 * In brief, this is a private avkon implementation of the
       
   346 * note control exported API (Set methods). The reason for
       
   347 * implementing this API here is because the note dialog usually
       
   348 * needs to call this API before the control is constructed.
       
   349 * Therefore, the dialog can now use this API and then transfer
       
   350 * the attributes from its locall instance of CAknNoteAttributes to
       
   351 * an instance of CAknNoteAttributes owned by the control. This
       
   352 * is done via the TransferL method as soon as the control as been 
       
   353 * initialised.
       
   354 *
       
   355 */  
       
   356     
       
   357 /**
       
   358  * Set a new animation 
       
   359  *
       
   360  * Redo layout and full redraw (partial layout and redraw left
       
   361  * for future extensions)
       
   362  */
       
   363 void CAknNoteAttributes::SetAnimationL(TInt aResourceId)
       
   364     {
       
   365     if (aResourceId <= 0)
       
   366         return;
       
   367 
       
   368     delete iAnimation;
       
   369     iAnimation = NULL;
       
   370     iAnimation = CAknBitmapAnimation::NewL();
       
   371 
       
   372     iAnimationID = aResourceId;
       
   373 
       
   374     if (iAnimationID == R_QGN_GRAF_WAIT_BAR_ANIM)
       
   375         {
       
   376         iAnimation->SetScaleModeForAnimationFrames(EAspectRatioNotPreserved);
       
   377         }
       
   378 
       
   379     CCoeEnv* coe = CCoeEnv::Static();
       
   380 
       
   381     TAknsItemID iid;
       
   382     iid.Set( EAknsMajorAvkon, aResourceId );
       
   383     
       
   384     TBool animation ( EFalse );
       
   385     TRAPD( err, animation = iAnimation->ConstructFromSkinL ( iid ) );
       
   386     
       
   387     if ( err != KErrNone || !animation )
       
   388         {
       
   389         TResourceReader readerForAnimation;
       
   390         coe->CreateResourceReaderLC(readerForAnimation,aResourceId);
       
   391         iAnimation->ConstructFromResourceL(readerForAnimation);
       
   392         CleanupStack::PopAndDestroy(); // readerForAnimation
       
   393         }
       
   394 
       
   395 // FIXME: Experimental heuristics for finding out popup context from image/animation
       
   396 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   397     switch ( aResourceId )
       
   398         {
       
   399         case EAknsMinorQgnNoteOkAnim:
       
   400             CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   401                 ( TAny* )KGfxConfirmationNoteControlUid.iUid );
       
   402             break;
       
   403         case EAknsMinorQgnNoteErrorAnim:
       
   404             CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   405                 ( TAny* )KGfxErrorNoteControlUid.iUid );
       
   406             break;
       
   407         case EAknsMinorQgnNoteInfoAnim:
       
   408             CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   409                 ( TAny* )KGfxInformationNoteControlUid.iUid );
       
   410             break;
       
   411         case EAknsMinorQgnNoteWarningAnim:
       
   412             CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   413                 ( TAny* )KGfxWarningNoteControlUid.iUid );
       
   414             break;
       
   415         case EAknsMinorQgnGrafBarWaitAnim:
       
   416             CAknTransitionUtils::SetData( ( TInt )iNoteControl, 
       
   417                 ( TAny* )KGfxWaitNoteControlUid.iUid );
       
   418             break;
       
   419         default:
       
   420             break;
       
   421         }
       
   422 #endif
       
   423     
       
   424     // If the image exists, but the dialog does not need it (is neither progress
       
   425     // nor wait dialog), delete the image
       
   426     if (iImage && iNoteControl->NoteLayout() != EProgressLayout &&
       
   427         iNoteControl->NoteLayout() != EWaitLayout )
       
   428         {
       
   429         delete iImage;
       
   430         iImage = NULL;
       
   431         }        
       
   432 
       
   433     TransferToControlL(iAnimation);
       
   434     if (iNoteControl)
       
   435         {
       
   436         iNoteControl->ParseTextL();
       
   437         }
       
   438     InvalidateLayout();    
       
   439     }
       
   440 
       
   441 void CAknNoteAttributes::StartAnimationL()
       
   442     {
       
   443     if (iAnimation)
       
   444         {
       
   445         SetAnimationBackGroundFrameL();
       
   446         iAnimation->StartAnimationL();
       
   447         iAnimation->AnimationHasStarted( ETrue );
       
   448         iFlags.Set(ENoteAnimationStarted);
       
   449         }
       
   450     }
       
   451 
       
   452 TInt CAknNoteAttributes::CancelAnimation()
       
   453     {
       
   454     iFlags.Clear(ENoteAnimationStarted);
       
   455     if (iAnimation)
       
   456         return iAnimation->CancelAnimation();
       
   457     else
       
   458         return KErrGeneral;
       
   459     }
       
   460 
       
   461 /**
       
   462  * Set a new image 
       
   463  *
       
   464  * Redo layout and full redraw (partial layout and redraw left
       
   465  * for future extensions)
       
   466  */
       
   467 void CAknNoteAttributes::SetImageL(CEikImage* aImage)
       
   468     { 
       
   469     TSize oldSize; 
       
   470     TRect oldRect;
       
   471 
       
   472     if (iImage)
       
   473         {
       
   474         oldSize = iImage->Bitmap()->SizeInPixels();
       
   475         oldRect = iImage->Rect();
       
   476         // skinned bitmaps behave badly..
       
   477         if ( iImage->IsPictureOwnedExternally() )
       
   478             {
       
   479             delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
   480             }
       
   481         }
       
   482 
       
   483     delete iImage;
       
   484     iImage = aImage;
       
   485 
       
   486     // if animation is already set and it is not a waitbar - delete it
       
   487     if (iNoteControl && iNoteControl->NoteLayout() != EProgressLayout && iNoteControl->NoteLayout() != EWaitLayout )
       
   488         {
       
   489         delete iAnimation;
       
   490         iAnimation = NULL;
       
   491         }    
       
   492 
       
   493     if (iImage)
       
   494         {
       
   495         if (iNoteControl)
       
   496             { 
       
   497             TransferToControlL(iImage);
       
   498             iNoteControl->ReduceImageIfNeeded();
       
   499 
       
   500             TSize size(iImage->Bitmap()->SizeInPixels());
       
   501             if (size != TSize(0,0) && size == oldSize)
       
   502                 {
       
   503                 iImage->SetRect(oldRect);
       
   504                 iImage->ActivateL();
       
   505                 iImage->DrawNow();
       
   506                 }
       
   507             else
       
   508                 {
       
   509                 iNoteControl->ParseTextL();
       
   510                 InvalidateLayout();
       
   511                 }
       
   512             }
       
   513         }
       
   514     }
       
   515 
       
   516 /**
       
   517  * Set a new icon
       
   518  *
       
   519  * Redo layout and full redraw (partial layout and redraw left
       
   520  * for future extensions)
       
   521  */
       
   522 void CAknNoteAttributes::SetIconL(CEikImage* aIcon)
       
   523     {
       
   524     if ( iIcon && iIcon->IsPictureOwnedExternally() )
       
   525         {
       
   526         delete ((CApaMaskedBitmap*) iIcon->Bitmap());
       
   527         }   
       
   528     delete iIcon;
       
   529     iIcon = aIcon;
       
   530 
       
   531     TransferToControlL(iIcon);
       
   532     if (iNoteControl)
       
   533         {
       
   534         iNoteControl->ParseTextL();
       
   535         }
       
   536     InvalidateLayout();
       
   537     }
       
   538 
       
   539 //
       
   540 // PROGRESS RELATED METHODS
       
   541 //
       
   542 
       
   543 void CAknNoteAttributes::SetFinalProgressValue(TInt aValue)
       
   544     {
       
   545     if (iProgressBar)
       
   546         iProgressBar->SetFinalValue(aValue);
       
   547     }
       
   548 
       
   549 TInt CAknNoteAttributes::IncrementBarsAndDraw(TInt aIncrement)
       
   550     {
       
   551     if (!iProgressBar)
       
   552         return 0;
       
   553 
       
   554     TInt returnValue = 1;
       
   555     iProgressBar->IncrementAndDraw(aIncrement);
       
   556     CEikProgressInfo::SInfo info = iProgressBar->Info();
       
   557     if (iProgressBar->CurrentValue() == info.iFinalValue)
       
   558         returnValue = 0;
       
   559     return returnValue;
       
   560     }
       
   561 
       
   562 void CAknNoteAttributes::CreateProgressBarL()
       
   563     {
       
   564     if (iProgressBar)
       
   565         {
       
   566         return;
       
   567         }
       
   568 
       
   569     TInt numLines = iNoteText->NumberOfLines();
       
   570 
       
   571     // New parameter added to Wait_or_progress_note_pop_up_window_elements_Line_2 layout API.
       
   572     TInt tIndex = 0;
       
   573     if (numLines == 3)
       
   574         {
       
   575         tIndex = 1;
       
   576         }
       
   577     if (numLines >= 4)
       
   578         {
       
   579         tIndex = 2;
       
   580         }
       
   581     TRect mainPane = iAvkonAppUi->ClientRect();
       
   582     TAknLayoutRect parent;
       
   583     
       
   584     AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() );
       
   585     TInt variety( 0 );
       
   586     
       
   587     if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight )
       
   588         {
       
   589         variety = 3;
       
   590         }
       
   591     else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft )
       
   592         {
       
   593         variety = 6;
       
   594         }
       
   595     else
       
   596         {
       
   597         variety = 0;
       
   598         }
       
   599         
       
   600     parent.LayoutRect(mainPane, AknLayoutScalable_Avkon::popup_note_wait_window( variety + tIndex ));
       
   601     
       
   602     TAknLayoutRect layRect;
       
   603     layRect.LayoutRect(parent.Rect(), AKN_LAYOUT_WINDOW_Wait_or_progress_note_pop_up_window_elements_Line_2(tIndex));
       
   604         
       
   605     CEikProgressInfo::SInfo info;
       
   606     info.iHeight = layRect.Rect().Height();//lay.iH;
       
   607     info.iWidth = layRect.Rect().Width();//lay.iW;
       
   608     
       
   609     info.iFinalValue = 1;
       
   610     info.iSplitsInBlock = 0;
       
   611     info.iTextType = EEikProgressTextNone;
       
   612     
       
   613     iProgressBar = new(ELeave) CEikProgressInfo(info);
       
   614     iProgressBar->ConstructL();
       
   615     
       
   616     TransferToControlL(iProgressBar);
       
   617     InvalidateLayout();
       
   618     }
       
   619 
       
   620 
       
   621 //
       
   622 // LABEL TEXT RELEATED SET METHODS
       
   623 //
       
   624 
       
   625 void CAknNoteAttributes::SetTextPluralityL(TBool aIsPlural)
       
   626     {
       
   627     if (!iNoteText)
       
   628         iNoteText = CAknTextControl::NewL();
       
   629 
       
   630     TInt numLines = iNoteText->NumberOfLines();
       
   631     iNoteText->SetTextPluralityL(aIsPlural);
       
   632     AttemptOptimizedTextDrawingL(numLines);
       
   633     }
       
   634 
       
   635 void CAknNoteAttributes::SetTextNumberL(TInt aNumber)
       
   636     {
       
   637     if (!iNoteText)
       
   638         iNoteText = CAknTextControl::NewL();
       
   639 
       
   640     TInt numLines = iNoteText->NumberOfLines();
       
   641     iNoteText->SetTextNumberL(aNumber);
       
   642     AttemptOptimizedTextDrawingL(numLines);
       
   643     }
       
   644 
       
   645 void CAknNoteAttributes::SetTextL(const TDesC& aText)
       
   646     {
       
   647     if (!iNoteText)
       
   648         iNoteText = CAknTextControl::NewL();
       
   649 
       
   650     TInt numLines = iNoteText->NumberOfLines();
       
   651     iNoteText->SetTextL(aText);
       
   652     AttemptOptimizedTextDrawingL(numLines);
       
   653     }
       
   654 
       
   655 void CAknNoteAttributes::SetTextL(const TDesC& aText, TInt aLineNum, const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths )
       
   656     {
       
   657     if (!iNoteText)
       
   658         iNoteText = CAknTextControl::NewL();
       
   659 
       
   660     TInt numLines = iNoteText->NumberOfLines();
       
   661 
       
   662     iNoteText->SetTextL(aText, aLineNum, aFont, aLineWidths);
       
   663     AttemptOptimizedTextDrawingL(numLines);
       
   664     }
       
   665 
       
   666 TPtrC CAknNoteAttributes::Text() const
       
   667     {
       
   668     if (iNoteText)
       
   669         return iNoteText->Text();
       
   670     return TPtrC(0,0);
       
   671     }
       
   672 
       
   673 void CAknNoteAttributes::ParseTextL(const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths)
       
   674     {    
       
   675     if (!iNoteText)
       
   676         return;
       
   677 
       
   678     CAknTextControl::TWrapMethod mode;
       
   679 
       
   680     if (iFlags.IsSet(ENoteDoNotAllocateMem))
       
   681         {
       
   682         mode = CAknTextControl::ENoAllocation;
       
   683         }
       
   684     else if (iFlags.IsSet(ENoteNoTextProcessing))
       
   685         {
       
   686         mode = CAknTextControl::ENoProcessing;
       
   687         }
       
   688     else if (iFlags.IsSet(ENoteNoTextWrapping))
       
   689         {
       
   690         mode = CAknTextControl::ELine;
       
   691         }
       
   692     else
       
   693         {
       
   694         mode = CAknTextControl::EWord;
       
   695         }
       
   696 
       
   697     iNoteText->ParseTextL(aFont,aLineWidths,mode);
       
   698     }
       
   699 
       
   700 void CAknNoteAttributes::AttemptOptimizedTextDrawingL(TInt aOldNumberOfLines)
       
   701     {
       
   702     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   703     MAknsControlContext* cc = iBgContext;
       
   704     
       
   705     if (iNoteControl)
       
   706         {
       
   707         iNoteControl->ParseTextL();
       
   708         if (aOldNumberOfLines == iNoteText->NumberOfLines() && iAllowOptimizedDrawing )
       
   709             {
       
   710             for (TInt i=0; i < iNoteText->NumberOfLines(); i++)
       
   711                 {
       
   712                 if (iNoteText->LineModified(i))
       
   713                     {
       
   714                     TRect lineRect = iNoteText->Line(i)->Rect();
       
   715                     iNoteControl->Window().Invalidate( lineRect );
       
   716                     iNoteControl->ActivateGc();
       
   717                     iNoteControl->Window().BeginRedraw( lineRect );
       
   718 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS
       
   719                     AknsDrawUtils::Background( 
       
   720                         skin, cc, iNoteControl, iNoteControl->SystemGc(), iNoteText->Line(i)->Rect() );
       
   721 #else                   
       
   722                     AknsDrawUtils::Background( 
       
   723                         skin, cc, iNoteControl, iNoteControl->iCoeEnv->SystemGc(), iNoteText->Line(i)->Rect() );
       
   724 #endif
       
   725                     iNoteText->Line(i)->Draw( lineRect );
       
   726 
       
   727                     iNoteControl->Window().EndRedraw();
       
   728                     iNoteControl->DeactivateGc();
       
   729 
       
   730                     iNoteText->SetLineModified(i,EFalse);
       
   731                     }
       
   732                 }
       
   733             }
       
   734         else
       
   735             {
       
   736             InvalidateLayout(); 
       
   737             }
       
   738         }
       
   739     }
       
   740 
       
   741 TBool CAknNoteAttributes::IsLayoutNeeded(const TLayoutType& aType) const
       
   742     {
       
   743     __ASSERT_DEBUG(aType == EControl || aType == EDialog ,Panic(EAknPanicInvalidValue));
       
   744     if (aType == EControl)
       
   745         {
       
   746         return iFlags.IsSet(ENoteNeedLayoutControl);
       
   747         }
       
   748     else if (aType == EDialog)
       
   749         {
       
   750         return iFlags.IsSet(ENoteNeedLayoutDialog);
       
   751         }
       
   752     return EFalse; 
       
   753     }
       
   754 
       
   755 void  CAknNoteAttributes::SetLayoutDone(const TLayoutType& aType)
       
   756     {
       
   757     __ASSERT_DEBUG(aType == EControl || aType == EDialog ,Panic(EAknPanicInvalidValue));
       
   758     if (aType == EControl)
       
   759         {
       
   760         iFlags.Clear(ENoteNeedLayoutControl);
       
   761         }
       
   762     else if (aType == EDialog)
       
   763         {
       
   764         iFlags.Clear(ENoteNeedLayoutDialog);
       
   765         }
       
   766     }
       
   767 
       
   768 void CAknNoteAttributes::InvalidateLayout()
       
   769     {
       
   770     iFlags.Set(ENoteNeedLayoutControl);
       
   771     iFlags.Set(ENoteNeedLayoutDialog);
       
   772     }
       
   773 
       
   774 EXPORT_C TAknsItemID CAknNoteAttributes::GetSkinnedBitmapID(TInt aIcon)
       
   775     {
       
   776     TAknsItemID id;
       
   777     id.Set(0,0);
       
   778 
       
   779     switch(aIcon)
       
   780         {
       
   781         case EMbmAvkonQgn_note_info:
       
   782             id = KAknsIIDQgnNoteInfo;
       
   783             break;
       
   784 
       
   785         case EMbmAvkonQgn_note_error:
       
   786             id = KAknsIIDQgnNoteError;
       
   787             break;
       
   788 
       
   789         case EMbmAvkonQgn_note_ok:
       
   790             id = KAknsIIDQgnNoteOk;
       
   791             break;
       
   792 
       
   793         case EMbmAvkonQgn_note_warning:
       
   794             id = KAknsIIDQgnNoteWarning;
       
   795             break;
       
   796         
       
   797         case EMbmAvkonQgn_note_query:
       
   798             id = KAknsIIDQgnNoteQuery; 
       
   799             break;
       
   800 
       
   801         case EMbmAvkonQgn_note_progress:
       
   802             id = KAknsIIDQgnNoteProgress;
       
   803             break;
       
   804 
       
   805         case EMbmAvkonQgn_note_alarm_calendar:
       
   806             id = KAknsIIDQgnNoteAlarmCalendar;
       
   807             break;
       
   808 
       
   809         case EMbmAvkonQgn_note_alarm_clock:
       
   810             id = KAknsIIDQgnNoteAlarmClock;
       
   811             break;
       
   812 
       
   813         case EMbmAvkonQgn_note_alarm_misc:
       
   814             id = KAknsIIDQgnNoteAlarmMisc;
       
   815             break;
       
   816         
       
   817         case EMbmAvkonQgn_note_batt_charging:
       
   818             id = KAknsIIDQgnNoteBattCharging;
       
   819             break;
       
   820         
       
   821         case EMbmAvkonQgn_note_batt_full:
       
   822             id = KAknsIIDQgnNoteBattFull;
       
   823             break;
       
   824         
       
   825         case EMbmAvkonQgn_note_batt_low:
       
   826             id = KAknsIIDQgnNoteBattLow;
       
   827             break;
       
   828         
       
   829         case EMbmAvkonQgn_note_batt_not_charging:
       
   830             id = KAknsIIDQgnNoteBattNotCharging;
       
   831             break;
       
   832 
       
   833         case EMbmAvkonQgn_note_batt_recharge:
       
   834             id = KAknsIIDQgnNoteBattRecharge;
       
   835             break;
       
   836 
       
   837         case EMbmAvkonQgn_note_erased:
       
   838             id = KAknsIIDQgnNoteErased;
       
   839             break;
       
   840 
       
   841         case EMbmAvkonQgn_note_keyguard:
       
   842             id = KAknsIIDQgnNoteKeyguard;
       
   843             break;
       
   844 
       
   845         case EMbmAvkonQgn_note_call:
       
   846             id = KAknsIIDQgnNoteCall;
       
   847             break;
       
   848 
       
   849         case EMbmAvkonQgn_note_copy:
       
   850             id = KAknsIIDQgnNoteCopy;
       
   851             break;
       
   852 
       
   853         case EMbmAvkonQgn_note_im_message:
       
   854             id = KAknsIIDQgnNoteImMessage;
       
   855             break;
       
   856 
       
   857         case EMbmAvkonQgn_note_mail:
       
   858             id = KAknsIIDQgnNoteMail;
       
   859             break;
       
   860 
       
   861         case EMbmAvkonQgn_note_message:
       
   862             id = KAknsIIDQgnNoteMessage;
       
   863             break;
       
   864 
       
   865         case EMbmAvkonQgn_note_mms:
       
   866             id = KAknsIIDQgnNoteMms;
       
   867             break;
       
   868 
       
   869         case EMbmAvkonQgn_note_move:
       
   870             id = KAknsIIDQgnNoteMove;
       
   871             break;
       
   872 
       
   873         case EMbmAvkonQgn_note_remote_mailbox:
       
   874             id = KAknsIIDQgnNoteRemoteMailbox;
       
   875             break;
       
   876 
       
   877         case EMbmAvkonQgn_note_sml:
       
   878             id = KAknsIIDQgnNoteSml;
       
   879             break;
       
   880 
       
   881         case EMbmAvkonQgn_note_voice:
       
   882             id = KAknsIIDQgnNoteVoice;
       
   883             break;
       
   884 
       
   885         case EMbmAvkonQgn_note_voice_found:
       
   886             id = KAknsIIDQgnNoteVoiceFound;
       
   887             break;
       
   888 
       
   889         case EMbmAvkonQgn_note_warr:
       
   890             id = KAknsIIDQgnNoteWarr;
       
   891             break;
       
   892 
       
   893         default:
       
   894             break;
       
   895         }
       
   896     return id;
       
   897     }
       
   898 
       
   899 void CAknNoteAttributes::SetAnimationBackGroundFrameL()
       
   900     {
       
   901     // R_QGN_GRAF_WAIT_BAR_ANIM case is OK without background frame.
       
   902     if (iAnimation && iAnimationID != R_QGN_GRAF_WAIT_BAR_ANIM)
       
   903         {
       
   904         // Not set background frame, if there is only one frame in animation.
       
   905         CBitmapAnimClientData *animClientData = iAnimation->BitmapAnimData();
       
   906         if (animClientData != NULL && animClientData->FrameArray().Count() <= 1)
       
   907             {
       
   908             return;
       
   909             }
       
   910     
       
   911         const TDisplayMode displayMode( CCoeEnv::Static()->ScreenDevice()->DisplayMode() );
       
   912 
       
   913         // Create skinned background frame
       
   914         
       
   915         CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
       
   916         CleanupStack::PushL(bitmap);
       
   917         
       
   918         User::LeaveIfError( bitmap->Create( iAnimation->Rect().Size(), displayMode ) );
       
   919         
       
   920         CFbsBitmapDevice* doubleBufferDev = CFbsBitmapDevice::NewL( bitmap );
       
   921         CleanupStack::PushL(doubleBufferDev);    
       
   922         
       
   923         CFbsBitGc* doubleBufferGc = 0;
       
   924         User::LeaveIfError( doubleBufferDev->CreateContext( doubleBufferGc ) );    
       
   925         CleanupStack::PushL(doubleBufferGc);    
       
   926         
       
   927         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   928         MAknsControlContext* cc = iBgContext;
       
   929         
       
   930         AknsDrawUtils::DrawBackground( skin, cc, iNoteControl, *doubleBufferGc,
       
   931             TPoint(0,0), iAnimation->Rect(), KAknsDrawParamDefault );
       
   932 #if 0              
       
   933         // waitbar background border
       
   934         if ( iAnimationID == R_QGN_GRAF_WAIT_BAR_ANIM )
       
   935             {   
       
   936             CFbsBitmap* frameL = NULL;
       
   937             CFbsBitmap* frameCenter = NULL;
       
   938             CFbsBitmap* frameR = NULL;
       
   939             CFbsBitmap* lMask = NULL;
       
   940             CFbsBitmap* centerMask = NULL;
       
   941             CFbsBitmap* rMask = NULL;
       
   942             
       
   943             AknIconUtils::CreateIconLC( frameL, lMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_side_l, EMbmAvkonQgn_graf_bar_frame_side_l_mask  );
       
   944             AknIconUtils::CreateIconLC( frameCenter, centerMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_center, EMbmAvkonQgn_graf_bar_frame_center_mask);
       
   945             AknIconUtils::CreateIconLC( frameR, rMask, KAvkonBitmapFile, EMbmAvkonQgn_graf_bar_frame_side_r, EMbmAvkonQgn_graf_bar_frame_side_r_mask  );
       
   946 
       
   947             TAknLayoutRect frameGraphicLayout;
       
   948             
       
   949             frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g1() );            
       
   950             User::LeaveIfError( AknIconUtils::SetSize( frameL, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) );
       
   951 
       
   952             frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g2() );
       
   953             User::LeaveIfError( AknIconUtils::SetSize( frameCenter, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) );
       
   954 
       
   955             frameGraphicLayout.LayoutRect( iAnimation->Rect(), AknLayoutScalable_Avkon::wait_border_pane_g3() );
       
   956             User::LeaveIfError( AknIconUtils::SetSize( frameR, frameGraphicLayout.Rect().Size(), EAspectRatioNotPreserved ) );
       
   957                
       
   958             TPoint centerPoint( frameL->SizeInPixels().iWidth, 0 );
       
   959             TPoint rightPoint( centerPoint.iX + frameCenter->SizeInPixels().iWidth, 0 );
       
   960 
       
   961             doubleBufferGc->BitBltMasked( TPoint( 0, 0), frameL, 
       
   962                                           TRect( TPoint( 0, 0 ), frameL->SizeInPixels() ),
       
   963                                           lMask, EFalse );
       
   964 
       
   965             doubleBufferGc->BitBltMasked( centerPoint, frameCenter, 
       
   966                                           TRect( frameCenter->SizeInPixels() ),
       
   967                                           centerMask, EFalse );
       
   968 
       
   969             doubleBufferGc->BitBltMasked( rightPoint, frameR, 
       
   970                                           TRect( frameR->SizeInPixels() ),
       
   971                                           rMask, EFalse );
       
   972 
       
   973             CleanupStack::PopAndDestroy( 6 );
       
   974             if ( iAnimation->BitmapAnimData()->PlayMode() == CBitmapAnimClientData::EPlay )
       
   975                 iAnimation->BitmapAnimData()->SetPlayMode(CBitmapAnimClientData::ECycle);
       
   976             }  
       
   977 #endif
       
   978             
       
   979         CleanupStack::PopAndDestroy(2); // doubleBufferGc, doubleBufferDev
       
   980    
       
   981         // finally set background frame
       
   982         CBitmapFrameData* data = CBitmapFrameData::NewL();
       
   983         data->SetBitmapsOwnedExternally( EFalse );
       
   984         data->SetBitmap( bitmap );
       
   985         
       
   986         // Set frame to animation
       
   987         iAnimation->BitmapAnimData()->SetBackgroundFrame( data ); // gets ownership
       
   988         
       
   989         CleanupStack::Pop(bitmap); // bitmap
       
   990         }       
       
   991     }
       
   992 
       
   993 // Callback for doing a redraw when animating pictographs
       
   994 TInt CAknNoteAttributes::StaticPictographCallBack( TAny* aPtr )
       
   995     {
       
   996     CAknNoteAttributes* me = static_cast<CAknNoteAttributes*>( aPtr );
       
   997     me->PictographCallBack();
       
   998     return KErrNone;
       
   999     }
       
  1000 
       
  1001 void CAknNoteAttributes::PictographCallBack()
       
  1002     {
       
  1003     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1004     MAknsControlContext* cc = iBgContext;
       
  1005 
       
  1006     for ( TInt i = 0 ; i < iNoteText->NumberOfLines() ; i++ )
       
  1007         {
       
  1008         CAknPictographInterface* picto = iNoteText->PictographInterface();
       
  1009 
       
  1010         // Only update the note line if it contains pictographs
       
  1011 
       
  1012         if ( picto->Interface()->ContainsPictographs( 
       
  1013             *( iNoteText->Line( i )->Text() ) ) )
       
  1014             {
       
  1015             TRect lineRect = iNoteText->Line(i)->Rect();
       
  1016             iNoteControl->Window().Invalidate( lineRect );
       
  1017 
       
  1018             iNoteControl->ActivateGc();
       
  1019             iNoteControl->Window().BeginRedraw();
       
  1020 
       
  1021             AknsDrawUtils::Background(
       
  1022                 skin,
       
  1023                 cc,
       
  1024                 iNoteControl,
       
  1025                 iNoteControl->iCoeEnv->SystemGc(),
       
  1026                 lineRect );
       
  1027 
       
  1028             iNoteControl->Window().EndRedraw();
       
  1029             iNoteControl->DeactivateGc();
       
  1030 
       
  1031             // Redraw the label after the background
       
  1032             iNoteText->Line( i )->ActivateL(); // Never leaves
       
  1033             iNoteText->Line( i )->DrawNow();
       
  1034             iNoteText->SetLineModified( i, EFalse );
       
  1035             }
       
  1036         }
       
  1037     }
       
  1038 
       
  1039 void CAknNoteAttributes::AllowOptimizedDrawing()
       
  1040     {
       
  1041     iAllowOptimizedDrawing = ETrue;
       
  1042     }
       
  1043     
       
  1044 void CAknNoteAttributes::HandleSkinChangeL()
       
  1045     {
       
  1046     // Reload animation every time
       
  1047     SetAnimationL(iAnimationID);
       
  1048     
       
  1049     // iImageId is null with no sense
       
  1050     if (!iImage || !iImageFile || !iImageId)
       
  1051         {
       
  1052         return;
       
  1053         }
       
  1054     
       
  1055     // Check for skin icon.
       
  1056     CFbsBitmap* bitmap = NULL;
       
  1057     CFbsBitmap* mask = NULL;
       
  1058    
       
  1059     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1060    
       
  1061     AknsUtils::CreateIconL(
       
  1062         skin, 
       
  1063         iSkinIdForImage,
       
  1064         bitmap, 
       
  1065         mask,
       
  1066         *iImageFile,
       
  1067         iImageId, 
       
  1068         iImageMask);
       
  1069 
       
  1070     if (iImage->IsPictureOwnedExternally())
       
  1071         {
       
  1072         delete ((CApaMaskedBitmap*) iImage->Bitmap());
       
  1073         }
       
  1074 
       
  1075     iImage->SetPicture(bitmap, mask);    
       
  1076     }
       
  1077 
       
  1078 // End of File