uifw/EikStd/coctlsrc/aknedwincustomdrawbase.cpp
branchRCL_3
changeset 10 9f56a4e1b8ab
parent 0 2f259fa3e83a
child 15 08e69e956a8c
equal deleted inserted replaced
9:aabf2c525e0f 10:9f56a4e1b8ab
    76     iWsBufferRequestId = CAknEnv::Static()->RequestWsBuffer( KWsBufferSize );
    76     iWsBufferRequestId = CAknEnv::Static()->RequestWsBuffer( KWsBufferSize );
    77     // Returns NULL if feature not supported.
    77     // Returns NULL if feature not supported.
    78     iPictographDrawer = CAknPictographInterface::NewL(
    78     iPictographDrawer = CAknPictographInterface::NewL(
    79         static_cast<CCoeControl&>( const_cast<CEikEdwin&>( iEdwin ) ),
    79         static_cast<CCoeControl&>( const_cast<CEikEdwin&>( iEdwin ) ),
    80         *static_cast<MAknPictographAnimatorCallBack*>( this ) );
    80         *static_cast<MAknPictographAnimatorCallBack*>( this ) );
       
    81     
       
    82     iSkinInstance = AknsUtils::SkinInstance();
    81     }
    83     }
    82 
    84 
    83 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    84 // CAknEdwinCustomDraw::NewL
    86 // CAknEdwinCustomDraw::NewL
    85 // Two-phased constructor.
    87 // Two-phased constructor.
   189         aParam.iGc.SetUnderlineStyle( EUnderlineOff);  // and force it off in the GC
   191         aParam.iGc.SetUnderlineStyle( EUnderlineOff);  // and force it off in the GC
   190         }
   192         }
   191     CFont* font = NULL;
   193     CFont* font = NULL;
   192     aParam.iMap.GetNearestFontInTwips( font, aFormat.iFontSpec );
   194     aParam.iMap.GetNearestFontInTwips( font, aFormat.iFontSpec );
   193     RRegion rgn;
   195     RRegion rgn;
   194     if ( iEdwin.IsSmileyEnabled() && font )
   196     TBool drawSmiley( iEdwin.IsSmileyEnabled() && font && ( &aParam.iGc ==
   195         {
   197         static_cast<CGraphicsContext*>( iTextView->BitmapContext() ) ) );
       
   198     if ( drawSmiley )
       
   199         {
       
   200         TPoint startPt( aParam.iDrawRect.iTl );
       
   201         startPt.iY = aLineInfo.iBaseline;
       
   202         CBitmapContext* bitmapGc( iTextView->BitmapContext() );
       
   203         CEikEdwin& edwin = const_cast<CEikEdwin&>( iEdwin );
   196         rgn.AddRect( iEdwin.AdjustDrawRectForSmiley( aParam.iDrawRect ) );
   204         rgn.AddRect( iEdwin.AdjustDrawRectForSmiley( aParam.iDrawRect ) );
   197         iEdwin.GetClipRegionForSmiley( rgn, *font, aText, aTextOrigin, 
   205         TRAP_IGNORE( edwin.DrawSmileyInTextL( rgn, aParam.iDrawRect, *bitmapGc, 
   198             aParam.iDrawRect );
   206             *font, aText, startPt ) );
   199         aParam.iGc.SetClippingRegion( rgn );
   207         aParam.iGc.SetClippingRegion( rgn );
   200         }
   208         }
   201     CLafEdwinCustomDrawBase::DrawText( aParam, aLineInfo, alteredFormat, 
   209     CLafEdwinCustomDrawBase::DrawText( aParam, aLineInfo, alteredFormat, 
   202         aText, aTextOrigin, aExtraPixels );
   210         aText, aTextOrigin, aExtraPixels );
   203     if ( iEdwin.IsSmileyEnabled() )
   211     if ( drawSmiley )
   204         {
   212         {
   205         aParam.iGc.CancelClippingRegion();
   213         aParam.iGc.CancelClippingRegion();
   206         }
   214         }
   207     rgn.Close();
   215     rgn.Close();
   208     
       
   209     if ( iEdwin.IsSmileyEnabled() && font && ( &aParam.iGc ==
       
   210         static_cast<CGraphicsContext*>( iTextView->BitmapContext() ) ) )
       
   211         {
       
   212         CBitmapContext* bitmapGc( iTextView->BitmapContext() );
       
   213         CEikEdwin& edwin = const_cast<CEikEdwin&>( iEdwin );
       
   214         TPoint startPt( aParam.iDrawRect.iTl );
       
   215         startPt.iY = aLineInfo.iBaseline;
       
   216         TRAP_IGNORE( {
       
   217             edwin.HandleScrollForSmileyL();
       
   218             edwin.DrawSmileyInTextL( *bitmapGc, *font, aText, startPt );
       
   219             } );
       
   220         }
       
   221 
   216 
   222     // Draw pictographs if the feature is supported.
   217     // Draw pictographs if the feature is supported.
   223     // Character justification is not supported.
   218     // Character justification is not supported.
   224     if ( ( iPictographDrawer && !aExtraPixels ) )
   219     if ( ( iPictographDrawer && !aExtraPixels ) )
   225         {
   220         {
   326 TRgb CAknEdwinCustomDrawBase::SystemColor(TUint aColorIndex,TRgb aDefaultColor) const
   321 TRgb CAknEdwinCustomDrawBase::SystemColor(TUint aColorIndex,TRgb aDefaultColor) const
   327     {
   322     {
   328     TRgb ret = aDefaultColor;
   323     TRgb ret = aDefaultColor;
   329     if (aColorIndex==TLogicalRgb::ESystemForegroundIndex)
   324     if (aColorIndex==TLogicalRgb::ESystemForegroundIndex)
   330         {
   325         {
   331         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   326         if (iSkinInstance && iEdwin.SkinColorId() != KErrNotFound)
   332         if (skin && iEdwin.SkinColorId() != KErrNotFound)
   327             {
   333             {
   328             AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnTextColors, iEdwin.SkinColorId());
   334             AknsUtils::GetCachedColor(skin, ret, KAknsIIDQsnTextColors, iEdwin.SkinColorId());
       
   335             }
   329             }
   336         }
   330         }
   337     else if (aColorIndex==TLogicalRgb::ESystemBackgroundIndex)
   331     else if (aColorIndex==TLogicalRgb::ESystemBackgroundIndex)
   338         {
   332         {
   339         // Only override aDefaultColor if SetBackgroundColorL was called:
   333         // Only override aDefaultColor if SetBackgroundColorL was called:
   343         }
   337         }
   344 
   338 
   345     else if (aColorIndex==TLogicalRgb::ESystemSelectionForegroundIndex)
   339     else if (aColorIndex==TLogicalRgb::ESystemSelectionForegroundIndex)
   346         {
   340         {
   347         ret = KRgbWhite;
   341         ret = KRgbWhite;
   348         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   342 
   349         if (skin)
   343         if (iSkinInstance)
   350             {
   344             {
   351             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   345             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   352                 {
   346                 {
   353                 AknsUtils::GetCachedColor(skin, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG3);
   347                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG3);
   354                 }
   348                 }
   355             else // default
   349             else // default
   356                 {
   350                 {
   357                 AknsUtils::GetCachedColor(skin, ret, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG24);
   351                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG24);
   358                 }
   352                 }
   359             }
   353             }
   360         }
   354         }
   361     else if (aColorIndex==TLogicalRgb::ESystemSelectionBackgroundIndex)
   355     else if (aColorIndex==TLogicalRgb::ESystemSelectionBackgroundIndex)
   362         {
   356         {
   363         ret = KRgbBlue;
   357         ret = KRgbBlue;
   364         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   358 
   365         if (skin)
   359         if (iSkinInstance)
   366             {
   360             {
   367             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   361             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   368                 {
   362                 {
   369                 AknsUtils::GetCachedColor(skin, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG1);
   363                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG1);
   370                 }
   364                 }
   371             else // default
   365             else // default
   372                 {
   366                 {
   373                 AknsUtils::GetCachedColor(skin, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2);
   367                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2);
   374                 }
   368                 }
   375             }
   369             }
   376         }
   370         }
   377 
   371 
   378     return ret;
   372     return ret;
   405         else if( &aGc == static_cast<CGraphicsContext*>( &(iControl.SystemGc()) ) )
   399         else if( &aGc == static_cast<CGraphicsContext*>( &(iControl.SystemGc()) ) )
   406             bitmapGc = &(iControl.SystemGc());
   400             bitmapGc = &(iControl.SystemGc());
   407 #endif //RD_UI_TRANSITION_EFFECTS_POPUPS
   401 #endif //RD_UI_TRANSITION_EFFECTS_POPUPS
   408         if ( bitmapGc && iEdwin.SkinEnabled() )
   402         if ( bitmapGc && iEdwin.SkinEnabled() )
   409             {
   403             {
   410             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   404             if ( AknsDrawUtils::DrawBackground( 
   411             // Edwin manages the skin background
   405                 iSkinInstance, 
   412             MAknsControlContext* edCc = iEdwin.SkinBackgroundControlContext();
   406                 iEdwin.SkinBackgroundControlContext(),
   413 
   407                 &iControl,
   414             TInt drawFlags = KAknsDrawParamDefault;
   408                 *bitmapGc,
   415             if( CAknEnv::Static()->TransparencyEnabled() )
   409                 aRect.iTl,
   416             {
   410                 aRect,
   417                 drawFlags |= KAknsDrawParamNoClearUnderImage;
   411                 KAknsDrawParamNoClearUnderImage ) )
   418             }
       
   419 
       
   420             if( AknsDrawUtils::DrawBackground( skin, edCc,
       
   421                     &iControl, *bitmapGc, aRect.iTl, aRect,
       
   422                     drawFlags ))
       
   423                 {
   412                 {
   424                 aDrawnRect = aRect;
   413                 aDrawnRect = aRect;
   425                 drawn = ETrue;
   414                 drawn = ETrue;
   426                 }
   415                 }
   427             }
   416             }