|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of the CNcsEngine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <AknsConstants.h> |
|
21 #include <AknsUtils.h> |
|
22 #include <AknsSkinInstance.h> |
|
23 #include <gulcolor.h> |
|
24 #include <eikdef.h> |
|
25 |
|
26 #include "ncscontrol.h" |
|
27 #include "FreestyleEmailUiLayoutData.h" |
|
28 // <cmail> Plaform layout change |
|
29 #include "ncsutility.h" |
|
30 // </cmail> Plaform layout change |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // MNcsControl::MNcsControl |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 MNcsControl::MNcsControl( MNcsFieldSizeObserver* aObserver ) : |
|
37 iSizeObserver( aObserver ) |
|
38 { |
|
39 FUNC_LOG; |
|
40 } |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CNcsLabel::CNcsLabel |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 // <cmail> Platform layout changes |
|
48 CNcsLabel::CNcsLabel( const CCoeControl& aParent, MNcsFieldSizeObserver* aSizeObserver ) : |
|
49 MNcsControl( aSizeObserver ), iParent( aParent ) |
|
50 { |
|
51 FUNC_LOG; |
|
52 UpdateTextColor(); |
|
53 } |
|
54 // </cmail> Platform layout changes |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CNcsLabel::Reposition |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void CNcsLabel::Reposition( TPoint& aPt, TInt /*aWidth <Cmail>*/ ) |
|
61 { |
|
62 FUNC_LOG; |
|
63 // <cmail> Platform layout changes |
|
64 /* |
|
65 TInt ht = Font()->HeightInPixels() + Font()->DescentInPixels(); |
|
66 ht += 2 * KAifLabelMarginHorizontal; |
|
67 TSize sz( aWidth, ht ); |
|
68 if ( Rect() != TRect( aPt, sz ) ) |
|
69 { |
|
70 SetExtent( aPt, sz ); |
|
71 } |
|
72 aPt.iY += Size().iHeight; |
|
73 */ |
|
74 // </cmail> Platform layout changes |
|
75 SetPosition( aPt ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CNcsLabel::FocusChanged |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CNcsLabel::FocusChanged( TDrawNow aDrawNow ) |
|
83 { |
|
84 FUNC_LOG; |
|
85 if( IsFocused() ) |
|
86 { |
|
87 //Check if we need to reposition |
|
88 if (Rect().iTl.iY < 0) |
|
89 { |
|
90 TPoint pt = TPoint(0,0); |
|
91 Reposition(pt,Rect().Width()); |
|
92 if ( iSizeObserver ) |
|
93 { |
|
94 iSizeObserver->UpdateFieldPosition(this); |
|
95 } |
|
96 } |
|
97 } |
|
98 |
|
99 if( aDrawNow ) |
|
100 { |
|
101 DrawNow(); |
|
102 } |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CNcsLabel::HandleResourceChange |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CNcsLabel::HandleResourceChange( TInt aType ) |
|
110 { |
|
111 FUNC_LOG; |
|
112 CEikLabel::HandleResourceChange( aType ); |
|
113 if ( aType == KAknsMessageSkinChange || |
|
114 aType == KEikMessageColorSchemeChange ) |
|
115 { |
|
116 UpdateTextColor(); |
|
117 } |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CNcsLabel::UpdateTextColor |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CNcsLabel::UpdateTextColor() |
|
125 { |
|
126 FUNC_LOG; |
|
127 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
128 TRgb newColor; |
|
129 |
|
130 TInt err = AknsUtils::GetCachedColor( |
|
131 skin, |
|
132 newColor, |
|
133 KAknsIIDFsTextColors, |
|
134 EAknsCIFsTextColorsCG8 ); |
|
135 |
|
136 if ( err == KErrNone ) |
|
137 { |
|
138 TRAP_IGNORE( OverrideColorL( EColorLabelText, newColor ) ); |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CNcsLabel::LayoutLineCount |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CNcsLabel::LayoutLineCount() const |
|
147 { |
|
148 return IsVisible() ? 1 : 0; |
|
149 } |