extras/about/src/AboutContainer.cpp
changeset 0 3ee3dfdd8d69
child 9 90f44fa581ce
equal deleted inserted replaced
-1:000000000000 0:3ee3dfdd8d69
       
     1 /*
       
     2 * Copyright (c) 2002 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: application container control.  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "AboutContainer.h"
       
    22 #include "AboutImage.h"
       
    23 #include "about.hrh"
       
    24 #include "about_test.hrh"
       
    25 #include <layoutmetadata.cdl.h>
       
    26 #include <about.rsg>
       
    27 #include <eiksbfrm.h>
       
    28 #include <eikscrlb.h>
       
    29 #include <eikrted.h>
       
    30 #include <txtrich.h>
       
    31 #include <barsread.h>
       
    32 #include <eikenv.h>
       
    33 #include <aknenv.h>
       
    34 #include <AknUtils.h>
       
    35 #include <aknconsts.h>
       
    36 #include <txtfrmat.h>
       
    37 #include <AknBidiTextUtils.h>
       
    38 #include <data_caging_path_literals.hrh>
       
    39 #include <f32file.h>
       
    40 #include <aknlayoutscalable_apps.cdl.h>
       
    41 #include <aknappui.h>
       
    42 #include <AknsDrawUtils.h> 
       
    43 #include    <AknsBasicBackgroundControlContext.h>
       
    44 #include    <AknsConstants.h>
       
    45 #include <AknDef.h>
       
    46 #include <about.mbg>
       
    47 #include <StringLoader.h> 
       
    48 
       
    49 // CONSTANTS
       
    50 
       
    51 _LIT( KAboutPanicCategory, "About" );
       
    52 
       
    53 enum TAboutPanic
       
    54     {
       
    55     EAboutNotSupported = 0
       
    56     };
       
    57 
       
    58 /**
       
    59 * SCROLLING:
       
    60 *
       
    61 * Scrolling is implemented according to the following rules
       
    62 * when scrolling down:
       
    63 *
       
    64 * (same screens are shown again when scrolling up)
       
    65 *
       
    66 * - If the last line in previous screen was a text line,
       
    67 *   next screen is started with that line, ie. the last
       
    68 *   line is shown again in the next screen.
       
    69 *
       
    70 * - If previous screen ended with an image that did not
       
    71 *   fully fit, next screen is started with that image so
       
    72 *   that it can be seen as a whole.
       
    73 *
       
    74 * - If previous screen ended with an image that fit there fully,
       
    75 *   next screen is started with next text line or image.
       
    76 */
       
    77 
       
    78 // constructors
       
    79 
       
    80 CAboutContainer::CAboutContainer():iNumItem( 0 )
       
    81     {
       
    82     }
       
    83 
       
    84 void CAboutContainer::ConstructL( const TRect& aRect )
       
    85     {
       
    86     CreateWindowL();
       
    87 
       
    88     iScrollBarDragged = EFalse;
       
    89 	iSkinContext = NULL;
       
    90 	iText = NULL;
       
    91 	iImages = NULL;
       
    92 	iScreenStarts = NULL;
       
    93 	iSBFrame = NULL;
       
    94     CalculateL(aRect); 
       
    95     ActivateL();
       
    96     }
       
    97 
       
    98 // destructor
       
    99 
       
   100 CAboutContainer::~CAboutContainer()
       
   101     {
       
   102 	delete iSkinContext;
       
   103     delete iSBFrame;
       
   104     delete iScreenStarts;
       
   105     delete iIcon;
       
   106 
       
   107     if ( iText )
       
   108         {
       
   109         iText->ResetAndDestroy();
       
   110         delete iText;
       
   111         }
       
   112 
       
   113     if ( iImages )
       
   114         {
       
   115         iImages->ResetAndDestroy();
       
   116         delete iImages;
       
   117         }
       
   118     }
       
   119 
       
   120 void CAboutContainer::SizeChanged()
       
   121     {
       
   122     TRect parentRect(Rect());
       
   123 	if (iSkinContext)
       
   124         {
       
   125         iSkinContext->SetRect(parentRect);
       
   126         }
       
   127 	}
       
   128 // -----------------------------------------------------------------------------
       
   129 // CAboutContainer::Draw()
       
   130 // -----------------------------------------------------------------------------
       
   131 
       
   132 void CAboutContainer::Draw( const TRect& aRect ) const
       
   133     {
       
   134     CWindowGc& gc = SystemGc();
       
   135 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   136 	if (iSkinContext)
       
   137 		{//Draw the skin background
       
   138 		AknsDrawUtils::Background(
       
   139 			skin, iSkinContext, this, gc, aRect);
       
   140 		}
       
   141 	else
       
   142 		{//  clear the area
       
   143 		gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
       
   144 		gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   145 		gc.Clear( aRect );
       
   146 		}
       
   147 
       
   148     // draw text
       
   149     gc.UseFont( iFont );
       
   150     // index of the first line on the screen in the text array
       
   151     TInt firstLine = 0 ;
       
   152 
       
   153     // The value of firstLine can not be the same.
       
   154     if ( !iScrollBarDragged )
       
   155         {
       
   156         if ( ( iScreenStarts ) && (iScreenStarts->Count() >= iCurrentScreen ) )
       
   157             {
       
   158     	    firstLine = ( ( *iScreenStarts )[ iCurrentScreen ] ); 	
       
   159             }        
       
   160         }
       
   161     else
       
   162         {                    
       
   163         if ( iCurrentScreen <= ( ( *iScreenStarts )[ iScreenStarts->Count() - 1 ] ) )
       
   164             {
       
   165             firstLine = iCurrentScreen ;
       
   166             }
       
   167         }
       
   168     // index of the last line on the screen in the text array
       
   169     TInt lastLine( firstLine + iLinesPerScreen - 1 );
       
   170 
       
   171     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   172     TPoint position( iTopBaseLineX, iTopBaseLineY );
       
   173     TPoint topLeft;
       
   174     TSize rectSize( iLineWidth, iBaseLineDelta +iFont->DescentInPixels() );
       
   175 
       
   176     for ( TInt index = firstLine ;
       
   177           index < iText->Count() && index <= lastLine ;
       
   178           index++, position.iY += iBaseLineDelta )
       
   179         {
       
   180         HBufC* text = (*iText)[ index ];
       
   181 
       
   182         if ( text )
       
   183             {
       
   184             topLeft = TPoint( position.iX, position.iY-iBaseLineDelta );
       
   185 			TRgb color;			
       
   186 			TInt error = AknsUtils::GetCachedColor( skin, 
       
   187 							color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
       
   188 			
       
   189 			if(error == KErrNone)
       
   190 				{
       
   191 				gc.SetPenColor(color);
       
   192 				}		
       
   193             gc.DrawText( *text,
       
   194                          TRect( topLeft, rectSize ),
       
   195                          iBaseLineDelta,
       
   196                          iTextAlign );
       
   197             }
       
   198         }
       
   199 
       
   200     gc.DiscardFont();
       
   201 
       
   202     // draw images
       
   203 
       
   204     for ( TInt i = 0 ; i < iImages->Count() ; i++ )
       
   205         {
       
   206         CAboutImage* image = (*iImages)[ i ];
       
   207 
       
   208         // If part of the image resides in visible lines, draw it.
       
   209         if ( image->StartLine() <= lastLine && image->EndLine() >= firstLine )
       
   210             {
       
   211             position.SetXY( iTopBaseLineX, iTopBaseLineY );
       
   212             position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta;
       
   213 
       
   214             position.iY -= iBaseLineDelta - iFont->DescentInPixels();
       
   215             // Now iY is the top line of rectangle where the picture is
       
   216             // centered in.
       
   217             position.iY += ( (image->Lines()+1) * iBaseLineDelta -
       
   218                              iFont->HeightInPixels() -
       
   219                              image->HeightInPixels() ) / 2;
       
   220 
       
   221             // If text is right-aligned, also align images to the right.
       
   222 
       
   223             if ( iTextAlign == CGraphicsContext::ERight )
       
   224                 {
       
   225                 position.iX += ( iLineWidth - image->WidthInPixels() );
       
   226                 }
       
   227 
       
   228             gc.BitBlt( position, image->Bitmap(), aRect );
       
   229             }
       
   230         }
       
   231      /*   if(iCurrentScreen == 0)
       
   232     {
       
   233         TAknWindowLineLayout area = AknLayoutScalable_Apps::mce_icon_pane().LayoutLine();
       
   234  	    TAknLayoutRect layoutRect;
       
   235  	    TRect iconrect = Rect();
       
   236  	    iconrect.iTl.iX = position.iX;
       
   237 	    layoutRect.LayoutRect(iconrect, area);
       
   238   	    layoutRect.DrawImage(gc, iIcon->Bitmap(),iIcon->Mask());
       
   239         
       
   240     }*/
       
   241 
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CAboutContainer::ActivateL()
       
   246 // -----------------------------------------------------------------------------
       
   247 
       
   248 void CAboutContainer::ActivateL()
       
   249     {
       
   250     CCoeControl::ActivateL();
       
   251     UpdateScrollIndicatorL();
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CAboutContainer::SetTextL()
       
   256 // -----------------------------------------------------------------------------
       
   257 
       
   258 void CAboutContainer::SetTextL( const TDesC& aText , const TInt aItem )
       
   259     {
       
   260     CArrayFix<TPtrC>* wrappedArray =
       
   261         new( ELeave ) CArrayFixFlat<TPtrC>( 10 );
       
   262 
       
   263     CleanupStack::PushL( wrappedArray );
       
   264 
       
   265     HBufC* dataToDestroy =
       
   266         AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
       
   267             aText, iLineWidth, *iFont, *wrappedArray
       
   268         );
       
   269 
       
   270     TInt numLines( wrappedArray->Count() );
       
   271     for ( TInt i = 0 ; i < numLines ; i++ )
       
   272         {
       
   273         HBufC* line = (*wrappedArray)[i].AllocLC();
       
   274 
       
   275         if(!line->Length())
       
   276             {
       
   277             iText->AppendL( NULL );
       
   278 			
       
   279             CleanupStack::PopAndDestroy(line);  // line
       
   280             }
       
   281         else
       
   282             {
       
   283             iText->AppendL( line );
       
   284             CleanupStack::Pop(line);  // line
       
   285             }
       
   286         }
       
   287 	iText->AppendL( NULL );
       
   288 
       
   289     // If the last char was newline, add one extra, since
       
   290     // wrapping automatically removes it.
       
   291     if ( aText[ aText.Length() - 1 ] == '\n' )
       
   292         {
       
   293         iText->AppendL( NULL );
       
   294 		}
       
   295 
       
   296     CleanupStack::PopAndDestroy(wrappedArray); // wrappedArray
       
   297     delete dataToDestroy;
       
   298 
       
   299     // update screen scrolling info array
       
   300 
       
   301     TInt lastLine( iText->Count() - 1 );
       
   302     TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
       
   303 
       
   304     TBool firstNewScreenHandled( EFalse );
       
   305 
       
   306     while ( lastLine >= screenStart + iLinesPerScreen )
       
   307         {
       
   308         if ( !firstNewScreenHandled && iDoNotShowLastLineAgain )
       
   309             {
       
   310             screenStart++;
       
   311             firstNewScreenHandled = ETrue;
       
   312             }
       
   313 
       
   314         screenStart += iLinesPerScreen - 1;
       
   315         iScreenStarts->AppendL( screenStart );
       
   316         if ( ( lastLine == screenStart + 1 ) && ( aItem == iNumItem - 1 ) )
       
   317         	{
       
   318         	iScreenStarts->Delete( iScreenStarts->Count() - 1 );
       
   319         	}
       
   320         }
       
   321 
       
   322     // if text, last line is shown again in next screen
       
   323     iDoNotShowLastLineAgain = EFalse;
       
   324     }
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 // CAboutContainer::SetImageL()
       
   328 // -----------------------------------------------------------------------------
       
   329 
       
   330 void CAboutContainer::SetImageL( const TDesC& aFileName, TInt aBitmapId )
       
   331     {
       
   332     TInt firstLineOfImage( iText->Count() );
       
   333 
       
   334     CAboutImage* image =
       
   335     CAboutImage::NewLC( aFileName, aBitmapId, firstLineOfImage, iBaseLineDelta );
       
   336 
       
   337     // new lines to make room for the picture
       
   338 
       
   339     for ( TInt i = 0 ; i < image->Lines() ; i++ )
       
   340         {
       
   341         iText->AppendL( NULL );
       
   342         }
       
   343 
       
   344     iImages->AppendL( image );
       
   345     CleanupStack::Pop(image); // image
       
   346 
       
   347     // update screen scrolling info array
       
   348 
       
   349     TInt lastLineOfImage( iText->Count() - 1 );
       
   350     TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
       
   351 
       
   352     TBool firstNewScreenHandled( EFalse );
       
   353 
       
   354     // If the image was not fully shown in the first screen,
       
   355     // start the next screen with the image.
       
   356 
       
   357     if ( firstLineOfImage < screenStart + iLinesPerScreen &&
       
   358          lastLineOfImage >= screenStart + iLinesPerScreen )
       
   359         {
       
   360         screenStart = firstLineOfImage;
       
   361         iScreenStarts->AppendL( screenStart );
       
   362         firstNewScreenHandled = ETrue;
       
   363         }
       
   364 
       
   365     while ( lastLineOfImage >= screenStart + iLinesPerScreen )
       
   366         {
       
   367         if ( !firstNewScreenHandled && iDoNotShowLastLineAgain )
       
   368             {
       
   369             screenStart++;
       
   370             firstNewScreenHandled = ETrue;
       
   371             }
       
   372 
       
   373         screenStart += iLinesPerScreen - 1;
       
   374         iScreenStarts->AppendL( screenStart );
       
   375         }
       
   376 
       
   377     if ( lastLineOfImage == screenStart + iLinesPerScreen - 1 )
       
   378         {
       
   379         iDoNotShowLastLineAgain = ETrue;
       
   380         }
       
   381     else
       
   382         {
       
   383         iDoNotShowLastLineAgain = EFalse;
       
   384         }
       
   385     }
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // CAboutContainer::OfferKeyEventL()
       
   389 // -----------------------------------------------------------------------------
       
   390 
       
   391 TKeyResponse CAboutContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   392                                               TEventCode aType )
       
   393     {
       
   394     // Operation is different in dragging and thumbing.
       
   395     if ( ( iScrollBarDragged ) && ( aType == EEventKey ) )
       
   396         {
       
   397         for( TInt i=0; i<iScreenStarts->Count(); i++ )
       
   398             {
       
   399             if ( iCurrentScreen <= ( ( *iScreenStarts )[i] ) ) 
       
   400                 {
       
   401                 // if last state is dragging, value of iCurrentScreen should be adjusted.
       
   402                 switch ( aKeyEvent.iCode )
       
   403                     {
       
   404                     case EKeyUpArrow:
       
   405                         {
       
   406                         iScrollBarDragged = EFalse;
       
   407                         // Do nothing if the scroll bar is on the top, when pressing arrow up.
       
   408                         if ( i != 0 )
       
   409                             {
       
   410                             iCurrentScreen =  ( i - 1 );
       
   411                             }
       
   412                         DrawNow();
       
   413                         UpdateScrollIndicatorL();
       
   414                         break;
       
   415                         }
       
   416                     case EKeyDownArrow:
       
   417                         {
       
   418                         iScrollBarDragged = EFalse;
       
   419                         if ( ( iCurrentScreen == ( *iScreenStarts )[i] )
       
   420                             // Do nothing if the scroll bar is on the bottom, when pressing arrow down.
       
   421                             && ( i != ( iScreenStarts->Count() - 1 ) ) )
       
   422                             {
       
   423                             iCurrentScreen = ( i + 1 );
       
   424                             }
       
   425                        	else
       
   426                             {
       
   427                             iCurrentScreen = i;
       
   428                             }
       
   429                         DrawNow();
       
   430                         UpdateScrollIndicatorL();
       
   431                         break;
       
   432                         }
       
   433                     default:
       
   434                         break;
       
   435                     }
       
   436                 return EKeyWasConsumed;
       
   437                 }
       
   438             } 
       
   439         }
       
   440         
       
   441     if ( aType == EEventKey && iScreenStarts->Count() > 1 )
       
   442         {
       
   443         switch ( aKeyEvent.iCode )
       
   444             {
       
   445             case EKeyUpArrow:
       
   446                 {
       
   447                 if ( iCurrentScreen > 0 )
       
   448                     {
       
   449                     iCurrentScreen--;
       
   450                     DrawNow();
       
   451                     UpdateScrollIndicatorL();
       
   452                     }
       
   453                 }
       
   454                 break;
       
   455 
       
   456             case EKeyDownArrow:
       
   457                 {
       
   458                 if ( iCurrentScreen < iScreenStarts->Count() - 1 )
       
   459                     {
       
   460                     iCurrentScreen++;
       
   461                     DrawNow();
       
   462                     UpdateScrollIndicatorL();
       
   463                     }
       
   464                 }
       
   465                 break;
       
   466 
       
   467             default:
       
   468                 break;
       
   469             }
       
   470         return EKeyWasConsumed;
       
   471         }
       
   472 
       
   473     // When pressing the Send Key and the event's type is not EEvenKey return EKeyWasNotConsumed
       
   474     return EKeyWasNotConsumed;
       
   475     }
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CAboutContainer::UpdateScrollIndicatorL()
       
   479 // -----------------------------------------------------------------------------
       
   480 
       
   481 void CAboutContainer::UpdateScrollIndicatorL()
       
   482  {
       
   483     if ( iScreenStarts->Count() <= 1 )
       
   484     {
       
   485         return;
       
   486     }
       
   487 
       
   488     if ( !iSBFrame )
       
   489     {
       
   490         iSBFrame = new( ELeave ) CEikScrollBarFrame( this,this, ETrue );
       
   491         
       
   492 		// Decide which type of scrollbar is to be shown
       
   493         CAknAppUi* appUi = iAvkonAppUi;
       
   494 		if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
       
   495 		{
       
   496 			// For EDoubleSpan type scrollbar
       
   497 			iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar            
       
   498 			iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
       
   499 		}
       
   500 		else
       
   501 		{
       
   502 			// For EArrowHead type scrollbar
       
   503 			iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead);
       
   504 		}  
       
   505 		iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
   506     }
       
   507 
       
   508 	TEikScrollBarModel hSbarModel;
       
   509     TEikScrollBarModel vSbarModel;
       
   510 
       
   511     // The member of vSbarModel shoul be changed because the state when dragging scroll bar shoul be considered.
       
   512     TInt spanAdjust = iLinesPerScreen - ( iText->Count() - ( *iScreenStarts )[ iScreenStarts->Count() - 1 ] + 1 );
       
   513     if ( iScrollBarDragged )
       
   514     {
       
   515     vSbarModel.iThumbPosition = iCurrentScreen;
       
   516     }
       
   517     else
       
   518     {
       
   519         vSbarModel.iThumbPosition = iCurrentScreen * ( iLinesPerScreen - 1 );
       
   520     }
       
   521     vSbarModel.iScrollSpan = iText->Count() + spanAdjust;
       
   522     vSbarModel.iThumbSpan = ( iLinesPerScreen - 1 );
       
   523 	
       
   524 	TRect rect(Rect());  
       
   525     TEikScrollBarFrameLayout layout;
       
   526 	layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
       
   527 
       
   528     if (iSBFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
       
   529     {    
       
   530         // For EDoubleSpan type scrollbar
       
   531         if (vSbarModel.iThumbPosition + vSbarModel.iThumbSpan > vSbarModel.iScrollSpan)
       
   532         {
       
   533             // Not let scrollbar values overflow
       
   534             vSbarModel.iThumbPosition = vSbarModel.iScrollSpan - vSbarModel.iThumbSpan;
       
   535         }
       
   536 		
       
   537         TAknDoubleSpanScrollBarModel hDsSbarModel(hSbarModel);
       
   538         TAknDoubleSpanScrollBarModel vDsSbarModel(vSbarModel);
       
   539        
       
   540         // When resolution is changed, changing the drawing area of layout for the text.
       
   541         TRect currentRect( iAvkonAppUi->ClientRect() );
       
   542         iSBFrame->TileL(&hDsSbarModel, &vDsSbarModel, currentRect, rect, layout);        
       
   543         iSBFrame->SetVFocusPosToThumbPos(vDsSbarModel.FocusPosition());
       
   544 	}  
       
   545 	else
       
   546 	{
       
   547 		iSBFrame->TileL( &hSbarModel, &vSbarModel, rect, rect, layout );
       
   548 		iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition );
       
   549 	}
       
   550 }
       
   551 
       
   552 
       
   553 // End of File
       
   554 
       
   555 void CAboutContainer::CalculateL(const TRect& aRect)
       
   556     {
       
   557     TRect rect( 0, 0, 0, 0 );
       
   558     iCurrentScreen = 0;
       
   559 	
       
   560     if ( iSkinContext )
       
   561         {
       
   562         delete iSkinContext;
       
   563         iSkinContext = NULL;
       
   564         }  
       
   565 	
       
   566     // Temporary rect is passed. Correct rect is set in SizeChanged.
       
   567     iSkinContext = CAknsBasicBackgroundControlContext::NewL(
       
   568     KAknsIIDQsnBgAreaMain , rect, EFalse );
       
   569 
       
   570     iFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont );
       
   571 
       
   572     // Calculate various text positioning parameters
       
   573     iBaseLineDelta = iFont->HeightInPixels() * 4 / 3;
       
   574 
       
   575     TInt mainPaneWidth( aRect.iBr.iX - aRect.iTl.iX );
       
   576     TInt mainPaneHeight( aRect.iBr.iY - aRect.iTl.iY );
       
   577     // Line width is 87% of client rect, horizontal margins 13%
       
   578     iLineWidth = mainPaneWidth * 87 / 100;
       
   579     iTopBaseLineX = ( mainPaneWidth - iLineWidth ) / 2;
       
   580 
       
   581     // top margin is 6.5% of the client rect
       
   582     TInt topMargin = mainPaneHeight * 65 / 1000;    
       
   583     iTopBaseLineY = topMargin + iFont->AscentInPixels();
       
   584 
       
   585     // minimum bottom margin is 3% of the client rect
       
   586     TInt bottomMargin = mainPaneHeight * 3 / 100;
       
   587     iLinesPerScreen =
       
   588         ( mainPaneHeight - topMargin - bottomMargin ) / iBaseLineDelta;
       
   589 
       
   590     iTextAlign = CGraphicsContext::ELeft;
       
   591    
       
   592     if ( iText )
       
   593         {
       
   594         iText->ResetAndDestroy();
       
   595         delete iText;
       
   596         iText = NULL;
       
   597         }
       
   598 
       
   599     // Every text line on screen is one entry in this array
       
   600     iText = new( ELeave ) CArrayPtrFlat<HBufC>( 20 );
       
   601 
       
   602     if ( iImages )
       
   603         {
       
   604         iImages->ResetAndDestroy();
       
   605         delete iImages;
       
   606         iImages = NULL;
       
   607         }
       
   608 
       
   609     // Every image on screen is one entry in this array
       
   610     iImages = new( ELeave ) CArrayPtrFlat<CAboutImage>( 1 );
       
   611 
       
   612     if ( iScreenStarts )
       
   613         {
       
   614         delete iScreenStarts;
       
   615         iScreenStarts = NULL;
       
   616         }
       
   617     // This array contains indices for lines that start the subsequent
       
   618     // screens, for custom scrolling
       
   619     iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 );
       
   620     // Initialisation: first screen starts at line 0.
       
   621     iScreenStarts->AppendL( 0 );
       
   622 
       
   623     // Read text and image items to be shown on the screen from a resource file.
       
   624 #ifdef __ABOUT_USE_TEST_RESOURCE__
       
   625     #include <about_test.rsg>
       
   626     // test resource
       
   627     _LIT(KDirAndFile, "Z:about_test.rsc");
       
   628     TParse* fp = new(ELeave) TParse ();
       
   629     fp->Set (KDirAndFile, &KDC_APP_RESOURCE_DIR, NULL);
       
   630     TBuf<254> KAboutTestResourceFileName;
       
   631     KAboutTestResourceFileName.Copy(fp ->FullName());
       
   632     delete fp;
       
   633     fp=NULL;
       
   634 
       
   635     TFileName fileName( KAboutTestResourceFileName );
       
   636     BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename );
       
   637     TInt testResourceFileOffset = iCoeEnv->AddResourceFileL( fileName );
       
   638     TResourceReader reader;
       
   639     iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_TEST_MAIN_TEXT );
       
   640 #else
       
   641     // real resource
       
   642     TResourceReader reader;
       
   643     iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_MAIN_TEXT );
       
   644 #endif
       
   645     
       
   646     CFbsBitmap* bitmap,*mask;
       
   647     bitmap = NULL;
       
   648     mask= NULL;
       
   649     TFileName bmpPath;
       
   650     _LIT( KMbmFileName, "Z:about.mif" );
       
   651 
       
   652     TParse* fpMbm = new(ELeave) TParse ();
       
   653     fpMbm->Set ( KMbmFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   654     bmpPath.Copy( fpMbm ->FullName() );
       
   655     delete fpMbm;
       
   656     fpMbm=NULL;
       
   657 
       
   658     TResourceReader readerSVG;                   
       
   659     iEikonEnv->CreateResourceReaderLC( readerSVG, R_ABOUT_SVG_TEXT );
       
   660     TInt svgId = readerSVG.ReadInt16();
       
   661     TInt svgIdmask = readerSVG.ReadInt16();
       
   662     TInt height = readerSVG.ReadInt16();
       
   663     TInt width = readerSVG.ReadInt16();
       
   664     CleanupStack::PopAndDestroy();      // readerSVG
       
   665 	  
       
   666     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   667     AknsUtils::CreateIconL( skinInstance, KAknsIIDQgnMenuSmsvoLst, bitmap, mask, bmpPath, svgId, svgIdmask );	
       
   668     //AknsUtils::CreateIconL( skinInstance, KAknsIIDQgnMenuSmsvoLst, bitmap, bmpPath, EMbmAboutQgn_graf_java_logo );	
       
   669     if ( iIcon )
       
   670         {
       
   671         delete( iIcon );
       
   672         iIcon = NULL;
       
   673         }
       
   674     iIcon = CGulIcon::NewL( bitmap,mask );
       
   675     
       
   676     TRect rect1; 
       
   677    	rect1.iTl.iX = 0;
       
   678    	rect1.iTl.iY = 0;
       
   679    	rect1.iBr.iX = height;
       
   680    	rect1.iBr.iY = width;
       
   681 	  AknIconUtils::SetSize( iIcon->Bitmap(), rect1.Size() ); 
       
   682 	  AknIconUtils::SetSize( iIcon->Mask(), rect1.Size() );
       
   683 
       
   684     TInt lines( bitmap->SizeInPixels().iHeight +
       
   685                   KImageTopMargin + 
       
   686                   KImageBottomMargin +
       
   687                   ( iBaseLineDelta - 1 ) / iBaseLineDelta );
       
   688 
       
   689 /*        for(TInt i =0; i< 2; i++)
       
   690 		{
       
   691 		    iText->AppendL(NULL);    
       
   692 		}*/
       
   693     TInt NumItem( reader.ReadInt16() );
       
   694     iNumItem = NumItem;
       
   695 
       
   696     for ( TInt i = 0 ; i < iNumItem ; i++ )
       
   697         {
       
   698         TInt type = reader.ReadInt8();
       
   699 
       
   700         if ( type == EAboutTextItem )    
       
   701             { 
       
   702             HBufC* text;  
       
   703             if ( reader.ReadInt8() == EAboutUpdateTime )
       
   704                 {  
       
   705                 TTime time;
       
   706                 time.UniversalTime();
       
   707                 TDateTime currentTime = time.DateTime();
       
   708                 text = StringLoader::LoadLC( reader.ReadInt32(), 
       
   709                                             currentTime.Year(), CEikonEnv::Static() );
       
   710                 }
       
   711             else
       
   712                 {
       
   713                 text = iEikonEnv->AllocReadResourceLC( reader.ReadInt32() );
       
   714                 }
       
   715             SetTextL( *text , i );
       
   716             CleanupStack::PopAndDestroy( text );
       
   717             }
       
   718         else if ( type == EAboutImageItem )
       
   719             {
       
   720             TPtrC bitmapFile = reader.ReadTPtrC();
       
   721             TInt bitmapId = reader.ReadInt16();
       
   722             SetImageL( bitmapFile, bitmapId );
       
   723             }
       
   724         else
       
   725             {
       
   726             User::Panic( KAboutPanicCategory, EAboutNotSupported );
       
   727             }
       
   728         }
       
   729 
       
   730     CleanupStack::PopAndDestroy(); // reader
       
   731 
       
   732 #ifdef __ABOUT_USE_TEST_RESOURCE__
       
   733     if ( testResourceFileOffset )
       
   734         {
       
   735         iCoeEnv->DeleteResourceFile( testResourceFileOffset );
       
   736         }
       
   737 #endif
       
   738 
       
   739     SetRect( aRect );  
       
   740     UpdateScrollIndicatorL();
       
   741     }
       
   742 
       
   743 
       
   744  void CAboutContainer::HandleResourceChange(TInt aType)
       
   745  {
       
   746 
       
   747 switch ( aType )
       
   748   {
       
   749   case KEikDynamicLayoutVariantSwitch :
       
   750        {
       
   751        TRAP_IGNORE(CalculateL(iAvkonAppUi->ClientRect()));   
       
   752        DrawNow();
       
   753        }
       
   754        break;
       
   755         
       
   756   case KAknsMessageSkinChange :
       
   757        {
       
   758        TRAP_IGNORE(iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse)); // window owning scrollbar            
       
   759        iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
       
   760  	   TRAP_IGNORE(iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn));
       
   761 	   TRAP_IGNORE(UpdateScrollIndicatorL());
       
   762        }
       
   763         
       
   764   default:
       
   765        {
       
   766        CCoeControl::HandleResourceChange(aType);
       
   767        }
       
   768 	   break;
       
   769   }
       
   770 }  
       
   771 // ---------------------------------------------------------
       
   772 // CAboutContainer::MopSupplyObject()
       
   773 // Pass skin information if need.
       
   774 // ---------------------------------------------------------
       
   775 
       
   776 TTypeUid::Ptr CAboutContainer::MopSupplyObject(TTypeUid aId)
       
   777     {
       
   778     if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext)
       
   779         {
       
   780         return MAknsControlContext::SupplyMopObject(aId, iSkinContext);
       
   781         }
       
   782 
       
   783     return CCoeControl::MopSupplyObject(aId);
       
   784     }
       
   785 
       
   786 // ---------------------------------------------------------
       
   787 // CAboutContainer::HandleScrollEventL()
       
   788 // Capture Touch Events on the Scroll Bar
       
   789 // ---------------------------------------------------------
       
   790 void CAboutContainer::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
       
   791 {
       
   792     //Only on page up/down,scroll up/down and drag events
       
   793     if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || 
       
   794        (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
       
   795        (aEventType == EEikScrollDown))
       
   796     {
       
   797         //Get the current position from the scroll bar
       
   798         iCurrentScreen = aScrollBar->ThumbPosition();
       
   799         
       
   800         // Reset flag when dragging scroll bar
       
   801         iScrollBarDragged = ETrue;
       
   802         //Refresh now
       
   803         DrawNow();
       
   804         UpdateScrollIndicatorL();
       
   805     }
       
   806     
       
   807 }