|
1 /* |
|
2 * Copyright (c) 2009 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: Button of ending call. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknsConstants.h> |
|
20 #include <AknsSkinInstance.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <AknsFrameBackgroundControlContext.h> |
|
23 #include <aknlayoutscalable_avkon.cdl.h> |
|
24 #include <AknsDrawUtils.h> |
|
25 #include <gulicon.h> |
|
26 #include <AknIconUtils.h> |
|
27 #include <AknBidiTextUtils.h> |
|
28 #include <cvtlogger.h> |
|
29 |
|
30 #include "CVtUiEndCallButton.h" |
|
31 #include "VtUiLayout.h" |
|
32 |
|
33 const TInt KEndCallButtonText = 255; |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CVtUiEndCallButton::CVtUiEndCallButton |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CVtUiEndCallButton::CVtUiEndCallButton(): CAknButton( 0 ) |
|
40 { |
|
41 // No implementation required |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CVtUiEndCallButton::NewL |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CVtUiEndCallButton* CVtUiEndCallButton::NewL() |
|
49 { |
|
50 CVtUiEndCallButton* self = new (ELeave) CVtUiEndCallButton(); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop(); // self; |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CVtUiEndCallButton::ConstructL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CVtUiEndCallButton::ConstructL() |
|
62 { |
|
63 CAknButton::ConstructL(); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CVtUiEndCallButton::~CVtUiEndCallButton |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CVtUiEndCallButton::~CVtUiEndCallButton() |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CVtUiEndCallButton::ConstructFromResourceL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CVtUiEndCallButton::ConstructFromResourceL( const TInt aResourceId ) |
|
79 { |
|
80 CAknButton::ConstructFromResourceL( aResourceId ); |
|
81 |
|
82 // function button text color |
|
83 SetTextColorIds( KAknsIIDQsnTextColors, |
|
84 EAknsCIQsnTextColorsCG65 ); |
|
85 |
|
86 // Customize icons |
|
87 LoadButtonIcon( EVtUiBitmap_qgn_indi_button_end_active_call, |
|
88 EVtUiBitmap_qgn_indi_button_end_active_call_mask ); |
|
89 |
|
90 if ( State()->Icon() ) |
|
91 { |
|
92 SetIconScaleMode( EAspectRatioPreserved ); |
|
93 } |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CVtUiEndCallButton::SetLayout |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CVtUiEndCallButton::SetLayout( const TAknLayoutText aLayoutText, |
|
101 const TRect aIconRect ) |
|
102 { |
|
103 iLayoutText = aLayoutText; |
|
104 iIconRect = aIconRect; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CVtUiEndCallButton::Draw |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CVtUiEndCallButton::Draw(const TRect& aRect) const |
|
112 { |
|
113 __VTPRINTENTER( "CCVtUiEndCallButton::Draw" ) |
|
114 TAknLayoutRect centerLayout; |
|
115 centerLayout.LayoutRect( aRect, |
|
116 AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() ); |
|
117 TRect innerRect = centerLayout.Rect(); |
|
118 CWindowGc& gc = SystemGc(); |
|
119 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
120 |
|
121 TAknsItemID frameId = KAknsIIDQsnFrButtonNormalReject; |
|
122 |
|
123 if ( iButtonPressed ) |
|
124 { |
|
125 frameId = KAknsIIDQsnFrButtonPressedReject; |
|
126 } |
|
127 else if ( IsDimmed() ) |
|
128 { |
|
129 frameId = KAknsIIDQsnFrButtonInactiveReject; |
|
130 } |
|
131 |
|
132 iBgContext->SetFrame( frameId ); |
|
133 iBgContext->SetCenter( KAknsIIDQsnFrButtonCenterNormal ); |
|
134 iBgContext->SetFrameRects( aRect, innerRect ); |
|
135 |
|
136 if ( !AknsDrawUtils::Background( skin, |
|
137 iBgContext, |
|
138 NULL, |
|
139 gc, |
|
140 aRect, |
|
141 KAknsDrawParamNoClearUnderImage ) ) |
|
142 { |
|
143 gc.SetBrushColor( KRgbRed ); |
|
144 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
145 gc.DrawRect( aRect ); |
|
146 } |
|
147 |
|
148 LayoutIconAndText( gc ); |
|
149 __VTPRINTEXIT( "CCVtUiEndCallButton::Draw" ) |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CVtUiEndCallButton::HandleResourceChange |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CVtUiEndCallButton::HandleResourceChange( TInt aType ) |
|
157 { |
|
158 __VTPRINTENTER( "CCVtUiEndCallButton::HandleResourceChange" ) |
|
159 CAknButton::HandleResourceChange( aType ); |
|
160 |
|
161 if ( aType == KAknsMessageSkinChange ) |
|
162 { |
|
163 LoadButtonIcon( EVtUiBitmap_qgn_indi_button_end_active_call, |
|
164 EVtUiBitmap_qgn_indi_button_end_active_call_mask ); |
|
165 } |
|
166 __VTPRINTEXIT( "CCVtUiEndCallButton::HandleResourceChange" ) |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CVtUiEndCallButton::GetTextColors |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CVtUiEndCallButton::GetTextColors( TRgb& aPenColor ) const |
|
174 { |
|
175 __VTPRINTENTER( "CCVtUiEndCallButton::GetTextColors" ) |
|
176 if ( IsDimmed() ) |
|
177 { |
|
178 aPenColor = iEikonEnv->ControlColor( EColorButtonTextDimmed, *this ); |
|
179 } |
|
180 else if ( iButtonPressed ) |
|
181 { |
|
182 aPenColor = iEikonEnv->ControlColor( EColorButtonTextPressed, *this ); |
|
183 } |
|
184 else |
|
185 { |
|
186 aPenColor = iEikonEnv->ControlColor( EColorButtonText, *this ); |
|
187 } |
|
188 __VTPRINTEXIT( "CCVtUiEndCallButton::GetTextColors" ) |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CVtUiEndCallButton::LoadButtonIcon |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CVtUiEndCallButton::LoadButtonIcon( TVtUiBitmapId aIconId, TVtUiBitmapId aMaskId ) |
|
196 { |
|
197 __VTPRINTENTER( "CCVtUiEndCallButton::LoadButtonIcon" ) |
|
198 CGulIcon* icon = NULL; |
|
199 TFileName fileName; |
|
200 TInt fileIndex; |
|
201 TInt maskIndex; |
|
202 TAknsItemID skinId = |
|
203 VtUiLayout::MapBitmapToSkinId( aIconId ); |
|
204 VtUiLayout::Resolve( aIconId, fileName, fileIndex ); |
|
205 VtUiLayout::Resolve( aMaskId, fileName, maskIndex ); |
|
206 |
|
207 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
208 |
|
209 icon = AknsUtils::CreateGulIconL( skin, |
|
210 skinId, |
|
211 fileName, |
|
212 fileIndex, |
|
213 maskIndex ); |
|
214 |
|
215 if ( icon ) |
|
216 { |
|
217 CAknButtonState* state = State(); |
|
218 // State takes ownership of icon |
|
219 state->SetIcon( icon ); |
|
220 } |
|
221 __VTPRINTEXIT( "CCVtUiEndCallButton::LoadButtonIcon" ) |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CVtUiEndCallButton::LayoutIconAndText |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CVtUiEndCallButton::LayoutIconAndText( CWindowGc& aGc ) const |
|
229 { |
|
230 __VTPRINTENTER( "CCVtUiEndCallButton::LayoutIconAndText" ) |
|
231 CAknButtonState* state = State(); |
|
232 if ( !state || |
|
233 !state->Icon() || |
|
234 !state->Text().Length() ) |
|
235 { |
|
236 return; |
|
237 } |
|
238 TRgb penColor; |
|
239 TRgb brushColor; |
|
240 GetTextColors( penColor ); |
|
241 |
|
242 // buffer for visually ordered text |
|
243 TBuf< KEndCallButtonText + KAknBidiExtraSpacePerLine> visualText; |
|
244 TInt clipWidth = iLayoutText.TextRect().Width(); |
|
245 |
|
246 // bidi processing - using AknBidiTextUtils. |
|
247 AknBidiTextUtils::ConvertToVisualAndClip( |
|
248 state->Text(), |
|
249 visualText, |
|
250 *iLayoutText.Font(), |
|
251 clipWidth, |
|
252 clipWidth ); |
|
253 |
|
254 iLayoutText.DrawText( aGc, visualText, EFalse, penColor ); |
|
255 |
|
256 const CGulIcon* icon = GetCurrentIcon(); |
|
257 |
|
258 if ( icon ) |
|
259 { |
|
260 CFbsBitmap* buttonBmp = icon->Bitmap(); |
|
261 CFbsBitmap* buttonMask = icon->Mask(); |
|
262 |
|
263 if( buttonBmp && buttonMask ) |
|
264 { |
|
265 aGc.BitBltMasked( iIconRect.iTl, buttonBmp, |
|
266 iIconRect.Size(), buttonMask, EFalse ); |
|
267 } |
|
268 } |
|
269 __VTPRINTEXIT( "CCVtUiEndCallButton::LayoutIconAndText" ) |
|
270 } |