diff -r e5618cc85d74 -r 6c158198356e javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swttextbase.cpp --- a/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swttextbase.cpp Thu Jul 15 18:31:06 2010 +0300 +++ b/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swttextbase.cpp Thu Aug 19 09:48:13 2010 +0300 @@ -216,19 +216,37 @@ charMask.SetAttrib(EAttFontPosture); } - // when we set the new font color also changes. So we have to set the color again. - if (!iTextColor) + TRgb color(0); + TInt err(KErrNone); + + if (HasHighlight()) { - TRgb color; - AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), color, - KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); - charFormat.iFontPresentation.iTextColor = color; + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KHighlightedTextColor); + if (err == KErrNone) + { + charFormat.iFontPresentation.iTextColor = color; + charMask.SetAttrib(EAttColor); + } + } + else if (iTextColor) + { + charFormat.iFontPresentation.iTextColor = GetForeground(); charMask.SetAttrib(EAttColor); } else { - charFormat.iFontPresentation.iTextColor = GetForeground(); - charMask.SetAttrib(EAttColor); + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KNonHighlightedTextColor); + if (err == KErrNone) + { + charFormat.iFontPresentation.iTextColor = color; + charMask.SetAttrib(EAttColor); + } } if (iStyle & KSwtStyleSingle) @@ -287,18 +305,23 @@ void CSwtTextBase::SetForegroundL(const MSwtColor* aColor) { ASwtControlBase::DoSetForegroundL(aColor); - TRgb color(aColor ? aColor->RgbValue() : - iDisplay.CoeEnv()->Color(EColorControlText)); - if (iEditor) + + iTextColor = ETrue; + if (!aColor) + { + iTextColor = EFalse; + } + else if (iEditor) { TCharFormat charFormat; TCharFormatMask charMask; - charFormat.iFontPresentation.iTextColor=color; + charFormat.iFontPresentation.iTextColor = aColor->RgbValue(); charMask.SetAttrib(EAttColor); static_cast(iEditor->Text())-> ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength()); - iTextColor = ETrue; } + + UpdateTextColor(); Redraw(); } @@ -345,6 +368,61 @@ return ASwtScrollableBase::Dispose(); } +TInt CSwtTextBase::PressBackgroundPolicy() const +{ + return EPressBackground; +} + +void CSwtTextBase::UpdateTextColor() +{ + if (iEditor) + { + TCharFormat charFormat; + TCharFormatMask charMask; + TRgb color(0); + TInt err(KErrNone); + + if (HasHighlight()) + { + // Highlighted foreground color, overrides all others. + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KHighlightedTextColor); + if (err == KErrNone) + { + charFormat.iFontPresentation.iTextColor = color; + } + } + else if (iTextColor) + { + // Custom foreground color, overrides the default. + charFormat.iFontPresentation.iTextColor = GetForeground(); + } + else + { + // Default foreground color. + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KNonHighlightedTextColor); + if (err == KErrNone) + { + charFormat.iFontPresentation.iTextColor = color; + } + } + + charMask.SetAttrib(EAttColor); + TRAP_IGNORE(static_cast(iEditor->Text())-> + ApplyCharFormatL(charFormat, charMask, 0, iEditor->TextLength())); + } +} + +void CSwtTextBase::HandleHighlightChange() +{ + UpdateTextColor(); +} + // --------------------------------------------------------------------------- // CSwtTextBase::ComputeDelta // --------------------------------------------------------------------------- @@ -835,9 +913,11 @@ if (aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch) { + // The highlight color will be updated from ProcessFontUpdateL() + if (!iFont) { - RetrieveDefaultFontL(); + RetrieveDefaultFontL(); // ProcessFontUpdateL() will get called also. } else { @@ -906,14 +986,15 @@ vsb->HandlePointerEventL(aPointerEvent); } + TBool forward(EFalse); + TPointerEvent pointerEvent(aPointerEvent); + // Edwin tap. Button1Up after the long tap is not forwarded to the editor if (!(aPointerEvent.iType == TPointerEvent::EButton1Up && (iDisplay.RevertPointerEvent() || !hit)) && !iVScrollBarGrabsPointerEvents && !iIgnorePointerDown) { - TPointerEvent pointerEvent(aPointerEvent); - // If clicking on margins, move the pointer event. TRect viewRect(iEditor->TextView()->ViewRect()); TRect viewRectWithoutMargins(viewRect); @@ -949,7 +1030,7 @@ } } - iEditor->HandlePointerEventL(pointerEvent); + forward = ETrue; } // Stop scrollbar grabbing @@ -967,7 +1048,9 @@ } if (pressed != iPressed) - Redraw(); + { + GetShell().UpdateHighlight(ETrue); // draw now + } #endif #ifndef RD_JAVA_S60_RELEASE_9_2 @@ -975,6 +1058,12 @@ iIgnorePointerDown = EFalse; #endif // RD_JAVA_S60_RELEASE_9_2 + // Forwarding this late due to splitview + pressed flicker issues. + if (forward) + { + iEditor->HandlePointerEventL(pointerEvent); + } + PostMouseEventL(aPointerEvent); } #else //RD_SCALABLE_UI_V2 @@ -1175,25 +1264,6 @@ } // --------------------------------------------------------------------------- -// CSwtTextBase::FocusBackgroundPolicy -// From MSwtControl -// While background color is set, the editor's control context must be null, -// otherwise there will be ugly background drawing problems while typing. -// --------------------------------------------------------------------------- -// -TInt CSwtTextBase::FocusBackgroundPolicy() const -{ - if (!IsDefaultBackgroundUse()) - { - return EEmbeddedFocusBackground; - } - else - { - return ASwtControlBase::FocusBackgroundPolicy(); - } -}; - -// --------------------------------------------------------------------------- // CSwtTextBase::ClientRect // From MSwtControl // ---------------------------------------------------------------------------