javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swthyperlink.cpp
branchRCL_3
changeset 60 6c158198356e
parent 34 71c436fe3ce0
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
    84     CAknControl::SetDimmed(coeParent.IsDimmed());
    84     CAknControl::SetDimmed(coeParent.IsDimmed());
    85 
    85 
    86     UpdateDefaultFontL();
    86     UpdateDefaultFontL();
    87     iFormattedText.CreateL(KNullDesC);
    87     iFormattedText.CreateL(KNullDesC);
    88     iOriginalText.CreateL(KNullDesC);
    88     iOriginalText.CreateL(KNullDesC);
    89     UpdateSkinColor();
       
    90     SetBackground(this);   // Back will be drawn by ASwtControlBase::Draw
    89     SetBackground(this);   // Back will be drawn by ASwtControlBase::Draw
    91 
    90 
    92 #ifdef RD_TACTILE_FEEDBACK
    91 #ifdef RD_TACTILE_FEEDBACK
    93     iFeedback = MTouchFeedback::Instance();
    92     iFeedback = MTouchFeedback::Instance();
    94 #endif // RD_TACTILE_FEEDBACK
    93 #endif // RD_TACTILE_FEEDBACK
   100 void CSwtHyperLink::SwtHandleResourceChangeL(TInt aType)
    99 void CSwtHyperLink::SwtHandleResourceChangeL(TInt aType)
   101 {
   100 {
   102     if (aType == KEikDynamicLayoutVariantSwitch)
   101     if (aType == KEikDynamicLayoutVariantSwitch)
   103     {
   102     {
   104         UpdateDefaultFontL();
   103         UpdateDefaultFontL();
   105     }
       
   106     else if (aType == KAknsMessageSkinChange)
       
   107     {
       
   108         if (!iCustomTextColor)
       
   109         {
       
   110             UpdateSkinColor();
       
   111         }
       
   112     }
   104     }
   113 }
   105 }
   114 
   106 
   115 
   107 
   116 void CSwtHyperLink::DrawText(CWindowGc& aGc,
   108 void CSwtHyperLink::DrawText(CWindowGc& aGc,
   163     else if (aAlignment == CGraphicsContext::ERight)
   155     else if (aAlignment == CGraphicsContext::ERight)
   164     {
   156     {
   165         textLocation.iX += alignmentSpace;
   157         textLocation.iX += alignmentSpace;
   166     }
   158     }
   167 
   159 
   168     TRgb textColor = iLinkColor;
   160     TRgb textColor = LinkColor();
   169     // Same background highlight as that of Link
   161     // Same background highlight as that of Link
   170     if (iPressed || (iDisplay.UiUtils().NaviKeyInput() && IsFocused()))
   162     if (iPressed || (iDisplay.UiUtils().NaviKeyInput() && IsFocused()))
   171     {
   163     {
   172         textColor = iHighlightedLinkColor;
   164         textColor = PressedLinkColor();
   173         aGc.SetPenStyle(CGraphicsContext::ENullPen);
   165         aGc.SetPenStyle(CGraphicsContext::ENullPen);
   174         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   166         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   175         aGc.SetBrushColor(iHighlightColor);
   167         aGc.SetBrushColor(LinkBgColor());
   176         aGc.DrawRect(TRect(TPoint(textLocation.iX, textLocation.iY - aFont->FontMaxAscent()),
   168         aGc.DrawRect(TRect(TPoint(textLocation.iX, textLocation.iY - aFont->FontMaxAscent()),
   177                            TSize(textWidth, aFont->FontLineGap())));
   169                            TSize(textWidth, aFont->FontLineGap())));
   178     }
   170     }
   179 
   171 
   180     aGc.UseFont(aFont);
   172     aGc.UseFont(aFont);
   186     aGc.DrawText(textToDraw, textLocation);
   178     aGc.DrawText(textToDraw, textLocation);
   187     convertedText.Close();
   179     convertedText.Close();
   188 }
   180 }
   189 
   181 
   190 
   182 
   191 void CSwtHyperLink::UpdateSkinColor()
       
   192 {
       
   193     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   194                               iLinkColor,
       
   195                               KAknsIIDQsnHighlightColors,
       
   196                               EAknsCIQsnHighlightColorsCG3);
       
   197     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   198                               iHighlightColor,
       
   199                               KAknsIIDQsnHighlightColors,
       
   200                               EAknsCIQsnHighlightColorsCG2);
       
   201     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   202                               iHighlightedLinkColor,
       
   203                               KAknsIIDQsnTextColors,
       
   204                               EAknsCIQsnTextColorsCG24);
       
   205 }
       
   206 
       
   207 
       
   208 void CSwtHyperLink::UpdateDefaultFontL()
   183 void CSwtHyperLink::UpdateDefaultFontL()
   209 {
   184 {
   210     if (iDefaultFont)
   185     if (iDefaultFont)
   211     {
   186     {
   212         iDefaultFont->RemoveRef();
   187         iDefaultFont->RemoveRef();
   270         break;
   245         break;
   271     }
   246     }
   272     return scheme;
   247     return scheme;
   273 }
   248 }
   274 
   249 
       
   250 TRgb CSwtHyperLink::LinkColor() const
       
   251 {
       
   252     TBool highlighted = HasHighlight();
       
   253     if (!highlighted && iCustomFg)
       
   254     {
       
   255         return iCustomFg->RgbValue();
       
   256     }
       
   257     else
       
   258     {
       
   259         TRgb res(0);
       
   260         AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   261                                   res,
       
   262                                   KAknsIIDQsnHighlightColors,
       
   263                                   EAknsCIQsnHighlightColorsCG3);
       
   264         return res;
       
   265     }
       
   266 }
       
   267 
       
   268 TRgb CSwtHyperLink::PressedLinkColor() const
       
   269 {
       
   270     TRgb res(0);
       
   271     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   272                               res,
       
   273                               KAknsIIDQsnTextColors,
       
   274                               EAknsCIQsnTextColorsCG24);
       
   275     return res;
       
   276 }
       
   277 
       
   278 TRgb CSwtHyperLink::LinkBgColor() const
       
   279 {
       
   280     TRgb res(0);
       
   281     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   282                               res,
       
   283                               KAknsIIDQsnHighlightColors,
       
   284                               EAknsCIQsnHighlightColorsCG2);
       
   285     return res;
       
   286 }
   275 
   287 
   276 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   277 // From class CCoeControl.
   289 // From class CCoeControl.
   278 // ---------------------------------------------------------------------------
   290 // ---------------------------------------------------------------------------
   279 //
   291 //
   444 #else
   456 #else
   445             iFeedback->InstantFeedback(ETouchFeedbackBasic);
   457             iFeedback->InstantFeedback(ETouchFeedbackBasic);
   446 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
   458 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
   447         }
   459         }
   448 #endif //RD_TACTILE_FEEDBACK
   460 #endif //RD_TACTILE_FEEDBACK
   449         Redraw();
   461         GetShell().UpdateHighlight(ETrue); // draw now
   450         break;
   462         break;
   451     }
   463     }
   452 
   464 
   453     case TPointerEvent::EDrag:
   465     case TPointerEvent::EDrag:
   454     {
   466     {
   461         {
   473         {
   462             iPressed = EFalse;
   474             iPressed = EFalse;
   463         }
   475         }
   464         if (pressed != iPressed)
   476         if (pressed != iPressed)
   465         {
   477         {
   466             Redraw();
   478             GetShell().UpdateHighlight(ETrue); // draw now
   467         }
   479         }
   468         break;
   480         break;
   469     }
   481     }
   470 
   482 
   471     case TPointerEvent::EButton1Up:
   483     case TPointerEvent::EButton1Up:
   476         {
   488         {
   477             LaunchHandler();
   489             LaunchHandler();
   478         }
   490         }
   479         if (pressed != iPressed)
   491         if (pressed != iPressed)
   480         {
   492         {
   481             Redraw();
   493             GetShell().UpdateHighlight(ETrue); // draw now
   482         }
   494         }
   483         break;
   495         break;
   484     }
   496     }
   485 
   497 
   486     default:
   498     default:
   495 // ---------------------------------------------------------------------------
   507 // ---------------------------------------------------------------------------
   496 //
   508 //
   497 void CSwtHyperLink::SetForegroundL(const MSwtColor* aColor)
   509 void CSwtHyperLink::SetForegroundL(const MSwtColor* aColor)
   498 {
   510 {
   499     ASwtControlBase::DoSetForegroundL(aColor);
   511     ASwtControlBase::DoSetForegroundL(aColor);
   500     aColor ? iCustomTextColor = ETrue : iCustomTextColor = EFalse;
   512     iCustomFg = aColor;
   501     if (iCustomTextColor)
       
   502     {
       
   503         TRgb rgb;
       
   504         TBool overrideColorSet(GetColor(EColorControlText, rgb));
       
   505         ASSERT(overrideColorSet);
       
   506         iLinkColor = rgb;
       
   507     }
       
   508     else
       
   509     {
       
   510         UpdateSkinColor();
       
   511     }
       
   512     Redraw();
   513     Redraw();
   513 }
   514 }
   514 
   515 
   515 
   516 
   516 // ---------------------------------------------------------------------------
   517 // ---------------------------------------------------------------------------
   540     }
   541     }
   541 
   542 
   542     return res;
   543     return res;
   543 }
   544 }
   544 
   545 
       
   546 // ---------------------------------------------------------------------------
       
   547 // CSwtHyperLink::PressBackgroundPolicy
       
   548 // From MSwtControl
       
   549 // ---------------------------------------------------------------------------
       
   550 //
       
   551 TInt CSwtHyperLink::PressBackgroundPolicy() const
       
   552 {
       
   553     return EEmbeddedPressBackground;
       
   554 }
   545 
   555 
   546 // ---------------------------------------------------------------------------
   556 // ---------------------------------------------------------------------------
   547 // From class ASwtControlBase.
   557 // From class ASwtControlBase.
   548 // ---------------------------------------------------------------------------
   558 // ---------------------------------------------------------------------------
   549 //
   559 //