1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 // System includes |
|
22 #include <coecntrl.h> |
|
23 #include <aknconsts.h> |
|
24 #include <aknvolumecontrol.h> |
|
25 #include <akniconutils.h> |
|
26 #include <barsread.h> |
|
27 #include <aknsutils.h> |
|
28 #include <aknsconstants.h> |
|
29 #include <aknsdrawutils.h> |
|
30 #include <aknsitemdef.h> |
|
31 #include <VideoEditorUiComponents.mbg> |
|
32 #include <avkon.mbg> |
|
33 |
|
34 #ifdef RD_TACTILE_FEEDBACK |
|
35 #include <touchfeedback.h> |
|
36 #endif /* RD_TACTILE_FEEDBACK */ |
|
37 |
|
38 // User includes |
|
39 #include "VeiTimeLabelNavi.h" |
|
40 #include "VideoEditorCommon.h" |
|
41 #include "VideoEditorUtils.h" |
|
42 #include "VideoEditorDebugUtils.h" |
|
43 #include "mtimelabelnaviobserver.h" |
|
44 |
|
45 // CONSTANTS |
|
46 _LIT(KDefaultLabel,""); // empty label text |
|
47 |
|
48 enum TVeiTimeLabelLayout |
|
49 { |
|
50 EArrayItem = 0, |
|
51 ESpeakerItem, |
|
52 EPausedItem |
|
53 }; |
|
54 |
|
55 // ================= MEMBER FUNCTIONS ======================= |
|
56 |
|
57 // --------------------------------------------------------- |
|
58 // CTimeLabelNavi::~CTimeLabelNavi() |
|
59 // Destructor |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C CVeiTimeLabelNavi::~CVeiTimeLabelNavi() |
|
63 { |
|
64 DeleteBitmaps(); |
|
65 } |
|
66 |
|
67 void CVeiTimeLabelNavi::DeleteBitmaps() |
|
68 { |
|
69 delete iArrowBitmap; |
|
70 iArrowBitmap = NULL; |
|
71 |
|
72 delete iArrowBitmapMask; |
|
73 iArrowBitmapMask = NULL; |
|
74 |
|
75 delete iVolumeBitmap; |
|
76 iVolumeBitmap = NULL; |
|
77 |
|
78 delete iVolumeBitmapMask; |
|
79 iVolumeBitmapMask = NULL; |
|
80 |
|
81 delete iMutedBitmap; |
|
82 iMutedBitmap = NULL; |
|
83 |
|
84 delete iMutedBitmapMask; |
|
85 iMutedBitmapMask = NULL; |
|
86 |
|
87 delete iPausedBitmap; |
|
88 iPausedBitmap = NULL; |
|
89 |
|
90 delete iPausedBitmapMask; |
|
91 iPausedBitmapMask = NULL; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CTimeLabelNavi::CTimeLabelNavi() |
|
96 // Constructor |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 CVeiTimeLabelNavi::CVeiTimeLabelNavi(): |
|
100 iArrowVisible(ETrue), |
|
101 iVolumeIconVisible(ETrue), |
|
102 iPauseIconVisible(EFalse) |
|
103 { |
|
104 iLabel = KDefaultLabel; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CTimeLabelNavi::ConstructL() |
|
109 // Constructor |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CVeiTimeLabelNavi::ConstructL() |
|
113 { |
|
114 LoadBitmapsL(); |
|
115 } |
|
116 |
|
117 void CVeiTimeLabelNavi::LoadBitmapsL() |
|
118 { |
|
119 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::LoadBitmapsL: in"); |
|
120 |
|
121 TFileName bitmapfile( VideoEditorUtils::IconFileNameAndPath( |
|
122 KVideoEditorUiComponentsIconFileId) ); |
|
123 |
|
124 //Loads a specific bitmap from a multi-bitmap file. |
|
125 //const bitmapfile = the filename of the multi-bitmap (.mbm) file. |
|
126 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
127 |
|
128 /* muted bitmap */ |
|
129 AknsUtils::CreateColorIconL( |
|
130 skinInstance, KAknsIIDQgnIndiSpeakerMuted,KAknsIIDQsnIconColors, |
|
131 EAknsCIQsnIconColorsCG6, |
|
132 iMutedBitmap, iMutedBitmapMask, |
|
133 AknIconUtils::AvkonIconFileName(), |
|
134 EMbmAvkonQgn_indi_speaker_muted, |
|
135 EMbmAvkonQgn_indi_speaker_muted_mask,KRgbBlack); |
|
136 // Arrow bitmap |
|
137 AknsUtils::CreateColorIconL( |
|
138 skinInstance, KAknsIIDNone,KAknsIIDQsnIconColors, |
|
139 EAknsCIQsnIconColorsCG6, |
|
140 iArrowBitmap, iArrowBitmapMask, |
|
141 bitmapfile, |
|
142 EMbmVideoeditoruicomponentsQgn_indi_vded_volume_up_down, |
|
143 EMbmVideoeditoruicomponentsQgn_indi_vded_volume_up_down_mask, |
|
144 KRgbBlack); |
|
145 |
|
146 /* Speaker bitmap */ |
|
147 AknsUtils::CreateColorIconL( |
|
148 skinInstance, KAknsIIDQgnIndiSpeaker,KAknsIIDQsnIconColors, |
|
149 EAknsCIQsnIconColorsCG6, |
|
150 iVolumeBitmap, iVolumeBitmapMask, |
|
151 AknIconUtils::AvkonIconFileName(), |
|
152 EMbmAvkonQgn_indi_speaker, EMbmAvkonQgn_indi_speaker_mask, |
|
153 KRgbBlack); |
|
154 |
|
155 /* Pause bitmap */ |
|
156 // Pause bitmap in not used anywhere at the moment. There is not proper |
|
157 // icon to be used for it anyway in the platform. If needed in the future, |
|
158 // a new icon graphic need to be requested. |
|
159 /* |
|
160 AknsUtils::CreateColorIconL( |
|
161 skinInstance, KAknsIIDNone,KAknsIIDQsnIconColors, |
|
162 EAknsCIQsnIconColorsCG6, |
|
163 iPausedBitmap, iPausedBitmapMask, |
|
164 bitmapfile, |
|
165 EMbmVideoeditoruicomponentsQgn_prop_ve_pause, |
|
166 EMbmVideoeditoruicomponentsQgn_prop_ve_pause_mask,KRgbBlack); |
|
167 */ |
|
168 |
|
169 #ifdef RD_TACTILE_FEEDBACK |
|
170 iTouchFeedBack = MTouchFeedback::Instance(); |
|
171 #endif /* RD_TACTILE_FEEDBACK */ |
|
172 |
|
173 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::LoadBitmapsL: out"); |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CTimeLabelNavi::NewL() |
|
179 // Symbian OS two-phase contruction |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 EXPORT_C CVeiTimeLabelNavi* CVeiTimeLabelNavi::NewL() |
|
183 { |
|
184 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::NewL: in"); |
|
185 |
|
186 CVeiTimeLabelNavi* self = CVeiTimeLabelNavi::NewLC(); |
|
187 CleanupStack::Pop( self ); |
|
188 |
|
189 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::NewL: out"); |
|
190 return self; |
|
191 } |
|
192 |
|
193 EXPORT_C CVeiTimeLabelNavi* CVeiTimeLabelNavi::NewLC() |
|
194 { |
|
195 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::NewLC: in"); |
|
196 |
|
197 CVeiTimeLabelNavi* self = new(ELeave) CVeiTimeLabelNavi(); |
|
198 CleanupStack::PushL(self); |
|
199 self->ConstructL(); |
|
200 |
|
201 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::NewLC: out"); |
|
202 return self; |
|
203 } |
|
204 |
|
205 |
|
206 EXPORT_C void CVeiTimeLabelNavi::SetLabelL( const TDesC& aLabel ) |
|
207 { |
|
208 #ifdef VERBOSE |
|
209 LOGFMT(KVideoEditorLogFile, "CVeiTimeLabelNavi::SetLabelL: %S", &aLabel); |
|
210 #endif |
|
211 |
|
212 if (aLabel.Length() <= iLabel.MaxLength()) |
|
213 { |
|
214 iLabel = aLabel; |
|
215 } |
|
216 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
217 } |
|
218 |
|
219 EXPORT_C void CVeiTimeLabelNavi::SetLeftArrowVisibilityL(TBool aVisible) |
|
220 { |
|
221 iArrowVisible = aVisible; |
|
222 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
223 } |
|
224 |
|
225 EXPORT_C void CVeiTimeLabelNavi::SetRightArrowVisibilityL(TBool aVisible) |
|
226 { |
|
227 iArrowVisible = aVisible; |
|
228 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
229 } |
|
230 |
|
231 EXPORT_C void CVeiTimeLabelNavi::SetVolumeIconVisibilityL(TBool aVisible) |
|
232 { |
|
233 iVolumeIconVisible = aVisible; |
|
234 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
235 } |
|
236 |
|
237 EXPORT_C void CVeiTimeLabelNavi::SetPauseIconVisibilityL(TBool aVisible) |
|
238 { |
|
239 iPauseIconVisible = aVisible; |
|
240 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
241 } |
|
242 |
|
243 void CVeiTimeLabelNavi::SizeChanged() |
|
244 { |
|
245 TRect parentRect(Rect()); |
|
246 parentRect.iTl.iY+=2; |
|
247 /* |
|
248 const TRect & aParent, |
|
249 TInt C, |
|
250 TInt l, |
|
251 TInt t, |
|
252 TInt r, |
|
253 TInt b, |
|
254 TInt W, |
|
255 TInt H |
|
256 |
|
257 //C colour index, 0..255 |
|
258 //l left margin |
|
259 //r right margin |
|
260 //B Baseline from top of the parent rectangle |
|
261 //W text width in pixels |
|
262 //J justification. ELayoutAlignNone; ELayoutAlignCenter; ELayoutAlignLeft; ELayoutAlignRight |
|
263 */ |
|
264 |
|
265 const CFont* myFont = AknLayoutUtils::FontFromId( ELatinBold19/*EAknLogicalFontSecondaryFont*/ ); |
|
266 TInt baseline = ( parentRect.Height() / 2 ) + ( myFont->AscentInPixels() / 2 ); |
|
267 TInt iconHeightWidth = parentRect.Height(); |
|
268 |
|
269 TSize iconSize = TSize(STATIC_CAST(TInt,0.0649*parentRect.Width()), |
|
270 STATIC_CAST(TInt,0.5625*parentRect.Height() )); //14,18 |
|
271 |
|
272 AknIconUtils::SetSize( |
|
273 iArrowBitmap, |
|
274 iconSize, |
|
275 EAspectRatioNotPreserved ); |
|
276 |
|
277 AknIconUtils::SetSize( |
|
278 iPausedBitmap, |
|
279 iconSize, |
|
280 EAspectRatioNotPreserved ); |
|
281 |
|
282 TInt arrowTop = ( parentRect.iBr.iY/2 - iconSize.iHeight/2 ); |
|
283 |
|
284 iBitmapLayout[EArrayItem].LayoutRect(parentRect, ELayoutEmpty, STATIC_CAST(TInt, 0.0926*parentRect.Width()), arrowTop, ELayoutEmpty, ELayoutEmpty,iconHeightWidth,iconSize.iHeight); |
|
285 iBitmapLayout[ESpeakerItem].LayoutRect(parentRect, ELayoutEmpty, STATIC_CAST(TInt, 0.1625*parentRect.Width()), 0, ELayoutEmpty, ELayoutEmpty, iconHeightWidth, iconHeightWidth); |
|
286 iBitmapLayout[EPausedItem].LayoutRect(parentRect, ELayoutEmpty, 0, 0, ELayoutEmpty, ELayoutEmpty, 17, 16); |
|
287 |
|
288 TInt textLeftMargin = STATIC_CAST( TInt, 0.6045*parentRect.Width() ); |
|
289 TInt textRightMargin = STATIC_CAST( TInt, 0.9546*parentRect.Width() ); |
|
290 |
|
291 if( parentRect.iBr.iX != 108 ) |
|
292 { |
|
293 iTextLayout.LayoutText(parentRect, ELatinBold19, 0, textLeftMargin, 0, |
|
294 baseline, textRightMargin-textLeftMargin, ELayoutAlignLeft); |
|
295 |
|
296 } |
|
297 else |
|
298 { |
|
299 arrowTop = STATIC_CAST( TInt, parentRect.iBr.iY/2 - 9/2 ); |
|
300 iBitmapLayout[EArrayItem].LayoutRect(parentRect, ELayoutEmpty, 14, arrowTop, ELayoutEmpty, ELayoutEmpty,iconHeightWidth,9); |
|
301 iBitmapLayout[ESpeakerItem].LayoutRect(parentRect, ELayoutEmpty, 20, 0, ELayoutEmpty, ELayoutEmpty,iconHeightWidth,iconHeightWidth); |
|
302 iBitmapLayout[EPausedItem].LayoutRect(parentRect, ELayoutEmpty, 0, 0, ELayoutEmpty, ELayoutEmpty,17, 16); |
|
303 |
|
304 |
|
305 textLeftMargin = STATIC_CAST( TInt, 0.7273*parentRect.Width()/2 +20); |
|
306 textRightMargin = STATIC_CAST( TInt, 0.9546*parentRect.Width()/2 +20); |
|
307 |
|
308 iTextLayout.LayoutText(parentRect, ELatinBold19, 0, textLeftMargin, 0, |
|
309 baseline, textRightMargin-textLeftMargin, ELayoutAlignLeft); |
|
310 } |
|
311 |
|
312 |
|
313 AknIconUtils::SetSize( iVolumeBitmap, TSize( iconHeightWidth, iconHeightWidth) ); |
|
314 |
|
315 AknIconUtils::SetSize( iMutedBitmap, TSize( iconHeightWidth, iconHeightWidth) ); |
|
316 } |
|
317 |
|
318 void CVeiTimeLabelNavi::Draw(const TRect& /*aRect*/) const |
|
319 { |
|
320 CWindowGc& gc=SystemGc(); |
|
321 |
|
322 if ( iVolumeIconVisible ) |
|
323 { |
|
324 iBitmapLayout[ESpeakerItem].DrawImage( gc, iVolumeBitmap, iVolumeBitmapMask ); |
|
325 |
|
326 if ( iArrowVisible && !AknLayoutUtils::PenEnabled() ) |
|
327 { |
|
328 iBitmapLayout[EArrayItem].DrawImage( gc, iArrowBitmap, iArrowBitmapMask ); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 iBitmapLayout[ESpeakerItem].DrawImage( gc, iMutedBitmap, iMutedBitmapMask ); |
|
334 } |
|
335 |
|
336 if ( iPauseIconVisible ) |
|
337 { |
|
338 // not in use at the moment, pause icon is drawed in main pane instead |
|
339 //iBitmapLayout[EPausedItem].DrawImage( gc, iPausedBitmap, NULL ); |
|
340 } |
|
341 |
|
342 TBuf<32> labelWithConvNumbers; |
|
343 labelWithConvNumbers.Append( iLabel ); |
|
344 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( labelWithConvNumbers ); |
|
345 |
|
346 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
347 //AknsDrawUtils::DrawCachedImage(skinInstance,gc,TRect(0,0,24,24),KAknsIIDQgnIndiSpeaker); |
|
348 |
|
349 // Get navi pane text color from skin |
|
350 TRgb textColor( KRgbBlack ); |
|
351 // Note: we are using the navi icon color for the text. There should |
|
352 // be separate color definition for the text, but I could not find |
|
353 // out what it is. Apparently KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG2 |
|
354 // is NOT the correct color. Someone should find out which color is used |
|
355 // for the label in CAknNavigationDecorator. |
|
356 //AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG2 ); |
|
357 AknsUtils::GetCachedColor(skinInstance, textColor, KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG6 ); |
|
358 |
|
359 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
360 iTextLayout.DrawText(gc, labelWithConvNumbers, ETrue, textColor); |
|
361 } |
|
362 |
|
363 void CVeiTimeLabelNavi::HandleResourceChange(TInt aType) |
|
364 { |
|
365 LOGFMT(KVideoEditorLogFile, "CVeiTimeLabelNavi::HandleResourceChange() In, aType:%d", aType); |
|
366 |
|
367 if (KAknsMessageSkinChange == aType) |
|
368 { |
|
369 // Reload the icon bitmaps with the current skin color |
|
370 DeleteBitmaps(); |
|
371 TRAP_IGNORE( LoadBitmapsL() ); |
|
372 } |
|
373 CCoeControl::HandleResourceChange(aType); |
|
374 |
|
375 LOG(KVideoEditorLogFile, "CVeiTimeLabelNavi::HandleResourceChange() Out"); |
|
376 } |
|
377 |
|
378 void CVeiTimeLabelNavi::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
379 { |
|
380 if( iObserver && |
|
381 iBitmapLayout[ESpeakerItem].Rect().Contains( aPointerEvent.iPosition ) ) |
|
382 { |
|
383 #ifdef RD_TACTILE_FEEDBACK |
|
384 if ( iTouchFeedBack ) |
|
385 { |
|
386 iTouchFeedBack->InstantFeedback( ETouchFeedbackBasic ); |
|
387 } |
|
388 #endif /* RD_TACTILE_FEEDBACK */ |
|
389 |
|
390 iObserver->HandleNaviEventL(); |
|
391 } |
|
392 } |
|
393 |
|
394 // End of File |
|
395 |
|