|
1 /* |
|
2 * Copyright (c) 2002-2009 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: AVKON smiley data model. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef AKNSMILEYMODEL_H |
|
22 #define AKNSMILEYMODEL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <AknIconObserver.h> |
|
26 |
|
27 #include "AknSmileyImage.h" |
|
28 |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 |
|
33 //////////////////////////////////////////////////////////////////// |
|
34 |
|
35 const TInt KSmileyNameLength = 8; |
|
36 |
|
37 NONSHARABLE_CLASS(TSmileyIconInfo) |
|
38 { |
|
39 public: |
|
40 TSmileyIconInfo(); |
|
41 TSmileyIconInfo(const TSmileyIconInfo& aInfo); |
|
42 void Reset(); |
|
43 |
|
44 TBuf<KSmileyNameLength> iName; |
|
45 TInt iId; |
|
46 TAknsItemID iSkinItemID; // from skin |
|
47 TInt iDefaultThumbnailID; // from mif |
|
48 TInt iDefaultAnimationID; // from mif |
|
49 }; |
|
50 |
|
51 //////////////////////////////////////////////////////////////////// |
|
52 |
|
53 class CSmileyIcon; |
|
54 |
|
55 class MSmileyIconObserver |
|
56 { |
|
57 public: |
|
58 virtual void ThumbnailLoaded(CSmileyIcon* aSmileyIcon)=0; |
|
59 virtual void AnimationChanged(CSmileyIcon* aSmileyIcon)=0; |
|
60 }; |
|
61 |
|
62 //////////////////////////////////////////////////////////////////// |
|
63 |
|
64 class CSmileyIcon : public CBase, public MSmileyImageObserver |
|
65 { |
|
66 public: |
|
67 static CSmileyIcon* NewL(const TSmileyIconInfo& aInfo, MSmileyIconObserver* aObserver); |
|
68 virtual ~CSmileyIcon(); |
|
69 |
|
70 private: |
|
71 CSmileyIcon(const TSmileyIconInfo& aInfo, MSmileyIconObserver* aObserver); |
|
72 void ConstructL(); |
|
73 |
|
74 public: |
|
75 const TDesC& Name() const { return iInfo.iName; } |
|
76 TInt Id() const { return iInfo.iId; } |
|
77 |
|
78 TBool ReadyToDraw() const; |
|
79 const CFbsBitmap* Image() const; |
|
80 const CFbsBitmap* Mask() const; |
|
81 |
|
82 public: |
|
83 void LoadThumbnailL(); |
|
84 TBool ThumbnailReady() const; |
|
85 |
|
86 void PlayAnimationL(TInt aRepeat, TInt aDelay); |
|
87 void StopAnimation(); |
|
88 |
|
89 public: |
|
90 void SetSize(const TSize& aSize); |
|
91 const TSize& Size() const; |
|
92 |
|
93 private: // from MSmileyImageObserver |
|
94 virtual void BitmapChanged(CSmileyImage* aSmileyImage, CFbsBitmap* aBitmap); |
|
95 |
|
96 private: |
|
97 TBool ShouldShowAnimation() const; |
|
98 |
|
99 private: |
|
100 const TSmileyIconInfo iInfo; |
|
101 MSmileyIconObserver* iSmileyIconObserver; |
|
102 |
|
103 CSmileyImage* iThumbnailImage; |
|
104 CSmileyImage* iAnimationImage; |
|
105 |
|
106 }; |
|
107 |
|
108 typedef RArray<CSmileyIcon*> RSmileyIconPtrArray; |
|
109 |
|
110 |
|
111 //////////////////////////////////////////////////////////////////// |
|
112 |
|
113 class CSmileyTnumbnailAsynLoader : public CBase |
|
114 { |
|
115 public: |
|
116 CSmileyTnumbnailAsynLoader(); |
|
117 ~CSmileyTnumbnailAsynLoader(); |
|
118 |
|
119 void AddTaskL(CSmileyIcon* aSmileyIcon); |
|
120 void DiscardAll(); |
|
121 TInt TaskCount() const; |
|
122 void DoNextTaskL(); |
|
123 |
|
124 private: |
|
125 RSmileyIconPtrArray iTaskArray; |
|
126 TBool iIsLoading; |
|
127 |
|
128 }; |
|
129 |
|
130 //////////////////////////////////////////////////////////////////// |
|
131 |
|
132 class CSmileyModel : public CBase, public MSmileyIconObserver |
|
133 { |
|
134 public: |
|
135 CSmileyModel(MSmileyIconObserver* aObserver); |
|
136 ~CSmileyModel(); |
|
137 |
|
138 public: |
|
139 void LoadResourceL(); |
|
140 void ReleaseResource(); |
|
141 void LoadThumbnailAsyn(TInt aIndex); |
|
142 void SetSize(const TSize& aSize); |
|
143 |
|
144 public: |
|
145 enum TIconId |
|
146 { |
|
147 EIconSwitchToSmiley = 0, |
|
148 EIconSwitchToSct, |
|
149 EIconSmiley |
|
150 }; |
|
151 |
|
152 CSmileyIcon* operator[](TInt aIndex) const; |
|
153 TInt Count() const; |
|
154 |
|
155 private: // from MSmileyIconObserver |
|
156 virtual void ThumbnailLoaded(CSmileyIcon* aSmileyIcon); |
|
157 virtual void AnimationChanged(CSmileyIcon* aSmileyIcon); |
|
158 |
|
159 private: |
|
160 MSmileyIconObserver* iSmileyIconObserver; |
|
161 RSmileyIconPtrArray iSmileyIconArray; |
|
162 CSmileyTnumbnailAsynLoader iSmileyThumbnailLoader; |
|
163 |
|
164 }; |
|
165 |
|
166 #endif // AKNSMILEYMODEL_H |