javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtlink.cpp
branchRCL_3
changeset 24 6c158198356e
parent 19 71c436fe3ce0
--- a/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtlink.cpp	Thu Jul 15 18:31:06 2010 +0300
+++ b/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtlink.cpp	Thu Aug 19 09:48:13 2010 +0300
@@ -193,7 +193,6 @@
     UpdateDefaultFontL();
     DoSetFont(&iDefaultFont->Font());
     UpdateMarginValues();
-    UpdateSkinColor();
     SetBackground(this);   // Back will be drawn by ASwtControlBase::Draw
 
 #ifdef RD_TACTILE_FEEDBACK
@@ -216,40 +215,9 @@
         UpdateMarginValues();
         BuildDrawableFragmentsListL(TextRect());
     }
-    else if (aType == KAknsMessageSkinChange)
-    {
-        if (!iCustomTextColor)
-        {
-            UpdateSkinColor();
-        }
-    }
 }
 
 /**
- * Updates skin colors
- */
-void CSwtLink::UpdateSkinColor()
-{
-    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
-                              iTextColor,
-                              KAknsIIDQsnTextColors,
-                              EAknsCIQsnTextColorsCG6);
-    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
-                              iLinkColor,
-                              KAknsIIDQsnHighlightColors,
-                              EAknsCIQsnHighlightColorsCG3);
-    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
-                              iHighlightColor,
-                              KAknsIIDQsnHighlightColors,
-                              EAknsCIQsnHighlightColorsCG2);
-    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
-                              iHighlightedLinkColor,
-                              KAknsIIDQsnTextColors,
-                              EAknsCIQsnTextColorsCG24);
-}
-
-
-/**
  * Updates default font
  */
 void CSwtLink::UpdateDefaultFontL()
@@ -1006,20 +974,20 @@
         TRect rect = fragment->Rect();
         rect.Move(textRect.iTl);
 
-        TRgb textColor = iTextColor;
+        TRgb textColor = TextColor();
         if (fragment->FragmentDescriptor()->Target())
         {
-            textColor = iLinkColor;
+            textColor = LinkColor();
         }
 
         // Same background highlight as that of HyperLink
         if (fragment->FragmentDescriptor() == iFocusedFragment
                 && (iPressed || iDisplay.UiUtils().NaviKeyInput()))
         {
-            textColor = iHighlightedLinkColor;
+            textColor = PressedLinkColor();
             gc.SetPenStyle(CGraphicsContext::ENullPen);
             gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
-            gc.SetBrushColor(iHighlightColor);
+            gc.SetBrushColor(LinkBgColor());
             gc.DrawRect(rect);
         }
 
@@ -1128,7 +1096,7 @@
 
         if (iPressed)
         {
-            Redraw();
+            GetShell().UpdateHighlight(ETrue); // draw now
         }
         break;
     }
@@ -1162,7 +1130,7 @@
 
         if (pressed != iPressed)
         {
-            Redraw();
+            GetShell().UpdateHighlight(ETrue); // draw now
         }
         break;
     }
@@ -1193,7 +1161,7 @@
 
         if (pressed != iPressed)
         {
-            Redraw();
+            GetShell().UpdateHighlight(ETrue); // draw now
         }
         break;
     }
@@ -1209,23 +1177,10 @@
 void CSwtLink::SetForegroundL(const MSwtColor* aColor)
 {
     ASwtControlBase::DoSetForegroundL(aColor);
-    aColor ? iCustomTextColor = ETrue : iCustomTextColor = EFalse;
-    if (iCustomTextColor)
-    {
-        TRgb rgb;
-        TBool overrideColorSet(GetColor(EColorControlText, rgb));
-        ASSERT(overrideColorSet);
-        iTextColor = rgb;
-        iLinkColor = rgb;
-    }
-    else
-    {
-        UpdateSkinColor();
-    }
+    iCustomFg = aColor;
     Redraw();
 }
 
-
 // ---------------------------------------------------------------------------
 // From class MSwtControl.
 // ---------------------------------------------------------------------------
@@ -1240,6 +1195,36 @@
     return ComputeTextSizeL(aWHint, aHHint);
 }
 
+// ---------------------------------------------------------------------------
+// CSwtLink::DefaultFont
+// From MSwtControl
+// ---------------------------------------------------------------------------
+//
+void CSwtLink::SetFontL(const MSwtFont* aFont)
+{
+    ASwtControlBase::DoSetFontL(aFont);
+    DoSetFont(&GetFont()->Font());
+    Redraw();
+}
+
+TBool CSwtLink::SetSwtFocus(TInt aReason /*= KSwtFocusByApi*/)
+{
+    TBool prevFocused = IsFocusControl();
+    TBool res = ASwtControlBase::SetSwtFocus(aReason);
+
+    // Gaines focus by pointer
+    if (IsFocusControl() && !prevFocused)
+    {
+        iFocusChanged = ETrue;
+    }
+
+    return res;
+}
+
+TInt CSwtLink::PressBackgroundPolicy() const
+{
+    return EEmbeddedPressBackground;
+}
 
 // ---------------------------------------------------------------------------
 // CSwtLink::ComputeTextSizeL
@@ -1450,18 +1435,61 @@
     return result;
 }
 
-// ---------------------------------------------------------------------------
-// CSwtLink::DefaultFont
-// From MSwtControl
-// ---------------------------------------------------------------------------
-//
-void CSwtLink::SetFontL(const MSwtFont* aFont)
+TRgb CSwtLink::TextColor() const
 {
-    ASwtControlBase::DoSetFontL(aFont);
-    DoSetFont(&GetFont()->Font());
-    Redraw();
+    TBool highlighted = HasHighlight();
+    if (!highlighted && iCustomFg)
+    {
+        return iCustomFg->RgbValue();
+    }
+    else
+    {
+        TRgb res(0);
+        AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
+                                  res,
+                                  KAknsIIDQsnTextColors,
+                                  highlighted ? KHighlightedTextColor : KNonHighlightedTextColor);
+        return res;
+    }
 }
 
+TRgb CSwtLink::LinkColor() const
+{
+    TBool highlighted = HasHighlight();
+    if (!highlighted && iCustomFg)
+    {
+        return iCustomFg->RgbValue();
+    }
+    else
+    {
+        TRgb res(0);
+        AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
+                                  res,
+                                  KAknsIIDQsnHighlightColors,
+                                  EAknsCIQsnHighlightColorsCG3);
+        return res;
+    }
+}
+
+TRgb CSwtLink::PressedLinkColor() const
+{
+    TRgb res(0);
+    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
+                              res,
+                              KAknsIIDQsnTextColors,
+                              EAknsCIQsnTextColorsCG24);
+    return res;
+}
+
+TRgb CSwtLink::LinkBgColor() const
+{
+    TRgb res(0);
+    AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
+                              res,
+                              KAknsIIDQsnHighlightColors,
+                              EAknsCIQsnHighlightColorsCG2);
+    return res;
+}
 
 void CSwtLink::DoSetFont(const CFont* aFont)
 {
@@ -1564,20 +1592,6 @@
     }
 }
 
-TBool CSwtLink::SetSwtFocus(TInt aReason /*= KSwtFocusByApi*/)
-{
-    TBool prevFocused = IsFocusControl();
-    TBool res = ASwtControlBase::SetSwtFocus(aReason);
-
-    // Gaines focus by pointer
-    if (IsFocusControl() && !prevFocused)
-    {
-        iFocusChanged = ETrue;
-    }
-
-    return res;
-}
-
 // ---------------------------------------------------------------------------
 // CSwtLinkFragmentDescriptor
 // ---------------------------------------------------------------------------