author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:29:17 +0300 | |
branch | RCL_3 |
changeset 64 | 85902f042028 |
parent 56 | d48ab3b357f1 |
child 72 | a5e7a4f63858 |
permissions | -rw-r--r-- |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include <barsread.h> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <AknUtils.h> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include <aknlayoutscalable_avkon.cdl.h> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <centralrepository.h> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <AvkonInternalCRKeys.h> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
56 | 25 |
#include <AknBidiTextUtils.h> |
26 |
#include <AknPanic.h> |
|
27 |
||
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include <smiley.rsg> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
#include <smiley.mbg> |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
#include "AknSmileyModel.h" |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
#include "AknSmileyImage.h" |
56 | 33 |
#include "akntrace.h" |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
// TSmileyIconInfo |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
TSmileyIconInfo::TSmileyIconInfo() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
Reset(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
TSmileyIconInfo::TSmileyIconInfo(const TSmileyIconInfo& aInfo) : |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
iSkinItemID(aInfo.iSkinItemID), |
56 | 46 |
iDefaultStillImageID(aInfo.iDefaultStillImageID), |
47 |
iDefaultAnimationImageID(aInfo.iDefaultAnimationImageID) |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
void TSmileyIconInfo::Reset() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
iSkinItemID.Set(0, 0); |
56 | 54 |
iDefaultStillImageID = 0; |
55 |
iDefaultAnimationImageID = 0; |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
// CSmileyIcon |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
|
56 | 64 |
CSmileyIcon* CSmileyIcon::NewL(const TSmileyIconInfo& aInfo, MAknSmileyObserver* aObserver) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
{ |
56 | 66 |
CSmileyIcon* self = new (ELeave) CSmileyIcon(aObserver); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
CleanupStack::PushL(self); |
56 | 68 |
self->ConstructL(aInfo); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
CleanupStack::Pop(); // self; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
return self; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
56 | 73 |
void CSmileyIcon::ConstructL(const TSmileyIconInfo& aInfo) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
{ |
56 | 75 |
iIndex = aInfo.iIndex; |
76 |
||
77 |
iStillImage = CSmileyImage::NewL(aInfo.iSkinItemID, aInfo.iDefaultStillImageID, EFalse, this); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
|
56 | 79 |
if(aInfo.iSkinItemID.iMinor==0 && aInfo.iDefaultAnimationImageID>0) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
{ |
56 | 81 |
TAknsItemID nullID; |
82 |
nullID.Set(0, 0); |
|
83 |
iAnimationImage = CSmileyImage::NewL(nullID, aInfo.iDefaultAnimationImageID, ETrue, this); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
84 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
|
56 | 87 |
CSmileyIcon::CSmileyIcon(MAknSmileyObserver* aObserver) : iSmileyIconObserver(aObserver) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
CSmileyIcon::~CSmileyIcon() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
{ |
56 | 93 |
delete iStillImage; |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
delete iAnimationImage; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
|
56 | 96 |
iTextArray.Close(); |
97 |
iCodeArray.Close(); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
98 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
99 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
const CFbsBitmap* CSmileyIcon::Image() const |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
{ |
56 | 102 |
if(AnimationImageIsReadyToDraw()) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
return iAnimationImage->Image(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
else |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
{ |
56 | 108 |
return iStillImage->Image(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
const CFbsBitmap* CSmileyIcon::Mask() const |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
{ |
56 | 114 |
if(AnimationImageIsReadyToDraw()) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
return iAnimationImage->Mask(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
else |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
{ |
56 | 120 |
return iStillImage->Mask(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
|
56 | 124 |
TBool CSmileyIcon::ReadyToDraw() const |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
{ |
56 | 126 |
return StillImageIsReadyToDraw() || AnimationImageIsReadyToDraw(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
|
56 | 129 |
void CSmileyIcon::SetSize(const TSize& aSize) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
{ |
56 | 131 |
iStillImage->SetSize(aSize); |
132 |
||
133 |
if(iAnimationImage) |
|
134 |
{ |
|
135 |
iAnimationImage->SetSize(aSize); |
|
136 |
} |
|
137 |
} |
|
138 |
||
139 |
const TSize& CSmileyIcon::Size() const |
|
140 |
{ |
|
141 |
return iStillImage->Size(); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
void CSmileyIcon::PlayAnimationL(TInt aRepeat, TInt aDelay) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
if(iAnimationImage) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
147 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
iAnimationImage->LoadL(aRepeat, aDelay); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
void CSmileyIcon::StopAnimation() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
154 |
if(iAnimationImage) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
iAnimationImage->Release(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
|
56 | 160 |
void CSmileyIcon::BitmapChanged(CSmileyImage* aSmileyImage, CFbsBitmap* /*aBitmap*/) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
{ |
56 | 162 |
if(aSmileyImage == iStillImage) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
{ |
56 | 164 |
if(iSmileyIconObserver) iSmileyIconObserver->SmileyStillImageLoaded(this); |
165 |
} |
|
166 |
else |
|
167 |
{ |
|
168 |
if(iSmileyIconObserver) iSmileyIconObserver->SmileyAnimationChanged(this); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
|
56 | 172 |
TInt CSmileyIcon::Index() const |
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
173 |
{ |
56 | 174 |
return iIndex; |
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
} |
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
|
56 | 177 |
void CSmileyIcon::LoadStillImageL(TInt aDelay) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
{ |
56 | 179 |
iStillImage->LoadL(0, aDelay); |
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
} |
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
|
56 | 182 |
TBool CSmileyIcon::StillImageIsReadyToDraw() const |
183 |
{ |
|
184 |
return iStillImage->ReadyToDraw(); |
|
185 |
} |
|
186 |
||
187 |
TBool CSmileyIcon::AnimationImageIsReadyToDraw() const |
|
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
{ |
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
return (iAnimationImage && iAnimationImage->ReadyToDraw()); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
|
56 | 192 |
void CSmileyIcon::AddVariant(const TDesC& aText, TChar aBaseCode) |
193 |
{ |
|
194 |
TPtrC ptr(aText); |
|
195 |
TUint16 baseCode = aBaseCode; |
|
196 |
||
197 |
while(ptr.Length()) |
|
198 |
{ |
|
199 |
TInt left = ptr.Find(_L(" ")); |
|
200 |
TInt right = ptr.Length() - left - 1; |
|
201 |
if(left == KErrNotFound) |
|
202 |
{ |
|
203 |
left = ptr.Length(); |
|
204 |
right = 0; |
|
205 |
} |
|
206 |
||
207 |
iTextArray.Append(ptr.Left(left)); |
|
208 |
ptr.Set(ptr.Right(right)); |
|
209 |
iCodeArray.Append(baseCode++); |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
TInt CSmileyIcon::VariantCount() const |
|
214 |
{ |
|
215 |
return iTextArray.Count(); |
|
216 |
} |
|
217 |
const TDesC& CSmileyIcon::Text(TInt aVariant) const |
|
218 |
{ |
|
219 |
if(aVariant>=0 && aVariant<VariantCount()) |
|
220 |
{ |
|
221 |
return iTextArray[aVariant]; |
|
222 |
} |
|
223 |
else |
|
224 |
{ |
|
225 |
return KNullDesC; |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
TChar CSmileyIcon::Code(TInt aVariant) const |
|
230 |
{ |
|
231 |
if(aVariant>=0 && aVariant<VariantCount()) |
|
232 |
{ |
|
233 |
return iCodeArray[aVariant]; |
|
234 |
} |
|
235 |
else |
|
236 |
{ |
|
237 |
return 0; |
|
238 |
} |
|
239 |
} |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
242 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
// CSmileyTnumbnailAsynLoader |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
245 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
CSmileyTnumbnailAsynLoader::CSmileyTnumbnailAsynLoader() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
248 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
CSmileyTnumbnailAsynLoader::~CSmileyTnumbnailAsynLoader() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
{ |
56 | 253 |
iLoadingTaskArray.Close(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
void CSmileyTnumbnailAsynLoader::AddTaskL(CSmileyIcon* aSmileyIcon) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
if(aSmileyIcon) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
{ |
56 | 260 |
TBool isIdel = (TaskCount() == 0); |
261 |
iLoadingTaskArray.Append(aSmileyIcon); |
|
262 |
if(isIdel) |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
263 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
DoNextTaskL(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
267 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
268 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
void CSmileyTnumbnailAsynLoader::DiscardAll() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
270 |
{ |
56 | 271 |
iLoadingTaskArray.Reset(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
272 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
273 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
TInt CSmileyTnumbnailAsynLoader::TaskCount() const |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
275 |
{ |
56 | 276 |
return iLoadingTaskArray.Count(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
277 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
278 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
279 |
void CSmileyTnumbnailAsynLoader::DoNextTaskL() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
{ |
56 | 281 |
if(TaskCount() > 0) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
{ |
56 | 283 |
CSmileyIcon* icon = iLoadingTaskArray[0]; |
284 |
iLoadingTaskArray.Remove(0); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
285 |
|
56 | 286 |
if(icon->StillImageIsReadyToDraw()) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
287 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
288 |
DoNextTaskL(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
289 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
290 |
else |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
291 |
{ |
56 | 292 |
icon->LoadStillImageL(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
293 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
294 |
} |
56 | 295 |
} |
296 |
||
297 |
||
298 |
||
299 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
|
300 |
// CSmileyTextTreeNode |
|
301 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
|
302 |
||
303 |
NONSHARABLE_CLASS(CSmileyTextTreeNode) : public CBase |
|
304 |
{ |
|
305 |
public: |
|
306 |
CSmileyTextTreeNode(TChar aChar); |
|
307 |
~CSmileyTextTreeNode(); |
|
308 |
||
309 |
TChar Char() const; |
|
310 |
||
311 |
CSmileyTextTreeNode* AddTreeL(const TDesC& aText, TChar aCode); |
|
312 |
TInt ChildCount() const; |
|
313 |
CSmileyTextTreeNode* Child(TInt aIndex) const; |
|
314 |
CSmileyTextTreeNode* Child(TChar aChar) const; |
|
315 |
||
316 |
private: |
|
317 |
CSmileyTextTreeNode* AddChildAscendingL(TChar aChar); |
|
318 |
||
319 |
private: |
|
320 |
TChar iChar; |
|
321 |
||
322 |
typedef CArrayPtrFlat<CSmileyTextTreeNode> CSmileyTextTreeNodeArrayPtrFlat; |
|
323 |
CSmileyTextTreeNodeArrayPtrFlat* iChildArray; |
|
324 |
||
325 |
}; |
|
326 |
||
327 |
||
328 |
CSmileyTextTreeNode::CSmileyTextTreeNode(TChar aChar) : iChar(aChar) |
|
329 |
{ |
|
330 |
} |
|
331 |
||
332 |
CSmileyTextTreeNode::~CSmileyTextTreeNode() |
|
333 |
{ |
|
334 |
if(iChildArray) |
|
335 |
{ |
|
336 |
iChildArray->ResetAndDestroy(); |
|
337 |
delete iChildArray; |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
TChar CSmileyTextTreeNode::Char() const |
|
342 |
{ |
|
343 |
return iChar; |
|
344 |
} |
|
345 |
||
346 |
||
347 |
||
348 |
CSmileyTextTreeNode* CSmileyTextTreeNode::AddTreeL(const TDesC& aText, TChar aCode) |
|
349 |
{ |
|
350 |
TInt length = aText.Length(); |
|
351 |
if(length > 0) |
|
352 |
{ |
|
353 |
CSmileyTextTreeNode* node = AddChildAscendingL(aText[0]); |
|
354 |
return node->AddTreeL(aText.Right(length-1), aCode); |
|
355 |
} |
|
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
356 |
else |
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
357 |
{ |
56 | 358 |
return AddChildAscendingL(aCode); |
359 |
} |
|
360 |
} |
|
361 |
||
362 |
TInt CSmileyTextTreeNode::ChildCount() const |
|
363 |
{ |
|
364 |
if(iChildArray) |
|
365 |
{ |
|
366 |
return iChildArray->Count(); |
|
367 |
} |
|
368 |
else |
|
369 |
{ |
|
370 |
return 0; |
|
371 |
} |
|
372 |
} |
|
373 |
||
374 |
CSmileyTextTreeNode* CSmileyTextTreeNode::Child(TInt aIndex) const |
|
375 |
{ |
|
376 |
if(aIndex>=0 && aIndex<ChildCount()) |
|
377 |
{ |
|
378 |
return iChildArray->At(aIndex); |
|
379 |
} |
|
380 |
else |
|
381 |
{ |
|
382 |
return NULL; |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
383 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
385 |
|
56 | 386 |
CSmileyTextTreeNode* CSmileyTextTreeNode::Child(TChar aChar) const |
387 |
{ |
|
388 |
if(iChildArray) |
|
389 |
{ |
|
390 |
const TInt KFirstPos = 0; |
|
391 |
const TInt KEndPos = iChildArray->Count() - 1; |
|
392 |
if(aChar<iChildArray->At(KFirstPos)->Char() || aChar>iChildArray->At(KEndPos)->Char()) |
|
393 |
{ |
|
394 |
return NULL; |
|
395 |
} |
|
396 |
for(TInt i=KEndPos; i>=KFirstPos; i--) |
|
397 |
{ |
|
398 |
CSmileyTextTreeNode* node = iChildArray->At(i); |
|
399 |
if(node->Char() == aChar) |
|
400 |
{ |
|
401 |
return node; |
|
402 |
} |
|
403 |
} |
|
404 |
} |
|
405 |
||
406 |
return NULL; |
|
407 |
} |
|
408 |
||
409 |
CSmileyTextTreeNode* CSmileyTextTreeNode::AddChildAscendingL(TChar aChar) |
|
410 |
{ |
|
411 |
// new |
|
412 |
if(!iChildArray) |
|
413 |
{ |
|
414 |
iChildArray = new (ELeave) CSmileyTextTreeNodeArrayPtrFlat(1); |
|
415 |
} |
|
416 |
||
417 |
// sequential search |
|
418 |
TInt pos = 0; |
|
419 |
for(; pos<iChildArray->Count(); pos++) |
|
420 |
{ |
|
421 |
CSmileyTextTreeNode* node = iChildArray->At(pos); |
|
422 |
TChar character = node->Char(); |
|
423 |
if(aChar == character) |
|
424 |
{ |
|
425 |
return node; |
|
426 |
} |
|
427 |
else if(aChar < character) |
|
428 |
{ |
|
429 |
break; |
|
430 |
} |
|
431 |
} |
|
432 |
||
433 |
CSmileyTextTreeNode* node = new (ELeave) CSmileyTextTreeNode(aChar); |
|
434 |
iChildArray->InsertL(pos, node); |
|
435 |
return node; |
|
436 |
} |
|
437 |
||
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
438 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
440 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
// CSmileyModel |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
/////////////////////////////////////////////////////////////////////////////////////////////// |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
|
56 | 444 |
const TUint16 KBaseCode = 0xf880; |
445 |
//const TUint16 KBaseCodeOff = 0x7FFF; |
|
446 |
_LIT(KPlaceHolder, "\xf880i"); |
|
447 |
||
448 |
CSmileyModel::CSmileyModel(MAknSmileyObserver* aObserver) : iSmileyIconObserver(aObserver) |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
449 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
450 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
451 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
452 |
CSmileyModel::~CSmileyModel() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
453 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
454 |
ReleaseResource(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
455 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
iSmileyIconArray.Close(); |
56 | 457 |
iSmileyCodeIndexArray.Close(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
458 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
459 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
460 |
void CSmileyModel::LoadResourceL() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
if(Count() > 0) return; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
463 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
// append image resourece |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
TResourceReader reader; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
TFileName smileyRscName; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
SmileyUtils::GetCustomizableResPath(smileyRscName, KSmileyRsc); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
468 |
TInt offset = CCoeEnv::Static()->AddResourceFileL(smileyRscName); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
CCoeEnv::Static()->CreateResourceReaderLC(reader, R_SMILEY_ICONS_INFO); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
|
56 | 471 |
TUint16 codeRef = KBaseCode; |
472 |
TInt index = 0; |
|
473 |
||
474 |
iTextSearchTree = new (ELeave) CSmileyTextTreeNode(0); |
|
475 |
||
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
TInt count(reader.ReadInt16()); |
56 | 477 |
for(TInt i(0); i<count; i++) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
TSmileyIconInfo info; |
56 | 480 |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
481 |
TBool isAnimation = (reader.ReadInt16() == 1); |
15
08e69e956a8c
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
10
diff
changeset
|
482 |
TInt16 code = reader.ReadInt16(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
483 |
TInt bmpId1 = reader.ReadInt32(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
484 |
TInt maskId1 = reader.ReadInt32(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
TInt bmpId2 = reader.ReadInt32(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
TInt maskId2 = reader.ReadInt32(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
487 |
|
56 | 488 |
|
489 |
info.iIndex = index++; |
|
490 |
||
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
if(bmpId2 > 0) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
492 |
{ |
56 | 493 |
info.iDefaultStillImageID = bmpId2; |
494 |
info.iDefaultAnimationImageID = bmpId1; |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
495 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
496 |
else |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
497 |
{ |
56 | 498 |
info.iDefaultStillImageID = bmpId1; |
499 |
info.iDefaultAnimationImageID = 0; |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
500 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
501 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
502 |
TBuf<64> smileyName = reader.ReadTPtrC(); // strings |
56 | 503 |
|
504 |
CSmileyIcon* icon = CSmileyIcon::NewL(info, this); |
|
505 |
icon->AddVariant(smileyName, codeRef); |
|
506 |
iSmileyIconArray.Append(icon); |
|
507 |
||
508 |
// build text search tree |
|
509 |
for(TInt j=0; j<icon->VariantCount(); j++) |
|
510 |
{ |
|
511 |
iTextSearchTree->AddTreeL(icon->Text(j), codeRef++); |
|
512 |
iSmileyCodeIndexArray.Append(TSmileyCodeIndex(icon,j)); |
|
513 |
} |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
514 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
515 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
516 |
CCoeEnv::Static()->DeleteResourceFile(offset); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
CleanupStack::PopAndDestroy(); // reader |
56 | 518 |
|
519 |
// sct & smiley switch icon |
|
520 |
TSmileyIconInfo info; |
|
521 |
info.iIndex = index++; |
|
522 |
info.iSkinItemID = KAknsIIDQgnIndiSwitchSmiley2; |
|
523 |
info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_smiley2; |
|
524 |
CSmileyIcon* switchSmileyIcon = CSmileyIcon::NewL(info, this); |
|
525 |
iSmileyIconArray.Append(switchSmileyIcon); |
|
526 |
iSmileyCodeIndexArray.Append(TSmileyCodeIndex(switchSmileyIcon)); |
|
527 |
||
528 |
info.iIndex = index++; |
|
529 |
info.iSkinItemID = KAknsIIDQgnIndiSwitchSct2; |
|
530 |
info.iDefaultStillImageID = EMbmSmileyQgn_indi_switch_sct2; |
|
531 |
CSmileyIcon* switchSctIcon = CSmileyIcon::NewL(info,this); |
|
532 |
iSmileyIconArray.Append(switchSctIcon); |
|
533 |
iSmileyCodeIndexArray.Append(TSmileyCodeIndex(switchSctIcon)); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
534 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
536 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
537 |
void CSmileyModel::ReleaseResource() |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
538 |
{ |
56 | 539 |
if(Count() == 0) return; |
540 |
||
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
541 |
// reset array |
56 | 542 |
for(TInt i(0); i<ArrayCount(); i++) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
543 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
544 |
delete iSmileyIconArray[i]; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
545 |
iSmileyIconArray[i] = NULL; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
546 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
547 |
iSmileyIconArray.Reset(); |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
548 |
|
56 | 549 |
iSmileyCodeIndexArray.Reset(); |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
550 |
// reset task loader |
56 | 551 |
iSmileyLoader.DiscardAll(); |
552 |
||
553 |
delete iTextSearchTree; |
|
554 |
iTextSearchTree = NULL; |
|
555 |
||
556 |
} |
|
557 |
||
558 |
TInt CSmileyModel::ConvertCodesToTextL(TDes& aText) |
|
559 |
{ |
|
560 |
TInt converted = 0; |
|
561 |
iConvertBuffer.Zero(); |
|
562 |
||
563 |
// deal all |
|
564 |
TInt pos = 0; |
|
565 |
while(pos < aText.Length()) |
|
566 |
{ |
|
567 |
TChar character = aText[pos++]; |
|
568 |
if(IsSmiley(character)) |
|
569 |
{ |
|
570 |
converted++; |
|
571 |
pos++; // jump the 'i' |
|
572 |
iConvertBuffer.Append(Text(character)); |
|
573 |
} |
|
574 |
else |
|
575 |
{ |
|
576 |
iConvertBuffer.Append(character); |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
// replace |
|
581 |
if(converted) |
|
582 |
{ |
|
583 |
aText.Copy(iConvertBuffer); |
|
584 |
} |
|
585 |
||
586 |
return converted; |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
587 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
588 |
|
56 | 589 |
TInt CSmileyModel::ConvertTextToCodesL(TDes& aText) |
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
590 |
{ |
56 | 591 |
_AKNTRACE_FUNC_ENTER; |
592 |
TInt converted = 0; |
|
593 |
iConvertBuffer.Zero(); |
|
594 |
||
595 |
CSmileyTextTreeNode* node = iTextSearchTree; |
|
596 |
TInt matchedLength = 0; |
|
597 |
||
598 |
// deal all |
|
599 |
TInt pos = 0; |
|
600 |
while(pos < aText.Length()) |
|
601 |
{ |
|
602 |
TChar character = aText[pos++]; |
|
603 |
iConvertBuffer.Append(character); |
|
604 |
||
605 |
CSmileyTextTreeNode* find = node->Child(character); |
|
606 |
if(find) |
|
607 |
{ |
|
608 |
matchedLength++; // character is mathed |
|
609 |
||
610 |
CSmileyTextTreeNode* child = find->Child(0); |
|
611 |
TBool notFinished = (child && child->ChildCount()); |
|
612 |
if(notFinished) // not ended |
|
613 |
{ |
|
614 |
node = find; // match next |
|
615 |
continue; |
|
616 |
} |
|
617 |
else if(child) // whole combination is matched and ended |
|
618 |
{ |
|
619 |
TChar code = child->Char(); |
|
620 |
||
621 |
// replace with code |
|
622 |
iConvertBuffer.SetLength(iConvertBuffer.Length() - matchedLength); |
|
623 |
iConvertBuffer.Append(code); |
|
624 |
iConvertBuffer.Append('i'); |
|
625 |
converted++; // returned value added |
|
626 |
// load thumnail |
|
627 |
LoadStillImageL(code); |
|
628 |
||
629 |
// restart |
|
630 |
matchedLength = 0; |
|
631 |
node = iTextSearchTree; |
|
632 |
continue; |
|
633 |
} |
|
634 |
else // in this case matchedLength already increased by 1 |
|
635 |
{ |
|
636 |
matchedLength--; |
|
637 |
} |
|
638 |
} |
|
639 |
||
640 |
// matching failed |
|
641 |
if(matchedLength) |
|
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 |
|
649 |
matchedLength = 0; |
|
650 |
node = iTextSearchTree; |
|
651 |
} |
|
652 |
} |
|
653 |
||
654 |
// replace |
|
655 |
if(converted) |
|
656 |
{ |
|
657 |
aText.Copy(iConvertBuffer); |
|
658 |
} |
|
659 |
||
660 |
_AKNTRACE_FUNC_EXIT; |
|
661 |
return converted; |
|
662 |
} |
|
663 |
||
664 |
TBool CSmileyModel::IsSmiley(TChar aCode) const |
|
665 |
{ |
|
666 |
TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
|
667 |
return (smileyCodeIndex>=0 && smileyCodeIndex<iSmileyCodeIndexArray.Count()); |
|
668 |
} |
|
669 |
||
670 |
const TDesC& CSmileyModel::Text(TChar aCode) const |
|
671 |
{ |
|
672 |
if(IsSmiley(aCode)) |
|
673 |
{ |
|
674 |
TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
|
675 |
return iSmileyCodeIndexArray[smileyCodeIndex].Text(); |
|
676 |
} |
|
677 |
else |
|
678 |
{ |
|
679 |
return KNullDesC; |
|
680 |
} |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
681 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
682 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
683 |
void CSmileyModel::SetSize(const TSize& aSize) |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
684 |
{ |
56 | 685 |
if(ArrayCount() && iSmileyIconArray[0]->Size()!=aSize) |
686 |
{ |
|
687 |
for(TInt i(0); i<ArrayCount(); i++) |
|
688 |
{ |
|
689 |
iSmileyIconArray[i]->SetSize(aSize); |
|
690 |
} |
|
691 |
} |
|
692 |
} |
|
693 |
||
694 |
void CSmileyModel::SetSizeByFont(const CFont* aFont) |
|
695 |
{ |
|
696 |
TSize size(aFont->TextWidthInPixels(KPlaceHolder),aFont->HeightInPixels()); |
|
697 |
SetSize(size); |
|
698 |
} |
|
699 |
||
700 |
void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const CFont* aFont, const TPoint& aPosition) const |
|
701 |
{ |
|
702 |
TPtrC ptr = aText; |
|
703 |
TPoint pos = aPosition; |
|
704 |
||
705 |
aGc.UseFont(aFont); |
|
706 |
||
707 |
TBool metSmileyNotReady = EFalse; |
|
708 |
||
709 |
while(ptr.Length()) |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
710 |
{ |
56 | 711 |
TInt i = 0; |
712 |
for(; i<ptr.Length(); i++) // find next smiley code |
|
713 |
{ |
|
714 |
if(IsSmiley(ptr[i])) |
|
715 |
{ |
|
716 |
break; |
|
717 |
} |
|
718 |
} |
|
719 |
||
720 |
if(i > 0) // have text |
|
721 |
{ |
|
722 |
TPtrC txt = ptr.Left(i); |
|
723 |
aGc.DrawText(txt, pos); |
|
724 |
pos += TPoint(aFont->TextWidthInPixels(txt),0); |
|
725 |
||
726 |
ptr.Set(ptr.Right(ptr.Length()-i)); |
|
727 |
i = 0; |
|
728 |
} |
|
729 |
||
730 |
if(ptr.Length()) // breaked by smiley code |
|
731 |
{ |
|
732 |
CAknSmileyIcon* icon = Smiley(ptr[i]); |
|
733 |
if(icon) |
|
734 |
{ |
|
735 |
TSize size = icon->Size(); |
|
736 |
TPoint tl = pos; |
|
737 |
tl.iY = tl.iY - (size.iHeight + aFont->HeightInPixels()) / 2; |
|
738 |
if(!metSmileyNotReady && icon->ReadyToDraw()) |
|
739 |
{ |
|
740 |
aGc.BitBltMasked(tl, icon->Image(), TRect(size), icon->Mask(), EFalse); |
|
741 |
} |
|
742 |
else |
|
743 |
{ |
|
744 |
metSmileyNotReady = ETrue; |
|
745 |
} |
|
746 |
pos += TPoint(aFont->TextWidthInPixels(ptr.Left(2)),0); |
|
747 |
} |
|
748 |
||
749 |
ptr.Set(ptr.Right(ptr.Length()-2)); |
|
750 |
} |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
751 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
752 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
753 |
|
56 | 754 |
void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const TAknLayoutText& aLayout, TBool aUseLogicalToVisualConversion) const |
755 |
{ |
|
756 |
_AKNTRACE_FUNC_ENTER; |
|
757 |
// adapter variables |
|
758 |
const CFont* font = aLayout.Font(); |
|
759 |
TRect textRect = aLayout.TextRect(); |
|
760 |
TInt offset = aLayout.BaselineOffset(); |
|
761 |
CGraphicsContext::TTextAlign align = aLayout.Align(); |
|
762 |
||
763 |
// belows are all from |
|
764 |
// void TAknLayoutText::DrawText(CGraphicsContext& aGc,const TDesC& aText,TBool aUseLogicalToVisualConversion, const TRgb &aColor) const |
|
765 |
||
766 |
__ASSERT_DEBUG(font, Panic(EAknPanicLayoutTextNotCalled)); |
|
767 |
||
768 |
//aGc.UseFont( font ); |
|
769 |
//aGc.SetPenColor( aColor ); |
|
770 |
if ( aText.Length() ) |
|
771 |
{ |
|
772 |
HBufC* visualBuf = NULL; |
|
773 |
TPtrC text( aText ); |
|
774 |
||
775 |
if ( aUseLogicalToVisualConversion ) |
|
776 |
{ |
|
777 |
visualBuf = HBufC::New( aText.Length() + KAknBidiExtraSpacePerLine ); |
|
778 |
||
779 |
// In OOM, logical to visual conversion is not performed... |
|
780 |
||
781 |
if ( visualBuf ) |
|
782 |
{ |
|
783 |
*visualBuf = aText; // copy |
|
784 |
TPtr ptr = visualBuf->Des(); |
|
785 |
||
786 |
TInt maxWidth = textRect.Size().iWidth; |
|
787 |
// Logical to visual conversion. |
|
788 |
AknBidiTextUtils::ConvertToVisualAndClip( |
|
789 |
aText, |
|
790 |
ptr, |
|
791 |
*font, |
|
792 |
maxWidth, |
|
793 |
maxWidth ); |
|
794 |
// for smiley begin |
|
795 |
const TInt length = ptr.Length(); |
|
796 |
if(length>1 && IsSmiley(ptr[length-2])) |
|
797 |
{ |
|
798 |
if(ptr[length-1] != 'i') |
|
799 |
{ |
|
800 |
// smiley is clipped for visual, del this smiley |
|
801 |
ptr.Delete(length-2, 1); |
|
802 |
} |
|
803 |
} |
|
804 |
// for smiley end |
|
805 |
||
806 |
text.Set( ptr ); |
|
807 |
} |
|
808 |
} |
|
809 |
||
810 |
// Calculate x-offset based on the used alignment |
|
811 |
TInt margin = 0; |
|
812 |
if ( align != CGraphicsContext::ELeft ) |
|
813 |
{ |
|
814 |
// Measure the full width of the text (ie. what DrawText needs) |
|
815 |
TInt textWidth = AknBidiTextUtils::MeasureTextBoundsWidth( *font, text,CFont::TMeasureTextInput::EFVisualOrder ); |
|
816 |
||
817 |
const TInt extraWidth = textRect.Width() - textWidth; |
|
818 |
if ( align == CGraphicsContext::ECenter ) |
|
819 |
{ |
|
820 |
margin = extraWidth / 2; |
|
821 |
} |
|
822 |
else // right aligned |
|
823 |
{ |
|
824 |
margin = extraWidth; |
|
825 |
} |
|
826 |
} |
|
827 |
||
828 |
// Need to make the drawing rectangle bigger to account for underlines |
|
829 |
TRect drawRect(textRect); |
|
830 |
TInt height = drawRect.Height(); |
|
831 |
// The underline position is not available from the GC. The following code imitates what Symbian CFbsBitGC implements. |
|
832 |
// (height-offset) is the part below the baseline. Check if it sufficient |
|
833 |
TInt extraHeightForUnderlining = 1 + Max(1, height/10)-(height-offset); |
|
834 |
if ( extraHeightForUnderlining > 0 ) |
|
835 |
drawRect.iBr.iY += extraHeightForUnderlining; |
|
836 |
||
837 |
// for smiley |
|
838 |
//aGc.DrawText( text, drawRect, offset, CGraphicsContext::ELeft, margin ); |
|
839 |
DrawText(aGc, text, font, drawRect, offset, CGraphicsContext::ELeft, margin); |
|
840 |
||
841 |
delete visualBuf; |
|
842 |
} |
|
843 |
||
844 |
//aGc.DiscardFont(); // Release the font cache |
|
845 |
_AKNTRACE_FUNC_EXIT; |
|
846 |
} |
|
847 |
||
848 |
void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const CFont* aFont, const TRect& aBox, TInt aBaselineOffset, |
|
849 |
CGraphicsContext::TTextAlign aAlignment, TInt aLeftMargin) const |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
850 |
{ |
56 | 851 |
TInt boxWidth = aBox.Width(); |
852 |
TInt textWidth = aFont->TextWidthInPixels(aText); |
|
853 |
||
854 |
TPoint offset; |
|
855 |
offset.iY = aBaselineOffset; |
|
856 |
||
857 |
switch(aAlignment) |
|
858 |
{ |
|
859 |
case CGraphicsContext::ELeft: |
|
860 |
offset.iX = aLeftMargin; |
|
861 |
break; |
|
862 |
||
863 |
case CGraphicsContext::ERight: |
|
864 |
offset.iX = boxWidth - textWidth - aLeftMargin; |
|
865 |
break; |
|
866 |
||
867 |
case CGraphicsContext::ECenter: |
|
868 |
offset.iX = (boxWidth - textWidth) / 2; |
|
869 |
break; |
|
870 |
||
871 |
default: |
|
872 |
break; |
|
873 |
} |
|
874 |
||
875 |
DrawText(aGc, aText, aFont, aBox, offset); |
|
876 |
} |
|
877 |
||
878 |
void CSmileyModel::DrawText(CWindowGc& aGc, const TDesC& aText, const CFont* aFont, const TRect& aBox, const TPoint& aOffset) const |
|
879 |
{ |
|
880 |
TPtrC ptr = aText; |
|
881 |
TPoint offset = aOffset; |
|
882 |
||
883 |
aGc.UseFont(aFont); |
|
884 |
||
885 |
TInt fontH = aFont->FontMaxHeight(); |
|
886 |
||
887 |
TBool metSmileyNotReady = EFalse; |
|
888 |
||
889 |
while(ptr.Length()) |
|
890 |
{ |
|
891 |
TInt i = 0; |
|
892 |
for(; i<ptr.Length(); i++) // find next smiley code |
|
893 |
{ |
|
894 |
if(IsSmiley(ptr[i])) |
|
895 |
{ |
|
896 |
break; |
|
897 |
} |
|
898 |
} |
|
899 |
||
900 |
if(i > 0) // have text |
|
901 |
{ |
|
902 |
TPtrC txt = ptr.Left(i); |
|
903 |
aGc.DrawText(txt, aBox, offset.iY, CGraphicsContext::ELeft, offset.iX); |
|
904 |
offset.iX += aFont->TextWidthInPixels(txt); |
|
905 |
||
906 |
ptr.Set(ptr.Right(ptr.Length()-i)); |
|
907 |
i = 0; |
|
908 |
} |
|
909 |
||
910 |
if(ptr.Length()) // breaked by smiley code |
|
911 |
{ |
|
912 |
CAknSmileyIcon* icon = Smiley(ptr[i]); |
|
913 |
if(icon) |
|
914 |
{ |
|
915 |
TSize size = icon->Size(); |
|
916 |
TPoint tl = aBox.iTl; |
|
917 |
tl.iX += offset.iX; |
|
918 |
//tl.iY = tl.iY - size.iHeight/*(size.iHeight + fontH) / 2*/; |
|
919 |
TRect imgWindow(tl, size); |
|
920 |
imgWindow.Intersection(aBox); |
|
921 |
if(!imgWindow.IsEmpty()) |
|
922 |
{ |
|
923 |
TRect innerRect = TRect(imgWindow.iTl-tl,imgWindow.Size()); |
|
924 |
if(!metSmileyNotReady && icon->ReadyToDraw()) |
|
925 |
{ |
|
926 |
aGc.BitBltMasked(imgWindow.iTl, icon->Image(), innerRect, icon->Mask(), EFalse); |
|
927 |
} |
|
928 |
else |
|
929 |
{ |
|
930 |
metSmileyNotReady = ETrue; |
|
931 |
} |
|
932 |
} |
|
933 |
||
934 |
//offset += TPoint(aFont->TextWidthInPixels(ptr.Left(2)),0); |
|
935 |
offset.iX += size.iWidth; |
|
936 |
} |
|
937 |
||
938 |
ptr.Set(ptr.Right(ptr.Length()-2)); |
|
939 |
} |
|
940 |
} |
|
941 |
} |
|
942 |
||
943 |
CAknSmileyIcon* CSmileyModel::Smiley(TChar aCode) const |
|
944 |
{ |
|
945 |
if(IsSmiley(aCode)) |
|
946 |
{ |
|
947 |
TInt smileyCodeIndex = (TUint16)aCode - KBaseCode; |
|
948 |
return iSmileyCodeIndexArray[smileyCodeIndex].Smiley(); |
|
949 |
} |
|
950 |
else |
|
951 |
{ |
|
952 |
return NULL; |
|
953 |
} |
|
954 |
} |
|
955 |
||
956 |
CAknSmileyIcon* CSmileyModel::operator[](TInt aIndex) const |
|
957 |
{ |
|
958 |
if(aIndex>=0 && aIndex<ArrayCount()) |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
959 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
960 |
return iSmileyIconArray[aIndex]; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
961 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
962 |
else |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
963 |
{ |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
964 |
return NULL; |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
965 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
966 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
967 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
968 |
TInt CSmileyModel::Count() const |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
969 |
{ |
56 | 970 |
return iSmileyIconArray.Count() - 2; |
971 |
} |
|
972 |
||
973 |
CAknSmileyIcon* CSmileyModel::SwitchToSmileyIcon() const |
|
974 |
{ |
|
975 |
return (*this)[Count()]; |
|
976 |
} |
|
977 |
||
978 |
CAknSmileyIcon* CSmileyModel::SwitchToSctIcon() const |
|
979 |
{ |
|
980 |
return (*this)[Count()+1]; |
|
981 |
} |
|
982 |
||
983 |
TChar CSmileyModel::SwitchToSmileyCode() const |
|
984 |
{ |
|
985 |
return SmileyCode(Count()); |
|
986 |
} |
|
987 |
||
988 |
TChar CSmileyModel::SwitchToSctCode() const |
|
989 |
{ |
|
990 |
return SmileyCode(Count()+1); |
|
991 |
} |
|
992 |
||
993 |
TChar CSmileyModel::SmileyCode(TInt aIndex, TInt aVariant) const |
|
994 |
{ |
|
995 |
const CAknSmileyIcon* iconWrapper = (*this)[aIndex]; |
|
996 |
const CSmileyIcon* icon = static_cast<const CSmileyIcon*>(iconWrapper); |
|
997 |
if(icon) |
|
998 |
{ |
|
999 |
return icon->Code(aVariant); |
|
1000 |
} |
|
1001 |
else |
|
1002 |
{ |
|
1003 |
return 0; |
|
1004 |
} |
|
1005 |
} |
|
1006 |
||
1007 |
TChar CSmileyModel::SmileyCode(const CAknSmileyIcon* aSmileyIcon) const |
|
1008 |
{ |
|
1009 |
if(aSmileyIcon) |
|
1010 |
{ |
|
1011 |
const CSmileyIcon* icon = static_cast<const CSmileyIcon*>(aSmileyIcon); |
|
1012 |
return icon->Code(); |
|
1013 |
} |
|
1014 |
else |
|
1015 |
{ |
|
1016 |
return 0; |
|
1017 |
} |
|
1018 |
} |
|
1019 |
||
1020 |
void CSmileyModel::LoadStillImagesL(const TDesC& aText) |
|
1021 |
{ |
|
1022 |
for(TInt i(0); i<aText.Length(); i++) |
|
1023 |
{ |
|
1024 |
LoadStillImageL(aText[i]); |
|
1025 |
} |
|
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1026 |
} |
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1027 |
|
56 | 1028 |
void CSmileyModel::PlayAnimationL(const TDesC& aText, TInt aRepeat, TInt aDelay) |
1029 |
{ |
|
1030 |
for(TInt i(0); i<aText.Length(); i++) |
|
1031 |
{ |
|
1032 |
PlayAnimationL(aText[i], aRepeat, aDelay); |
|
1033 |
} |
|
1034 |
} |
|
1035 |
||
1036 |
void CSmileyModel::StopAnimation(const TDesC& aText) |
|
51
fcdfafb36fe7
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1037 |
{ |
56 | 1038 |
for(TInt i(0); i<aText.Length(); i++) |
1039 |
{ |
|
1040 |
StopAnimation(aText[i]); |
|
1041 |
} |
|
1042 |
} |
|
51
fcdfafb36fe7
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1043 |
|
56 | 1044 |
void CSmileyModel::LoadStillImageL(TChar aChar) |
1045 |
{ |
|
1046 |
CSmileyIcon* icon = static_cast<CSmileyIcon*>(Smiley(aChar)); |
|
1047 |
iSmileyLoader.AddTaskL(icon); |
|
1048 |
} |
|
1049 |
||
1050 |
void CSmileyModel::PlayAnimationL(TChar aChar, TInt aRepeat, TInt aDelay) |
|
1051 |
{ |
|
1052 |
CSmileyIcon* icon = static_cast<CSmileyIcon*>(Smiley(aChar)); |
|
1053 |
if(icon) icon->PlayAnimationL(aRepeat, aDelay); |
|
51
fcdfafb36fe7
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1054 |
} |
fcdfafb36fe7
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1055 |
|
56 | 1056 |
void CSmileyModel::StopAnimation(TChar aChar) |
1057 |
{ |
|
1058 |
CSmileyIcon* icon = static_cast<CSmileyIcon*>(Smiley(aChar)); |
|
1059 |
if(icon) icon->StopAnimation(); |
|
1060 |
} |
|
1061 |
||
1062 |
const TDesC& CSmileyModel::Text(TInt aIndex, TInt aVariant) const |
|
9
aabf2c525e0f
Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1063 |
{ |
56 | 1064 |
CSmileyIcon* icon = static_cast<CSmileyIcon*>((*this)[aIndex]); |
1065 |
if(icon) |
|
1066 |
{ |
|
1067 |
return icon->Text(aVariant); |
|
1068 |
} |
|
1069 |
else |
|
1070 |
{ |
|
1071 |
return KNullDesC; |
|
1072 |
} |
|
1073 |
} |
|
1074 |
||
1075 |
TInt CSmileyModel::ArrayCount() const |
|
1076 |
{ |
|
1077 |
return iSmileyIconArray.Count(); |
|
1078 |
||
1079 |
||
1080 |
||
1081 |
} |
|
1082 |
||
1083 |
void CSmileyModel::SmileyStillImageLoaded(CAknSmileyIcon* aSmileyIcon) |
|
1084 |
{ |
|
1085 |
TRAP_IGNORE(iSmileyLoader.DoNextTaskL()); |
|
1086 |
||
1087 |
if(iSmileyIconObserver) iSmileyIconObserver->SmileyStillImageLoaded(aSmileyIcon); |
|
1088 |
} |
|
1089 |
||
1090 |
void CSmileyModel::SmileyAnimationChanged(CAknSmileyIcon* aSmileyIcon) |
|
1091 |
{ |
|
1092 |
if(iSmileyIconObserver) iSmileyIconObserver->SmileyAnimationChanged(aSmileyIcon); |
|
0
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1093 |
} |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1094 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1095 |
|
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1096 |
// end of file |
2f259fa3e83a
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1097 |