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