202 right = 0; |
204 right = 0; |
203 } |
205 } |
204 |
206 |
205 iTextArray.Append(ptr.Left(left)); |
207 iTextArray.Append(ptr.Left(left)); |
206 ptr.Set(ptr.Right(right)); |
208 ptr.Set(ptr.Right(right)); |
207 } |
209 iCodeArray.Append(baseCode++); |
208 } |
210 } |
209 |
211 } |
210 const TDesC& CSmileyIcon::Text(TInt aVariate) const |
212 |
211 { |
213 TInt CSmileyIcon::VariantCount() const |
212 if(aVariate>=0 && aVariate<TextVariate()) |
214 { |
213 { |
215 return iTextArray.Count(); |
214 return iTextArray[aVariate]; |
216 } |
|
217 const TDesC& CSmileyIcon::Text(TInt aVariant) const |
|
218 { |
|
219 if(aVariant>=0 && aVariant<VariantCount()) |
|
220 { |
|
221 return iTextArray[aVariant]; |
215 } |
222 } |
216 else |
223 else |
217 { |
224 { |
218 return KNullDesC; |
225 return KNullDesC; |
219 } |
226 } |
220 } |
227 } |
221 |
228 |
222 TInt CSmileyIcon::TextVariate() const |
229 TChar CSmileyIcon::Code(TInt aVariant) const |
223 { |
230 { |
224 return iTextArray.Count(); |
231 if(aVariant>=0 && aVariant<VariantCount()) |
225 } |
232 { |
226 |
233 return iCodeArray[aVariant]; |
|
234 } |
|
235 else |
|
236 { |
|
237 return 0; |
|
238 } |
|
239 } |
227 |
240 |
228 |
241 |
229 /////////////////////////////////////////////////////////////////////////////////////////////// |
242 /////////////////////////////////////////////////////////////////////////////////////////////// |
230 // CSmileyTnumbnailAsynLoader |
243 // CSmileyTnumbnailAsynLoader |
231 /////////////////////////////////////////////////////////////////////////////////////////////// |
244 /////////////////////////////////////////////////////////////////////////////////////////////// |
292 public: |
305 public: |
293 CSmileyTextTreeNode(TChar aChar); |
306 CSmileyTextTreeNode(TChar aChar); |
294 ~CSmileyTextTreeNode(); |
307 ~CSmileyTextTreeNode(); |
295 |
308 |
296 TChar Char() const; |
309 TChar Char() const; |
297 TChar LastChildChar() const; |
|
298 TChar FirstChildChar() const; |
|
299 |
310 |
300 CSmileyTextTreeNode* AddTreeL(const TDesC& aText, TChar aCode); |
311 CSmileyTextTreeNode* AddTreeL(const TDesC& aText, TChar aCode); |
301 TInt ChildCount() const; |
312 TInt ChildCount() const; |
302 CSmileyTextTreeNode* Child(TInt aIndex) const; |
313 CSmileyTextTreeNode* Child(TInt aIndex) const; |
303 CSmileyTextTreeNode* Child(TChar aChar) const; |
314 CSmileyTextTreeNode* Child(TChar aChar) const; |
304 |
315 |
305 private: |
316 private: |
306 CSmileyTextTreeNode* AddChildL(TChar aChar); |
317 CSmileyTextTreeNode* AddChildAscendingL(TChar aChar); |
307 |
318 |
308 private: |
319 private: |
309 TChar iChar; |
320 TChar iChar; |
310 |
321 |
311 typedef CArrayPtrFlat<CSmileyTextTreeNode> CSmileyTextTreeNodeArrayPtrFlat; |
322 typedef CArrayPtrFlat<CSmileyTextTreeNode> CSmileyTextTreeNodeArrayPtrFlat; |
330 TChar CSmileyTextTreeNode::Char() const |
341 TChar CSmileyTextTreeNode::Char() const |
331 { |
342 { |
332 return iChar; |
343 return iChar; |
333 } |
344 } |
334 |
345 |
335 TChar CSmileyTextTreeNode::LastChildChar() const |
346 |
336 { |
|
337 if(iChildArray) |
|
338 { |
|
339 TInt index = iChildArray->Count() - 1; |
|
340 return iChildArray->At(index)->Char(); |
|
341 } |
|
342 else |
|
343 { |
|
344 return 0; |
|
345 } |
|
346 } |
|
347 |
|
348 TChar CSmileyTextTreeNode::FirstChildChar() const |
|
349 { |
|
350 if(iChildArray) |
|
351 { |
|
352 return iChildArray->At(0)->Char(); |
|
353 } |
|
354 else |
|
355 { |
|
356 return 0; |
|
357 } |
|
358 } |
|
359 |
347 |
360 CSmileyTextTreeNode* CSmileyTextTreeNode::AddTreeL(const TDesC& aText, TChar aCode) |
348 CSmileyTextTreeNode* CSmileyTextTreeNode::AddTreeL(const TDesC& aText, TChar aCode) |
361 { |
349 { |
362 TInt length = aText.Length(); |
350 TInt length = aText.Length(); |
363 if(length > 0) |
351 if(length > 0) |
364 { |
352 { |
365 CSmileyTextTreeNode* node = AddChildL(aText[0]); |
353 CSmileyTextTreeNode* node = AddChildAscendingL(aText[0]); |
366 return node->AddTreeL(aText.Right(length-1), aCode); |
354 return node->AddTreeL(aText.Right(length-1), aCode); |
367 } |
355 } |
368 else |
356 else |
369 { |
357 { |
370 return AddChildL(aCode); |
358 return AddChildAscendingL(aCode); |
371 } |
359 } |
372 } |
360 } |
373 |
361 |
374 TInt CSmileyTextTreeNode::ChildCount() const |
362 TInt CSmileyTextTreeNode::ChildCount() const |
375 { |
363 { |
445 |
439 |
446 /////////////////////////////////////////////////////////////////////////////////////////////// |
440 /////////////////////////////////////////////////////////////////////////////////////////////// |
447 // CSmileyModel |
441 // CSmileyModel |
448 /////////////////////////////////////////////////////////////////////////////////////////////// |
442 /////////////////////////////////////////////////////////////////////////////////////////////// |
449 |
443 |
450 const TUint16 KBaseCodeOn = 0xf880; |
444 const TUint16 KBaseCode = 0xf880; |
451 const TUint16 KBaseCodeOff = 0x7FFF; |
445 //const TUint16 KBaseCodeOff = 0x7FFF; |
452 _LIT(KPlaceHolder, "\xf880i"); |
446 _LIT(KPlaceHolder, "\xf880i"); |
453 |
447 |
454 CSmileyModel::CSmileyModel(MAknSmileyObserver* aObserver) : iSmileyIconObserver(aObserver) |
448 CSmileyModel::CSmileyModel(MAknSmileyObserver* aObserver) : iSmileyIconObserver(aObserver) |
455 { |
449 { |
456 } |
450 } |
471 TFileName smileyRscName; |
466 TFileName smileyRscName; |
472 SmileyUtils::GetCustomizableResPath(smileyRscName, KSmileyRsc); |
467 SmileyUtils::GetCustomizableResPath(smileyRscName, KSmileyRsc); |
473 TInt offset = CCoeEnv::Static()->AddResourceFileL(smileyRscName); |
468 TInt offset = CCoeEnv::Static()->AddResourceFileL(smileyRscName); |
474 CCoeEnv::Static()->CreateResourceReaderLC(reader, R_SMILEY_ICONS_INFO); |
469 CCoeEnv::Static()->CreateResourceReaderLC(reader, R_SMILEY_ICONS_INFO); |
475 |
470 |
476 iBaseCode = KBaseCodeOn; |
471 TUint16 codeRef = KBaseCode; |
477 TInt index = 0; |
472 TInt index = 0; |
478 |
473 |
479 iTextSearchTree = new (ELeave) CSmileyTextTreeNode(0); |
474 iTextSearchTree = new (ELeave) CSmileyTextTreeNode(0); |
480 |
475 |
481 TInt count(reader.ReadInt16()); |
476 TInt count(reader.ReadInt16()); |
482 for(TInt i(0); i<count; i++) |
477 for(TInt i(0); i<count; i++) |
483 { |
478 { |
484 TSmileyIconInfo info; |
479 TSmileyIconInfo info; |
485 |
480 |
486 TBool isAnimation = (reader.ReadInt16() == 1); |
481 TBool isAnimation = (reader.ReadInt16() == 1); |
487 TInt code = reader.ReadInt16(); |
482 TInt16 code = reader.ReadInt16(); |
488 TInt bmpId1 = reader.ReadInt32(); |
483 TInt bmpId1 = reader.ReadInt32(); |
489 TInt maskId1 = reader.ReadInt32(); |
484 TInt maskId1 = reader.ReadInt32(); |
490 TInt bmpId2 = reader.ReadInt32(); |
485 TInt bmpId2 = reader.ReadInt32(); |
491 TInt maskId2 = reader.ReadInt32(); |
486 TInt maskId2 = reader.ReadInt32(); |
492 |
487 |
493 if(iBaseCode > code) iBaseCode = code; |
|
494 |
488 |
495 info.iIndex = index++; |
489 info.iIndex = index++; |
496 |
490 |
497 if(bmpId2 > 0) |
491 if(bmpId2 > 0) |
498 { |
492 { |
506 } |
500 } |
507 |
501 |
508 TBuf<64> smileyName = reader.ReadTPtrC(); // strings |
502 TBuf<64> smileyName = reader.ReadTPtrC(); // strings |
509 |
503 |
510 CSmileyIcon* icon = CSmileyIcon::NewL(info, this); |
504 CSmileyIcon* icon = CSmileyIcon::NewL(info, this); |
511 icon->AddText(smileyName); |
505 icon->AddVariant(smileyName, codeRef); |
512 iSmileyIconArray.Append(icon); |
506 iSmileyIconArray.Append(icon); |
513 |
507 |
514 // build text search tree |
508 // build text search tree |
515 for(TInt j=0; j<icon->TextVariate(); j++) |
509 for(TInt j=0; j<icon->VariantCount(); j++) |
516 { |
510 { |
517 iTextSearchTree->AddTreeL(icon->Text(j), SmileyCode(i,j)); |
511 iTextSearchTree->AddTreeL(icon->Text(j), codeRef++); |
|
512 iSmileyCodeIndexArray.Append(TSmileyCodeIndex(icon,j)); |
518 } |
513 } |
519 } |
514 } |
520 |
515 |
521 CCoeEnv::Static()->DeleteResourceFile(offset); |
516 CCoeEnv::Static()->DeleteResourceFile(offset); |
522 CleanupStack::PopAndDestroy(); // reader |
517 CleanupStack::PopAndDestroy(); // reader |
524 // sct & smiley switch icon |
519 // sct & smiley switch icon |
525 TSmileyIconInfo info; |
520 TSmileyIconInfo info; |
526 info.iIndex = index++; |
521 info.iIndex = index++; |
527 info.iSkinItemID = KAknsIIDQgnIndiSwitchSmiley2; |
522 info.iSkinItemID = KAknsIIDQgnIndiSwitchSmiley2; |
528 info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_smiley2; |
523 info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_smiley2; |
529 iSmileyIconArray.Append(CSmileyIcon::NewL(info,this)); |
524 CSmileyIcon* switchSmileyIcon = CSmileyIcon::NewL(info, this); |
|
525 iSmileyIconArray.Append(switchSmileyIcon); |
|
526 iSmileyCodeIndexArray.Append(TSmileyCodeIndex(switchSmileyIcon)); |
530 |
527 |
531 info.iIndex = index++; |
528 info.iIndex = index++; |
532 info.iSkinItemID = KAknsIIDQgnIndiSwitchSct2; |
529 info.iSkinItemID = KAknsIIDQgnIndiSwitchSct2; |
533 info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_sct2; |
530 info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_sct2; |
534 iSmileyIconArray.Append(CSmileyIcon::NewL(info,this)); |
531 CSmileyIcon* switchSctIcon = CSmileyIcon::NewL(info,this); |
|
532 iSmileyIconArray.Append(switchSctIcon); |
|
533 iSmileyCodeIndexArray.Append(TSmileyCodeIndex(switchSctIcon)); |
535 |
534 |
536 } |
535 } |
537 |
536 |
538 void CSmileyModel::ReleaseResource() |
537 void CSmileyModel::ReleaseResource() |
539 { |
538 { |
545 delete iSmileyIconArray[i]; |
544 delete iSmileyIconArray[i]; |
546 iSmileyIconArray[i] = NULL; |
545 iSmileyIconArray[i] = NULL; |
547 } |
546 } |
548 iSmileyIconArray.Reset(); |
547 iSmileyIconArray.Reset(); |
549 |
548 |
|
549 iSmileyCodeIndexArray.Reset(); |
550 // reset task loader |
550 // reset task loader |
551 iSmileyLoader.DiscardAll(); |
551 iSmileyLoader.DiscardAll(); |
552 |
552 |
553 delete iTextSearchTree; |
553 delete iTextSearchTree; |
554 iTextSearchTree = NULL; |
554 iTextSearchTree = NULL; |
555 |
555 |
556 iBaseCode = 0x7FFF; // max value |
|
557 } |
556 } |
558 |
557 |
559 TInt CSmileyModel::ConvertCodesToTextL(TDes& aText) |
558 TInt CSmileyModel::ConvertCodesToTextL(TDes& aText) |
560 { |
559 { |
561 TInt converted = 0; |
560 TInt converted = 0; |
587 return converted; |
586 return converted; |
588 } |
587 } |
589 |
588 |
590 TInt CSmileyModel::ConvertTextToCodesL(TDes& aText) |
589 TInt CSmileyModel::ConvertTextToCodesL(TDes& aText) |
591 { |
590 { |
|
591 _AKNTRACE_FUNC_ENTER; |
592 TInt converted = 0; |
592 TInt converted = 0; |
593 iConvertBuffer.Zero(); |
593 iConvertBuffer.Zero(); |
594 |
594 |
595 CSmileyTextTreeNode* node = iTextSearchTree; |
595 CSmileyTextTreeNode* node = iTextSearchTree; |
596 TChar lastChar = node->LastChildChar(); |
|
597 TChar firstChar = node->FirstChildChar(); |
|
598 TInt matchedLength = 0; |
596 TInt matchedLength = 0; |
599 |
597 |
600 // deal all |
598 // deal all |
601 TInt pos = 0; |
599 TInt pos = 0; |
602 while(pos < aText.Length()) |
600 while(pos < aText.Length()) |
603 { |
601 { |
604 TChar character = aText[pos++]; |
602 TChar character = aText[pos++]; |
605 iConvertBuffer.Append(character); |
603 iConvertBuffer.Append(character); |
606 |
604 |
607 if(!(character<firstChar || character>lastChar)) // is possible |
|
608 { |
|
609 CSmileyTextTreeNode* find = node->Child(character); |
605 CSmileyTextTreeNode* find = node->Child(character); |
610 if(find) |
606 if(find) |
611 { |
607 { |
612 matchedLength++; // character is mathed |
608 matchedLength++; // character is mathed |
613 |
609 |
614 CSmileyTextTreeNode* child = find->Child(0); |
610 CSmileyTextTreeNode* child = find->Child(0); |
615 if(child && child->ChildCount()==0) // whole combination is matched |
611 TBool notFinished = (child && child->ChildCount()); |
|
612 if(notFinished) // not ended |
616 { |
613 { |
617 converted++; |
614 node = find; // match next |
618 |
615 continue; |
|
616 } |
|
617 else if(child) // whole combination is matched and ended |
|
618 { |
619 TChar code = child->Char(); |
619 TChar code = child->Char(); |
620 |
620 |
621 // replace with code |
621 // replace with code |
622 iConvertBuffer.SetLength(iConvertBuffer.Length() - matchedLength); |
622 iConvertBuffer.SetLength(iConvertBuffer.Length() - matchedLength); |
623 iConvertBuffer.Append(code); |
623 iConvertBuffer.Append(code); |
624 iConvertBuffer.Append('i'); |
624 iConvertBuffer.Append('i'); |
625 |
625 converted++; // returned value added |
626 // load thumnail |
626 // load thumnail |
627 LoadStillImageL(code); |
627 LoadStillImageL(code); |
628 |
628 |
629 // restart |
629 // restart |
630 matchedLength = 0; |
630 matchedLength = 0; |
631 node = iTextSearchTree; |
631 node = iTextSearchTree; |
|
632 continue; |
632 } |
633 } |
633 else |
634 else // in this case matchedLength already increased by 1 |
634 { |
635 { |
635 node = find; |
636 matchedLength--; |
636 } |
|
637 |
|
638 lastChar = node->LastChildChar(); |
|
639 firstChar = node->FirstChildChar(); |
|
640 continue; |
|
641 } |
637 } |
642 } |
638 } |
643 |
639 |
644 // character is not matched |
640 // matching failed |
645 if(matchedLength) |
641 if(matchedLength) |
646 { |
642 { |
|
643 // back to the 2nd char |
|
644 TInt rollBack = matchedLength; |
|
645 iConvertBuffer.SetLength(iConvertBuffer.Length() - rollBack); |
|
646 pos -= rollBack; |
|
647 |
|
648 // reset matching context |
647 matchedLength = 0; |
649 matchedLength = 0; |
648 node = iTextSearchTree; |
650 node = iTextSearchTree; |
649 lastChar = node->LastChildChar(); |
|
650 firstChar = node->FirstChildChar(); |
|
651 } |
651 } |
652 } |
652 } |
653 |
653 |
654 // replace |
654 // replace |
655 if(converted) |
655 if(converted) |
656 { |
656 { |
657 aText.Copy(iConvertBuffer); |
657 aText.Copy(iConvertBuffer); |
658 } |
658 } |
659 |
659 |
|
660 _AKNTRACE_FUNC_EXIT; |
660 return converted; |
661 return converted; |
661 } |
662 } |
662 |
663 |
663 TBool CSmileyModel::IsSmiley(TChar aCode) const |
664 TBool CSmileyModel::IsSmiley(TChar aCode) const |
664 { |
665 { |
665 return (aCode >= iBaseCode); |
666 TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
|
667 return (smileyCodeIndex>=0 && smileyCodeIndex<iSmileyCodeIndexArray.Count()); |
666 } |
668 } |
667 |
669 |
668 const TDesC& CSmileyModel::Text(TChar aCode) const |
670 const TDesC& CSmileyModel::Text(TChar aCode) const |
669 { |
671 { |
670 TInt index, variate; |
672 if(IsSmiley(aCode)) |
671 if(DecodeSmileyCode(aCode, index, variate)) |
673 { |
672 { |
674 TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
673 return Text(index, variate); |
675 return iSmileyCodeIndexArray[smileyCodeIndex].Text(); |
674 } |
676 } |
675 else |
677 else |
676 { |
678 { |
677 return KNullDesC; |
679 return KNullDesC; |
678 } |
680 } |
749 } |
751 } |
750 } |
752 } |
751 |
753 |
752 void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const TAknLayoutText& aLayout, TBool aUseLogicalToVisualConversion) const |
754 void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const TAknLayoutText& aLayout, TBool aUseLogicalToVisualConversion) const |
753 { |
755 { |
|
756 _AKNTRACE_FUNC_ENTER; |
754 // adapter variables |
757 // adapter variables |
755 const CFont* font = aLayout.Font(); |
758 const CFont* font = aLayout.Font(); |
756 TRect textRect = aLayout.TextRect(); |
759 TRect textRect = aLayout.TextRect(); |
757 TInt offset = aLayout.BaselineOffset(); |
760 TInt offset = aLayout.BaselineOffset(); |
758 CGraphicsContext::TTextAlign align = aLayout.Align(); |
761 CGraphicsContext::TTextAlign align = aLayout.Align(); |
779 { |
782 { |
780 *visualBuf = aText; // copy |
783 *visualBuf = aText; // copy |
781 TPtr ptr = visualBuf->Des(); |
784 TPtr ptr = visualBuf->Des(); |
782 |
785 |
783 TInt maxWidth = textRect.Size().iWidth; |
786 TInt maxWidth = textRect.Size().iWidth; |
784 |
|
785 // Logical to visual conversion. |
787 // Logical to visual conversion. |
786 AknBidiTextUtils::ConvertToVisualAndClip( |
788 AknBidiTextUtils::ConvertToVisualAndClip( |
787 aText, |
789 aText, |
788 ptr, |
790 ptr, |
789 *font, |
791 *font, |
790 maxWidth, |
792 maxWidth, |
791 maxWidth ); |
793 maxWidth ); |
792 |
|
793 // for smiley begin |
794 // for smiley begin |
794 const TInt length = ptr.Length(); |
795 const TInt length = ptr.Length(); |
795 if(length>1 && IsSmiley(ptr[length-2])) |
796 if(length>1 && IsSmiley(ptr[length-2])) |
796 { |
797 { |
797 if(ptr[length-1] != 'i') |
798 if(ptr[length-1] != 'i') |
909 { |
911 { |
910 CAknSmileyIcon* icon = Smiley(ptr[i]); |
912 CAknSmileyIcon* icon = Smiley(ptr[i]); |
911 if(icon) |
913 if(icon) |
912 { |
914 { |
913 TSize size = icon->Size(); |
915 TSize size = icon->Size(); |
914 TPoint tl = aBox.iTl + offset; |
916 TPoint tl = aBox.iTl; |
915 tl.iY = tl.iY - (size.iHeight + fontH) / 2; |
917 tl.iX += offset.iX; |
|
918 //tl.iY = tl.iY - size.iHeight/*(size.iHeight + fontH) / 2*/; |
916 TRect imgWindow(tl, size); |
919 TRect imgWindow(tl, size); |
917 imgWindow.Intersection(aBox); |
920 imgWindow.Intersection(aBox); |
918 if(!imgWindow.IsEmpty()) |
921 if(!imgWindow.IsEmpty()) |
919 { |
922 { |
920 TRect innerRect = TRect(imgWindow.iTl-tl,imgWindow.Size()); |
923 TRect innerRect = TRect(imgWindow.iTl-tl,imgWindow.Size()); |
926 { |
929 { |
927 metSmileyNotReady = ETrue; |
930 metSmileyNotReady = ETrue; |
928 } |
931 } |
929 } |
932 } |
930 |
933 |
931 offset += TPoint(aFont->TextWidthInPixels(ptr.Left(2)),0); |
934 //offset += TPoint(aFont->TextWidthInPixels(ptr.Left(2)),0); |
|
935 offset.iX += size.iWidth; |
932 } |
936 } |
933 |
937 |
934 ptr.Set(ptr.Right(ptr.Length()-2)); |
938 ptr.Set(ptr.Right(ptr.Length()-2)); |
935 } |
939 } |
936 } |
940 } |
937 } |
941 } |
938 |
942 |
939 CAknSmileyIcon* CSmileyModel::Smiley(TChar aCode) const |
943 CAknSmileyIcon* CSmileyModel::Smiley(TChar aCode) const |
940 { |
944 { |
941 TInt index, variate; |
945 if(IsSmiley(aCode)) |
942 if(DecodeSmileyCode(aCode, index, variate)) |
946 { |
943 { |
947 TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
944 return (*this)[index]; |
948 return iSmileyCodeIndexArray[smileyCodeIndex].Smiley(); |
945 } |
949 } |
946 else |
950 else |
947 { |
951 { |
948 return NULL; |
952 return NULL; |
949 } |
953 } |
984 TChar CSmileyModel::SwitchToSctCode() const |
988 TChar CSmileyModel::SwitchToSctCode() const |
985 { |
989 { |
986 return SmileyCode(Count()+1); |
990 return SmileyCode(Count()+1); |
987 } |
991 } |
988 |
992 |
989 TChar CSmileyModel::SmileyCode(TInt aIndex, TInt aVariate) const |
993 TChar CSmileyModel::SmileyCode(TInt aIndex, TInt aVariant) const |
990 { |
994 { |
991 return EncodeSmileyCode(aIndex, aVariate); |
995 const CAknSmileyIcon* iconWrapper = (*this)[aIndex]; |
992 } |
996 const CSmileyIcon* icon = static_cast<const CSmileyIcon*>(iconWrapper); |
993 |
997 if(icon) |
994 TChar CSmileyModel::SmileyCode(CAknSmileyIcon* aSmileyIcon) const |
998 { |
|
999 return icon->Code(aVariant); |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 return 0; |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 TChar CSmileyModel::SmileyCode(const CAknSmileyIcon* aSmileyIcon) const |
995 { |
1008 { |
996 if(aSmileyIcon) |
1009 if(aSmileyIcon) |
997 { |
1010 { |
998 CSmileyIcon* icon = static_cast<CSmileyIcon*>(aSmileyIcon); |
1011 const CSmileyIcon* icon = static_cast<const CSmileyIcon*>(aSmileyIcon); |
999 return EncodeSmileyCode(icon->Index(), 0); |
1012 return icon->Code(); |
1000 } |
1013 } |
1001 else |
1014 else |
1002 { |
1015 { |
1003 return 0; |
1016 return 0; |
1004 } |
1017 } |
1016 { |
1029 { |
1017 CSmileyIcon* icon = static_cast<CSmileyIcon*>(Smiley(aChar)); |
1030 CSmileyIcon* icon = static_cast<CSmileyIcon*>(Smiley(aChar)); |
1018 iSmileyLoader.AddTaskL(icon); |
1031 iSmileyLoader.AddTaskL(icon); |
1019 } |
1032 } |
1020 |
1033 |
1021 const TDesC& CSmileyModel::Text(TInt aIndex, TInt aVariate) const |
1034 const TDesC& CSmileyModel::Text(TInt aIndex, TInt aVariant) const |
1022 { |
1035 { |
1023 CSmileyIcon* icon = static_cast<CSmileyIcon*>((*this)[aIndex]); |
1036 CSmileyIcon* icon = static_cast<CSmileyIcon*>((*this)[aIndex]); |
1024 if(icon) |
1037 if(icon) |
1025 { |
1038 { |
1026 return icon->Text(aVariate); |
1039 return icon->Text(aVariant); |
1027 } |
1040 } |
1028 else |
1041 else |
1029 { |
1042 { |
1030 return KNullDesC; |
1043 return KNullDesC; |
1031 } |
1044 } |
1032 } |
1045 } |
1033 |
1046 |
1034 TInt CSmileyModel::ArrayCount() const |
1047 TInt CSmileyModel::ArrayCount() const |
1035 { |
1048 { |
1036 return iSmileyIconArray.Count(); |
1049 return iSmileyIconArray.Count(); |
1037 } |
1050 |
1038 |
1051 |
1039 TChar CSmileyModel::EncodeSmileyCode(TInt aIndex, TInt aVariate) const |
1052 |
1040 { |
|
1041 if(aVariate) |
|
1042 { |
|
1043 return (iBaseCode + aIndex + (aVariate<<8)); |
|
1044 } |
|
1045 else |
|
1046 { |
|
1047 return (iBaseCode + aIndex); |
|
1048 } |
|
1049 } |
|
1050 |
|
1051 #define KMaskL 0x00FF |
|
1052 |
|
1053 TBool CSmileyModel::DecodeSmileyCode(TChar aCode, TInt& aIndex, TInt& aVariate) const |
|
1054 { |
|
1055 if(aCode >= iBaseCode) |
|
1056 { |
|
1057 aIndex = (aCode&KMaskL) - (iBaseCode&KMaskL); |
|
1058 aVariate = (aCode>>8) - (iBaseCode>>8); |
|
1059 return ETrue; |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 return EFalse; |
|
1064 } |
|
1065 } |
1053 } |
1066 |
1054 |
1067 void CSmileyModel::SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon) |
1055 void CSmileyModel::SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon) |
1068 { |
1056 { |
1069 TRAP_IGNORE(iSmileyLoader.DoNextTaskL()); |
1057 TRAP_IGNORE(iSmileyLoader.DoNextTaskL()); |