extras/about/src/AboutContainer.cpp
branchRCL_3
changeset 22 bec11adf88f9
parent 21 10c6e6d6e4d9
equal deleted inserted replaced
21:10c6e6d6e4d9 22:bec11adf88f9
     1 /*
     1  /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0""
     5 * under the terms of "Eclipse Public License v1.0""
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
    20 
    20 
    21 #include "AboutContainer.h"
    21 #include "AboutContainer.h"
    22 #include "AboutImage.h"
    22 #include "AboutImage.h"
    23 #include "about.hrh"
    23 #include "about.hrh"
    24 #include "about_test.hrh"
    24 #include "about_test.hrh"
       
    25 #include "AboutResourceLoader.h"
       
    26 #include "AboutResource.h"
    25 #include <layoutmetadata.cdl.h>
    27 #include <layoutmetadata.cdl.h>
    26 #include <about.rsg>
    28 #include <about.rsg>
       
    29 #include <about_oss_part_text.rsg>
       
    30 #include <about_oss_other_text.rsg>
    27 #include <eiksbfrm.h>
    31 #include <eiksbfrm.h>
    28 #include <eikscrlb.h>
    32 #include <eikscrlb.h>
    29 #include <eikrted.h>
    33 #include <eikrted.h>
    30 #include <txtrich.h>
    34 #include <txtrich.h>
    31 #include <barsread.h>
    35 #include <barsread.h>
    38 #include <data_caging_path_literals.hrh>
    42 #include <data_caging_path_literals.hrh>
    39 #include <f32file.h>
    43 #include <f32file.h>
    40 #include <aknlayoutscalable_apps.cdl.h>
    44 #include <aknlayoutscalable_apps.cdl.h>
    41 #include <aknappui.h>
    45 #include <aknappui.h>
    42 #include <AknsDrawUtils.h> 
    46 #include <AknsDrawUtils.h> 
    43 #include    <AknsBasicBackgroundControlContext.h>
    47 #include <AknsBasicBackgroundControlContext.h>
    44 #include    <AknsConstants.h>
    48 #include <AknsConstants.h>
    45 #include <AknDef.h>
    49 #include <AknDef.h>
    46 #include <about.mbg>
    50 #include <about.mbg>
    47 #include <StringLoader.h> 
    51 #include <StringLoader.h> 
    48 
    52 
    49 // CONSTANTS
    53 // CONSTANTS
       
    54 const TInt KAboutOSSIndex = 14; // For adding blank break between OSS Text and real Text
    50 
    55 
    51 _LIT( KAboutPanicCategory, "About" );
    56 _LIT( KAboutPanicCategory, "About" );
       
    57 // Resource files for about application loading real data because this rsc file must be loaded by yourself
       
    58 _LIT( KRSCDirAndFile, "Z:\\resource\\apps\\about_oss_part_text.rsc" );
       
    59 _LIT( KRSCDirAndFileAdd, "Z:\\resource\\apps\\about_oss_other_text.rsc" );
       
    60 
    52 
    61 
    53 enum TAboutPanic
    62 enum TAboutPanic
    54     {
    63     {
    55     EAboutNotSupported = 0
    64     EAboutNotSupported = 0
    56     };
    65     };
    73 *
    82 *
    74 * - If previous screen ended with an image that fit there fully,
    83 * - If previous screen ended with an image that fit there fully,
    75 *   next screen is started with next text line or image.
    84 *   next screen is started with next text line or image.
    76 */
    85 */
    77 
    86 
    78 // constructors
    87 // ================= MEMBER FUNCTIONS =======================
    79 
    88 
    80 CAboutContainer::CAboutContainer():iNumItem( 0 )
    89 // -----------------------------------------------------------------------------
    81     {
    90 // CAboutContainer::CAboutContainer()
    82     }
    91 // -----------------------------------------------------------------------------
    83 
    92 CAboutContainer::CAboutContainer()
       
    93     {
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CAboutContainer::ConstructL()
       
    98 // -----------------------------------------------------------------------------
    84 void CAboutContainer::ConstructL( const TRect& aRect )
    99 void CAboutContainer::ConstructL( const TRect& aRect )
    85     {
   100     {
    86     CreateWindowL();
   101     CreateWindowL();
    87 
       
    88     iScrollBarDragged = EFalse;
   102     iScrollBarDragged = EFalse;
    89     iBreakFlag = EFalse;
   103     iBreakFlag = EFalse;
    90     iIsSvg = EFalse;
   104     iSkinContext = NULL;
    91 	iSkinContext = NULL;
   105     iText = NULL;
    92 	iText = NULL;
   106     iImages = NULL;
    93 	iImages = NULL;
   107     iScreenStarts = NULL;
    94 	iScreenStarts = NULL;
   108     iSBFrame = NULL;
    95 	iSBFrame = NULL;
   109     iHandleFlag = ETrue;
    96     CalculateL(aRect); 
   110     iLoader = CAboutResourceLoader::NewL( iEikonEnv, this );
       
   111     CalculateL( aRect ); 
    97     ActivateL();
   112     ActivateL();
    98     }
   113     }
    99 
   114 
   100 // destructor
   115 // -----------------------------------------------------------------------------
   101 
   116 // CAboutContainer::~CAboutContainer()
       
   117 // -----------------------------------------------------------------------------
   102 CAboutContainer::~CAboutContainer()
   118 CAboutContainer::~CAboutContainer()
   103     {
   119     {
   104 	delete iSkinContext;
   120     delete iSkinContext;
   105     delete iSBFrame;
   121     delete iSBFrame;
   106     delete iScreenStarts;
   122     delete iScreenStarts;
   107     delete iIcon;
   123     delete iIcon;
   108 
   124     
   109     if ( iText )
   125     if ( iText )
   110         {
   126         {
   111         iText->ResetAndDestroy();
   127         iText->ResetAndDestroy();
   112         delete iText;
   128         delete iText;
   113         }
   129         }
   114 
   130     
   115     if ( iImages )
   131     if ( iImages )
   116         {
   132         {
   117         iImages->ResetAndDestroy();
   133         iImages->ResetAndDestroy();
   118         delete iImages;
   134         delete iImages;
   119         }
   135         }
   120     }
   136     
   121 
   137     if ( iLoader )
       
   138         {
       
   139         iLoader->Cancel();
       
   140         delete iLoader;
       
   141         iLoader = NULL;
       
   142         }
       
   143     
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CAboutContainer::SizeChanged()
       
   148 // -----------------------------------------------------------------------------
   122 void CAboutContainer::SizeChanged()
   149 void CAboutContainer::SizeChanged()
   123     {
   150     {
   124     TRect parentRect(Rect());
   151     TRect parentRect( Rect() );
   125 	if (iSkinContext)
   152     if (iSkinContext)
   126         {
   153         {
   127         iSkinContext->SetRect(parentRect);
   154         iSkinContext->SetRect( parentRect );
   128         }
   155         }
   129 	}
   156     }
       
   157 
   130 // -----------------------------------------------------------------------------
   158 // -----------------------------------------------------------------------------
   131 // CAboutContainer::Draw()
   159 // CAboutContainer::Draw()
   132 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   133 
       
   134 void CAboutContainer::Draw( const TRect& aRect ) const
   161 void CAboutContainer::Draw( const TRect& aRect ) const
   135     {
   162     {
   136     CWindowGc& gc = SystemGc();
   163     CWindowGc& gc = SystemGc();
   137 	MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   164     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   138 	if (iSkinContext)
   165 	if ( iSkinContext )
   139 		{//Draw the skin background
   166 		{
       
   167 		//Draw the skin background
   140 		AknsDrawUtils::Background(
   168 		AknsDrawUtils::Background(
   141 			skin, iSkinContext, this, gc, aRect);
   169 			skin, iSkinContext, this, gc, aRect );
   142 		}
   170 		}
   143 	else
   171 	else
   144 		{//  clear the area
   172 		{//  clear the area
   145 		gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
   173 		gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
   146 		gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   174 		gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   155     // The value of firstLine can not be the same.
   183     // The value of firstLine can not be the same.
   156     if ( !iScrollBarDragged )
   184     if ( !iScrollBarDragged )
   157         {
   185         {
   158         if ( ( iScreenStarts ) && (iScreenStarts->Count() >= iCurrentScreen ) )
   186         if ( ( iScreenStarts ) && (iScreenStarts->Count() >= iCurrentScreen ) )
   159             {
   187             {
   160     	    firstLine = ( ( *iScreenStarts )[ iCurrentScreen ] ); 	
   188             firstLine = ( ( *iScreenStarts )[ iCurrentScreen ] );
   161             }        
   189             }        
   162         }
   190         }
   163     else
   191     else
   164         {                    
   192         {                    
   165         if ( iCurrentScreen <= ( ( *iScreenStarts )[ iScreenStarts->Count() - 1 ] ) )
   193         if ( iCurrentScreen <= ( ( *iScreenStarts )[ iScreenStarts->Count() - 1 ] ) )
   186             topLeft = TPoint( position.iX, position.iY-iBaseLineDelta );
   214             topLeft = TPoint( position.iX, position.iY-iBaseLineDelta );
   187 			TRgb color;			
   215 			TRgb color;			
   188 			TInt error = AknsUtils::GetCachedColor( skin, 
   216 			TInt error = AknsUtils::GetCachedColor( skin, 
   189 							color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
   217 							color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 );
   190 			
   218 			
   191 			if(error == KErrNone)
   219 			if( error == KErrNone )
   192 				{
   220 				{
   193 				gc.SetPenColor(color);
   221 				gc.SetPenColor( color );
   194 				}		
   222 				}		
   195             gc.DrawText( *text,
   223             gc.DrawText( *text,
   196                          TRect( topLeft, rectSize ),
   224                          TRect( topLeft, rectSize ),
   197                          iBaseLineDelta,
   225                          iBaseLineDelta,
   198                          iTextAlign );
   226                          iTextAlign );
   214             position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta;
   242             position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta;
   215 
   243 
   216             position.iY -= iBaseLineDelta - iFont->DescentInPixels();
   244             position.iY -= iBaseLineDelta - iFont->DescentInPixels();
   217             // Now iY is the top line of rectangle where the picture is
   245             // Now iY is the top line of rectangle where the picture is
   218             // centered in.
   246             // centered in.
   219             position.iY += ( (image->Lines()+1) * iBaseLineDelta -
   247             position.iY += ( ( image->Lines()+1 ) * iBaseLineDelta -
   220                              iFont->HeightInPixels() -
   248                              iFont->HeightInPixels() -
   221                              image->HeightInPixels() ) / 2;
   249                              image->HeightInPixels() ) / 2;
   222 
   250 
   223             // If text is right-aligned, also align images to the right.
   251             // If text is right-aligned, also align images to the right.
   224 
   252 
   225             if ( iTextAlign == CGraphicsContext::ERight )
   253             if ( iTextAlign == CGraphicsContext::ERight )
   226                 {
   254                 {
   227                 position.iX += ( iLineWidth - image->WidthInPixels() );
   255                 position.iX += ( iLineWidth - image->WidthInPixels() );
   228                 }
   256                 }
   229 
   257 
   230             gc.BitBlt( position, image->Bitmap(), aRect );
   258             // Draw javalogo on Screeen (PictureType: svg)
       
   259             gc.BitBltMasked( position, image->Bitmap(), aRect, 
       
   260                     image->BitmapMask(), ETrue );
   231             }
   261             }
   232         }
   262         }
   233     }
   263     }
   234 
   264 
   235 // -----------------------------------------------------------------------------
   265 // -----------------------------------------------------------------------------
   263         {
   293         {
   264         HBufC* line = (*wrappedArray)[i].AllocLC();
   294         HBufC* line = (*wrappedArray)[i].AllocLC();
   265 
   295 
   266 		switch( aItem )
   296 		switch( aItem )
   267 			{
   297 			{
   268 			// The fourteen string's setting
   298 			// Between About real text and oss text
   269 			case 14:
   299 			case KAboutOSSIndex:
   270 				{
   300 				{
   271 				iBreakFlag = ETrue;
   301 				iBreakFlag = ETrue;
   272 				break;
   302 				break;
   273 				}
   303 				}
   274 			default:
   304 			default:
   275 				break;
   305 				break;
   276 			}
   306 			}
   277         if(!line->Length())
   307         if( !line->Length() )
   278             {
   308             {
   279             iText->AppendL( NULL );
   309             iText->AppendL( NULL );
   280 			
   310 			
   281             CleanupStack::PopAndDestroy(line);  // line
   311             CleanupStack::PopAndDestroy( line );  // line
   282             }
   312             }
   283         else
   313         else
   284             {
   314             {
   285             if( iBreakFlag && ( numLines - 1 ) == i )
   315             if( iBreakFlag && ( numLines - 1 ) == i )
   286             	{
   316             	{
   314     if ( aText[ aText.Length() - 1 ] == '\n' )
   344     if ( aText[ aText.Length() - 1 ] == '\n' )
   315         {
   345         {
   316         iText->AppendL( NULL );
   346         iText->AppendL( NULL );
   317 		}
   347 		}
   318 
   348 
   319     CleanupStack::PopAndDestroy(wrappedArray); // wrappedArray
   349     CleanupStack::PopAndDestroy( wrappedArray ); // wrappedArray
   320     delete dataToDestroy;
   350     delete dataToDestroy;
   321 
   351 
   322     // update screen scrolling info array
   352     // update screen scrolling info array
   323 
   353 
   324     TInt lastLine( iText->Count() - 1 );
   354     TInt lastLine( iText->Count() - 1 );
   334             firstNewScreenHandled = ETrue;
   364             firstNewScreenHandled = ETrue;
   335             }
   365             }
   336 
   366 
   337         screenStart += iLinesPerScreen - 1;
   367         screenStart += iLinesPerScreen - 1;
   338         iScreenStarts->AppendL( screenStart );
   368         iScreenStarts->AppendL( screenStart );
   339         if ( ( lastLine == screenStart + 1 ) && ( aItem == iNumItem - 1 ) )
   369         if ( ( lastLine == screenStart + 1 ) && ( aItem == iLoader->ItemCount() - 1 ) )
   340         	{
   370         	{
   341         	iScreenStarts->Delete( iScreenStarts->Count() - 1 );
   371         	iScreenStarts->Delete( iScreenStarts->Count() - 1 );
   342         	}
   372         	}
   343         }
   373         }
   344 
   374 
   354     {
   384     {
   355     TInt firstLineOfImage( iText->Count() );
   385     TInt firstLineOfImage( iText->Count() );
   356 
   386 
   357     // If flag is ETrue, the file type is bmp 
   387     // If flag is ETrue, the file type is bmp 
   358     CAboutImage* image =
   388     CAboutImage* image =
   359     CAboutImage::NewLC( aFileName, aBitmapId, firstLineOfImage, iBaseLineDelta, ETrue );
   389     CAboutImage::NewLC( aFileName, aBitmapId, firstLineOfImage, iBaseLineDelta,
       
   390             EFalse );
   360 
   391 
   361     // new lines to make room for the picture
   392     // new lines to make room for the picture
   362 
   393 
   363     for ( TInt i = 0 ; i < image->Lines() ; i++ )
   394     for ( TInt i = 0 ; i < image->Lines() ; i++ )
   364         {
   395         {
   365         iText->AppendL( NULL );
   396         iText->AppendL( NULL );
   366         }
   397         }
   367 
   398 
   368     iImages->AppendL( image );
   399     iImages->AppendL( image );
   369     CleanupStack::Pop(image); // image
   400     CleanupStack::Pop( image ); // image
   370 
   401 
   371     // update screen scrolling info array
   402     // update screen scrolling info array
   372 
   403 
   373     TInt lastLineOfImage( iText->Count() - 1 );
   404     TInt lastLineOfImage( iText->Count() - 1 );
   374     TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
   405     TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
   439                         }
   470                         }
   440                     case EKeyDownArrow:
   471                     case EKeyDownArrow:
   441                         {
   472                         {
   442                         iScrollBarDragged = EFalse;
   473                         iScrollBarDragged = EFalse;
   443                         if ( ( iCurrentScreen == ( *iScreenStarts )[i] )
   474                         if ( ( iCurrentScreen == ( *iScreenStarts )[i] )
   444                             // Do nothing if the scroll bar is on the bottom, when pressing arrow down.
   475                             // Do nothing if the scroll bar is on the bottom, 
       
   476                             // when pressing arrow down.
   445                             && ( i != ( iScreenStarts->Count() - 1 ) ) )
   477                             && ( i != ( iScreenStarts->Count() - 1 ) ) )
   446                             {
   478                             {
   447                             iCurrentScreen = ( i + 1 );
   479                             iCurrentScreen = ( i + 1 );
   448                             }
   480                             }
   449                        	else
   481                        	else
   516 		// Decide which type of scrollbar is to be shown
   548 		// Decide which type of scrollbar is to be shown
   517         CAknAppUi* appUi = iAvkonAppUi;
   549         CAknAppUi* appUi = iAvkonAppUi;
   518 		if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
   550 		if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
   519 		{
   551 		{
   520 			// For EDoubleSpan type scrollbar
   552 			// For EDoubleSpan type scrollbar
   521 			iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar            
   553 			iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse); // non-window owning scrollbar
   522 			iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
   554 			iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
   523 		}
   555 		}
   524 		else
   556 		else
   525 		{
   557 		{
   526 			// For EArrowHead type scrollbar
   558 			// For EArrowHead type scrollbar
   571 		iSBFrame->TileL( &hSbarModel, &vSbarModel, rect, rect, layout );
   603 		iSBFrame->TileL( &hSbarModel, &vSbarModel, rect, rect, layout );
   572 		iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition );
   604 		iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition );
   573 	}
   605 	}
   574 }
   606 }
   575 
   607 
   576 
   608 // -----------------------------------------------------------------------------
   577 // End of File
   609 // CAboutContainer::CalculateL()
   578 
   610 // -----------------------------------------------------------------------------
   579 void CAboutContainer::CalculateL(const TRect& aRect)
   611 void CAboutContainer::CalculateL( const TRect& aRect )
   580     {
   612     {
   581     TRect rect( 0, 0, 0, 0 );
   613     TRect rect( 0, 0, 0, 0 );
   582     iCurrentScreen = 0;
   614     iCurrentScreen = 0;
   583 	
   615 	
   584     if ( iSkinContext )
   616     if ( iSkinContext )
   652     // This array contains indices for lines that start the subsequent
   684     // This array contains indices for lines that start the subsequent
   653     // screens, for custom scrolling
   685     // screens, for custom scrolling
   654     iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 );
   686     iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 );
   655     // Initialisation: first screen starts at line 0.
   687     // Initialisation: first screen starts at line 0.
   656     iScreenStarts->AppendL( 0 );
   688     iScreenStarts->AppendL( 0 );
   657 
   689     TInt resourceId = 0;
   658     // Read text and image items to be shown on the screen from a resource file.
   690     resourceId = R_ABOUT_MAIN_TEXT;
   659 #ifdef __ABOUT_USE_TEST_RESOURCE__
   691     iResourcePath.Zero();
   660     #include <about_test.rsg>
   692     iLoader->SetResourceId( resourceId, ETrue, iResourcePath );
   661     // test resource
   693     iLoader->StartL();
   662     _LIT(KDirAndFile, "Z:about_test.rsc");
       
   663     TParse* fp = new(ELeave) TParse ();
       
   664     fp->Set (KDirAndFile, &KDC_APP_RESOURCE_DIR, NULL);
       
   665     TBuf<254> KAboutTestResourceFileName;
       
   666     KAboutTestResourceFileName.Copy(fp ->FullName());
       
   667     delete fp;
       
   668     fp=NULL;
       
   669 
       
   670     TFileName fileName( KAboutTestResourceFileName );
       
   671     BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename );
       
   672     TInt testResourceFileOffset = iCoeEnv->AddResourceFileL( fileName );
       
   673     TResourceReader reader;
       
   674     iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_TEST_MAIN_TEXT );
       
   675 #else
       
   676     // real resource
       
   677     TResourceReader reader;
       
   678     iEikonEnv->CreateResourceReaderLC( reader, R_ABOUT_MAIN_TEXT );
       
   679 #endif
       
   680  
       
   681     TInt NumItem( reader.ReadInt16() );
       
   682     iNumItem = NumItem;
       
   683 
       
   684     for ( TInt i = 0 ; i < iNumItem ; i++ )
       
   685         {
       
   686         TInt type = reader.ReadInt8();
       
   687         if ( type == EAboutTextItem )    
       
   688             { 
       
   689             HBufC* text;  
       
   690             if ( reader.ReadInt8() == EAboutUpdateTime )
       
   691                 {  
       
   692                 TTime time;
       
   693                 time.UniversalTime();
       
   694                 TDateTime currentTime = time.DateTime();
       
   695                 text = StringLoader::LoadLC( reader.ReadInt32(), 
       
   696                                             currentTime.Year(), CEikonEnv::Static() );
       
   697                 }
       
   698             else
       
   699                 {
       
   700                 text = iEikonEnv->AllocReadResourceLC( reader.ReadInt32() );
       
   701                 }
       
   702 			SetTextL( *text , i );
       
   703 			CleanupStack::PopAndDestroy( text );
       
   704             }
       
   705         else if ( type == EAboutImageItem )
       
   706             {
       
   707             TPtrC bitmapFile = reader.ReadTPtrC();
       
   708             TInt bitmapId = reader.ReadInt16();
       
   709             if( iIsSvg )
       
   710             	{
       
   711             	TFileName svgPath;
       
   712             	_LIT( KSvgFileName, "Z:about.mif" );
       
   713             	TParse* fpSvg = new( ELeave ) TParse ();
       
   714             	fpSvg->Set( KSvgFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   715             	svgPath.Copy( fpSvg ->FullName() );
       
   716             	delete fpSvg;
       
   717             	fpSvg = NULL;    
       
   718             	SetImageL( svgPath, EMbmAboutQgn_graf_java_logo );
       
   719             	}
       
   720             else
       
   721             	{
       
   722             	SetImageL( bitmapFile, bitmapId );
       
   723             	}
       
   724             }
       
   725         else
       
   726             {
       
   727             User::Panic( KAboutPanicCategory, EAboutNotSupported );
       
   728             }
       
   729         }
       
   730 
       
   731     CleanupStack::PopAndDestroy(); // reader
       
   732 
   694 
   733 #ifdef __ABOUT_USE_TEST_RESOURCE__
   695 #ifdef __ABOUT_USE_TEST_RESOURCE__
   734     if ( testResourceFileOffset )
   696     if ( testResourceFileOffset )
   735         {
   697         {
   736         iCoeEnv->DeleteResourceFile( testResourceFileOffset );
   698         iCoeEnv->DeleteResourceFile( testResourceFileOffset );
   739 
   701 
   740     SetRect( aRect );  
   702     SetRect( aRect );  
   741     UpdateScrollIndicatorL();
   703     UpdateScrollIndicatorL();
   742     }
   704     }
   743 
   705 
   744 
   706 // -----------------------------------------------------------------------------
   745  void CAboutContainer::HandleResourceChange(TInt aType)
   707 // CAboutContainer::HandleResourceChange()
   746  {
   708 // -----------------------------------------------------------------------------
   747 
   709 void CAboutContainer::HandleResourceChange( TInt aType )
   748 switch ( aType )
   710     {
   749   {
   711     switch ( aType )
   750   case KEikDynamicLayoutVariantSwitch :
   712         {
   751        {
   713         case KEikDynamicLayoutVariantSwitch :
   752        TRAP_IGNORE(CalculateL(iAvkonAppUi->ClientRect()));   
   714             {
   753        DrawNow();
   715             TRAP_IGNORE( CalculateL( iAvkonAppUi->ClientRect() ) );
   754        }
   716             DrawNow();
   755        break;
   717             }
   756   case KEikMessageUnfadeWindows :
   718         break;
   757   case KAknsMessageSkinChange :
   719         case KEikMessageUnfadeWindows :
   758        {
   720         case KAknsMessageSkinChange :
   759        TRAP_IGNORE(iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse)); // window owning scrollbar            
   721             {
   760        iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
   722             // window owning scrollbar
   761  	   TRAP_IGNORE(iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn));
   723             TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse ) ); 
   762 	   TRAP_IGNORE(UpdateScrollIndicatorL());
   724             iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan );
   763        }
   725             TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( 
   764         
   726                     CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn ) );
   765   default:
   727             TRAP_IGNORE( UpdateScrollIndicatorL() );
   766        {
   728             }
   767        CCoeControl::HandleResourceChange(aType);
   729         default:
   768        }
   730             {
   769 	   break;
   731             CCoeControl::HandleResourceChange( aType );
   770   }
   732             }
   771 }  
   733         break;
       
   734         }
       
   735 }
   772 // ---------------------------------------------------------
   736 // ---------------------------------------------------------
   773 // CAboutContainer::MopSupplyObject()
   737 // CAboutContainer::MopSupplyObject()
   774 // Pass skin information if need.
   738 // Pass skin information if need.
   775 // ---------------------------------------------------------
   739 // ---------------------------------------------------------
   776 
   740 
   777 TTypeUid::Ptr CAboutContainer::MopSupplyObject(TTypeUid aId)
   741 TTypeUid::Ptr CAboutContainer::MopSupplyObject( TTypeUid aId )
   778     {
   742     {
   779     if (aId.iUid == MAknsControlContext::ETypeId && iSkinContext)
   743     if ( aId.iUid == MAknsControlContext::ETypeId && iSkinContext )
   780         {
   744         {
   781         return MAknsControlContext::SupplyMopObject(aId, iSkinContext);
   745         return MAknsControlContext::SupplyMopObject( aId, iSkinContext );
   782         }
   746         }
   783 
   747     return CCoeControl::MopSupplyObject( aId );
   784     return CCoeControl::MopSupplyObject(aId);
       
   785     }
   748     }
   786 
   749 
   787 // ---------------------------------------------------------
   750 // ---------------------------------------------------------
   788 // CAboutContainer::HandleScrollEventL()
   751 // CAboutContainer::HandleScrollEventL()
   789 // Capture Touch Events on the Scroll Bar
   752 // Capture Touch Events on the Scroll Bar
   790 // ---------------------------------------------------------
   753 // ---------------------------------------------------------
   791 void CAboutContainer::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType)
   754 void CAboutContainer::HandleScrollEventL( CEikScrollBar* aScrollBar, 
       
   755         TEikScrollEvent aEventType )
   792 {
   756 {
   793     //Only on page up/down,scroll up/down and drag events
   757     //Only on page up/down,scroll up/down and drag events
   794     if((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) || 
   758     if( ( aEventType == EEikScrollPageDown ) || ( aEventType == EEikScrollPageUp ) || 
   795        (aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
   759        ( aEventType == EEikScrollThumbDragVert ) || ( aEventType == EEikScrollUp ) ||
   796        (aEventType == EEikScrollDown))
   760        ( aEventType == EEikScrollDown ) )
   797     {
   761     {
   798         //Get the current position from the scroll bar
   762         //Get the current position from the scroll bar
   799         iCurrentScreen = aScrollBar->ThumbPosition();
   763         iCurrentScreen = aScrollBar->ThumbPosition();
   800         
   764         
   801         // Reset flag when dragging scroll bar
   765         // Reset flag when dragging scroll bar
   802         iScrollBarDragged = ETrue;
   766         iScrollBarDragged = ETrue;
   803         //Refresh now
   767         //Refresh now
   804         DrawNow();
   768         DrawNow();
   805         UpdateScrollIndicatorL();
   769         UpdateScrollIndicatorL();
   806     }
   770     }
   807     
       
   808 }
   771 }
       
   772 
       
   773 // ---------------------------------------------------------
       
   774 // CAboutContainer::HandleItemsLoadedL()
       
   775 // Handle resource load Items event.
       
   776 // ---------------------------------------------------------
       
   777 void CAboutContainer::HandleItemsLoadedL( TInt aError )
       
   778     {
       
   779     // Panic if error occurred.
       
   780     if ( aError != KErrNone )
       
   781         {
       
   782         User::Panic( KAboutPanicCategory, aError );
       
   783         }
       
   784     
       
   785     // Display loaded texts
       
   786     RPointerArray<CAboutResource>* items = iLoader->LoadedResourceItems();
       
   787     if ( items )
       
   788         {
       
   789         for ( TInt i = 0; i < items->Count(); i++ )
       
   790             {
       
   791             CAboutResource* item = ( *items )[i];
       
   792             if ( item->ResourceType() == EAboutTextItem )
       
   793                 {
       
   794                 if ( R_ABOUT_MAIN_TEXT == iLoader->CurrentResourceId() )
       
   795                     {
       
   796                     // Only one data record for each
       
   797                     if ( iHandleFlag )
       
   798                         {
       
   799                         // Store the count of the current resource
       
   800                         iCurrentCount = iLoader->ItemCount();
       
   801                         iHandleFlag = EFalse;
       
   802                         }
       
   803                     
       
   804                     SetTextL( *item->ResourceItem(), item->ResourceIndex() );
       
   805                     
       
   806                     // Set the flag to ETrue
       
   807                     if ( iCurrentCount == item->ResourceIndex() )
       
   808                         {
       
   809                         iHandleFlag = ETrue;
       
   810                         }
       
   811                     }
       
   812                 else if ( R_ABOUT_OSS_TEXT == iLoader->CurrentResourceId() )
       
   813                     {
       
   814                     iFinalCount = iCurrentCount + item->ResourceIndex() + 1;
       
   815                     SetTextL( *item->ResourceItem(), iFinalCount );
       
   816                     }
       
   817                 else
       
   818                     {
       
   819                     // Only one data record for each
       
   820                     if ( iHandleFlag )
       
   821                         {
       
   822                         iCurrentCount = iLoader->ItemCount();
       
   823                         iHandleFlag = EFalse;
       
   824                         }
       
   825                     
       
   826                     iFinalCount = iCurrentCount + item->ResourceIndex() + 1;
       
   827                     SetTextL( *item->ResourceItem(), iFinalCount );
       
   828                     }
       
   829                 }
       
   830             else if( item->ResourceType() == EAboutImageItem )
       
   831                 {
       
   832                 SetImageL( *item->ResourceItem(), item->BitmapId() );
       
   833                 }
       
   834             }
       
   835         iLoader->ReleaseLoadedItems();
       
   836         UpdateScrollIndicatorL();
       
   837         DrawDeferred();
       
   838         }
       
   839     }
       
   840 
       
   841 // ---------------------------------------------------------
       
   842 // CAboutContainer::HandleResourceLoadCompletedL()
       
   843 // Handle resource load Completed event.
       
   844 // ---------------------------------------------------------
       
   845 void CAboutContainer::HandleResourceLoadCompletedL( 
       
   846                                 TInt aResourceId, TInt aError )
       
   847     {
       
   848     // Panic if error occurred.
       
   849     if ( aError != KErrNone )
       
   850         {
       
   851         User::Panic( KAboutPanicCategory, aError );
       
   852         }
       
   853     
       
   854     // R_ABOUT_OSS_TEXT_ADD is the last one we loaded, 
       
   855     // do nothing here when it loaded.
       
   856     if ( R_ABOUT_OSS_TEXT_ADD == aResourceId )
       
   857         {
       
   858         return;
       
   859         }
       
   860     
       
   861     // Load other resources including R_ABOUT_OSS_TEXT and R_ABOUT_OSS_TEXT_ADD
       
   862     TInt resourceId( aResourceId );
       
   863     if( R_ABOUT_MAIN_TEXT == resourceId )
       
   864         {
       
   865         // Load the R_ABOUT_OSS_TEXT
       
   866         // Set the resource which you want to load next
       
   867         resourceId = R_ABOUT_OSS_TEXT;
       
   868         // Set the resource's path
       
   869         iResourcePath.Copy( KRSCDirAndFile );
       
   870         }
       
   871     else
       
   872         {
       
   873         // Load the R_ABOUT_OSS_TEXT_ADD
       
   874         resourceId = R_ABOUT_OSS_TEXT_ADD;
       
   875         iResourcePath.Copy( KRSCDirAndFileAdd );
       
   876         }
       
   877     
       
   878     // Load to complete a resource and continue to load next resources
       
   879     iLoader->SetResourceId( resourceId, EFalse, iResourcePath );
       
   880     iLoader->StartL();
       
   881     }
       
   882 
       
   883 // End of File