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