diff -r e5618cc85d74 -r 6c158198356e javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtbutton.cpp --- a/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtbutton.cpp Thu Jul 15 18:31:06 2010 +0300 +++ b/javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtbutton.cpp Thu Aug 19 09:48:13 2010 +0300 @@ -213,12 +213,7 @@ iButton->SetBackground(this); // Back will be drawn by ASwtControlBase::Draw // Set default color - TRgb color; - AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), - color, - KAknsIIDQsnTextColors, - EAknsCIQsnTextColorsCG6); - iButton->OverrideColorL(EColorButtonText, color); + UpdateTextColor(); } // --------------------------------------------------------------------------- @@ -412,6 +407,7 @@ { ChangeCheckOrRadioIconL(iSelected); } + UpdateTextColor(); } } } @@ -632,26 +628,9 @@ // void CSwtButton::SetForegroundL(const MSwtColor* aColor) { - TRgb color; - - if (aColor) - { - color = aColor->RgbValue(); - } - else - { - AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), - color, - KAknsIIDQsnTextColors, - EAknsCIQsnTextColorsCG6); - } - - if (iButton) - { - iButton->OverrideColorL(EColorButtonText, color); - } - ASwtControlBase::DoSetForegroundL(aColor); + iCustomFg = aColor; + UpdateTextColor(); Redraw(); } @@ -827,10 +806,78 @@ // TInt CSwtButton::FocusBackgroundPolicy() const { - return EEmbeddedFocusBackground; + TInt policy(EEmbeddedFocusBackground); + if (iStyle & (KSwtStyleCheck | KSwtStyleRadio)) + { + policy = EDefaultFocusBackground; + } + return policy; }; // --------------------------------------------------------------------------- +// CSwtButton::PressBackgroundPolicy +// From MSwtControl +// --------------------------------------------------------------------------- +// +TInt CSwtButton::PressBackgroundPolicy() const +{ + return EEmbeddedPressBackground; +} + +// --------------------------------------------------------------------------- +// CSwtButton::UpdateTextColor +// --------------------------------------------------------------------------- +// +void CSwtButton::UpdateTextColor() +{ + if (iButton) + { + TBool highlighted = HasHighlight() && (iStyle & (KSwtStyleCheck | KSwtStyleRadio)); + + TRgb color(0); + TInt err(KErrNone); + + if (highlighted) + { + // Highlighted foreground color, overrides all others. + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KHighlightedTextColor); + } + else if (iCustomFg) + { + // Custom foreground color, overrides the default. + color = iCustomFg->RgbValue(); + } + else + { + // Default foreground color. + err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() + , color + , KAknsIIDQsnTextColors + , KNonHighlightedTextColor); + } + + if (err == KErrNone) + { + TRAP_IGNORE(iButton->OverrideColorL(EColorButtonText, color)); + } + } +} + +// --------------------------------------------------------------------------- +// CSwtButton::HandleHighlightChange +// From MSwtControl +// --------------------------------------------------------------------------- +// +void CSwtButton::HandleHighlightChange() +{ + if (iStyle & (KSwtStyleCheck | KSwtStyleRadio)) + UpdateTextColor(); +} + +// --------------------------------------------------------------------------- // CSwtButton::Control // From MSwtButton // --------------------------------------------------------------------------- @@ -1182,6 +1229,15 @@ iButton->HandlePointerEventL(aPointerEvent); } + // If directly captioned, the CaptionedControl gets "pressed" as well. + if (aPointerEvent.iType == TPointerEvent::EButton1Up + || aPointerEvent.iType == TPointerEvent::EButton1Down) + { + iPressed = aPointerEvent.iType == TPointerEvent::EButton1Down; + if (iParent->Control()->CaptionedControlInterface()) + GetShell().UpdateHighlight(ETrue); + } + PostMouseEventL(aPointerEvent); } #endif // RD_SCALABLE_UI_V2