uifw/AvKon/src/akntitle.cpp
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Implementation for the default control in the
       
    15 *                status pane's title pane.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // SYSTEM INCLUDE FILES
       
    21 #include <eikclbd.h>
       
    22 #include <eikfutil.h>
       
    23 #include <eikappui.h>
       
    24 #include <eikapp.h>
       
    25 #include <eikspane.h>
       
    26 #include <apgcli.h>
       
    27 #include <eiklabel.h>
       
    28 #include <eikimage.h>
       
    29 #include <gulalign.h>
       
    30 #include <avkon.rsg>
       
    31 #include <AknLayout.lag>
       
    32 #include <AknsDrawUtils.h>
       
    33 #include <AknBidiTextUtils.h>
       
    34 #include <PUAcodes.hrh>
       
    35 #include <AknPictographInterface.h>
       
    36 #include <AknPictographDrawerInterface.h>
       
    37 #include <aknlayoutscalable_avkon.cdl.h>
       
    38 #include <eikenv.h>
       
    39 #include <layoutmetadata.cdl.h>
       
    40 
       
    41 #include <AknTasHook.h>
       
    42 // USER INCLUDE FILES
       
    43 #include "aknappui.h"
       
    44 #include "AknUtils.h"
       
    45 #include "avkon.hrh"
       
    46 #include "AknPanic.h"
       
    47 #include "akntitle.h"
       
    48 #include "aknconsts.h"
       
    49 #include "AknStatuspaneUtils.h"
       
    50 #include "AknTitlePaneLabel.h"
       
    51 #include "AknTitlePaneObserver.h"
       
    52 #include "aknnavi.h"
       
    53 #include "aknnavide.h"
       
    54 
       
    55 // Titlepane flags
       
    56 enum TTitlePaneControlFlags
       
    57     {
       
    58     EAknTitlePaneButton1DownInTitleRect = 0x00000001
       
    59     };
       
    60 
       
    61 // Scrolling related constants
       
    62 const TInt KScrollPauseBeforeScroll     = 1000000; // 1.0s
       
    63 const TInt KScrollPauseBeforeFadeOut    = 2000000; // 2s
       
    64 const TInt KScrollPauseBeforeFadeIn     = 500000;  // 0.5s
       
    65 const TInt KScrollFadeInFadeOutDuration = 1000000; // 1s
       
    66 
       
    67 const TInt KTitleMaxLines = 2;
       
    68 
       
    69 NONSHARABLE_CLASS( CAknTitlePaneExtension )
       
    70     : public CBase,
       
    71       public MAknPictographAnimatorCallBack
       
    72     {
       
    73 public:
       
    74     static CAknTitlePaneExtension* NewL( CAknTitlePane& aOwner );
       
    75     ~CAknTitlePaneExtension();
       
    76 
       
    77 private: // From MAknPictographAnimatorCallBack
       
    78     void DrawPictographArea();
       
    79 
       
    80 private:
       
    81     CAknTitlePaneExtension( CAknTitlePane& aOwner );
       
    82     void ConstructL();
       
    83 
       
    84 public:
       
    85     CAknTitlePane&           iOwner;
       
    86     CEikImage*               iTitleImage;
       
    87     CAknPictographInterface* iPictoInterface;
       
    88 
       
    89     TInt                     iFlags;
       
    90 
       
    91     TBool                    iSmallImageShown;
       
    92     TBool                    iScrollEffectEnabled;
       
    93     TBool                    iScrollEffectNeeded;
       
    94     TInt                     iCurrentNumberOfTextLines;
       
    95     TInt                     iLimitedNumberOfTextLines;
       
    96 
       
    97     TBool                    iImageAutoscaling;
       
    98     TBool                    iSmallImageAutoscaling;
       
    99     };
       
   100 
       
   101 
       
   102 // ----------------------------------------------------------------------------
       
   103 // CAknTitlePaneExtension::NewL
       
   104 // Two-phased constructor.
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 CAknTitlePaneExtension* CAknTitlePaneExtension::NewL( CAknTitlePane& aOwner )
       
   108     {
       
   109     CAknTitlePaneExtension* self =
       
   110         new( ELeave ) CAknTitlePaneExtension( aOwner );
       
   111 
       
   112     CleanupStack::PushL( self );
       
   113     self->ConstructL();
       
   114     CleanupStack::Pop( self );
       
   115 
       
   116     return self;
       
   117     }
       
   118 
       
   119 
       
   120 // ----------------------------------------------------------------------------
       
   121 // CAknTitlePaneExtension::~CAknTitlePaneExtension
       
   122 // Destructor.
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 CAknTitlePaneExtension::~CAknTitlePaneExtension()
       
   126     {
       
   127     delete iTitleImage;
       
   128     delete iPictoInterface;
       
   129     }
       
   130 
       
   131 
       
   132 // ----------------------------------------------------------------------------
       
   133 // CAknTitlePaneExtension::CAknTitlePaneExtension
       
   134 // C++ constructor.
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 CAknTitlePaneExtension::CAknTitlePaneExtension( CAknTitlePane& aOwner )
       
   138     : iOwner( aOwner )
       
   139     {
       
   140     }
       
   141 
       
   142 
       
   143 // ----------------------------------------------------------------------------
       
   144 // CAknTitlePaneExtension::ConstructL
       
   145 // Second-phase constructor.
       
   146 // ----------------------------------------------------------------------------
       
   147 //
       
   148 void CAknTitlePaneExtension::ConstructL()
       
   149     {
       
   150     iTitleImage = new( ELeave ) CEikImage;
       
   151     iTitleImage->SetContainerWindowL( iOwner );
       
   152     iTitleImage->SetNonFocusing();
       
   153     iTitleImage->ActivateL();
       
   154 
       
   155     // Returns NULL if not supported.
       
   156     iPictoInterface = CAknPictographInterface::NewL( iOwner, *this );
       
   157     iScrollEffectEnabled = EFalse;
       
   158     }
       
   159 
       
   160 
       
   161 // ----------------------------------------------------------------------------
       
   162 // CAknTitlePaneExtension::DrawPictographArea
       
   163 // Draws the pictographs.
       
   164 // ----------------------------------------------------------------------------
       
   165 //
       
   166 void CAknTitlePaneExtension::DrawPictographArea()
       
   167     {
       
   168     iOwner.DrawDeferred();
       
   169     }
       
   170 
       
   171 
       
   172 // ----------------------------------------------------------------------------
       
   173 // CAknTitlePane::CAknTitlePane
       
   174 // Default constructor.
       
   175 // ----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C CAknTitlePane::CAknTitlePane()
       
   178     {
       
   179     AKNTASHOOK_ADD( this, "CAknTitlePane" );
       
   180     }
       
   181 
       
   182 
       
   183 // ----------------------------------------------------------------------------
       
   184 // CAknTitlePane::~CAknTitlePane
       
   185 // Destructor.
       
   186 // ----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C CAknTitlePane::~CAknTitlePane()
       
   189     {
       
   190     AKNTASHOOK_REMOVE();
       
   191     AknsUtils::DeregisterControlPosition( this );
       
   192 
       
   193     delete iTitleText;
       
   194     delete iDefaultTitleText;
       
   195     delete iTitleLabel;
       
   196     delete iExtension;
       
   197     }
       
   198 
       
   199 
       
   200 // ----------------------------------------------------------------------------
       
   201 // CAknTitlePane::ConstructL
       
   202 // Second-phase constructor.
       
   203 // ----------------------------------------------------------------------------
       
   204 //
       
   205 EXPORT_C void CAknTitlePane::ConstructL()
       
   206     {
       
   207     CommonConstructL();
       
   208     SetTextToDefaultL();
       
   209 
       
   210     if ( AknLayoutUtils::PenEnabled() )
       
   211         {
       
   212         // set flags to default values
       
   213         iExtension->iFlags = 0;
       
   214         }
       
   215     }
       
   216 
       
   217 
       
   218 // ----------------------------------------------------------------------------
       
   219 // CAknTitlePane::ConstructFromResourceL
       
   220 // Resource constructor.
       
   221 // ----------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void CAknTitlePane::ConstructFromResourceL( TResourceReader& aReader )
       
   224     {
       
   225     CommonConstructL();
       
   226     ReadFromResourceFileL( aReader );
       
   227     }
       
   228 
       
   229 
       
   230 // ----------------------------------------------------------------------------
       
   231 // CAknTitlePane::SetTextL
       
   232 // Sets the title pane text.
       
   233 // ----------------------------------------------------------------------------
       
   234 //
       
   235 EXPORT_C void CAknTitlePane::SetTextL( const TDesC& aText )
       
   236     {
       
   237     SetText( aText.AllocL(), EFalse );
       
   238     }
       
   239 
       
   240 
       
   241 
       
   242 // ----------------------------------------------------------------------------
       
   243 // CAknTitlePane::SetText
       
   244 // Sets the title pane text.
       
   245 // ----------------------------------------------------------------------------
       
   246 //
       
   247 EXPORT_C void CAknTitlePane::SetText( HBufC* aText )
       
   248     {
       
   249     SetText( aText, EFalse );
       
   250     }
       
   251 
       
   252 
       
   253 // ----------------------------------------------------------------------------
       
   254 // CAknTitlePane::SetSmallPicture
       
   255 // Sets the small title pane picture.
       
   256 // ----------------------------------------------------------------------------
       
   257 //
       
   258 EXPORT_C void CAknTitlePane::SetSmallPicture( const CFbsBitmap* aBitmap,
       
   259                                               const CFbsBitmap* aMaskBitmap,
       
   260                                               TBool aVisible )
       
   261     {
       
   262     if ( iExtension->iTitleImage )
       
   263         {
       
   264         // If NULL image is given, previous (existing) image is shown.
       
   265         if ( aBitmap )
       
   266             {
       
   267             iExtension->iTitleImage->SetPictureOwnedExternally( EFalse );
       
   268             iExtension->iTitleImage->SetPicture( aBitmap, aMaskBitmap );
       
   269 
       
   270             if ( iExtension->iTitleImage->Bitmap() &&
       
   271                  iExtension->iTitleImage->Bitmap()->SizeInPixels() == TSize( 0, 0 ) )
       
   272                 {
       
   273                 // Picture is scaled by title pane if the bitmap's
       
   274                 // size is not set.
       
   275                 iExtension->iSmallImageAutoscaling = ETrue;
       
   276                 }
       
   277             else
       
   278                 {
       
   279                 iExtension->iSmallImageAutoscaling = EFalse;
       
   280                 }
       
   281             }
       
   282 
       
   283         if ( aVisible )
       
   284             {
       
   285             iExtension->iSmallImageShown = ETrue;
       
   286             iImageShown = EFalse;
       
   287             }
       
   288         else
       
   289             {
       
   290             iExtension->iSmallImageShown = EFalse;
       
   291             iImageShown = EFalse;
       
   292             }
       
   293 
       
   294         SizeChanged();
       
   295         DrawDeferred();
       
   296         }
       
   297     }
       
   298 
       
   299 
       
   300 // ----------------------------------------------------------------------------
       
   301 // CAknTitlePane::SetPicture
       
   302 // Sets the large title pane picture (operator logo).
       
   303 // ----------------------------------------------------------------------------
       
   304 //
       
   305 EXPORT_C void CAknTitlePane::SetPicture( const CFbsBitmap* aBitmap,
       
   306                                          const CFbsBitmap* aMaskBitmap )
       
   307     {
       
   308     if ( iExtension && iExtension->iTitleImage )
       
   309         {
       
   310         // If NULL image is given, previous (existing) image is shown.
       
   311         if ( aBitmap )
       
   312             {
       
   313             iExtension->iTitleImage->SetPictureOwnedExternally( EFalse );
       
   314             iExtension->iTitleImage->SetPicture( aBitmap, aMaskBitmap );
       
   315 
       
   316             if ( iExtension->iTitleImage->Bitmap() &&
       
   317                  iExtension->iTitleImage->Bitmap()->SizeInPixels() == TSize( 0, 0 ) )
       
   318                 {
       
   319                 // Picture is scaled by title pane if the bitmap's
       
   320                 // size is not set.
       
   321                 iExtension->iImageAutoscaling = ETrue;
       
   322                 }
       
   323             else
       
   324                 {
       
   325                 iExtension->iImageAutoscaling = EFalse;
       
   326                 }
       
   327             }
       
   328 
       
   329         iImageShown = ETrue;
       
   330         iExtension->iSmallImageShown = EFalse;
       
   331         SizeChanged();
       
   332         DrawDeferred();
       
   333         }
       
   334     }
       
   335 
       
   336 
       
   337 // ----------------------------------------------------------------------------
       
   338 // CAknTitlePane::SetSmallPictureFromFileL
       
   339 // Sets the small title pane picture from a file.
       
   340 // Used by the resource constructor.
       
   341 // ----------------------------------------------------------------------------
       
   342 //
       
   343 void CAknTitlePane::SetSmallPictureFromFileL( const TDesC& aFileName,
       
   344                                               TInt aMainId,
       
   345                                               TInt aMaskId )
       
   346     {
       
   347     if ( iExtension && iExtension->iTitleImage )
       
   348         {
       
   349         CEikImage*& img = iExtension->iTitleImage;
       
   350         delete img;
       
   351         img = NULL;
       
   352 
       
   353         img = new (ELeave) CEikImage;
       
   354         img->CreatePictureFromFileL( aFileName, aMainId, aMaskId );
       
   355 
       
   356         iImageShown = EFalse;
       
   357         iExtension->iSmallImageShown = ETrue;
       
   358 
       
   359         iExtension->iTitleImage->SetPictureOwnedExternally( EFalse );
       
   360 
       
   361         if ( iExtension->iTitleImage->Bitmap() &&
       
   362              iExtension->iTitleImage->Bitmap()->SizeInPixels() == TSize( 0, 0 ) )
       
   363                 {
       
   364                 // Picture is scaled by title pane if the bitmap's
       
   365                 // size is not set.
       
   366                 iExtension->iSmallImageAutoscaling = ETrue;
       
   367                 }
       
   368             else
       
   369                 {
       
   370                 iExtension->iSmallImageAutoscaling = EFalse;
       
   371                 }
       
   372 
       
   373         SizeChanged();
       
   374         DrawDeferred();
       
   375         }
       
   376     }
       
   377 
       
   378 
       
   379 // ----------------------------------------------------------------------------
       
   380 // CAknTitlePane::SetPictureFromFileL
       
   381 // Sets the large title pane picture (operator logo) from a file.
       
   382 // ----------------------------------------------------------------------------
       
   383 //
       
   384 EXPORT_C void CAknTitlePane::SetPictureFromFileL( const TDesC& aFileName,
       
   385                                                   TInt aMainId,
       
   386                                                   TInt aMaskId )
       
   387     {
       
   388     CEikImage*& img = iExtension->iTitleImage;
       
   389 
       
   390     delete img;
       
   391     img = NULL;
       
   392 
       
   393     img = new (ELeave) CEikImage;
       
   394     img->SetContainerWindowL( *this );
       
   395     img->SetNonFocusing();
       
   396     img->ActivateL();
       
   397     img->CreatePictureFromFileL( aFileName, aMainId, aMaskId );
       
   398 
       
   399     iImageShown = ETrue;
       
   400     iExtension->iSmallImageShown = EFalse;
       
   401 
       
   402     if ( iExtension->iTitleImage &&
       
   403          iExtension->iTitleImage->Bitmap() &&
       
   404          iExtension->iTitleImage->Bitmap()->SizeInPixels() == TSize( 0, 0 ) )
       
   405         {
       
   406         iExtension->iImageAutoscaling = ETrue;
       
   407         }
       
   408     else
       
   409         {
       
   410         iExtension->iImageAutoscaling = EFalse;
       
   411         }
       
   412 
       
   413     SizeChanged();
       
   414     DrawDeferred();
       
   415     }
       
   416 
       
   417 
       
   418 // ----------------------------------------------------------------------------
       
   419 // CAknTitlePane::SetFromResourceL
       
   420 // Sets the title pane content from a resource.
       
   421 // ----------------------------------------------------------------------------
       
   422 //
       
   423 EXPORT_C void CAknTitlePane::SetFromResourceL( TResourceReader& aReader )
       
   424     {
       
   425     if ( !iTitleLabel && !iExtension ) // not constructed yet
       
   426         {
       
   427         ConstructFromResourceL( aReader );
       
   428         }
       
   429     else // update from resource
       
   430         {
       
   431         ReadFromResourceFileL(aReader);
       
   432         }
       
   433     }
       
   434 
       
   435 
       
   436 // ----------------------------------------------------------------------------
       
   437 // CAknTitlePane::SetTextToDefaultL
       
   438 // Sets the title pane text to default (application name).
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 EXPORT_C void CAknTitlePane::SetTextToDefaultL()
       
   442     {
       
   443     iExtension->iScrollEffectEnabled = EFalse;
       
   444 
       
   445     if ( iDefaultTitleText )
       
   446         {
       
   447         SetTextL( *iDefaultTitleText );
       
   448         return;
       
   449         }
       
   450 
       
   451     TBool textSet = EFalse;
       
   452     RApaLsSession lsSession;
       
   453     TInt ret = lsSession.Connect();
       
   454     if ( ret == KErrNone )
       
   455         {
       
   456         CleanupClosePushL( lsSession );
       
   457         TApaAppInfo appInfo;
       
   458         ret = lsSession.GetAppInfo( appInfo, AppUid() );
       
   459         if ( ret == KErrNone )
       
   460             {
       
   461             iDefaultTitleText = appInfo.iCaption.AllocL();
       
   462             SetTextL( *iDefaultTitleText );
       
   463             textSet = ETrue;
       
   464             }
       
   465         CleanupStack::PopAndDestroy( &lsSession);
       
   466         }
       
   467 
       
   468     if ( !textSet )
       
   469         {
       
   470         SetTextL( KTitlePaneDefaultText );
       
   471         }
       
   472     }
       
   473 
       
   474 
       
   475 // ----------------------------------------------------------------------------
       
   476 // CAknTitlePane::PrepareContext
       
   477 // Updates the text color for the window context from skin.
       
   478 // ----------------------------------------------------------------------------
       
   479 //
       
   480 EXPORT_C void CAknTitlePane::PrepareContext( CWindowGc& aGc ) const
       
   481     {
       
   482     if ( !iImageShown )
       
   483         {
       
   484         TRgb color;
       
   485         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   486         TInt error = AknsUtils::GetCachedColor( skin,
       
   487                                                 color,
       
   488                                                 KAknsIIDQsnTextColors,
       
   489                                                 EAknsCIQsnTextColorsCG1 );
       
   490         if ( !error )
       
   491             {
       
   492             aGc.SetPenColor( color );
       
   493             }
       
   494         }
       
   495     }
       
   496 
       
   497 
       
   498 // ----------------------------------------------------------------------------
       
   499 // CAknTitlePane::SizeChanged
       
   500 // Handles size change events.
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 EXPORT_C void CAknTitlePane::SizeChanged()
       
   504     {
       
   505     // No fading if staconpane is active, because status pane
       
   506     // and control pane are combined.
       
   507     SetContainerWindowNonFading( AknStatuspaneUtils::StaconPaneActive() );
       
   508 
       
   509     // If fonts are destroyed with ENV destruction sequence, then abort.
       
   510     // TBD is a way to detect it right, we use this hack instead for now.
       
   511     if ( !( iEikonEnv->Alert() ) )
       
   512         {
       
   513         return;
       
   514         }
       
   515 
       
   516     TInt spLayout( AknStatuspaneUtils::CurrentStatusPaneLayoutResId() );
       
   517     
       
   518     if ( AknStatuspaneUtils::StaconPaneActive() )
       
   519         {
       
   520         SizeChangedInStaconPane();
       
   521         }
       
   522     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
   523         {
       
   524         SizeChangedInFlatStatusPane();
       
   525         }
       
   526     else if ( AknStatuspaneUtils::ExtendedLayoutActive() ||
       
   527               spLayout == R_AVKON_STATUS_PANE_LAYOUT_VT ||
       
   528               spLayout == R_AVKON_STATUS_PANE_LAYOUT_VT_MIRRORED )
       
   529         {
       
   530         // Use the extended title pane layout also for
       
   531         // the video telephony status pane layout, since
       
   532         // two-row title text is no longer supported.
       
   533         SizeChangedInExtendedStatusPane();
       
   534         }
       
   535     else
       
   536         {
       
   537         SizeChangedInNormalStatusPane();
       
   538         }
       
   539         
       
   540     // Update also the navi pane size, because in flat status pane layout
       
   541     // it draws part of the title pane if narrow navi pane
       
   542     // layout is in use.
       
   543     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
   544     if ( statusPane )
       
   545         {
       
   546         CCoeControl* naviPane = NULL;
       
   547         
       
   548         TRAP_IGNORE(
       
   549             naviPane = statusPane->ContainerControlL(
       
   550                 TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   551         
       
   552         if ( naviPane )
       
   553             {
       
   554             naviPane->DrawDeferred();
       
   555             }
       
   556         }
       
   557     }
       
   558 
       
   559 
       
   560 // ----------------------------------------------------------------------------
       
   561 // CAknTitlePane::PositionChanged
       
   562 // Handles position change events.
       
   563 // ----------------------------------------------------------------------------
       
   564 //
       
   565 EXPORT_C void CAknTitlePane::PositionChanged()
       
   566     {
       
   567     AknsUtils::RegisterControlPosition( this );
       
   568     }
       
   569 
       
   570 
       
   571 // ----------------------------------------------------------------------------
       
   572 // CAknTitlePane::HandleResourceChange
       
   573 // Handles resource change events.
       
   574 // ----------------------------------------------------------------------------
       
   575 //
       
   576 EXPORT_C void CAknTitlePane::HandleResourceChange( TInt aType )
       
   577     {
       
   578     CCoeControl::HandleResourceChange( aType );
       
   579 
       
   580     if ( aType == KEikDynamicLayoutVariantSwitch ||
       
   581          aType == KEikColorResourceChange ||
       
   582          aType == KAknsMessageSkinChange )
       
   583         {
       
   584         SizeChanged();
       
   585         DrawDeferred();
       
   586         }
       
   587     }
       
   588 
       
   589 
       
   590 // ----------------------------------------------------------------------------
       
   591 // CAknTitlePane::CountComponentControls
       
   592 // Returns the amount of component controls.
       
   593 // ----------------------------------------------------------------------------
       
   594 //
       
   595 EXPORT_C TInt CAknTitlePane::CountComponentControls() const
       
   596     {
       
   597     TInt controls( 0 );
       
   598 
       
   599     if ( ( AknStatuspaneUtils::StaconPaneActive() ||
       
   600            AknStatuspaneUtils::FlatLayoutActive() ||
       
   601            AknStatuspaneUtils::ExtendedLayoutActive()) &&
       
   602            !iImageShown )
       
   603         {
       
   604         // Both small image and text can be show simultaneusly
       
   605         if ( iTitleLabel )
       
   606             {
       
   607             controls++;
       
   608             }
       
   609 
       
   610         if ( iExtension->iSmallImageShown &&
       
   611              iExtension->iTitleImage )
       
   612             {
       
   613             controls++;
       
   614             }
       
   615         }
       
   616     else
       
   617         {
       
   618         // Only image or text can be shown simultaneusly
       
   619         if ( ( iImageShown &&
       
   620                iExtension->iTitleImage ) ||
       
   621              ( !iImageShown && iTitleLabel ) )
       
   622             {
       
   623             controls++;
       
   624             }
       
   625         }
       
   626 
       
   627     return controls;
       
   628     }
       
   629 
       
   630 
       
   631 // ----------------------------------------------------------------------------
       
   632 // CAknTitlePane::ComponentControl
       
   633 // Gets a component control by a control index.
       
   634 // ----------------------------------------------------------------------------
       
   635 //
       
   636 EXPORT_C CCoeControl* CAknTitlePane::ComponentControl( TInt aIndex ) const
       
   637     {
       
   638     CCoeControl* componentControl = NULL;
       
   639 
       
   640     if ( ( AknStatuspaneUtils::StaconPaneActive() ||
       
   641            AknStatuspaneUtils::FlatLayoutActive() ||
       
   642            AknStatuspaneUtils::ExtendedLayoutActive() ) &&
       
   643          !iImageShown )
       
   644         {
       
   645         // Both image and text can be show simultaneusly
       
   646         if ( aIndex == 0 && iExtension->iSmallImageShown )
       
   647             {
       
   648             componentControl = iExtension->iTitleImage;
       
   649             }
       
   650         else
       
   651             {
       
   652             componentControl = iTitleLabel;
       
   653             }
       
   654         }
       
   655     else
       
   656         {
       
   657         // Only image or text can be shown simultaneusly
       
   658         if ( iImageShown )
       
   659             {
       
   660             componentControl = iExtension->iTitleImage;
       
   661             }
       
   662         else
       
   663             {
       
   664             componentControl = iTitleLabel;
       
   665             }
       
   666         }
       
   667 
       
   668     return componentControl;
       
   669     }
       
   670 
       
   671 
       
   672 // ----------------------------------------------------------------------------
       
   673 // CAknTitlePane::Draw
       
   674 // Draws the title pane.
       
   675 // ----------------------------------------------------------------------------
       
   676 //
       
   677 EXPORT_C void CAknTitlePane::Draw( const TRect& aRect ) const
       
   678     {
       
   679     const TUid KActiveIdle2Uid = {0x102750F0};
       
   680 
       
   681     if ( AppUid() == KActiveIdle2Uid )
       
   682         {
       
   683         CWindowGc& gc = SystemGc();
       
   684         TRgb rgb(TRgb::Color16MA(0));
       
   685         gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
       
   686         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   687         gc.SetBrushColor(rgb);
       
   688         gc.Clear( aRect );
       
   689         return;
       
   690         }
       
   691 
       
   692     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   693 
       
   694     TRect rect( Rect() );
       
   695 
       
   696     CWindowGc& gc=SystemGc();
       
   697 
       
   698     if ( AknStatuspaneUtils::StaconPaneActive() ||
       
   699          AknStatuspaneUtils::FlatLayoutActive() )
       
   700         {
       
   701         MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   702 
       
   703         if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
       
   704             {
       
   705             gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   706             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   707             gc.SetBrushColor(
       
   708                 AKN_LAF_COLOR( KStatusPaneBackgroundGraphicsColorUsual ) );
       
   709             gc.DrawRect( rect );
       
   710             }
       
   711         }
       
   712     else
       
   713         {
       
   714         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   715         gc.SetBrushColor( AKN_LAF_COLOR( KStatusPaneBackgroundColor ) );
       
   716         AknsDrawUtils::Background( skin,
       
   717                                    AknsDrawUtils::ControlContext( this ),
       
   718                                    this,
       
   719                                    gc,
       
   720                                    rect );
       
   721         }
       
   722     }
       
   723 
       
   724 
       
   725 // ----------------------------------------------------------------------------
       
   726 // CAknTitlePane::CommonConstructL
       
   727 // Common second-phase constructor for normal and resource construction.
       
   728 // ----------------------------------------------------------------------------
       
   729 //
       
   730 void CAknTitlePane::CommonConstructL()
       
   731     {
       
   732     iTitleLabel = new (ELeave) CAknTitlePaneLabel;
       
   733     // we do logical to visual conversion ourselves while wrapping text
       
   734     iTitleLabel->UseLogicalToVisualConversion( EFalse );
       
   735 
       
   736     iExtension = CAknTitlePaneExtension::NewL( *this );
       
   737 
       
   738     if ( iExtension->iPictoInterface )
       
   739         {
       
   740         iTitleLabel->SetPictographInterface( *iExtension->iPictoInterface );
       
   741         }
       
   742 
       
   743     iTitleLabel->SetContainerWindowL( *this );
       
   744     iTitleLabel->SetNonFocusing();
       
   745     iTitleLabel->ActivateL();
       
   746 
       
   747     // Observer is needed with pensupport
       
   748     iTitlePaneObserver = NULL;
       
   749 
       
   750     SetControlContext( this );
       
   751     }
       
   752 
       
   753 
       
   754 // ----------------------------------------------------------------------------
       
   755 // CAknTitlePane::AppUid
       
   756 // Gets the application UID.
       
   757 // ----------------------------------------------------------------------------
       
   758 //
       
   759 TUid CAknTitlePane::AppUid() const
       
   760     {
       
   761     CEikApplication* app = iEikonEnv->EikAppUi()->Application();
       
   762     if ( app )
       
   763         {
       
   764         return app->AppDllUid();
       
   765         }
       
   766     else
       
   767         {
       
   768         return KNullUid;
       
   769         }
       
   770     }
       
   771 
       
   772 
       
   773 NONSHARABLE_CLASS( CTextLayoutManager ) : public CBase
       
   774     {
       
   775 public:
       
   776     enum TLayout
       
   777         {
       
   778         ENoLayout,
       
   779         EOneLineLayout,
       
   780         ETwoLineLayout
       
   781         };
       
   782 
       
   783 public:
       
   784     CTextLayoutManager( const TInt aOneLineLayoutWidth,
       
   785                         const TInt aTwoLineLayoutWidth,
       
   786                         const CFont* aOneLineFont,
       
   787                         const CFont* aTwoLineFont )
       
   788       : iOneLineWidth( aOneLineLayoutWidth ),
       
   789         iTwoLineWidth( aTwoLineLayoutWidth ),
       
   790         iOneLineFont( aOneLineFont ),
       
   791         iTwoLineFont( aTwoLineFont )
       
   792         {}
       
   793 
       
   794     static CTextLayoutManager* NewLC( const TInt aOneLineLayoutWidth,
       
   795                                       const TInt aTwoLineLayoutWidth,
       
   796                                       const CFont* aOneLineFont,
       
   797                                       const CFont* aTwoLineFont );
       
   798     void ConstructL();
       
   799     ~CTextLayoutManager();
       
   800 
       
   801     void Reset();
       
   802     void DoLayoutL( TInt aLineNum, const TDesC& aText );
       
   803     const TLayout& Layout() const;
       
   804 
       
   805     TInt Lines() const;
       
   806     const TDesC& Text() const;
       
   807 
       
   808 private:
       
   809     TInt                  iOneLineWidth;
       
   810     TInt                  iTwoLineWidth;
       
   811     const CFont*          iOneLineFont; // not owned
       
   812     const CFont*          iTwoLineFont; // not owned
       
   813 
       
   814     CArrayFixFlat<TInt>*  iLineWidthArray;
       
   815     HBufC*                iText;
       
   816     TLayout               iLayout;
       
   817 
       
   818     };
       
   819 
       
   820 
       
   821 CTextLayoutManager* CTextLayoutManager::NewLC( const TInt aOneLineLayoutWidth,
       
   822                                                const TInt aTwoLineLayoutWidth,
       
   823                                                const CFont* aOneLineFont,
       
   824                                                const CFont* aTwoLineFont )
       
   825     {
       
   826     CTextLayoutManager* self = new (ELeave) CTextLayoutManager(
       
   827         aOneLineLayoutWidth, aTwoLineLayoutWidth, aOneLineFont, aTwoLineFont );
       
   828     CleanupStack::PushL( self );
       
   829 
       
   830     self->ConstructL();
       
   831     return self;
       
   832     }
       
   833 
       
   834 
       
   835 void CTextLayoutManager::ConstructL()
       
   836     {
       
   837     iLineWidthArray = new (ELeave) CArrayFixFlat<TInt>( KTitleMaxLines );
       
   838     }
       
   839 
       
   840 
       
   841 CTextLayoutManager::~CTextLayoutManager()
       
   842     {
       
   843     if ( iLineWidthArray )
       
   844         {
       
   845         iLineWidthArray->Reset();
       
   846         }
       
   847 
       
   848     delete iLineWidthArray;
       
   849     delete iText;
       
   850     }
       
   851 
       
   852 
       
   853 void CTextLayoutManager::Reset()
       
   854     {
       
   855     delete iText;
       
   856     iText = NULL;
       
   857 
       
   858     if ( iLineWidthArray )
       
   859         {
       
   860         iLineWidthArray->Reset();
       
   861         }
       
   862     iLayout = ENoLayout;
       
   863     }
       
   864 
       
   865 
       
   866 void CTextLayoutManager::DoLayoutL( TInt aLineNum, const TDesC& aText )
       
   867     {
       
   868     __ASSERT_DEBUG( aLineNum == 1 || aLineNum == 2,
       
   869                     Panic( EAknPanicNotSupported ) );
       
   870 
       
   871     __ASSERT_DEBUG( iLineWidthArray->Count() == 0,
       
   872                     Panic( EAknPanicSelfCheckFailure ) );
       
   873 
       
   874     const CFont* font = NULL;
       
   875 
       
   876     if ( aLineNum == 1 )
       
   877         {
       
   878         iLineWidthArray->AppendL( iOneLineWidth );
       
   879         if ( iTwoLineWidth )
       
   880             {
       
   881             // Added only if there exists 2nd line.
       
   882             iLineWidthArray->AppendL( iTwoLineWidth );
       
   883             }
       
   884         font    = iOneLineFont;
       
   885         iLayout = EOneLineLayout;
       
   886         }
       
   887     else
       
   888         {
       
   889         iLineWidthArray->AppendL( iOneLineWidth );
       
   890         if ( iTwoLineWidth )
       
   891             {
       
   892             // Added only if there exists 2nd line.
       
   893             iLineWidthArray->AppendL( iTwoLineWidth );
       
   894             }
       
   895         font    = iTwoLineFont;
       
   896         iLayout = ETwoLineLayout;
       
   897         }
       
   898 
       
   899     __ASSERT_DEBUG( iText == NULL, Panic( EAknPanicNullPointer ) );
       
   900 
       
   901     if ( !iText )
       
   902         {
       
   903         // +1 is for line ends
       
   904         iText = HBufC::NewL(
       
   905             aText.Length() + KTitleMaxLines * (KAknBidiExtraSpacePerLine + 1) );
       
   906         }
       
   907 
       
   908     TPtr ptr = iText->Des();
       
   909     AknBidiTextUtils::ConvertToVisualAndWrapToStringL(
       
   910         aText, *iLineWidthArray, *font, ptr, ETrue );
       
   911 
       
   912     }
       
   913 
       
   914 
       
   915 /**
       
   916  * Return type of layout set in DoLayout operation, either one line
       
   917  * layout or two line layout.
       
   918  */
       
   919 const CTextLayoutManager::TLayout& CTextLayoutManager::Layout() const
       
   920     {
       
   921     return iLayout;
       
   922     }
       
   923 
       
   924 
       
   925 /**
       
   926  * Return number of lines by locating \n chars
       
   927  * in the text. These have been inserted by wrapping
       
   928  * algorithm.
       
   929  */
       
   930 TInt CTextLayoutManager::Lines() const
       
   931     {
       
   932     __ASSERT_DEBUG( iText, Panic( EAknPanicNullPointer ) );
       
   933     TInt nLines = 0;
       
   934     TInt pos = iText->Length();
       
   935 
       
   936     do
       
   937         {
       
   938         TPtrC ptrC( iText->Left( pos ) );
       
   939         pos = ptrC.LocateReverseF( '\n' );
       
   940         }
       
   941     while ( pos >= 0 && ++nLines );
       
   942     return nLines;
       
   943     }
       
   944 
       
   945 
       
   946 const TDesC& CTextLayoutManager::Text() const
       
   947     {
       
   948     __ASSERT_DEBUG( iText, Panic( EAknPanicNullPointer ) );
       
   949     return *iText;
       
   950     }
       
   951 
       
   952 
       
   953 // ----------------------------------------------------------------------------
       
   954 // CAknTitlePane::FormatTitlePaneLabelL
       
   955 // Formats the title pane text.
       
   956 // ----------------------------------------------------------------------------
       
   957 //
       
   958 TInt CAknTitlePane::FormatTitlePaneLabelL( const TInt aOneLineLayoutWidth,
       
   959                                            const TInt aTwoLineLayoutWidth,
       
   960                                            const CFont* aOneLineFont,
       
   961                                            const CFont* aTwoLineFont )
       
   962     {
       
   963     if ( !iTitleLabel )
       
   964         {
       
   965         return 0;
       
   966         }
       
   967 
       
   968     if ( Rect().Width() < 1 )
       
   969         {
       
   970         iTitleLabel->SetTextL( *iTitleText );
       
   971         return 0;
       
   972         }
       
   973 
       
   974     TPtr ptr( iTitleText->Des() );
       
   975     TBuf<1> stripCharacters;
       
   976     stripCharacters.Append( KPuaCodeLineFeedSymbol );
       
   977     AknTextUtils::StripCharacters( ptr, stripCharacters );
       
   978 
       
   979     // Check if 2nd line usage has been limited
       
   980     TInt oneLineLayoutWidth = aOneLineLayoutWidth;
       
   981     TInt twoLineLayoutWidth = aTwoLineLayoutWidth;
       
   982     if ( iExtension && iExtension->iLimitedNumberOfTextLines > 0 &&
       
   983          iExtension->iLimitedNumberOfTextLines < MaxNumberOfVisibleTextRows() )
       
   984         {
       
   985         twoLineLayoutWidth = 0;
       
   986         }
       
   987 
       
   988     // We remove control chars here if one line layout is in use,
       
   989     // but we don't touch the original text because if we go to
       
   990     // 2-line layout we would not have the line feeds anymore
       
   991     // that some text may contain.
       
   992     HBufC* titleText = iTitleText->AllocLC();
       
   993 
       
   994     if ( twoLineLayoutWidth == 0 )
       
   995         {
       
   996         iTitleLabel->ReplaceControlCharacters( titleText, ETrue );
       
   997         }
       
   998     else
       
   999         {
       
  1000         iTitleLabel->ReplaceControlCharacters( titleText, EFalse );
       
  1001         }
       
  1002 
       
  1003     CTextLayoutManager* layoutMgr = CTextLayoutManager::NewLC(
       
  1004         oneLineLayoutWidth, twoLineLayoutWidth, aOneLineFont, aTwoLineFont );
       
  1005 
       
  1006     layoutMgr->DoLayoutL( 1, *titleText );
       
  1007     if ( layoutMgr->Lines() > 1 )
       
  1008         {
       
  1009         layoutMgr->Reset();
       
  1010         layoutMgr->DoLayoutL( 2, *titleText );
       
  1011         }
       
  1012 
       
  1013     const CTextLayoutManager::TLayout& layout( layoutMgr->Layout() );
       
  1014 
       
  1015     TInt lines =
       
  1016         layout == CTextLayoutManager::ETwoLineLayout ? 2 : layoutMgr->Lines();
       
  1017 
       
  1018     iTitleLabel->SetTextL( layoutMgr->Text() );
       
  1019 
       
  1020     TBool truncated = iTitleLabel->Text()->Locate( KEllipsis ) != KErrNotFound;
       
  1021 
       
  1022     if ( iExtension )
       
  1023         {
       
  1024         iExtension->iCurrentNumberOfTextLines = lines;
       
  1025         }
       
  1026 
       
  1027     if ( iExtension )
       
  1028         {
       
  1029         iExtension->iScrollEffectNeeded = truncated;
       
  1030         }
       
  1031 
       
  1032     CleanupStack::PopAndDestroy( 2, titleText ); // titleText, layoutMgr
       
  1033     return lines;
       
  1034     }
       
  1035 
       
  1036 
       
  1037 // ----------------------------------------------------------------------------
       
  1038 // CAknTitlePane::ReadFromResourceFileL
       
  1039 // Updates title pane content from a resource file.
       
  1040 // ----------------------------------------------------------------------------
       
  1041 //
       
  1042 void CAknTitlePane::ReadFromResourceFileL( TResourceReader& aReader )
       
  1043     {
       
  1044     if ( iTitleLabel )
       
  1045         {
       
  1046         iTitleLabel->InvalidateText();
       
  1047         }
       
  1048 
       
  1049     delete iTitleText;
       
  1050     iTitleText = NULL;
       
  1051     iTitleText = aReader.ReadHBufCL();
       
  1052 
       
  1053     HBufC* bitmapFile = aReader.ReadHBufCL(); // bmp filename
       
  1054     TInt bitmapId     = aReader.ReadInt16();  // bmp id
       
  1055     TInt maskId       = aReader.ReadInt16();  // bmp mask id
       
  1056 
       
  1057     if ( !iTitleText )
       
  1058         {
       
  1059         if ( bitmapFile )
       
  1060             {
       
  1061             CleanupStack::PushL( bitmapFile );
       
  1062             if ( bitmapId != KErrNotFound )
       
  1063                 {
       
  1064                 SetPictureFromFileL( *bitmapFile, bitmapId, maskId );
       
  1065                 }
       
  1066             else
       
  1067                 {
       
  1068                 SetTextToDefaultL();
       
  1069                 }
       
  1070             CleanupStack::PopAndDestroy( bitmapFile );
       
  1071             }
       
  1072         else
       
  1073             {
       
  1074             SetTextToDefaultL();
       
  1075             }
       
  1076         }
       
  1077     else
       
  1078         {
       
  1079         if ( bitmapFile )
       
  1080             {
       
  1081             CleanupStack::PushL( bitmapFile );
       
  1082             if ( bitmapId != KErrNotFound )
       
  1083                 {
       
  1084                 SetSmallPictureFromFileL( *bitmapFile, bitmapId, maskId );
       
  1085                 }
       
  1086             else
       
  1087                 {
       
  1088                 SetTextToDefaultL();
       
  1089                 }
       
  1090             CleanupStack::PopAndDestroy( bitmapFile );
       
  1091             }
       
  1092 
       
  1093         iImageShown = EFalse;
       
  1094         SizeChanged();
       
  1095         DrawDeferred();
       
  1096         }
       
  1097     }
       
  1098 
       
  1099 
       
  1100 // ----------------------------------------------------------------------------
       
  1101 // CAknTitlePane::SizeChangedInNormalStatusPane
       
  1102 // Handles size change events in normal status pane layout.
       
  1103 // ----------------------------------------------------------------------------
       
  1104 //
       
  1105 void CAknTitlePane::SizeChangedInNormalStatusPane()
       
  1106     {
       
  1107     AknsUtils::RegisterControlPosition( this );
       
  1108 
       
  1109     TRect rect( Rect() );
       
  1110 
       
  1111     if ( iTitleLabel && !iImageShown )
       
  1112         {
       
  1113         __ASSERT_DEBUG( iTitleText, Panic( EAknPanicNullPointer ) );
       
  1114 
       
  1115         TInt indexW( 0 );
       
  1116         if ( AknStatuspaneUtils::IdleLayoutActive() )
       
  1117             {   // Is battery pane visible in current layout
       
  1118             indexW = 1;
       
  1119             }
       
  1120 
       
  1121         TAknTextLineLayout oneLineLayout(
       
  1122             AknLayoutScalable_Avkon::title_pane_t1( 0 ).LayoutLine() );
       
  1123 
       
  1124         const TAknMultiLineTextLayout twoLineLayout(
       
  1125             AKN_LAYOUT_MULTILINE_TEXT_Title_pane_texts_Line_2( indexW, 2 ) );
       
  1126 
       
  1127         // if text would truncate, then try to use
       
  1128         // smaller font with one line layout
       
  1129         if ( !TextFits( oneLineLayout ) )
       
  1130             {
       
  1131             oneLineLayout =
       
  1132                 AknLayoutScalable_Avkon::title_pane_t2( 1 ).LayoutLine();
       
  1133             }
       
  1134 
       
  1135         TAknLayoutText oneLineLayoutText;
       
  1136         oneLineLayoutText.LayoutText( rect, oneLineLayout);
       
  1137         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  1138 
       
  1139         TAknLayoutText twoLineLayoutText;
       
  1140         twoLineLayoutText.LayoutText( rect, twoLineLayout);
       
  1141         TRect twoLineLayoutRect( twoLineLayoutText.TextRect() );
       
  1142 
       
  1143         TInt lines = 0;
       
  1144         
       
  1145         TRAP_IGNORE(
       
  1146             lines = FormatTitlePaneLabelL(
       
  1147                 oneLineLayoutRect.Width(),
       
  1148                 twoLineLayoutRect.Width(),
       
  1149                 AknLayoutUtils::FontFromId( oneLineLayout.FontId() ),
       
  1150                 AknLayoutUtils::FontFromId( twoLineLayout.FontId() ) )
       
  1151             ); // Ignore leave. Only layout of the title pane
       
  1152                // suffers if leave happens.
       
  1153 
       
  1154         if ( lines <= 1 )
       
  1155             {
       
  1156             AknLayoutUtils::LayoutLabel( iTitleLabel, rect, oneLineLayout );
       
  1157             }
       
  1158         else
       
  1159             {
       
  1160             AknLayoutUtils::LayoutLabel( iTitleLabel, rect, twoLineLayout );
       
  1161             }
       
  1162 
       
  1163         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1164         TRgb color;
       
  1165 
       
  1166         TInt error = AknsUtils::GetCachedColor( skin,
       
  1167                                                 color,
       
  1168                                                 KAknsIIDQsnTextColors,
       
  1169                                                 EAknsCIQsnTextColorsCG1 );
       
  1170 
       
  1171         if ( !error )
       
  1172             {
       
  1173             // Ignore error
       
  1174             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1175                 *iTitleLabel, EColorLabelText, color ) );
       
  1176             }
       
  1177 
       
  1178         if ( iExtension &&
       
  1179              ( iExtension->iScrollEffectEnabled ||
       
  1180                iTitleLabel->TextEffect() ||
       
  1181                !iTitleLabel->EffectQueueIsEmpty() ) )
       
  1182             {
       
  1183             TRAP_IGNORE( SetupTitleLabelEffectL() );
       
  1184             if ( !iTitleLabel->TextEffect() )
       
  1185                 {
       
  1186                 if ( lines <= 1 )
       
  1187                     {
       
  1188                     AknLayoutUtils::LayoutLabel( iTitleLabel,
       
  1189                                                  rect,
       
  1190                                                  oneLineLayout );
       
  1191                     }
       
  1192                 else
       
  1193                     {
       
  1194                     AknLayoutUtils::LayoutLabel( iTitleLabel,
       
  1195                                                  rect,
       
  1196                                                  twoLineLayout );
       
  1197                     }
       
  1198                 // Ignore error
       
  1199                 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1200                     *iTitleLabel, EColorLabelText, color ) );
       
  1201                 }
       
  1202             }
       
  1203         }
       
  1204     else if ( iExtension && iExtension->iTitleImage )
       
  1205         {
       
  1206         TAknLayoutRect layoutRect;
       
  1207         layoutRect.LayoutRect( rect, AknLayoutScalable_Avkon::title_pane_g1() );
       
  1208         TRect bmpRect( layoutRect.Rect() );
       
  1209         TSize bmpSize( bmpRect.Size() );
       
  1210 
       
  1211         if ( iExtension->iImageAutoscaling &&
       
  1212              iExtension->iTitleImage->Bitmap() &&
       
  1213              iExtension->iTitleImage->Mask() )
       
  1214             {
       
  1215             CFbsBitmap* bitmap =
       
  1216                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1217             AknIconUtils::SetSize( bitmap, bmpSize );
       
  1218             }
       
  1219         else if ( !iExtension->iImageAutoscaling &&
       
  1220                   iExtension->iTitleImage->Bitmap() )
       
  1221             {
       
  1222             bmpSize = iExtension->iTitleImage->Bitmap()->SizeInPixels();
       
  1223             }
       
  1224 
       
  1225         TGulAlignment iAlignment;
       
  1226         iAlignment.SetVAlignment( EVCenter );
       
  1227         if ( AknLayoutUtils::LayoutMirrored() )
       
  1228             {
       
  1229             iAlignment.SetHAlignment( EHRight );
       
  1230             }
       
  1231         else
       
  1232             {
       
  1233             iAlignment.SetHAlignment( EHLeft );
       
  1234             }
       
  1235 
       
  1236         iExtension->iTitleImage->SetAlignment( iAlignment );
       
  1237 
       
  1238         TInt topMargin    = bmpRect.iTl.iY;
       
  1239         TInt leftMargin   = bmpRect.iTl.iX;
       
  1240         TInt bottomMargin = rect.iBr.iY - layoutRect.Rect().iBr.iY;
       
  1241         TInt rightMargin  = rect.iBr.iX - layoutRect.Rect().iBr.iX;
       
  1242 
       
  1243         iExtension->iTitleImage->SetRect(
       
  1244             iAlignment.InnerRect(
       
  1245             TRect( rect.iTl.iX + leftMargin,
       
  1246                    rect.iTl.iY + topMargin,
       
  1247                    rect.iBr.iX - rightMargin,
       
  1248                    rect.iBr.iY - bottomMargin),
       
  1249             bmpSize ) );
       
  1250         }
       
  1251     }
       
  1252 
       
  1253 
       
  1254 void CAknTitlePane::SizeChangedInStaconPane()
       
  1255     {
       
  1256     TRect rect( Rect() );
       
  1257 
       
  1258     AknsUtils::RegisterControlPosition( this );
       
  1259     TInt leftOrRightSoftKeysVariety = 0;
       
  1260     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
  1261         {
       
  1262         leftOrRightSoftKeysVariety = 1;
       
  1263         }
       
  1264 
       
  1265     if ( iExtension->iTitleImage &&
       
  1266          iExtension->iTitleImage->Bitmap() &&
       
  1267          iExtension->iSmallImageShown )
       
  1268         {
       
  1269         TAknWindowComponentLayout imageLayout(
       
  1270             AknLayoutScalable_Avkon::title_pane_stacon_g1(
       
  1271                 leftOrRightSoftKeysVariety ) );
       
  1272         TAknLayoutRect layoutRect;
       
  1273         layoutRect.LayoutRect( rect, imageLayout );
       
  1274 
       
  1275         if ( iExtension->iSmallImageAutoscaling &&
       
  1276              iExtension->iTitleImage->Bitmap() &&
       
  1277              iExtension->iTitleImage->Mask() )
       
  1278             {
       
  1279             CFbsBitmap* bitmap =
       
  1280                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1281             AknIconUtils::SetSize( bitmap, layoutRect.Rect().Size() );
       
  1282             }
       
  1283 
       
  1284         TGulAlignment alignment;
       
  1285         alignment.SetHAlignment( EHCenter );
       
  1286         alignment.SetVAlignment( EVCenter );
       
  1287         iExtension->iTitleImage->SetRect(
       
  1288             alignment.InnerRect(
       
  1289                 layoutRect.Rect(),
       
  1290                 iExtension->iTitleImage->Bitmap()->SizeInPixels() ) );
       
  1291         }
       
  1292 
       
  1293     if ( iTitleLabel && !iImageShown )
       
  1294         {
       
  1295         __ASSERT_DEBUG( iTitleText, Panic( EAknPanicNullPointer ) );
       
  1296 
       
  1297         // If image is shown, then select shorter text
       
  1298         if ( iExtension->iTitleImage &&
       
  1299              iExtension->iTitleImage->Bitmap() &&
       
  1300              iExtension->iSmallImageShown )
       
  1301             {
       
  1302             leftOrRightSoftKeysVariety += 2;
       
  1303             }
       
  1304 
       
  1305         TAknTextLineLayout oneLineLayout(
       
  1306             AknLayoutScalable_Avkon::title_pane_stacon_t1(
       
  1307                 leftOrRightSoftKeysVariety ).LayoutLine() );
       
  1308         TAknLayoutText oneLineLayoutText;
       
  1309         oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  1310         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  1311         
       
  1312         const CFont* fontUsed =
       
  1313             AknLayoutUtils::FontFromId( oneLineLayout.FontId() );
       
  1314         
       
  1315         TRAP_IGNORE(
       
  1316             TInt lines = FormatTitlePaneLabelL( oneLineLayoutRect.Width(),
       
  1317                                                 0,
       
  1318                                                 fontUsed,
       
  1319                                                 fontUsed ) ); // Ignore leave.
       
  1320             // Only layout of the title pane suffers if leave happens.
       
  1321 
       
  1322         AknLayoutUtils::LayoutLabel( iTitleLabel, rect, oneLineLayout );
       
  1323 
       
  1324         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1325         TRgb color;
       
  1326 
       
  1327         TInt error = 0;
       
  1328 
       
  1329         if ( AknStatuspaneUtils::IdleLayoutActive() )
       
  1330             {
       
  1331             error = AknsUtils::GetCachedColor( skin,
       
  1332                                                color,
       
  1333                                                KAknsIIDQsnTextColors,
       
  1334                                                EAknsCIQsnTextColorsCG38 );
       
  1335             }
       
  1336         else
       
  1337             {
       
  1338             error = AknsUtils::GetCachedColor( skin,
       
  1339                                                color,
       
  1340                                                KAknsIIDQsnTextColors,
       
  1341                                                EAknsCIQsnTextColorsCG37 );
       
  1342             }
       
  1343 
       
  1344         if ( !error )
       
  1345             {
       
  1346             // Ignore error
       
  1347             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1348                 *iTitleLabel, EColorLabelText, color ) );
       
  1349             }
       
  1350 
       
  1351         if ( iExtension &&
       
  1352              ( iExtension->iScrollEffectEnabled ||
       
  1353                iTitleLabel->TextEffect() ||
       
  1354                !iTitleLabel->EffectQueueIsEmpty() ) )
       
  1355             {
       
  1356             TRAP_IGNORE( SetupTitleLabelEffectL() );
       
  1357             if ( !iTitleLabel->TextEffect() )
       
  1358                 {
       
  1359                 AknLayoutUtils::LayoutLabel( iTitleLabel, rect, oneLineLayout );
       
  1360                 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1361                     *iTitleLabel, EColorLabelText, color ) );
       
  1362                 }
       
  1363             }
       
  1364         }
       
  1365     else if ( iExtension && iExtension->iTitleImage )
       
  1366         {
       
  1367         TAknLayoutRect layoutRect;
       
  1368         layoutRect.LayoutRect(
       
  1369             rect,
       
  1370             AknLayoutScalable_Avkon::title_pane_stacon_g2( 0 ) );
       
  1371         TRect bmpRect( layoutRect.Rect() );
       
  1372         TSize bmpSize( bmpRect.Size() );
       
  1373 
       
  1374         if  ( iExtension->iImageAutoscaling &&
       
  1375               iExtension->iTitleImage->Bitmap() &&
       
  1376               iExtension->iTitleImage->Mask() )
       
  1377             {
       
  1378             CFbsBitmap* bitmap =
       
  1379                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1380             AknIconUtils::SetSize( bitmap, bmpSize );
       
  1381             }
       
  1382         else if ( !iExtension->iImageAutoscaling &&
       
  1383                   iExtension->iTitleImage->Bitmap() )
       
  1384             {
       
  1385             bmpSize = iExtension->iTitleImage->Bitmap()->SizeInPixels();
       
  1386             }            
       
  1387 
       
  1388         TGulAlignment iAlignment;
       
  1389         iAlignment.SetVAlignment( EVCenter );
       
  1390         if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
  1391             {
       
  1392             iAlignment.SetHAlignment( EHRight );
       
  1393             }
       
  1394         else
       
  1395             {
       
  1396             iAlignment.SetHAlignment( EHLeft );
       
  1397             }
       
  1398 
       
  1399         iExtension->iTitleImage->SetAlignment( iAlignment );
       
  1400 
       
  1401         TInt topMargin    = bmpRect.iTl.iY;
       
  1402         TInt leftMargin   = bmpRect.iTl.iX;
       
  1403         TInt bottomMargin = rect.Height() - ( bmpRect.Height() + topMargin );
       
  1404         TInt rightMargin  = leftMargin;
       
  1405 
       
  1406         iExtension->iTitleImage->SetRect(
       
  1407             iAlignment.InnerRect(
       
  1408             TRect( rect.iTl.iX + leftMargin,
       
  1409                    rect.iTl.iY + topMargin,
       
  1410                    rect.iBr.iX - rightMargin,
       
  1411                    rect.iBr.iY - bottomMargin ),
       
  1412             bmpSize ) );
       
  1413         }
       
  1414     }
       
  1415 
       
  1416 
       
  1417 void CAknTitlePane::SizeChangedInFlatStatusPane()
       
  1418     {
       
  1419     AknsUtils::RegisterControlPosition( this );
       
  1420 
       
  1421     TRect rect( Rect() );
       
  1422 
       
  1423     if ( iExtension->iTitleImage &&
       
  1424          iExtension->iTitleImage->Bitmap() &&
       
  1425          iExtension->iSmallImageShown )
       
  1426         {
       
  1427         TBool touchLsc( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1428                         AknLayoutUtils::PenEnabled() );
       
  1429 
       
  1430         TAknLayoutRect layoutRect;
       
  1431         layoutRect.LayoutRect(
       
  1432             rect,
       
  1433             AknLayoutScalable_Avkon::title_pane_g2( touchLsc ? 4 : 0 ) );
       
  1434 
       
  1435         if ( iExtension->iSmallImageAutoscaling &&
       
  1436              iExtension->iTitleImage->Bitmap() &&
       
  1437              iExtension->iTitleImage->Mask() )
       
  1438             {
       
  1439             CFbsBitmap* bitmap =
       
  1440                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1441             AknIconUtils::SetSize( bitmap, layoutRect.Rect().Size() );
       
  1442             }
       
  1443 
       
  1444         TGulAlignment alignment;
       
  1445         alignment.SetHAlignment( EHCenter );
       
  1446         alignment.SetVAlignment( EVCenter );
       
  1447         iExtension->iTitleImage->SetRect( alignment.InnerRect(
       
  1448             layoutRect.Rect(),
       
  1449             iExtension->iTitleImage->Bitmap()->SizeInPixels() ) );
       
  1450         }
       
  1451 
       
  1452     if ( iTitleLabel && !iImageShown )
       
  1453         {
       
  1454         __ASSERT_DEBUG( iTitleText, Panic( EAknPanicNullPointer ) );
       
  1455 
       
  1456         TAknTextLineLayout oneLineLayout;
       
  1457         TBool touchLsc( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  1458                         AknLayoutUtils::PenEnabled() );
       
  1459         
       
  1460         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  1461             {
       
  1462             // if image is shown, use shorter version of text
       
  1463             oneLineLayout =
       
  1464                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 3 ).LayoutLine();
       
  1465             }
       
  1466         else
       
  1467             {
       
  1468             // if image is not shown, use longer version of text
       
  1469             oneLineLayout =
       
  1470                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 2 ).LayoutLine();
       
  1471             }
       
  1472 
       
  1473         TAknLayoutText oneLineLayoutText;
       
  1474         oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  1475         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  1476 
       
  1477         const CFont* fontUsed =
       
  1478             AknLayoutUtils::FontFromId( oneLineLayout.FontId() );
       
  1479 
       
  1480         TRAP_IGNORE(
       
  1481             TInt lines = FormatTitlePaneLabelL(
       
  1482                 oneLineLayoutRect.Width(),
       
  1483                 0,
       
  1484                 fontUsed,
       
  1485                 fontUsed )
       
  1486             ); // Ignore leave.
       
  1487                // Only layout of the title pane suffers if leave happens.
       
  1488 
       
  1489         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1490         TRgb color = 0;
       
  1491 
       
  1492         // Flat statuspane uses same color skinning as stacon pane
       
  1493         AknsUtils::GetCachedColor( skin,
       
  1494                                    color,
       
  1495                                    KAknsIIDQsnTextColors,
       
  1496                                    EAknsCIQsnTextColorsCG37 );
       
  1497 
       
  1498         // Ignore error
       
  1499         TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL(
       
  1500             *iTitleLabel, EColorLabelText, color ) );
       
  1501 
       
  1502         TRAP_IGNORE( SetupTitleLabelEffectL() );
       
  1503         if ( !iTitleLabel->TextEffect() )
       
  1504             {
       
  1505             AknLayoutUtils::LayoutLabel( iTitleLabel, rect, oneLineLayout );
       
  1506             // Ignore error
       
  1507             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1508                 *iTitleLabel, EColorLabelText, color ) );
       
  1509             }
       
  1510         }
       
  1511     else if ( iExtension && iExtension->iTitleImage )
       
  1512         {
       
  1513         TRect bmpRect( rect );
       
  1514         TSize bmpSize( bmpRect.Size() );
       
  1515 
       
  1516         if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  1517             {
       
  1518             // Stacon layout is used for this layout too.
       
  1519             TAknLayoutRect layoutRect;
       
  1520             layoutRect.LayoutRect(
       
  1521                 rect,
       
  1522                 AknLayoutScalable_Avkon::title_pane_stacon_g2( 0 ) );
       
  1523             bmpRect = layoutRect.Rect();
       
  1524             bmpSize = bmpRect.Size();
       
  1525             }
       
  1526 
       
  1527         if  ( iExtension->iImageAutoscaling &&
       
  1528               iExtension->iTitleImage->Bitmap() &&
       
  1529               iExtension->iTitleImage->Mask() )
       
  1530             {
       
  1531             CFbsBitmap* bitmap =
       
  1532                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1533             AknIconUtils::SetSize( bitmap, bmpSize );
       
  1534             }
       
  1535         else if ( !iExtension->iImageAutoscaling &&
       
  1536                   iExtension->iTitleImage->Bitmap() )
       
  1537             {
       
  1538             bmpSize = iExtension->iTitleImage->Bitmap()->SizeInPixels();
       
  1539             }
       
  1540 
       
  1541         TGulAlignment iAlignment;
       
  1542         iAlignment.SetVAlignment( EVCenter );
       
  1543         if ( AknLayoutUtils::LayoutMirrored() )
       
  1544             {
       
  1545             iAlignment.SetHAlignment( EHRight );
       
  1546             }
       
  1547         else
       
  1548             {
       
  1549             iAlignment.SetHAlignment( EHLeft );
       
  1550             }
       
  1551 
       
  1552         iExtension->iTitleImage->SetAlignment( iAlignment );
       
  1553 
       
  1554         TInt topMargin    = bmpRect.iTl.iY;
       
  1555         TInt leftMargin   = bmpRect.iTl.iX;
       
  1556         TInt bottomMargin = rect.Height() - ( bmpRect.Height() + topMargin );
       
  1557         TInt rightMargin  = leftMargin;
       
  1558 
       
  1559         iExtension->iTitleImage->SetRect(
       
  1560             iAlignment.InnerRect(
       
  1561             TRect( rect.iTl.iX + leftMargin,
       
  1562                    rect.iTl.iY + topMargin,
       
  1563                    rect.iBr.iX - rightMargin,
       
  1564                    rect.iBr.iY - bottomMargin ),
       
  1565             bmpSize ) );
       
  1566         }
       
  1567     }
       
  1568 
       
  1569 
       
  1570 void CAknTitlePane::SizeChangedInExtendedStatusPane()
       
  1571     {
       
  1572     AknsUtils::RegisterControlPosition( this );
       
  1573 
       
  1574     TRect rect( Rect() );
       
  1575     
       
  1576     TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
  1577     TBool hdLayout( AknStatuspaneUtils::HDLayoutActive() );
       
  1578     
       
  1579     if (iExtension->iTitleImage && iExtension->iTitleImage->Bitmap() && iExtension->iSmallImageShown)
       
  1580         {
       
  1581         TAknWindowComponentLayout imageLayout(
       
  1582             AknLayoutScalable_Avkon::title_pane_g2( hdLayout ? 4 : 1) );
       
  1583 
       
  1584         TAknLayoutRect layoutRect;
       
  1585         layoutRect.LayoutRect( rect, imageLayout );
       
  1586 
       
  1587         if ( iExtension->iSmallImageAutoscaling &&
       
  1588              iExtension->iTitleImage->Bitmap() &&
       
  1589              iExtension->iTitleImage->Mask() )
       
  1590             {
       
  1591             CFbsBitmap* bitmap =
       
  1592                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1593             AknIconUtils::SetSize( bitmap, layoutRect.Rect().Size() );
       
  1594             }
       
  1595 
       
  1596         TGulAlignment alignment;
       
  1597         alignment.SetHAlignment( EHCenter );
       
  1598         alignment.SetVAlignment( EVCenter );
       
  1599         iExtension->iTitleImage->SetRect(
       
  1600             alignment.InnerRect(
       
  1601                 layoutRect.Rect(),
       
  1602                 iExtension->iTitleImage->Bitmap()->SizeInPixels() ) );
       
  1603         }
       
  1604 
       
  1605     if ( iTitleLabel && !iImageShown )
       
  1606         {
       
  1607         __ASSERT_DEBUG( iTitleText, Panic( EAknPanicNullPointer ) );
       
  1608 
       
  1609         TAknTextLineLayout oneLineLayout;
       
  1610         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  1611             {
       
  1612             // if image is shown, use shorter version of text
       
  1613             oneLineLayout = AknLayoutScalable_Avkon::title_pane_t1( hdLayout ? 11 : 6 ).LayoutLine();                
       
  1614             if ( !TextFits( oneLineLayout ) )
       
  1615                 {
       
  1616                 if ( hdLayout )
       
  1617                     {
       
  1618                     oneLineLayout =
       
  1619                         AknLayoutScalable_Avkon::title_pane_t1( 13 ).LayoutLine();
       
  1620                     }
       
  1621                 else
       
  1622                     {
       
  1623                     oneLineLayout =
       
  1624                         AknLayoutScalable_Avkon::title_pane_t2( 2 ).LayoutLine();
       
  1625                     }
       
  1626                 }
       
  1627             }
       
  1628         else
       
  1629             {
       
  1630             // if image is not shown, use longer version of text
       
  1631             oneLineLayout = AknLayoutScalable_Avkon::title_pane_t1( hdLayout ? 10 : 5 ).LayoutLine();                
       
  1632             if ( !TextFits( oneLineLayout ) )
       
  1633                 {
       
  1634                 if ( hdLayout )
       
  1635                     {
       
  1636                     oneLineLayout =
       
  1637                         AknLayoutScalable_Avkon::title_pane_t1( 12 ).LayoutLine();
       
  1638                     }
       
  1639                 else
       
  1640                     {
       
  1641                     oneLineLayout =
       
  1642                         AknLayoutScalable_Avkon::title_pane_t2( 1 ).LayoutLine();
       
  1643                     }
       
  1644                 }
       
  1645             }
       
  1646 
       
  1647         TAknLayoutText oneLineLayoutText;
       
  1648         oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  1649         TRect oneLineLayoutRect = oneLineLayoutText.TextRect();
       
  1650         
       
  1651         const CFont* fontUsed =
       
  1652             AknLayoutUtils::FontFromId( oneLineLayout.FontId() );
       
  1653         
       
  1654         TRAP_IGNORE(
       
  1655             TInt lines = FormatTitlePaneLabelL(
       
  1656                 oneLineLayoutRect.Width(),
       
  1657                 0,
       
  1658                 fontUsed,
       
  1659                 fontUsed )
       
  1660             ); // Ignore leave.
       
  1661                // Only layout of the title pane suffers if leave happens.
       
  1662 
       
  1663         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1664         TRgb color = 0;
       
  1665 
       
  1666         // Same color skinning as normal status pane
       
  1667         AknsUtils::GetCachedColor( skin,
       
  1668                                    color,
       
  1669                                    KAknsIIDQsnTextColors,
       
  1670                                    EAknsCIQsnTextColorsCG1 );
       
  1671 
       
  1672         // Ignore error
       
  1673         TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1674             *iTitleLabel, EColorLabelText, color ) );
       
  1675 
       
  1676         TRAP_IGNORE( SetupTitleLabelEffectL() );
       
  1677         if ( !iTitleLabel->TextEffect() )
       
  1678             {
       
  1679             AknLayoutUtils::LayoutLabel( iTitleLabel, rect, oneLineLayout );
       
  1680             // Ignore error
       
  1681             TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(
       
  1682                 *iTitleLabel, EColorLabelText, color ) );
       
  1683             }
       
  1684         }
       
  1685     else if ( iExtension && iExtension->iTitleImage )
       
  1686         {
       
  1687         TAknLayoutRect layoutRect;
       
  1688         layoutRect.LayoutRect(
       
  1689             rect,
       
  1690             AknLayoutScalable_Avkon::title_pane_g1( hdLayout ) );
       
  1691         TRect bmpRect( layoutRect.Rect() );
       
  1692         TSize bmpSize( bmpRect.Size() );
       
  1693 
       
  1694         if  ( iExtension->iImageAutoscaling &&
       
  1695               iExtension->iTitleImage->Bitmap() &&
       
  1696               iExtension->iTitleImage->Mask() )
       
  1697             {
       
  1698             CFbsBitmap* bitmap =
       
  1699                 const_cast<CFbsBitmap*> ( iExtension->iTitleImage->Bitmap() );
       
  1700             AknIconUtils::SetSize( bitmap, bmpSize );
       
  1701             }
       
  1702         else if ( !iExtension->iImageAutoscaling &&
       
  1703                   iExtension->iTitleImage->Bitmap() )
       
  1704             {
       
  1705             bmpSize = iExtension->iTitleImage->Bitmap()->SizeInPixels();
       
  1706             }
       
  1707 
       
  1708         TGulAlignment iAlignment;
       
  1709         iAlignment.SetVAlignment( EVCenter );
       
  1710         if ( AknLayoutUtils::LayoutMirrored() )
       
  1711             {
       
  1712             iAlignment.SetHAlignment( EHRight );
       
  1713             }
       
  1714         else
       
  1715             {
       
  1716             iAlignment.SetHAlignment( EHLeft );
       
  1717             }
       
  1718 
       
  1719         iExtension->iTitleImage->SetAlignment( iAlignment );
       
  1720 
       
  1721         TInt topMargin    = bmpRect.iTl.iY;
       
  1722         TInt leftMargin   = bmpRect.iTl.iX;
       
  1723         TInt bottomMargin = rect.Height() - ( bmpRect.Height() + topMargin );
       
  1724         TInt rightMargin  = leftMargin;
       
  1725 
       
  1726         iExtension->iTitleImage->SetRect(
       
  1727             iAlignment.InnerRect(
       
  1728             TRect( rect.iTl.iX + leftMargin,
       
  1729                    rect.iTl.iY + topMargin,
       
  1730                    rect.iBr.iX - rightMargin,
       
  1731                    rect.iBr.iY - bottomMargin ),
       
  1732             bmpSize ) );
       
  1733         }
       
  1734     }
       
  1735 
       
  1736 
       
  1737 RWindow* CAknTitlePane::StatuspaneContainerWindow() const
       
  1738     {
       
  1739     RWindow* window = NULL;
       
  1740     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
  1741     if ( statusPane )
       
  1742         {
       
  1743         CCoeControl* control = NULL;
       
  1744         TRAP_IGNORE( control = statusPane->ContainerControlL(
       
  1745             TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1746         if( control )
       
  1747             {
       
  1748             RDrawableWindow* drawableWindow = control->DrawableWindow();
       
  1749             if ( drawableWindow )
       
  1750                 {
       
  1751                 // Trust that container is always RWindow.
       
  1752                 window = static_cast <RWindow*> ( drawableWindow );
       
  1753                 }
       
  1754             }
       
  1755        }
       
  1756 
       
  1757     return window;
       
  1758     }
       
  1759 
       
  1760 
       
  1761 void  CAknTitlePane::SetupTitleLabelEffectL()
       
  1762     {
       
  1763     if ( iTitleLabel )
       
  1764         {
       
  1765         iTitleLabel->InitEffectQueueL();
       
  1766         }
       
  1767 
       
  1768     if ( AknStatuspaneUtils::StaconPaneActive() )
       
  1769         {
       
  1770         if ( iExtension &&
       
  1771              iExtension->iScrollEffectEnabled )
       
  1772             {
       
  1773             SetupStaconPaneScrollEffectL();
       
  1774             }
       
  1775         else
       
  1776             {
       
  1777             SetupNoEffectL(); // Default is no effect
       
  1778             }
       
  1779         }
       
  1780     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
  1781         {
       
  1782         if ( iExtension &&
       
  1783              iExtension->iScrollEffectEnabled )
       
  1784             {
       
  1785             SetupFlatStatusPaneFadeEffectL();
       
  1786             SetupFlatStatusPaneScrollEffectL();
       
  1787             SetupFlatStatusPaneFadeEffectL();
       
  1788             }
       
  1789         else
       
  1790             {
       
  1791             SetupFlatStatusPaneFadeEffectL(); // Default is fade effect
       
  1792             }
       
  1793         }
       
  1794     else if ( AknStatuspaneUtils::ExtendedLayoutActive() )
       
  1795         {
       
  1796         if ( iExtension &&
       
  1797              iExtension->iScrollEffectEnabled )
       
  1798             {
       
  1799             SetupExtendedStatusPaneScrollEffectL();
       
  1800             }
       
  1801         else
       
  1802             {
       
  1803             SetupNoEffectL(); // Default is no effect
       
  1804             }
       
  1805         }
       
  1806     else
       
  1807         {
       
  1808         if ( iExtension &&
       
  1809              iExtension->iScrollEffectEnabled )
       
  1810             {
       
  1811             SetupNormalStatusPaneScrollEffectL();
       
  1812             }
       
  1813         else
       
  1814             {
       
  1815             SetupNoEffectL(); // Default is no effect
       
  1816             }
       
  1817         }
       
  1818 
       
  1819     if ( iTitleLabel && iTitleLabel->EffectQueueIsEmpty() )
       
  1820         {
       
  1821         SetupNoEffectL();
       
  1822         }
       
  1823 
       
  1824     if ( iTitleLabel )
       
  1825         {
       
  1826         iTitleLabel->ActivateEffectQueue();
       
  1827         }
       
  1828     }
       
  1829 
       
  1830 
       
  1831 // ----------------------------------------------------------------------------
       
  1832 // CAknTitlePane::SetTitlePaneObserver()
       
  1833 // Set's aObserver as title pane observer
       
  1834 // ----------------------------------------------------------------------------
       
  1835 EXPORT_C void CAknTitlePane::SetTitlePaneObserver(
       
  1836     MAknTitlePaneObserver* aObserver)
       
  1837     {
       
  1838     iTitlePaneObserver = aObserver;
       
  1839     }
       
  1840 
       
  1841 
       
  1842 EXPORT_C void* CAknTitlePane::ExtensionInterface( TUid /*aInterface*/ )
       
  1843     {
       
  1844     return NULL;
       
  1845     }
       
  1846 
       
  1847 
       
  1848 // ----------------------------------------------------------------------------
       
  1849 // CAknTitlePane::HandlePointerEventL()
       
  1850 // Processes TitlePane's pointer event's by informing observer about tapping
       
  1851 // ----------------------------------------------------------------------------
       
  1852 
       
  1853 EXPORT_C void CAknTitlePane::HandlePointerEventL(
       
  1854     const TPointerEvent& aPointerEvent )
       
  1855     {
       
  1856     if ( AknLayoutUtils::PenEnabled() )
       
  1857         {
       
  1858         if ( IsDimmed() )
       
  1859             {
       
  1860             iExtension->iFlags &= ( ~EAknTitlePaneButton1DownInTitleRect );
       
  1861             return;
       
  1862             }
       
  1863 
       
  1864         // get rect of SignalPane
       
  1865         TRect rect( Rect() );
       
  1866 
       
  1867         // Switch by type
       
  1868         switch ( aPointerEvent.iType )
       
  1869             {
       
  1870             case TPointerEvent::EButton1Down:
       
  1871                 {
       
  1872                 // if signalPane's rect contains pointer down position
       
  1873                 if ( rect.Contains( aPointerEvent.iPosition ) )
       
  1874                     {
       
  1875                     // set flag that down was inside titlePane
       
  1876                     iExtension->iFlags |= EAknTitlePaneButton1DownInTitleRect;
       
  1877                     }
       
  1878                 }
       
  1879                 break;
       
  1880 
       
  1881             case TPointerEvent::EButton1Up:
       
  1882                 {
       
  1883                 // if signalPane's rect contains pointer down position
       
  1884                 if ( iExtension->iFlags&EAknTitlePaneButton1DownInTitleRect &&
       
  1885                      rect.Contains( aPointerEvent.iPosition ) )
       
  1886                     {
       
  1887                     if ( iTitlePaneObserver )
       
  1888                         {
       
  1889                         iTitlePaneObserver->HandleTitlePaneEventL(
       
  1890                             MAknTitlePaneObserver::EAknTitlePaneTapped );
       
  1891                         }
       
  1892                     }
       
  1893 
       
  1894                 // Up happened, reset button down flag
       
  1895                 iExtension->iFlags &= ( ~EAknTitlePaneButton1DownInTitleRect );
       
  1896                 }
       
  1897                 break;
       
  1898 
       
  1899             default:
       
  1900                 break;
       
  1901             }
       
  1902         }
       
  1903     }
       
  1904 
       
  1905 
       
  1906 CEikLabel* CAknTitlePane::TextLabel()
       
  1907     {
       
  1908     return iTitleLabel;
       
  1909     }
       
  1910 
       
  1911 
       
  1912 CEikImage* CAknTitlePane::TitleImage()
       
  1913     {
       
  1914     if ( iExtension &&
       
  1915          iExtension->iTitleImage &&
       
  1916          iExtension->iTitleImage->Bitmap() &&
       
  1917          !iExtension->iSmallImageShown )
       
  1918         {
       
  1919         return iExtension->iTitleImage;
       
  1920         }
       
  1921 
       
  1922     return NULL;
       
  1923     }
       
  1924 
       
  1925 
       
  1926 void CAknTitlePane::SetContainerWindowNonFading( TBool aNonFading )
       
  1927     {
       
  1928     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
  1929     if ( statusPane )
       
  1930         {
       
  1931         CCoeControl* control = NULL;
       
  1932         TRAP_IGNORE( control =
       
  1933             statusPane->ContainerControlL(
       
  1934                 TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
  1935 
       
  1936         if( control )
       
  1937             {
       
  1938             control->DrawableWindow()->SetNonFading( aNonFading );
       
  1939             }
       
  1940         }
       
  1941     }
       
  1942 
       
  1943 
       
  1944 void CAknTitlePane::SetupStaconPaneScrollEffectL()
       
  1945     {
       
  1946     if ( !iExtension->iScrollEffectNeeded )
       
  1947         {
       
  1948         return;
       
  1949         }
       
  1950 
       
  1951     TRect rect( Rect() );
       
  1952 
       
  1953     // If image is shown, then select shorter text
       
  1954     TInt leftOrRightSoftKeysVariety = 0;
       
  1955     if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
  1956         {
       
  1957         leftOrRightSoftKeysVariety = 1;
       
  1958         }
       
  1959     if ( iExtension->iTitleImage &&
       
  1960          iExtension->iTitleImage->Bitmap() &&
       
  1961          iExtension->iSmallImageShown )
       
  1962         {
       
  1963         leftOrRightSoftKeysVariety += 2;
       
  1964         }
       
  1965 
       
  1966     TAknTextLineLayout oneLineLayout(
       
  1967         AknLayoutScalable_Avkon::title_pane_stacon_t1(
       
  1968             leftOrRightSoftKeysVariety ).LayoutLine() );
       
  1969     TAknLayoutText oneLineLayoutText;
       
  1970     oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  1971     TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  1972 
       
  1973     TRect effectRect( rect );
       
  1974 
       
  1975     CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  1976 
       
  1977     // First show text without effect
       
  1978     effect.iEffectDuration = 0;
       
  1979     effect.iEffect         = 0;
       
  1980     effect.iEffectRect     = oneLineLayoutRect;
       
  1981     effect.iLabelRect      = rect;
       
  1982     effect.iObserver       = NULL;
       
  1983     effect.iTitleText      = iTitleText;
       
  1984     effect.iTextLayout     = oneLineLayoutText;
       
  1985     effect.iTextLayoutLine = oneLineLayout;
       
  1986     iTitleLabel->AddToEffectQueueL( effect );
       
  1987 
       
  1988     // Pause
       
  1989     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  1990     effect.iEffectRect     = effectRect;
       
  1991     effect.iEffectDuration = KScrollPauseBeforeScroll;
       
  1992     iTitleLabel->AddToEffectQueueL( effect );
       
  1993 
       
  1994     // Scroll text once
       
  1995     effect.iEffect     = CAknTitlePaneLabel::EEffectScrollOnceWithFade;
       
  1996     effect.iEffectRect = oneLineLayoutRect;
       
  1997     iTitleLabel->AddToEffectQueueL( effect );
       
  1998 
       
  1999     // Pause
       
  2000     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2001     effect.iEffectRect     = rect;
       
  2002     effect.iEffectDuration = KScrollPauseBeforeFadeOut;
       
  2003     iTitleLabel->AddToEffectQueueL( effect );
       
  2004 
       
  2005     // Fade out
       
  2006     effect.iEffect         = CAknTitlePaneLabel::EEffectFadeOut;
       
  2007     effect.iEffectDuration = KScrollFadeInFadeOutDuration;
       
  2008     iTitleLabel->AddToEffectQueueL( effect );
       
  2009 
       
  2010     // Pause
       
  2011     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2012     effect.iEffectDuration = KScrollPauseBeforeFadeIn;
       
  2013     iTitleLabel->AddToEffectQueueL( effect );
       
  2014 
       
  2015     // Default
       
  2016     effect.iEffect = CAknTitlePaneLabel::EEffectToggleScrolledTextTruncation;
       
  2017     iTitleLabel->AddToEffectQueueL( effect );
       
  2018 
       
  2019     // No fade in because we don't do it in other layouts either
       
  2020 
       
  2021     // Finally show text without effect
       
  2022     effect.iEffectDuration = 0;
       
  2023     effect.iEffect         = 0;
       
  2024     effect.iEffectRect     = oneLineLayoutRect;
       
  2025     iTitleLabel->AddToEffectQueueL( effect );
       
  2026     }
       
  2027 
       
  2028 void CAknTitlePane::SetupExtendedStatusPaneScrollEffectL()
       
  2029     {
       
  2030     if ( !iExtension->iScrollEffectNeeded )
       
  2031         {
       
  2032         return;
       
  2033         }
       
  2034 
       
  2035     TRect rect( Rect() );
       
  2036     TBool hdLayout( AknStatuspaneUtils::HDLayoutActive() );
       
  2037 
       
  2038     TInt variety = hdLayout ? 10 : 5;
       
  2039     TBool imageShown = EFalse;
       
  2040 
       
  2041     // If image is shown, then select shorter text
       
  2042     if ( iExtension->iTitleImage &&
       
  2043          iExtension->iTitleImage->Bitmap() &&
       
  2044          iExtension->iSmallImageShown )
       
  2045         {
       
  2046         variety = hdLayout ? 11 : 6;
       
  2047         imageShown = ETrue;
       
  2048         }
       
  2049 
       
  2050     TAknTextLineLayout oneLineLayout(
       
  2051         AknLayoutScalable_Avkon::title_pane_t1( variety ).LayoutLine() );
       
  2052 
       
  2053     // if text would truncate, then use smaller font.
       
  2054     // (No smaller font layout with image exist)
       
  2055     if ( !TextFits( oneLineLayout ) )
       
  2056         {
       
  2057         if ( !imageShown )
       
  2058             {
       
  2059             if ( hdLayout )
       
  2060                 {
       
  2061                 oneLineLayout =
       
  2062                     AknLayoutScalable_Avkon::title_pane_t1( 12 ).LayoutLine();
       
  2063                 }
       
  2064             else
       
  2065                 {
       
  2066                 oneLineLayout =
       
  2067                     AknLayoutScalable_Avkon::title_pane_t2( 1 ).LayoutLine();
       
  2068                 }
       
  2069             }
       
  2070         else
       
  2071             {
       
  2072             if ( hdLayout )
       
  2073                 {
       
  2074                 oneLineLayout =
       
  2075                     AknLayoutScalable_Avkon::title_pane_t1( 13 ).LayoutLine();
       
  2076                 }
       
  2077             else
       
  2078                 {
       
  2079                 oneLineLayout =
       
  2080                     AknLayoutScalable_Avkon::title_pane_t2( 2 ).LayoutLine();
       
  2081                 }
       
  2082             }
       
  2083         }
       
  2084 
       
  2085     TAknLayoutText oneLineLayoutText;
       
  2086     oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  2087     TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  2088 
       
  2089     TRect effectRect( rect );
       
  2090 
       
  2091     CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  2092 
       
  2093     // First show text without effect
       
  2094     effect.iEffectDuration = 0;
       
  2095     effect.iEffect         = 0;
       
  2096     effect.iEffectRect     = oneLineLayoutRect;
       
  2097     effect.iLabelRect      = rect;
       
  2098     effect.iObserver       = NULL;
       
  2099     effect.iTitleText      = iTitleText;
       
  2100     effect.iTextLayout     = oneLineLayoutText;
       
  2101     effect.iTextLayoutLine = oneLineLayout;
       
  2102     iTitleLabel->AddToEffectQueueL( effect );
       
  2103 
       
  2104     // Pause
       
  2105     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2106     effect.iEffectRect     = effectRect;
       
  2107     effect.iEffectDuration = KScrollPauseBeforeScroll;
       
  2108     iTitleLabel->AddToEffectQueueL( effect );
       
  2109 
       
  2110     // Scroll text once
       
  2111     effect.iEffect     = CAknTitlePaneLabel::EEffectScrollOnceWithFade;
       
  2112     effect.iEffectRect = oneLineLayoutRect;
       
  2113     iTitleLabel->AddToEffectQueueL( effect );
       
  2114 
       
  2115     // Pause
       
  2116     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2117     effect.iEffectRect     = rect;
       
  2118     effect.iEffectDuration = KScrollPauseBeforeFadeOut;
       
  2119     iTitleLabel->AddToEffectQueueL( effect );
       
  2120 
       
  2121     // Fade out
       
  2122     effect.iEffect         = CAknTitlePaneLabel::EEffectFadeOut;
       
  2123     effect.iEffectDuration = KScrollFadeInFadeOutDuration;
       
  2124     iTitleLabel->AddToEffectQueueL( effect );
       
  2125 
       
  2126     // Pause
       
  2127     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2128     effect.iEffectDuration = KScrollPauseBeforeFadeIn;
       
  2129     iTitleLabel->AddToEffectQueueL( effect );
       
  2130 
       
  2131     // Default
       
  2132     effect.iEffect = CAknTitlePaneLabel::EEffectToggleScrolledTextTruncation;
       
  2133     iTitleLabel->AddToEffectQueueL( effect );
       
  2134 
       
  2135     // No fade in because we don't do it in other layouts either
       
  2136 
       
  2137     // Finally show text without effect
       
  2138     effect.iEffectDuration = 0;
       
  2139     effect.iEffect         = 0;
       
  2140     effect.iEffectRect     = oneLineLayoutRect;
       
  2141     iTitleLabel->AddToEffectQueueL( effect );
       
  2142     }
       
  2143 
       
  2144 
       
  2145 void CAknTitlePane::SetupFlatStatusPaneScrollEffectL()
       
  2146     {
       
  2147     if ( !iExtension->iScrollEffectNeeded )
       
  2148         {
       
  2149         return;
       
  2150         }
       
  2151 
       
  2152     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
  2153     TBool fade                               = EFalse;
       
  2154     TBool narrowNaviPane                     = EFalse;
       
  2155     TBool forcedNormalNaviPane               = EFalse;
       
  2156     
       
  2157     RWindow* naviwindow                      = NULL;
       
  2158     RWindow* titlewindow                     = NULL;
       
  2159     CCoeControl* naviContainerControl        = NULL;
       
  2160     CCoeControl* titleContainerControl       = NULL;
       
  2161     CAknNavigationControlContainer* naviPane = NULL;
       
  2162     CAknNavigationDecorator* decorator       = NULL;
       
  2163 
       
  2164     TPoint naviControlPosition;
       
  2165     TSize naviControlSize;
       
  2166 
       
  2167     if ( statusPane )
       
  2168         {
       
  2169         naviContainerControl = statusPane->ContainerControlL(
       
  2170             TUid::Uid( EEikStatusPaneUidNavi ) );
       
  2171         titleContainerControl = statusPane->ContainerControlL(
       
  2172             TUid::Uid( EEikStatusPaneUidTitle ) );
       
  2173         if ( naviContainerControl && titleContainerControl )
       
  2174             {
       
  2175             RDrawableWindow* drawableWindow =
       
  2176                 naviContainerControl->DrawableWindow();
       
  2177             if ( drawableWindow )
       
  2178                 {
       
  2179                 // Trust that container is always RWindow.
       
  2180                 naviwindow = static_cast <RWindow*> ( drawableWindow );
       
  2181                 }
       
  2182 
       
  2183             drawableWindow = titleContainerControl->DrawableWindow();
       
  2184             if ( drawableWindow )
       
  2185                 {
       
  2186                 // Trust that container is always RWindow.
       
  2187                 titlewindow = static_cast <RWindow*> ( drawableWindow );
       
  2188                 }
       
  2189 
       
  2190 
       
  2191             naviControlPosition = naviContainerControl->Position();
       
  2192             naviControlSize     = naviContainerControl->Size();
       
  2193             }
       
  2194 
       
  2195         CCoeControl* control = NULL;
       
  2196         TRAP_IGNORE( control =
       
  2197             statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  2198         if ( control )
       
  2199             {
       
  2200             // Control cannot be casted directly because someone may have
       
  2201             // swapped the control. Use this method instead.
       
  2202             control->MopGetObject( naviPane );
       
  2203             if ( naviPane )
       
  2204                 {
       
  2205                 decorator = naviPane->Top( EFalse );
       
  2206                 if ( decorator )
       
  2207                     {
       
  2208                     if ( decorator->NaviControlLayoutStyle() ==
       
  2209                             CAknNavigationDecorator::ENaviControlLayoutNarrow )
       
  2210                         {
       
  2211                         naviControlPosition +=
       
  2212                             CAknNavigationDecorator::DecoratedControlNarrowRect(
       
  2213                                 decorator->ControlType() ).iTl;
       
  2214                         naviControlSize =
       
  2215                             CAknNavigationDecorator::DecoratedControlNarrowRect(
       
  2216                                 decorator->ControlType() ).Size();
       
  2217                         narrowNaviPane = ETrue;
       
  2218                         }
       
  2219                     if ( decorator->NaviControlLayoutStyle() == CAknNavigationDecorator::ENaviControlLayoutNormal &&
       
  2220                          decorator->NaviControlLayoutMode() == CAknNavigationDecorator::ENaviControlLayoutModeForced )
       
  2221                         {
       
  2222                         forcedNormalNaviPane = ETrue;
       
  2223                         }
       
  2224                     }
       
  2225                 }
       
  2226             }
       
  2227         }
       
  2228 
       
  2229     if ( naviwindow && titlewindow )
       
  2230         {
       
  2231         // Fade title text only if navipane window is above titlepane
       
  2232         TInt naviWindowOrdinalPosition = naviwindow->OrdinalPosition();
       
  2233         TInt titleWindowOrdinalPosition = titlewindow->OrdinalPosition();
       
  2234         fade = naviWindowOrdinalPosition < titleWindowOrdinalPosition;
       
  2235         }
       
  2236 
       
  2237 
       
  2238     TAknTextLineLayout oneLineLayout;
       
  2239 
       
  2240     TBool touchLsc( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  2241                     AknLayoutUtils::PenEnabled() );
       
  2242     
       
  2243     if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  2244         {
       
  2245         // if image is shown, use shorter version of text
       
  2246         oneLineLayout =
       
  2247             AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 3 ).LayoutLine();
       
  2248         }
       
  2249     else
       
  2250         {
       
  2251         // if image is not shown, use longer version of text
       
  2252         oneLineLayout =
       
  2253             AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 2 ).LayoutLine();
       
  2254         }
       
  2255 
       
  2256     TAknLayoutText oneLineLayoutText;
       
  2257     oneLineLayoutText.LayoutText( Rect(), oneLineLayout );
       
  2258     TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  2259 
       
  2260     TRect effectRect( oneLineLayoutText.TextRect() );
       
  2261     if ( fade )
       
  2262         {
       
  2263         if ( !AknLayoutUtils::LayoutMirrored() )
       
  2264             {
       
  2265             effectRect.iBr.iX =
       
  2266                 naviControlPosition.iX - titleContainerControl->Position().iX;
       
  2267             }
       
  2268         else
       
  2269             {
       
  2270             effectRect.iTl.iX = naviControlSize.iWidth + naviControlPosition.iX;
       
  2271             }
       
  2272         }
       
  2273     else
       
  2274         {
       
  2275         effectRect = oneLineLayoutText.TextRect();
       
  2276         }
       
  2277 
       
  2278     // Decide scrolling need
       
  2279     if ( narrowNaviPane || forcedNormalNaviPane )
       
  2280         {
       
  2281         const CFont* fontUsed =
       
  2282             AknLayoutUtils::FontFromId( oneLineLayout.FontId() );
       
  2283         CFont::TMeasureTextInput input;
       
  2284         input.iFlags = CFont::TMeasureTextInput::EFVisualOrder;
       
  2285         TInt textLength = fontUsed->MeasureText( *iTitleText, &input );
       
  2286 
       
  2287         TRect visibleTextRect( effectRect );
       
  2288 
       
  2289         if ( textLength > visibleTextRect.Width() )
       
  2290             {
       
  2291             iExtension->iScrollEffectNeeded = ETrue;
       
  2292             }
       
  2293         }
       
  2294     else
       
  2295         {
       
  2296         // No scroll if navipane is not in short mode but fade is on.
       
  2297         if ( fade )
       
  2298             {
       
  2299             iExtension->iScrollEffectNeeded = EFalse;
       
  2300             }
       
  2301         }
       
  2302 
       
  2303     // This is the earliest place where we really know
       
  2304     // if scrolling is needed or not.
       
  2305     if ( !iExtension->iScrollEffectNeeded )
       
  2306         {
       
  2307         return;
       
  2308         }
       
  2309 
       
  2310     CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  2311 
       
  2312     // Initilize effect struct
       
  2313     effect.iEffectDuration = 0;
       
  2314     effect.iEffect         = 0;
       
  2315     effect.iEffectRect     = Rect();
       
  2316     effect.iLabelRect      = Rect();
       
  2317     effect.iObserver       = static_cast <CCoeControl*> ( naviPane );
       
  2318     effect.iTitleText      = iTitleText;
       
  2319     effect.iTextLayout     = oneLineLayoutText;
       
  2320     effect.iTextLayoutLine = oneLineLayout;
       
  2321 
       
  2322     // Pause
       
  2323     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2324     effect.iEffectDuration = KScrollPauseBeforeScroll;
       
  2325     iTitleLabel->AddToEffectQueueL( effect );
       
  2326 
       
  2327     // Scroll text once
       
  2328     effect.iEffectDuration = 0;
       
  2329     effect.iEffectRect     = effectRect;
       
  2330     effect.iEffect         = CAknTitlePaneLabel::EEffectScrollOnceWithFade;
       
  2331     iTitleLabel->AddToEffectQueueL( effect );
       
  2332 
       
  2333     // Pause
       
  2334     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2335     effect.iEffectDuration = KScrollPauseBeforeFadeOut;
       
  2336     iTitleLabel->AddToEffectQueueL( effect );
       
  2337 
       
  2338     // Fade out
       
  2339     effect.iEffect         = CAknTitlePaneLabel::EEffectFadeOut;
       
  2340     effect.iEffectDuration = KScrollFadeInFadeOutDuration;
       
  2341     iTitleLabel->AddToEffectQueueL( effect );
       
  2342 
       
  2343     // Pause
       
  2344     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2345     effect.iEffectDuration = KScrollPauseBeforeFadeIn;
       
  2346     iTitleLabel->AddToEffectQueueL( effect );
       
  2347 
       
  2348     // Default
       
  2349     effect.iEffect = CAknTitlePaneLabel::EEffectToggleScrolledTextTruncation;
       
  2350     iTitleLabel->AddToEffectQueueL( effect );
       
  2351 
       
  2352     // No fade in because we don't support fade in with
       
  2353     // other effects (fade left or right).
       
  2354 
       
  2355     // Finally text is shown with fade effect if needed
       
  2356     // (setup in its own method).
       
  2357     }
       
  2358 
       
  2359 void CAknTitlePane::SetupNormalStatusPaneScrollEffectL()
       
  2360     {
       
  2361     if ( !iExtension->iScrollEffectNeeded )
       
  2362         {
       
  2363         return;
       
  2364         }
       
  2365 
       
  2366     TRect rect( Rect() );
       
  2367 
       
  2368     // Is battery pane visible in current layout
       
  2369     TInt indexW = AknStatuspaneUtils::IdleLayoutActive() ? 1 : 0;
       
  2370 
       
  2371     TAknTextLineLayout oneLineLayout(
       
  2372          AknLayoutScalable_Avkon::title_pane_t1( 0 ).LayoutLine() );
       
  2373 
       
  2374     const TAknMultiLineTextLayout twoLineLayout(
       
  2375         AKN_LAYOUT_MULTILINE_TEXT_Title_pane_texts_Line_2( indexW, 2 ) );
       
  2376 
       
  2377     // if text would truncate, then try to use smaller font with one line layout
       
  2378     if ( !TextFits( oneLineLayout ) )
       
  2379         {
       
  2380         oneLineLayout =
       
  2381             AknLayoutScalable_Avkon::title_pane_t2( 1 ).LayoutLine();
       
  2382         }
       
  2383 
       
  2384     TAknLayoutText oneLineLayoutText;
       
  2385     oneLineLayoutText.LayoutText(rect, oneLineLayout);
       
  2386     TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  2387 
       
  2388     TAknLayoutText twoLineLayoutText;
       
  2389     twoLineLayoutText.LayoutText(rect, twoLineLayout);
       
  2390     TRect twoLineLayoutRect( twoLineLayoutText.TextRect() );
       
  2391 
       
  2392     CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  2393 
       
  2394     effect.iEffect         = 0;
       
  2395     effect.iEffectDuration = 0;
       
  2396     effect.iLabelRect      = rect;
       
  2397     effect.iObserver       = NULL;
       
  2398     effect.iTitleText      = iTitleText;
       
  2399     effect.iEffectRect     = oneLineLayoutRect;
       
  2400     effect.iTextLayout     = oneLineLayoutText;
       
  2401     effect.iTextLayoutLine = oneLineLayout;
       
  2402     iTitleLabel->AddToEffectQueueL( effect );
       
  2403 
       
  2404     // Pause
       
  2405     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2406     effect.iEffectDuration = KScrollPauseBeforeScroll;
       
  2407     iTitleLabel->AddToEffectQueueL( effect );
       
  2408 
       
  2409     // Scroll text once
       
  2410     effect.iEffect     = CAknTitlePaneLabel::EEffectScrollOnceWithFade;
       
  2411     effect.iEffectRect = oneLineLayoutRect;
       
  2412     iTitleLabel->AddToEffectQueueL( effect );
       
  2413 
       
  2414     // Pause
       
  2415     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2416     effect.iEffectDuration = KScrollPauseBeforeFadeOut;
       
  2417     iTitleLabel->AddToEffectQueueL( effect );
       
  2418 
       
  2419     // Fade out
       
  2420     effect.iEffect         = CAknTitlePaneLabel::EEffectFadeOut;
       
  2421     effect.iEffectRect     = rect;
       
  2422     effect.iEffectDuration = KScrollFadeInFadeOutDuration;
       
  2423     iTitleLabel->AddToEffectQueueL( effect );
       
  2424 
       
  2425     // Pause
       
  2426     effect.iEffect         = CAknTitlePaneLabel::EEffectPause;
       
  2427     effect.iEffectDuration = KScrollPauseBeforeFadeIn;
       
  2428     iTitleLabel->AddToEffectQueueL( effect );
       
  2429 
       
  2430     // No fade in done, drawing two line text with effects is not supported.
       
  2431 
       
  2432     // Finally show text without effect
       
  2433     effect.iEffect = 0;
       
  2434     if ( iExtension && iExtension->iCurrentNumberOfTextLines == 2 )
       
  2435         {
       
  2436         effect.iEffectRect     = twoLineLayoutRect;
       
  2437         effect.iLabelRect      = rect;
       
  2438         effect.iTextLayout     = twoLineLayoutText;
       
  2439         effect.iTextLayoutLine = twoLineLayout;
       
  2440         }
       
  2441     else
       
  2442         {
       
  2443         effect.iEffectRect     = oneLineLayoutRect;
       
  2444         effect.iLabelRect      = rect;
       
  2445         effect.iTextLayout     = oneLineLayoutText;
       
  2446         effect.iTextLayoutLine = oneLineLayout;
       
  2447         }
       
  2448     iTitleLabel->AddToEffectQueueL( effect );
       
  2449     }
       
  2450 
       
  2451 
       
  2452 void CAknTitlePane::SetupFlatStatusPaneFadeEffectL()
       
  2453     {
       
  2454     // For flat statuspane we fade the titletext under navipane
       
  2455     // in situations where navipane is covering part of titlepane.
       
  2456     CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
       
  2457     TBool fade                               = EFalse;
       
  2458     TBool narrowNaviPane                     = EFalse;
       
  2459     TBool forcedNormalNaviPane               = EFalse;
       
  2460     RWindow* naviwindow                      = NULL;
       
  2461     RWindow* titlewindow                     = NULL;
       
  2462     CCoeControl* naviContainerControl        = NULL;
       
  2463     CCoeControl* titleContainerControl       = NULL;
       
  2464     CAknNavigationControlContainer* naviPane = NULL;
       
  2465     CAknNavigationDecorator* decorator       = NULL;
       
  2466 
       
  2467     TPoint naviControlPosition( 0, 0 );
       
  2468     TSize  naviControlSize( 0, 0 );
       
  2469     TRect  rect( Rect() );
       
  2470 
       
  2471     if ( statusPane )
       
  2472         {
       
  2473         naviContainerControl =
       
  2474             statusPane->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
       
  2475         titleContainerControl =
       
  2476             statusPane->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle ) );
       
  2477 
       
  2478         if ( naviContainerControl && titleContainerControl )
       
  2479             {
       
  2480             RDrawableWindow* drawableWindow =
       
  2481                 naviContainerControl->DrawableWindow();
       
  2482 
       
  2483             if ( drawableWindow )
       
  2484                 {
       
  2485                 // Trust that container is always RWindow.
       
  2486                 naviwindow = static_cast <RWindow*> ( drawableWindow );
       
  2487                 }
       
  2488 
       
  2489             drawableWindow = titleContainerControl->DrawableWindow();
       
  2490             if ( drawableWindow )
       
  2491                 {
       
  2492                 // Trust that container is always RWindow.
       
  2493                 titlewindow = static_cast <RWindow*> ( drawableWindow );
       
  2494                 }
       
  2495 
       
  2496             naviControlPosition = naviContainerControl->Position();
       
  2497             naviControlSize     = naviContainerControl->Size();
       
  2498             }
       
  2499 
       
  2500         CCoeControl* control = NULL;
       
  2501         TRAP_IGNORE( control =
       
  2502             statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
  2503 
       
  2504         if ( control )
       
  2505             {
       
  2506             // Control cannot be casted directly beacause someone
       
  2507             // may have swapped the control.
       
  2508             // Use this workaround instead.
       
  2509             control->MopGetObject( naviPane );
       
  2510             if ( naviPane )
       
  2511                 {
       
  2512                 decorator = naviPane->Top( EFalse );
       
  2513                 if ( decorator )
       
  2514                     {
       
  2515                     if ( decorator->NaviControlLayoutStyle() ==
       
  2516                             CAknNavigationDecorator::ENaviControlLayoutNarrow )
       
  2517                         {
       
  2518                         naviControlPosition +=
       
  2519                             CAknNavigationDecorator::DecoratedControlNarrowRect(
       
  2520                                 decorator->ControlType() ).iTl;
       
  2521                                 
       
  2522                         naviControlSize =
       
  2523                             CAknNavigationDecorator::DecoratedControlNarrowRect(
       
  2524                                 decorator->ControlType() ).Size();
       
  2525                                 
       
  2526                         narrowNaviPane = ETrue;
       
  2527                         }
       
  2528                     if ( decorator->NaviControlLayoutStyle() == CAknNavigationDecorator::ENaviControlLayoutNormal &&
       
  2529                          decorator->NaviControlLayoutMode() == CAknNavigationDecorator::ENaviControlLayoutModeForced )
       
  2530                         {
       
  2531                         forcedNormalNaviPane = ETrue;
       
  2532                         }
       
  2533                     }
       
  2534                 }
       
  2535             }
       
  2536         }
       
  2537 
       
  2538     if ( naviwindow && titlewindow )
       
  2539         {
       
  2540         // Fade title text only if navipane window is above titlepane
       
  2541         TInt naviWindowOrdinalPosition  = naviwindow->OrdinalPosition();
       
  2542         TInt titleWindowOrdinalPosition = titlewindow->OrdinalPosition();
       
  2543         fade =  titleWindowOrdinalPosition >  naviWindowOrdinalPosition;
       
  2544         }
       
  2545 
       
  2546     if ( fade )
       
  2547         {
       
  2548         TAknTextLineLayout oneLineLayout;
       
  2549         TBool touchLsc( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  2550                         AknLayoutUtils::PenEnabled() );
       
  2551         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  2552             {
       
  2553             // if image is shown, use shorter version of text
       
  2554             oneLineLayout =
       
  2555                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 3 ).LayoutLine();
       
  2556             }
       
  2557         else
       
  2558             {
       
  2559             // if image is not shown, use longer version of text
       
  2560             oneLineLayout =
       
  2561                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 2 ).LayoutLine();
       
  2562             }      
       
  2563 
       
  2564 
       
  2565         TAknLayoutText oneLineLayoutText;
       
  2566         oneLineLayoutText.LayoutText(rect, oneLineLayout);
       
  2567         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
       
  2568 
       
  2569         TRect effectRect( rect );
       
  2570         TInt effectType = 0;
       
  2571 
       
  2572         // In landscape mode fade about 25% of the title, and in portrait
       
  2573         // fade the whole title.
       
  2574         TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() );
       
  2575 
       
  2576             if ( !AknLayoutUtils::LayoutMirrored() )
       
  2577                 {
       
  2578                 effectType = CAknTitlePaneLabel::EEffectFadeToRight;
       
  2579                 effectRect.iBr.iX = naviControlPosition.iX - titleContainerControl->Position().iX;
       
  2580                 effectRect.iTl.iX = effectRect.iBr.iX - effectRect.iBr.iX / 4;
       
  2581                 }
       
  2582             else
       
  2583                 {
       
  2584                 effectType = CAknTitlePaneLabel::EEffectFadeToLeft;
       
  2585                 effectRect.iTl.iX = naviControlPosition.iX + naviControlSize.iWidth;
       
  2586                 effectRect.iBr.iX = rect.iBr.iX;
       
  2587                 effectRect.iTl.iX -= titleContainerControl->Position().iX;
       
  2588                 effectRect.iBr.iX -= effectRect.Size().iWidth * 3 / 4;
       
  2589                 }
       
  2590 
       
  2591         CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  2592         effect.iEffectDuration = 0;
       
  2593         effect.iEffect         = effectType;
       
  2594         effect.iEffectRect     = effectRect;
       
  2595         effect.iLabelRect      = rect;
       
  2596         effect.iObserver       = naviPane;
       
  2597         effect.iTitleText      = iTitleText;
       
  2598         effect.iTextLayout     = oneLineLayoutText;
       
  2599         effect.iTextLayoutLine = oneLineLayout;
       
  2600         iTitleLabel->AddToEffectQueueL( effect );
       
  2601 
       
  2602         // Decide scrolling need
       
  2603         if ( narrowNaviPane || forcedNormalNaviPane )
       
  2604             {
       
  2605             const CFont* fontUsed =
       
  2606                 AknLayoutUtils::FontFromId( oneLineLayout.FontId() );
       
  2607             CFont::TMeasureTextInput input;
       
  2608             input.iFlags = CFont::TMeasureTextInput::EFVisualOrder;
       
  2609             TInt textLength = fontUsed->MeasureText( *iTitleText, &input );
       
  2610 
       
  2611             TRect visibleTextRect( oneLineLayoutRect );
       
  2612             if ( !AknLayoutUtils::LayoutMirrored() )
       
  2613                 {
       
  2614                 visibleTextRect.iBr.iX = effectRect.iTl.iX;
       
  2615                 }
       
  2616             else
       
  2617                 {
       
  2618                 visibleTextRect.iTl.iX = effectRect.iBr.iX;
       
  2619                 }
       
  2620 
       
  2621             if ( textLength > visibleTextRect.Width() )
       
  2622                 {
       
  2623                 iExtension->iScrollEffectNeeded = ETrue;
       
  2624                 }
       
  2625             }
       
  2626         else
       
  2627             {
       
  2628             // No scroll if navipane is not in short mode but fade is on.
       
  2629             if ( fade )
       
  2630                 {
       
  2631                 iExtension->iScrollEffectNeeded = EFalse;
       
  2632                 }
       
  2633             }
       
  2634         }
       
  2635     else
       
  2636         {
       
  2637         SetupNoEffectL();
       
  2638         }
       
  2639     }
       
  2640 
       
  2641 
       
  2642 void CAknTitlePane::SetupNoEffectL()
       
  2643     {
       
  2644     TAknLayoutText     oneLineLayoutText;
       
  2645     TAknTextLineLayout oneLineLayout;
       
  2646     
       
  2647     TRect rect( Rect() );
       
  2648 
       
  2649     if ( AknStatuspaneUtils::StaconPaneActive() )
       
  2650         {
       
  2651         // If image is shown, then select shorter text
       
  2652         TInt leftOrRightSoftKeysVariety = 0;
       
  2653         if ( AknStatuspaneUtils::StaconSoftKeysLeft() )
       
  2654             {
       
  2655             leftOrRightSoftKeysVariety = 1;
       
  2656             }
       
  2657         if ( iExtension->iTitleImage &&
       
  2658              iExtension->iTitleImage->Bitmap() &&
       
  2659              iExtension->iSmallImageShown )
       
  2660             {
       
  2661             leftOrRightSoftKeysVariety += 2;
       
  2662             }
       
  2663 
       
  2664         oneLineLayout =
       
  2665             AknLayoutScalable_Avkon::title_pane_stacon_t1(
       
  2666                 leftOrRightSoftKeysVariety ).LayoutLine();
       
  2667         }
       
  2668     else if ( AknStatuspaneUtils::FlatLayoutActive() )
       
  2669         {
       
  2670         TBool touchLsc( Layout_Meta_Data::IsLandscapeOrientation() &&
       
  2671                         AknLayoutUtils::PenEnabled() );
       
  2672         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  2673             {
       
  2674             // if image is shown, use shorter version of text
       
  2675             oneLineLayout =
       
  2676                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 3 ).LayoutLine();
       
  2677             }
       
  2678         else
       
  2679             {
       
  2680             // if image is not shown, use longer version of text
       
  2681             oneLineLayout =
       
  2682                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 2 ).LayoutLine();
       
  2683             }      
       
  2684         }
       
  2685     else if ( AknStatuspaneUtils::ExtendedLayoutActive() )
       
  2686         {
       
  2687         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
       
  2688             {
       
  2689             // if image is shown, use shorter version of text
       
  2690             oneLineLayout =
       
  2691                 AknLayoutScalable_Avkon::title_pane_t1( 6 ).LayoutLine();
       
  2692             }
       
  2693         else
       
  2694             {
       
  2695             // if image is not shown, use longer version of text
       
  2696             oneLineLayout =
       
  2697                 AknLayoutScalable_Avkon::title_pane_t1( 5 ).LayoutLine();
       
  2698             }
       
  2699         }
       
  2700     else
       
  2701         {
       
  2702         // Is battery pane visible in current layout
       
  2703         TInt indexW = AknStatuspaneUtils::IdleLayoutActive() ? 1 : 0;
       
  2704         oneLineLayout =
       
  2705             AknLayoutScalable_Avkon::title_pane_t1( 0 ).LayoutLine();
       
  2706 
       
  2707         if ( !TextFits( oneLineLayout ) )
       
  2708             {
       
  2709             oneLineLayout =
       
  2710                 AknLayoutScalable_Avkon::title_pane_t2( 1 ).LayoutLine();
       
  2711             }
       
  2712 
       
  2713         TAknMultiLineTextLayout twoLineLayout(
       
  2714             AKN_LAYOUT_MULTILINE_TEXT_Title_pane_texts_Line_2( indexW, 2 ) );
       
  2715 
       
  2716         if ( iExtension && iExtension->iCurrentNumberOfTextLines == 2 )
       
  2717             {
       
  2718             oneLineLayout = twoLineLayout;
       
  2719             }
       
  2720         }
       
  2721 
       
  2722     oneLineLayoutText.LayoutText( rect, oneLineLayout );
       
  2723     CAknTitlePaneLabel::SAknTitleLableEffect effect;
       
  2724     effect.iEffectDuration = 0;
       
  2725     effect.iEffect         = 0;
       
  2726     effect.iEffectRect     = rect;
       
  2727     effect.iLabelRect      = rect;
       
  2728     effect.iObserver       = NULL;
       
  2729     effect.iTitleText      = iTitleText;
       
  2730     effect.iTextLayout     = oneLineLayoutText;
       
  2731     effect.iTextLayoutLine = oneLineLayout;
       
  2732     iTitleLabel->AddToEffectQueueL( effect );
       
  2733     }
       
  2734 
       
  2735 // ----------------------------------------------------------------------------
       
  2736 // CAknTitlePane::SetTextL
       
  2737 // Sets the title pane text and scrolling effect.
       
  2738 // CAknTitlePane takes the ownership of aText.
       
  2739 // ----------------------------------------------------------------------------
       
  2740 //
       
  2741 EXPORT_C void CAknTitlePane::SetText( HBufC* aText, TBool aScroll )
       
  2742     {
       
  2743     __ASSERT_ALWAYS( aText, Panic( EAknPanicNullPointer ) );
       
  2744 
       
  2745     TBool textChanged = !iTitleText || aText != iTitleText || *aText != *iTitleText
       
  2746                         || iImageShown || aScroll != iExtension->iScrollEffectEnabled;
       
  2747     
       
  2748     iExtension->iScrollEffectEnabled = aScroll;
       
  2749     if ( iTitleLabel )
       
  2750         {
       
  2751         iTitleLabel->InvalidateText();
       
  2752         }
       
  2753     if ( iTitleText != aText )
       
  2754         {
       
  2755         delete iTitleText;
       
  2756         iTitleText = aText;
       
  2757         }
       
  2758 
       
  2759     if ( textChanged )
       
  2760         {
       
  2761         iImageShown = EFalse;
       
  2762         SizeChanged();
       
  2763         DrawDeferred();
       
  2764         }
       
  2765     }
       
  2766 
       
  2767 
       
  2768 // ----------------------------------------------------------------------------
       
  2769 // CAknTitlePane::SetTextL
       
  2770 // Sets the title pane text and scrolling effect.
       
  2771 // ----------------------------------------------------------------------------
       
  2772 //
       
  2773 EXPORT_C void CAknTitlePane::SetTextL( const TDesC& aText, TBool aScroll )
       
  2774     {
       
  2775     SetText( aText.AllocL(), aScroll );
       
  2776     }
       
  2777 
       
  2778 
       
  2779 EXPORT_C TInt CAknTitlePane::MaxNumberOfVisibleTextRows() const
       
  2780     {
       
  2781     if ( AknStatuspaneUtils::StaconPaneActive() ||
       
  2782          AknStatuspaneUtils::FlatLayoutActive() ||
       
  2783          AknStatuspaneUtils::ExtendedLayoutActive() )
       
  2784         {
       
  2785         return 1;
       
  2786         }
       
  2787     else
       
  2788         {
       
  2789         return 2;
       
  2790         }
       
  2791     }
       
  2792 
       
  2793 
       
  2794 EXPORT_C void CAknTitlePane::SetNumberOfVisibleTextRows( TInt aRows )
       
  2795     {
       
  2796     if ( iExtension && aRows > 0 && aRows <= MaxNumberOfVisibleTextRows() )
       
  2797         {
       
  2798         if ( iExtension->iLimitedNumberOfTextLines != aRows )
       
  2799             {
       
  2800             iExtension->iLimitedNumberOfTextLines = aRows;
       
  2801             SizeChanged();
       
  2802             DrawDeferred();
       
  2803             }
       
  2804         }
       
  2805     }
       
  2806 
       
  2807 
       
  2808 // ---------------------------------------------------------------------------
       
  2809 // CAknTitlePane::TextFits
       
  2810 // Checks if the text fits inside the title pane area.
       
  2811 // ---------------------------------------------------------------------------
       
  2812 //	
       
  2813 TBool CAknTitlePane::TextFits( TAknTextLineLayout& aTextLayout )
       
  2814     {
       
  2815     TInt textLength = 0;
       
  2816     TInt maxLength  = 0;
       
  2817 
       
  2818     const CFont* fontUsed = AknLayoutUtils::FontFromId( aTextLayout.FontId() );
       
  2819     CFont::TMeasureTextInput input;
       
  2820     
       
  2821     // We need to check if the title text's directionality
       
  2822     // is from right to left to measure it correctly.
       
  2823     TBool rtl =
       
  2824         TBidiText::TextDirectionality( *iTitleText ) == TBidiText::ERightToLeft;
       
  2825     if ( !rtl )
       
  2826         {
       
  2827         input.iFlags = CFont::TMeasureTextInput::EFVisualOrder;
       
  2828         }
       
  2829     else
       
  2830         {
       
  2831         input.iFlags = CFont::TMeasureTextInput::EFVisualOrderRightToLeft;
       
  2832         }
       
  2833     textLength = fontUsed->MeasureText( *iTitleText, &input );
       
  2834 
       
  2835     TAknLayoutText oneLineLayoutText;
       
  2836     oneLineLayoutText.LayoutText( Rect(), aTextLayout );
       
  2837     maxLength = oneLineLayoutText.TextRect().Width();
       
  2838 
       
  2839     if ( textLength < maxLength )
       
  2840         {
       
  2841         return ETrue;
       
  2842         }
       
  2843     else
       
  2844         {
       
  2845         return EFalse;
       
  2846         }
       
  2847     }
       
  2848 
       
  2849 //  End of File