uifw/EikStd/coctlsrc/aknedwincustomdrawbase.cpp
branchRCL_3
changeset 15 08e69e956a8c
parent 10 9f56a4e1b8ab
child 55 aecbbf00d063
equal deleted inserted replaced
10:9f56a4e1b8ab 15:08e69e956a8c
    35 
    35 
    36 
    36 
    37 // CONSTANTS
    37 // CONSTANTS
    38 
    38 
    39 // This is the last character that will be treated as requiring higher underline
    39 // This is the last character that will be treated as requiring higher underline
    40 // const TText KMaxSpecialUnderliningChar = 0x0E5B;
    40 
    41 const TInt KWsBufferSize = 16000;
    41 const TInt KWsBufferSize = 16000;
       
    42 const TInt KOneHundred = 100;
    42 
    43 
    43 // MEMBER FUNCTIONS
    44 // MEMBER FUNCTIONS
    44 
    45 
    45 CAknEdwinCustomDrawBase::CAknEdwinCustomDrawBase(
    46 CAknEdwinCustomDrawBase::CAknEdwinCustomDrawBase(
    46     const MLafEnv& aEnv, const CEikEdwin& aEdwin ) :
    47     const MLafEnv& aEnv, const CEikEdwin& aEdwin ) :
    76     iWsBufferRequestId = CAknEnv::Static()->RequestWsBuffer( KWsBufferSize );
    77     iWsBufferRequestId = CAknEnv::Static()->RequestWsBuffer( KWsBufferSize );
    77     // Returns NULL if feature not supported.
    78     // Returns NULL if feature not supported.
    78     iPictographDrawer = CAknPictographInterface::NewL(
    79     iPictographDrawer = CAknPictographInterface::NewL(
    79         static_cast<CCoeControl&>( const_cast<CEikEdwin&>( iEdwin ) ),
    80         static_cast<CCoeControl&>( const_cast<CEikEdwin&>( iEdwin ) ),
    80         *static_cast<MAknPictographAnimatorCallBack*>( this ) );
    81         *static_cast<MAknPictographAnimatorCallBack*>( this ) );
    81     
       
    82     iSkinInstance = AknsUtils::SkinInstance();
       
    83     }
    82     }
    84 
    83 
    85 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    86 // CAknEdwinCustomDraw::NewL
    85 // CAknEdwinCustomDraw::NewL
    87 // Two-phased constructor.
    86 // Two-phased constructor.
    92     { // static
    91     { // static
    93     CAknEdwinCustomDrawBase* self =
    92     CAknEdwinCustomDrawBase* self =
    94         new( ELeave ) CAknEdwinCustomDrawBase( aEnv, aControl );
    93         new( ELeave ) CAknEdwinCustomDrawBase( aEnv, aControl );
    95     CleanupStack::PushL( self );
    94     CleanupStack::PushL( self );
    96     self->ConstructL();
    95     self->ConstructL();
    97     CleanupStack::Pop();
    96     CleanupStack::Pop( self );
    98     return self;
    97     return self;
    99     }
    98     }
   100 
    99 
   101 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
   102 // CAknEdwinCustomDraw::NewL
   101 // CAknEdwinCustomDraw::NewL
   111     { // static
   110     { // static
   112     CAknEdwinCustomDrawBase* self = new( ELeave ) CAknEdwinCustomDrawBase(
   111     CAknEdwinCustomDrawBase* self = new( ELeave ) CAknEdwinCustomDrawBase(
   113         aEnv, aControl, aTextView, aSystemGc );
   112         aEnv, aControl, aTextView, aSystemGc );
   114     CleanupStack::PushL( self );
   113     CleanupStack::PushL( self );
   115     self->ConstructL();
   114     self->ConstructL();
   116     CleanupStack::Pop();
   115     CleanupStack::Pop( self );
   117     return self;
   116     return self;
   118     }
   117     }
   119 
   118 
   120 // Destructor
   119 // Destructor
   121 CAknEdwinCustomDrawBase::~CAknEdwinCustomDrawBase()
   120 CAknEdwinCustomDrawBase::~CAknEdwinCustomDrawBase()
   165         {
   164         {
   166         // Inhibit all excess pixels
   165         // Inhibit all excess pixels
   167         aExtraPixels = 0;
   166         aExtraPixels = 0;
   168 
   167 
   169         TInt underlinePos(0);
   168         TInt underlinePos(0);
   170         (void)TextNeedsCustomUnderline( aText, aParam, aFormat, underlinePos ) ;
   169         TextNeedsCustomUnderline( aText, aParam, aFormat, underlinePos ) ;
   171         // always perform custom underlining
   170         // always perform custom underlining
   172 
   171 
   173         TRect underlineRect(aParam.iDrawRect);
   172         TRect underlineRect(aParam.iDrawRect);
   174         TAknTextDecorationMetrics decoration( 0 ); // Give dummy font id for default decoration
   173         TAknTextDecorationMetrics decoration( 0 ); // Give dummy font id for default decoration
   175         // Note that underlinePos in scalable is a delta relative to normal baseline
   174         // Note that underlinePos in scalable is a delta relative to normal baseline
   316     {
   315     {
   317     CLafEdwinCustomDrawBase::DrawLineGraphics( aParam, aLineInfo ); // Base Call
   316     CLafEdwinCustomDrawBase::DrawLineGraphics( aParam, aLineInfo ); // Base Call
   318     }
   317     }
   319 
   318 
   320 
   319 
   321 TRgb CAknEdwinCustomDrawBase::SystemColor(TUint aColorIndex,TRgb aDefaultColor) const
   320 TRgb CAknEdwinCustomDrawBase::SystemColor( TUint aColorIndex, TRgb aDefaultColor ) const
   322     {
   321     {
   323     TRgb ret = aDefaultColor;
   322     TRgb ret = aDefaultColor;
       
   323     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   324     if (aColorIndex==TLogicalRgb::ESystemForegroundIndex)
   324     if (aColorIndex==TLogicalRgb::ESystemForegroundIndex)
   325         {
   325         {
   326         if (iSkinInstance && iEdwin.SkinColorId() != KErrNotFound)
   326         if ( skin && iEdwin.SkinColorId() != KErrNotFound )
   327             {
   327             {
   328             AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnTextColors, iEdwin.SkinColorId());
   328             AknsUtils::GetCachedColor( skin, ret, KAknsIIDQsnTextColors, 
   329             }
   329                     iEdwin.SkinColorId() );
   330         }
   330             }
   331     else if (aColorIndex==TLogicalRgb::ESystemBackgroundIndex)
   331         }
       
   332     else if ( aColorIndex==TLogicalRgb::ESystemBackgroundIndex )
   332         {
   333         {
   333         // Only override aDefaultColor if SetBackgroundColorL was called:
   334         // Only override aDefaultColor if SetBackgroundColorL was called:
   334         (void)iEdwin.EditorBackgroundColor(ret);
   335         iEdwin.EditorBackgroundColor( ret );
   335         // Insist on opaque background
   336         // Insist on opaque background
   336         ret.SetAlpha(0xFF);
   337         ret.SetAlpha( 0xFF );
   337         }
   338         }
   338 
       
   339     else if (aColorIndex==TLogicalRgb::ESystemSelectionForegroundIndex)
   339     else if (aColorIndex==TLogicalRgb::ESystemSelectionForegroundIndex)
   340         {
   340         {
   341         ret = KRgbWhite;
   341         ret = KRgbWhite;
   342 
   342         if ( skin )
   343         if (iSkinInstance)
       
   344             {
   343             {
   345             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   344             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   346                 {
   345                 {
   347                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG3);
   346                 AknsUtils::GetCachedColor( skin, ret, KAknsIIDQsnHighlightColors,
       
   347                         EAknsCIQsnTextColorsCG3 );
   348                 }
   348                 }
   349             else // default
   349             else // default
   350                 {
   350                 {
   351                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG24);
   351                 AknsUtils::GetCachedColor( skin, ret, KAknsIIDQsnTextColors, 
   352                 }
   352                         EAknsCIQsnTextColorsCG24 );
   353             }
   353                 }
   354         }
   354             }
   355     else if (aColorIndex==TLogicalRgb::ESystemSelectionBackgroundIndex)
   355         }
       
   356     else if ( aColorIndex==TLogicalRgb::ESystemSelectionBackgroundIndex )
   356         {
   357         {
   357         ret = KRgbBlue;
   358         ret = KRgbBlue;
   358 
   359         if ( skin )
   359         if (iSkinInstance)
       
   360             {
   360             {
   361             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   361             if ( iEdwin.HighlightStyle() == EEikEdwinHighlightLink )
   362                 {
   362                 {
   363                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnTextColorsCG1);
   363                 AknsUtils::GetCachedColor( skin, ret, KAknsIIDQsnHighlightColors, 
       
   364                         EAknsCIQsnTextColorsCG1 );
   364                 }
   365                 }
   365             else // default
   366             else // default
   366                 {
   367                 {
   367                 AknsUtils::GetCachedColor(iSkinInstance, ret, KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG2);
   368                 AknsUtils::GetCachedColor( skin, ret, KAknsIIDQsnHighlightColors, 
       
   369                         EAknsCIQsnHighlightColorsCG2 );
   368                 }
   370                 }
   369             }
   371             }
   370         }
   372         }
   371 
   373 
   372     return ret;
   374     return ret;
   399         else if( &aGc == static_cast<CGraphicsContext*>( &(iControl.SystemGc()) ) )
   401         else if( &aGc == static_cast<CGraphicsContext*>( &(iControl.SystemGc()) ) )
   400             bitmapGc = &(iControl.SystemGc());
   402             bitmapGc = &(iControl.SystemGc());
   401 #endif //RD_UI_TRANSITION_EFFECTS_POPUPS
   403 #endif //RD_UI_TRANSITION_EFFECTS_POPUPS
   402         if ( bitmapGc && iEdwin.SkinEnabled() )
   404         if ( bitmapGc && iEdwin.SkinEnabled() )
   403             {
   405             {
   404             if ( AknsDrawUtils::DrawBackground( 
   406             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   405                 iSkinInstance, 
   407             if ( skin )
   406                 iEdwin.SkinBackgroundControlContext(),
   408                 {
   407                 &iControl,
   409                 if ( AknsDrawUtils::DrawBackground( 
   408                 *bitmapGc,
   410                         skin, 
   409                 aRect.iTl,
   411                         iEdwin.SkinBackgroundControlContext(),
   410                 aRect,
   412                         &iControl,
   411                 KAknsDrawParamNoClearUnderImage ) )
   413                         *bitmapGc,
   412                 {
   414                         aRect.iTl,
   413                 aDrawnRect = aRect;
   415                         aRect,
   414                 drawn = ETrue;
   416                         KAknsDrawParamNoClearUnderImage ) )
       
   417                     {
       
   418                     aDrawnRect = aRect;
       
   419                     drawn = ETrue;
       
   420                     }
   415                 }
   421                 }
   416             }
   422             }
   417         else
   423         else
   418             {
   424             {
   419             // perform unoptimized draw of skin using bitmap brushstyle?
   425             // perform unoptimized draw of skin using bitmap brushstyle?
   713                     DrawLineAndRecord( aParam.iGc, aUnderlineRect, startPoint, lastPos+1, row, lengthDrawnOnThisLine, numberSegmentsDrawn);
   719                     DrawLineAndRecord( aParam.iGc, aUnderlineRect, startPoint, lastPos+1, row, lengthDrawnOnThisLine, numberSegmentsDrawn);
   714                     }
   720                     }
   715                 }
   721                 }
   716             }
   722             }
   717 
   723 
   718         maxPercentOfALineDrawn = Max( maxPercentOfALineDrawn, (lengthDrawnOnThisLine * 100 )/aUnderlineRect.Width()  );
   724         maxPercentOfALineDrawn = Max( maxPercentOfALineDrawn, 
       
   725                 ( lengthDrawnOnThisLine * KOneHundred )/aUnderlineRect.Width() );
   719         } // end of for loop over rows
   726         } // end of for loop over rows
   720 
   727 
   721     util.End();
   728     util.End();
   722 
   729 
   723     // Check criteria for whether to say this was successful or not.
   730     // Check criteria for whether to say this was successful or not.