|
1 /* |
|
2 * Copyright (c) 2006 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: Bubble for call object text display. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "BMBubbleOutlookFiveLined.h" |
|
21 #include "BMResourceManager.h" |
|
22 #include "BMBubbleHeader.h" |
|
23 #include "BMUtils.h" |
|
24 #include "BMLayout.h" |
|
25 #include "BMLayout2.h" |
|
26 #include "BMCustomManager.h" |
|
27 |
|
28 #include <telbubblecustomelement.h> |
|
29 #include <telbubbleanim.h> |
|
30 |
|
31 #include <eiklabel.h> |
|
32 #include <eikimage.h> |
|
33 #include <featmgr.h> |
|
34 #include <AknsDrawUtils.h> |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // |
|
41 CBubbleOutlookFiveLined::CBubbleOutlookFiveLined( |
|
42 CBubbleManager& aBubbleManager ) : CBubbleOutlook( aBubbleManager ) |
|
43 { |
|
44 } |
|
45 |
|
46 // Symbian OS default constructor can leave. |
|
47 void CBubbleOutlookFiveLined::ConstructL() |
|
48 { |
|
49 iHeader = NULL; |
|
50 iTextLineNumber = 0; |
|
51 |
|
52 CBubbleOutlook::ConstructL( ); |
|
53 ActivateL(); |
|
54 } |
|
55 |
|
56 // Destructor |
|
57 CBubbleOutlookFiveLined::~CBubbleOutlookFiveLined() |
|
58 { |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CBubbleOutlookFiveLined::Reset |
|
64 // |
|
65 // |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CBubbleOutlookFiveLined::Reset( ) |
|
69 { |
|
70 CBubbleResourceManager& res = iBubbleManager.ResourceManager(); |
|
71 res.ReleaseEikImage( iBubble ); |
|
72 iBubbleManager.CustomManager().ReleaseCustomElement( iSmallCallIndication ); |
|
73 iBubbleManager.CustomManager().ReleaseCustomElement( iNumberType ); |
|
74 res.ReleaseEikImage( iTypeIndication1 ); |
|
75 res.ReleaseEikImage( iTypeIndication2 ); |
|
76 res.ReleaseEikImage( iCyphOffImage ); |
|
77 res.ReleaseEikImage( iTnImage ); |
|
78 res.ReleaseEikLabel( iTextLine1 ); |
|
79 res.ReleaseEikLabel( iTextLine2 ); |
|
80 res.ReleaseEikLabel( iTextLine3 ); |
|
81 res.ReleaseEikLabel( iTextLine4 ); |
|
82 res.ReleaseEikLabel( iTextLine5 ); |
|
83 |
|
84 iBubbleManager.CustomManager().ReleaseCustomElement( iBigCallIndicator ); |
|
85 |
|
86 iFullText1.Set( NULL, 0 ); |
|
87 iFullText2.Set( NULL, 0 ); |
|
88 iFullText3.Set( NULL, 0 ); |
|
89 iFullText4.Set( NULL, 0 ); |
|
90 iFullText5.Set( NULL, 0 ); |
|
91 iTextLineNumber = 0; |
|
92 |
|
93 iHeader = NULL; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CBubbleOutlookFiveLined::ReadBubbleHeader |
|
98 // |
|
99 // |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CBubbleOutlookFiveLined::ReadBubbleHeader( CBubbleHeader& aHeader ) |
|
103 { |
|
104 iHeader = &aHeader; |
|
105 |
|
106 CBubbleManager::TPhoneCallState callState = iHeader->CallState( ); |
|
107 |
|
108 switch ( callState ) |
|
109 { |
|
110 case CBubbleManager::EIncoming: |
|
111 case CBubbleManager::EOutgoing: |
|
112 case CBubbleManager::EAlerting: |
|
113 case CBubbleManager::EAlertToDisconnected: |
|
114 // Set big call indicator icon |
|
115 TBool defaultCallIndicator; |
|
116 iBigCallIndicator = |
|
117 iBubbleManager.CustomManager().ReserveCustomElement( |
|
118 aHeader, |
|
119 CTelBubbleCustomElement::EBigCallIndicator, |
|
120 defaultCallIndicator ); |
|
121 |
|
122 // Number type not shown with custom call indicator |
|
123 if ( defaultCallIndicator ) |
|
124 { |
|
125 // Set number type icon |
|
126 iNumberType = |
|
127 iBubbleManager.CustomManager().ReserveCustomElement( |
|
128 aHeader, |
|
129 CTelBubbleCustomElement::ENumberTypeIcon, |
|
130 defaultCallIndicator ); |
|
131 } |
|
132 break; |
|
133 |
|
134 default: |
|
135 break; |
|
136 } |
|
137 |
|
138 BubbleUtils::SetCyphOffImage( *iHeader, iCyphOffImage, iBubbleManager ); |
|
139 |
|
140 BubbleUtils::ChooseTextsToFiveLines( |
|
141 *iHeader, |
|
142 iFullText1, |
|
143 iFullText2, |
|
144 iFullText3, |
|
145 iTextLine1, |
|
146 iTextLine2, |
|
147 iTextLine3, |
|
148 iTextLine4, |
|
149 iTextLine5, |
|
150 iBubbleManager, |
|
151 iText1ClipDirection, |
|
152 iText2ClipDirection, |
|
153 iText3ClipDirection, |
|
154 iTextLineNumber, |
|
155 iThreeLinedLayout ); |
|
156 |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CBubbleOutlookFiveLined::CountComponentControls |
|
161 // |
|
162 // All the controls are not used at all times. Athough we want to |
|
163 // keep the drawing order. |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CBubbleOutlookFiveLined::CountComponentControls() const |
|
167 { |
|
168 TInt amount = 0; |
|
169 |
|
170 if ( iNumberType ) |
|
171 { |
|
172 amount++; |
|
173 } |
|
174 |
|
175 if ( iSmallCallIndication ) |
|
176 { |
|
177 amount++; |
|
178 } |
|
179 |
|
180 if ( iTypeIndication1 ) |
|
181 { |
|
182 amount++; |
|
183 } |
|
184 |
|
185 if ( iTypeIndication2 ) |
|
186 { |
|
187 amount++; |
|
188 } |
|
189 |
|
190 if ( iCyphOffImage ) |
|
191 { |
|
192 amount++; |
|
193 } |
|
194 |
|
195 if ( iTextLine1 ) |
|
196 { |
|
197 amount++; |
|
198 } |
|
199 |
|
200 if ( iTextLine2 ) |
|
201 { |
|
202 amount++; |
|
203 } |
|
204 |
|
205 if ( iTextLine3 ) |
|
206 { |
|
207 amount++; |
|
208 } |
|
209 |
|
210 if ( iTextLine4 ) |
|
211 { |
|
212 amount++; |
|
213 } |
|
214 |
|
215 if ( iTextLine5 ) |
|
216 { |
|
217 amount++; |
|
218 } |
|
219 |
|
220 if ( iTimerCost ) |
|
221 { |
|
222 amount++; |
|
223 } |
|
224 |
|
225 if ( iBigCallIndicator ) |
|
226 { |
|
227 amount++; |
|
228 } |
|
229 |
|
230 return amount; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CBubbleOutlookFiveLined::ComponentControl |
|
235 // |
|
236 // |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 CCoeControl* CBubbleOutlookFiveLined::ComponentControl(TInt aIndex) const |
|
240 { |
|
241 TInt amount = -1; |
|
242 // coverity[var_compare_op] |
|
243 if ( iNumberType ) |
|
244 { |
|
245 amount++; |
|
246 } |
|
247 |
|
248 if ( aIndex == amount ) |
|
249 { |
|
250 // coverity[var_deref_model] |
|
251 return iNumberType->Control(); |
|
252 } |
|
253 |
|
254 if ( iCyphOffImage ) |
|
255 { |
|
256 amount++; |
|
257 } |
|
258 |
|
259 if ( aIndex == amount ) |
|
260 { |
|
261 return iCyphOffImage; |
|
262 } |
|
263 |
|
264 if ( iTextLine1 ) |
|
265 { |
|
266 amount++; |
|
267 } |
|
268 |
|
269 if ( aIndex == amount ) |
|
270 { |
|
271 return iTextLine1; |
|
272 } |
|
273 |
|
274 if ( iTextLine2 ) |
|
275 { |
|
276 amount++; |
|
277 } |
|
278 |
|
279 if ( aIndex == amount ) |
|
280 { |
|
281 return iTextLine2; |
|
282 } |
|
283 |
|
284 if ( iTextLine3 ) |
|
285 { |
|
286 amount++; |
|
287 } |
|
288 |
|
289 if ( aIndex == amount ) |
|
290 { |
|
291 return iTextLine3; |
|
292 } |
|
293 |
|
294 if ( iTextLine4 ) |
|
295 { |
|
296 amount++; |
|
297 } |
|
298 |
|
299 if ( aIndex == amount ) |
|
300 { |
|
301 return iTextLine4; |
|
302 } |
|
303 |
|
304 if ( iTextLine5 ) |
|
305 { |
|
306 amount++; |
|
307 } |
|
308 |
|
309 if ( aIndex == amount ) |
|
310 { |
|
311 return iTextLine5; |
|
312 } |
|
313 |
|
314 if ( iTimerCost ) |
|
315 { |
|
316 amount++; |
|
317 } |
|
318 |
|
319 if ( aIndex == amount ) |
|
320 { |
|
321 return iTimerCost; |
|
322 } |
|
323 |
|
324 if ( iSmallCallIndication ) |
|
325 { |
|
326 amount++; |
|
327 } |
|
328 |
|
329 if ( aIndex == amount ) |
|
330 { |
|
331 // coverity[var_deref_model] |
|
332 return iSmallCallIndication->Control(); |
|
333 } |
|
334 |
|
335 if ( iTypeIndication1 ) |
|
336 { |
|
337 amount++; |
|
338 } |
|
339 |
|
340 if ( aIndex == amount ) |
|
341 { |
|
342 return iTypeIndication1; |
|
343 } |
|
344 |
|
345 if ( iTypeIndication2 ) |
|
346 { |
|
347 amount++; |
|
348 } |
|
349 |
|
350 if ( aIndex == amount ) |
|
351 { |
|
352 return iTypeIndication2; |
|
353 } |
|
354 |
|
355 if ( iBigCallIndicator ) |
|
356 { |
|
357 amount++; |
|
358 } |
|
359 |
|
360 if ( aIndex == amount ) |
|
361 { |
|
362 // coverity[var_deref_model] |
|
363 return iBigCallIndicator->Control(); |
|
364 } |
|
365 |
|
366 return NULL; |
|
367 |
|
368 } |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // CBubbleOutlookFiveLined::Draw |
|
372 // |
|
373 // |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CBubbleOutlookFiveLined::Draw( const TRect& /*aRect*/ ) const |
|
377 { |
|
378 CGraphicsContext& gc = SystemGc(); |
|
379 |
|
380 // Check that proper call header is set |
|
381 if ( iHeader == NULL ) |
|
382 { |
|
383 return; |
|
384 } |
|
385 |
|
386 if ( !iHeader->IsUsed( ) ) |
|
387 { |
|
388 return; |
|
389 } |
|
390 |
|
391 TUint32 callFlag = iHeader->CallFlags( ); |
|
392 CBubbleManager::TPhoneCallState callState = iHeader->CallState( ); |
|
393 |
|
394 // Set texts to fit. |
|
395 switch (iTextLineNumber) |
|
396 { |
|
397 case 0: |
|
398 BubbleUtils::ClipToLabel( |
|
399 iFullText1 , iTextLine1 , iText1ClipDirection ); |
|
400 BubbleUtils::AddTextToEikLabel( iTextLine2 , KNullDesC ); |
|
401 break; |
|
402 case 1: |
|
403 BubbleUtils::SetTextInLabel( |
|
404 iFullText1 , iTextLine1 , iText1ClipDirection ); |
|
405 BubbleUtils::ClipToLabel( |
|
406 iFullText2 , iTextLine2 , iText2ClipDirection ); |
|
407 BubbleUtils::ClipToLabel( |
|
408 iFullText3 , iTextLine3 , iText2ClipDirection ); |
|
409 break; |
|
410 case 2: |
|
411 BubbleUtils::ClipToLabel( |
|
412 iFullText1 , iTextLine1 , iText1ClipDirection ); |
|
413 BubbleUtils::SetTextInLabel( |
|
414 iFullText2 , iTextLine2 , iText2ClipDirection ); |
|
415 break; |
|
416 case 3: |
|
417 BubbleUtils::ClipToLabel( |
|
418 iFullText1 , iTextLine1 , iText1ClipDirection ); |
|
419 BubbleUtils::ClipToLabel( |
|
420 iFullText2 , iTextLine2 , iText2ClipDirection ); |
|
421 BubbleUtils::SetTextInLabel( |
|
422 iFullText3 , iTextLine3 , iText3ClipDirection ); |
|
423 break; |
|
424 default: |
|
425 BubbleUtils::AddTextToEikLabel( iTextLine1 , KNullDesC ); |
|
426 BubbleUtils::AddTextToEikLabel( iTextLine2 , KNullDesC ); |
|
427 BubbleUtils::AddTextToEikLabel( iTextLine3 , KNullDesC ); |
|
428 break; |
|
429 } |
|
430 |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 //CBubbleOutlookFiveLined::DrawTimerCostNow |
|
435 // |
|
436 // |
|
437 // --------------------------------------------------------------------------- |
|
438 // |
|
439 void CBubbleOutlookFiveLined::DrawTimerCostNow() |
|
440 { |
|
441 if ( iHeader == NULL || iTimerCost == NULL ) |
|
442 { |
|
443 return; |
|
444 } |
|
445 |
|
446 if ( iHeader->CallState() != CBubbleManager::EActive |
|
447 || iTimerCost->Text()->Compare( iHeader->TimerCost() ) == 0 ) |
|
448 { |
|
449 return; |
|
450 } |
|
451 |
|
452 BubbleUtils::ClipToLabel( iHeader->TimerCost() , iTimerCost , |
|
453 CBubbleManager::ERight ); |
|
454 DrawLabelNow( iTimerCost); |
|
455 } |
|
456 |
|
457 // --------------------------------------------------------------------------- |
|
458 // CBubbleOutlookFiveLined::DrawCLINow |
|
459 // |
|
460 // |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 void CBubbleOutlookFiveLined::DrawCLINow() |
|
464 { |
|
465 if ( iHeader == NULL ) |
|
466 { |
|
467 return; |
|
468 } |
|
469 |
|
470 CEikLabel* cli = NULL; |
|
471 |
|
472 if ( iTextLineNumber == 1 ) |
|
473 { |
|
474 iFullText3.Set( iHeader->CLI() ); |
|
475 cli = iTextLine3; |
|
476 } |
|
477 else |
|
478 { |
|
479 iFullText1.Set( iHeader->CLI() ); |
|
480 cli = iTextLine1; |
|
481 } |
|
482 |
|
483 CBubbleManager::TBubbleLabelString full = iHeader->CLI(); |
|
484 CBubbleManager::TPhoneClippingDirection clipDir |
|
485 = iHeader->CLIClipDirection(); |
|
486 |
|
487 // Set texts to fit. |
|
488 if ( full.Length() > 0 ) |
|
489 { |
|
490 BubbleUtils::ClipToLabel( full , cli , clipDir ); |
|
491 BubbleUtils::AddTextToEikLabel( cli , full ); |
|
492 } |
|
493 else |
|
494 { |
|
495 BubbleUtils::AddTextToEikLabel( cli , KNullDesC ); |
|
496 } |
|
497 |
|
498 // First clear the area and then draw the new text |
|
499 DrawLabelNow( cli ); |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // CBubbleOutlookFiveLined::DrawBitmaps |
|
504 // |
|
505 // |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 void CBubbleOutlookFiveLined::DrawBitmaps( CBitmapContext& aGc ) const |
|
509 { |
|
510 // Check that proper call header is set |
|
511 if ( iHeader == NULL ) |
|
512 { |
|
513 return; |
|
514 } |
|
515 |
|
516 if ( !iHeader->IsUsed() ) |
|
517 { |
|
518 return; |
|
519 } |
|
520 |
|
521 // Now starts actual drawing. |
|
522 aGc.SetBrushColor( AKN_LAF_COLOR( BubbleLayout::LayoutColourWhite() ) ); |
|
523 |
|
524 if ( iBubble->Bitmap() ) |
|
525 { |
|
526 BubbleUtils::DrawMaskedImage( aGc , iBubble ); |
|
527 } |
|
528 else |
|
529 { |
|
530 // Draw bubble frame |
|
531 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
532 if ( !AknsDrawUtils::DrawFrame( skin, |
|
533 (CWindowGc&) aGc, |
|
534 iOuterRect, |
|
535 iInnerRect, |
|
536 iFrameId, |
|
537 KAknsIIDDefault ) ) |
|
538 { |
|
539 BubbleUtils::DrawBackgroundRect( aGc, Rect() ); |
|
540 } |
|
541 } |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // CBubbleOutlookFiveLined::HandleAnimationStartL |
|
546 // |
|
547 // |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 void CBubbleOutlookFiveLined::HandleAnimationStartL() const |
|
551 { |
|
552 if ( iBigCallIndicator && iBigCallIndicator->ControlType() == |
|
553 CTelBubbleCustomElement::EBubbleAnimation ) |
|
554 { |
|
555 CTelBubbleAnim* anim = |
|
556 static_cast<CTelBubbleAnim*> ( iBigCallIndicator->Control() ); |
|
557 anim->StartAnimationL(); |
|
558 } |
|
559 |
|
560 if ( iSmallCallIndication && iSmallCallIndication->ControlType() == |
|
561 CTelBubbleCustomElement::EBubbleAnimation ) |
|
562 { |
|
563 CTelBubbleAnim* anim = |
|
564 static_cast<CTelBubbleAnim*> ( iSmallCallIndication->Control() ); |
|
565 anim->StartAnimationL(); |
|
566 } |
|
567 |
|
568 if( iNumberType && iNumberType->ControlType() == |
|
569 CTelBubbleCustomElement::EBubbleAnimation ) |
|
570 { |
|
571 CTelBubbleAnim* anim = |
|
572 static_cast<CTelBubbleAnim*> ( iNumberType->Control() ); |
|
573 anim->StartAnimationL(); |
|
574 } |
|
575 |
|
576 } |
|
577 |
|
578 // --------------------------------------------------------------------------- |
|
579 // CBubbleOutlookFiveLined::DrawCallHeaderText |
|
580 // --------------------------------------------------------------------------- |
|
581 // |
|
582 void CBubbleOutlookFiveLined::DrawCallHeaderText() |
|
583 { |
|
584 if ( iHeader == NULL || iTextLine1 == NULL ) |
|
585 { |
|
586 return; |
|
587 } |
|
588 |
|
589 if ( iHeader->CallState() != CBubbleManager::EOutgoing ) |
|
590 { |
|
591 return; |
|
592 } |
|
593 |
|
594 CEikLabel* label = NULL; |
|
595 iFullText1.Set( iHeader->Text() ); |
|
596 label = iTextLine1; |
|
597 |
|
598 CBubbleManager::TPhoneClippingDirection textDir = |
|
599 iHeader->TextClipDirection(); |
|
600 |
|
601 BubbleUtils::ClipToLabel( iHeader->Text(), label, textDir ); |
|
602 DrawLabelNow( label ); |
|
603 } |
|
604 |
|
605 |
|
606 |
|
607 // End of File |