211 iButton->SetIconScaleMode(EAspectRatioPreserved); |
211 iButton->SetIconScaleMode(EAspectRatioPreserved); |
212 |
212 |
213 iButton->SetBackground(this); // Back will be drawn by ASwtControlBase::Draw |
213 iButton->SetBackground(this); // Back will be drawn by ASwtControlBase::Draw |
214 |
214 |
215 // Set default color |
215 // Set default color |
216 TRgb color; |
216 UpdateTextColor(); |
217 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
218 color, |
|
219 KAknsIIDQsnTextColors, |
|
220 EAknsCIQsnTextColorsCG6); |
|
221 iButton->OverrideColorL(EColorButtonText, color); |
|
222 } |
217 } |
223 |
218 |
224 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |
225 // CSwtButton::ChangeStateL |
220 // CSwtButton::ChangeStateL |
226 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
630 // From ASwtControlbase |
626 // From ASwtControlbase |
631 // --------------------------------------------------------------------------- |
627 // --------------------------------------------------------------------------- |
632 // |
628 // |
633 void CSwtButton::SetForegroundL(const MSwtColor* aColor) |
629 void CSwtButton::SetForegroundL(const MSwtColor* aColor) |
634 { |
630 { |
635 TRgb color; |
|
636 |
|
637 if (aColor) |
|
638 { |
|
639 color = aColor->RgbValue(); |
|
640 } |
|
641 else |
|
642 { |
|
643 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
644 color, |
|
645 KAknsIIDQsnTextColors, |
|
646 EAknsCIQsnTextColorsCG6); |
|
647 } |
|
648 |
|
649 if (iButton) |
|
650 { |
|
651 iButton->OverrideColorL(EColorButtonText, color); |
|
652 } |
|
653 |
|
654 ASwtControlBase::DoSetForegroundL(aColor); |
631 ASwtControlBase::DoSetForegroundL(aColor); |
|
632 iCustomFg = aColor; |
|
633 UpdateTextColor(); |
655 Redraw(); |
634 Redraw(); |
656 } |
635 } |
657 |
636 |
658 // --------------------------------------------------------------------------- |
637 // --------------------------------------------------------------------------- |
659 // CSwtButton::DefaultFont |
638 // CSwtButton::DefaultFont |
825 // From MSwtControl |
804 // From MSwtControl |
826 // --------------------------------------------------------------------------- |
805 // --------------------------------------------------------------------------- |
827 // |
806 // |
828 TInt CSwtButton::FocusBackgroundPolicy() const |
807 TInt CSwtButton::FocusBackgroundPolicy() const |
829 { |
808 { |
830 return EEmbeddedFocusBackground; |
809 TInt policy(EEmbeddedFocusBackground); |
|
810 if (iStyle & (KSwtStyleCheck | KSwtStyleRadio)) |
|
811 { |
|
812 policy = EDefaultFocusBackground; |
|
813 } |
|
814 return policy; |
831 }; |
815 }; |
|
816 |
|
817 // --------------------------------------------------------------------------- |
|
818 // CSwtButton::PressBackgroundPolicy |
|
819 // From MSwtControl |
|
820 // --------------------------------------------------------------------------- |
|
821 // |
|
822 TInt CSwtButton::PressBackgroundPolicy() const |
|
823 { |
|
824 return EEmbeddedPressBackground; |
|
825 } |
|
826 |
|
827 // --------------------------------------------------------------------------- |
|
828 // CSwtButton::UpdateTextColor |
|
829 // --------------------------------------------------------------------------- |
|
830 // |
|
831 void CSwtButton::UpdateTextColor() |
|
832 { |
|
833 if (iButton) |
|
834 { |
|
835 TBool highlighted = HasHighlight() && (iStyle & (KSwtStyleCheck | KSwtStyleRadio)); |
|
836 |
|
837 TRgb color(0); |
|
838 TInt err(KErrNone); |
|
839 |
|
840 if (highlighted) |
|
841 { |
|
842 // Highlighted foreground color, overrides all others. |
|
843 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
|
844 , color |
|
845 , KAknsIIDQsnTextColors |
|
846 , KHighlightedTextColor); |
|
847 } |
|
848 else if (iCustomFg) |
|
849 { |
|
850 // Custom foreground color, overrides the default. |
|
851 color = iCustomFg->RgbValue(); |
|
852 } |
|
853 else |
|
854 { |
|
855 // Default foreground color. |
|
856 err = AknsUtils::GetCachedColor(AknsUtils::SkinInstance() |
|
857 , color |
|
858 , KAknsIIDQsnTextColors |
|
859 , KNonHighlightedTextColor); |
|
860 } |
|
861 |
|
862 if (err == KErrNone) |
|
863 { |
|
864 TRAP_IGNORE(iButton->OverrideColorL(EColorButtonText, color)); |
|
865 } |
|
866 } |
|
867 } |
|
868 |
|
869 // --------------------------------------------------------------------------- |
|
870 // CSwtButton::HandleHighlightChange |
|
871 // From MSwtControl |
|
872 // --------------------------------------------------------------------------- |
|
873 // |
|
874 void CSwtButton::HandleHighlightChange() |
|
875 { |
|
876 if (iStyle & (KSwtStyleCheck | KSwtStyleRadio)) |
|
877 UpdateTextColor(); |
|
878 } |
832 |
879 |
833 // --------------------------------------------------------------------------- |
880 // --------------------------------------------------------------------------- |
834 // CSwtButton::Control |
881 // CSwtButton::Control |
835 // From MSwtButton |
882 // From MSwtButton |
836 // --------------------------------------------------------------------------- |
883 // --------------------------------------------------------------------------- |
1180 } |
1227 } |
1181 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
1228 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
1182 iButton->HandlePointerEventL(aPointerEvent); |
1229 iButton->HandlePointerEventL(aPointerEvent); |
1183 } |
1230 } |
1184 |
1231 |
|
1232 // If directly captioned, the CaptionedControl gets "pressed" as well. |
|
1233 if (aPointerEvent.iType == TPointerEvent::EButton1Up |
|
1234 || aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
1235 { |
|
1236 iPressed = aPointerEvent.iType == TPointerEvent::EButton1Down; |
|
1237 if (iParent->Control()->CaptionedControlInterface()) |
|
1238 GetShell().UpdateHighlight(ETrue); |
|
1239 } |
|
1240 |
1185 PostMouseEventL(aPointerEvent); |
1241 PostMouseEventL(aPointerEvent); |
1186 } |
1242 } |
1187 #endif // RD_SCALABLE_UI_V2 |
1243 #endif // RD_SCALABLE_UI_V2 |
1188 |
1244 |
1189 // --------------------------------------------------------------------------- |
1245 // --------------------------------------------------------------------------- |