uifw/AvKon/src/akntitle.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
     1 /*
     1 /*
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    94     TInt                     iCurrentNumberOfTextLines;
    94     TInt                     iCurrentNumberOfTextLines;
    95     TInt                     iLimitedNumberOfTextLines;
    95     TInt                     iLimitedNumberOfTextLines;
    96 
    96 
    97     TBool                    iImageAutoscaling;
    97     TBool                    iImageAutoscaling;
    98     TBool                    iSmallImageAutoscaling;
    98     TBool                    iSmallImageAutoscaling;
       
    99     
       
   100     CEikStatusPaneBase*      iStatusPane;
    99     };
   101     };
   100 
   102 
   101 
   103 
   102 // ----------------------------------------------------------------------------
   104 // ----------------------------------------------------------------------------
   103 // CAknTitlePaneExtension::NewL
   105 // CAknTitlePaneExtension::NewL
   210     if ( AknLayoutUtils::PenEnabled() )
   212     if ( AknLayoutUtils::PenEnabled() )
   211         {
   213         {
   212         // set flags to default values
   214         // set flags to default values
   213         iExtension->iFlags = 0;
   215         iExtension->iFlags = 0;
   214         }
   216         }
       
   217    	iExtension->iStatusPane = CEikStatusPaneBase::Current();
   215     }
   218     }
   216 
   219 
   217 
   220 
   218 // ----------------------------------------------------------------------------
   221 // ----------------------------------------------------------------------------
   219 // CAknTitlePane::ConstructFromResourceL
   222 // CAknTitlePane::ConstructFromResourceL
   222 //
   225 //
   223 EXPORT_C void CAknTitlePane::ConstructFromResourceL( TResourceReader& aReader )
   226 EXPORT_C void CAknTitlePane::ConstructFromResourceL( TResourceReader& aReader )
   224     {
   227     {
   225     CommonConstructL();
   228     CommonConstructL();
   226     ReadFromResourceFileL( aReader );
   229     ReadFromResourceFileL( aReader );
       
   230     iExtension->iStatusPane = CEikStatusPaneBase::Current();
   227     }
   231     }
   228 
   232 
   229 
   233 
   230 // ----------------------------------------------------------------------------
   234 // ----------------------------------------------------------------------------
   231 // CAknTitlePane::SetTextL
   235 // CAknTitlePane::SetTextL
   674 // Draws the title pane.
   678 // Draws the title pane.
   675 // ----------------------------------------------------------------------------
   679 // ----------------------------------------------------------------------------
   676 //
   680 //
   677 EXPORT_C void CAknTitlePane::Draw( const TRect& aRect ) const
   681 EXPORT_C void CAknTitlePane::Draw( const TRect& aRect ) const
   678     {
   682     {
   679     const TUid KActiveIdle2Uid = {0x102750F0};
   683     	      
   680 
   684     if ( iExtension->iStatusPane && 
   681     if ( AppUid() == KActiveIdle2Uid )
   685          iExtension->iStatusPane->IsTransparent() )
   682         {
   686         {
   683         CWindowGc& gc = SystemGc();
   687         CWindowGc& gc = SystemGc();
   684         TRgb rgb(TRgb::Color16MA(0));
   688         TRgb rgb(TRgb::Color16MA(0));
   685         gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   689         gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
   686         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   690         gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   687         gc.SetBrushColor(rgb);
   691         gc.SetBrushColor(rgb);
   688         gc.Clear( aRect );
   692         gc.Clear( aRect );
   689         return;
   693         return;
   690         }
   694         }
   691 
   695 
   692     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   696     // Don't allow normal background drawing if
   693 
   697     // background is already drawn with a background drawer.
   694     TRect rect( Rect() );
   698     const MCoeControlBackground* backgroundDrawer = FindBackground();
   695 
   699     if ( !backgroundDrawer )
   696     CWindowGc& gc=SystemGc();
   700         {
   697 
   701         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   698     if ( AknStatuspaneUtils::StaconPaneActive() ||
   702 
   699          AknStatuspaneUtils::FlatLayoutActive() )
   703         TRect rect( Rect() );
   700         {
   704 
   701         MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
   705         CWindowGc& gc=SystemGc();
   702 
   706 
   703         if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
   707         if ( AknStatuspaneUtils::StaconPaneActive() ||
   704             {
   708              AknStatuspaneUtils::FlatLayoutActive() )
   705             gc.SetPenStyle( CGraphicsContext::ENullPen );
   709             {
       
   710             MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   711 
       
   712             if( !AknsDrawUtils::Background( skin, cc, this, gc, rect ) )
       
   713                 {
       
   714                 gc.SetPenStyle( CGraphicsContext::ENullPen );
       
   715                 gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   716                 gc.SetBrushColor(
       
   717                     AKN_LAF_COLOR( KStatusPaneBackgroundGraphicsColorUsual ) );
       
   718                 gc.DrawRect( rect );
       
   719                 }
       
   720             }
       
   721         else
       
   722             {
   706             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   723             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
   707             gc.SetBrushColor(
   724             gc.SetBrushColor( AKN_LAF_COLOR( KStatusPaneBackgroundColor ) );
   708                 AKN_LAF_COLOR( KStatusPaneBackgroundGraphicsColorUsual ) );
   725             AknsDrawUtils::Background( skin,
   709             gc.DrawRect( rect );
   726                                        AknsDrawUtils::ControlContext( this ),
   710             }
   727                                        this,
   711         }
   728                                        gc,
   712     else
   729                                        rect );
   713         {
   730             }
   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         }
   731         }
   722     }
   732     }
   723 
   733 
   724 
   734 
   725 // ----------------------------------------------------------------------------
   735 // ----------------------------------------------------------------------------
   906         }
   916         }
   907 
   917 
   908     TPtr ptr = iText->Des();
   918     TPtr ptr = iText->Des();
   909     AknBidiTextUtils::ConvertToVisualAndWrapToStringL(
   919     AknBidiTextUtils::ConvertToVisualAndWrapToStringL(
   910         aText, *iLineWidthArray, *font, ptr, ETrue );
   920         aText, *iLineWidthArray, *font, ptr, ETrue );
   911 
   921     
       
   922     TInt len = iText->Length();
       
   923     if (( aLineNum == 1 ) && ( iText->LocateReverseF( '\n' ) == len -1 ) && len >= 1 )
       
   924         {
       
   925         ptr.Delete( len - 1, 1 );
       
   926         }
   912     }
   927     }
   913 
   928 
   914 
   929 
   915 /**
   930 /**
   916  * Return type of layout set in DoLayout operation, either one line
   931  * Return type of layout set in DoLayout operation, either one line
  1428                         AknLayoutUtils::PenEnabled() );
  1443                         AknLayoutUtils::PenEnabled() );
  1429 
  1444 
  1430         TAknLayoutRect layoutRect;
  1445         TAknLayoutRect layoutRect;
  1431         layoutRect.LayoutRect(
  1446         layoutRect.LayoutRect(
  1432             rect,
  1447             rect,
  1433             AknLayoutScalable_Avkon::title_pane_g2( touchLsc ? 4 : 0 ) );
  1448             AknLayoutScalable_Avkon::title_pane_g2( touchLsc ? 4 : 1 ) );
  1434 
  1449 
  1435         if ( iExtension->iSmallImageAutoscaling &&
  1450         if ( iExtension->iSmallImageAutoscaling &&
  1436              iExtension->iTitleImage->Bitmap() &&
  1451              iExtension->iTitleImage->Bitmap() &&
  1437              iExtension->iTitleImage->Mask() )
  1452              iExtension->iTitleImage->Mask() )
  1438             {
  1453             {
  1459         
  1474         
  1460         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
  1475         if ( iExtension->iTitleImage && iExtension->iSmallImageShown )
  1461             {
  1476             {
  1462             // if image is shown, use shorter version of text
  1477             // if image is shown, use shorter version of text
  1463             oneLineLayout =
  1478             oneLineLayout =
  1464                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 3 ).LayoutLine();
  1479                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 11 : 6 ).LayoutLine();
  1465             }
  1480             }
  1466         else
  1481         else
  1467             {
  1482             {
  1468             // if image is not shown, use longer version of text
  1483             // if image is not shown, use longer version of text
  1469             oneLineLayout =
  1484             oneLineLayout =
  1470                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 2 ).LayoutLine();
  1485                 AknLayoutScalable_Avkon::title_pane_t1( touchLsc ? 10 : 5 ).LayoutLine();
  1471             }
  1486             }
  1472 
  1487 
  1473         TAknLayoutText oneLineLayoutText;
  1488         TAknLayoutText oneLineLayoutText;
  1474         oneLineLayoutText.LayoutText( rect, oneLineLayout );
  1489         oneLineLayoutText.LayoutText( rect, oneLineLayout );
  1475         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );
  1490         TRect oneLineLayoutRect( oneLineLayoutText.TextRect() );