26 #include "cautils.h" |
26 #include "cautils.h" |
27 #include "cainnerentry.h" |
27 #include "cainnerentry.h" |
28 #include "camenuiconutility.h" |
28 #include "camenuiconutility.h" |
29 #include "caarraycleanup.inl" |
29 #include "caarraycleanup.inl" |
30 #include "casathandler.h" |
30 #include "casathandler.h" |
31 // Constants |
|
32 _LIT( KMifIconPath, "\\resource\\apps\\" ); |
|
33 const TUint32 KMifIconPathLenght = 18; |
|
34 |
31 |
35 // ================= LOCAL FUNCTIONS ======================== |
32 // ================= LOCAL FUNCTIONS ======================== |
36 |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // ParseIconFilePathL |
|
40 // --------------------------------------------------------- |
|
41 // |
|
42 |
|
43 LOCAL_C void ParseIconFilePathL( const TDesC& aIconFilePath, |
|
44 RBuf& aIconFilePathBuf ) |
|
45 { |
|
46 TParsePtrC fileParsePtrC( aIconFilePath ); |
|
47 if( !fileParsePtrC.PathPresent() ) |
|
48 { |
|
49 aIconFilePathBuf.CreateL( KMifIconPathLenght |
|
50 + aIconFilePath.Length() ); |
|
51 aIconFilePathBuf.Append( KMifIconPath ); |
|
52 } |
|
53 else |
|
54 { |
|
55 aIconFilePathBuf.CreateL( aIconFilePath.Length() ); |
|
56 } |
|
57 aIconFilePathBuf.Append( aIconFilePath ); |
|
58 } |
|
59 |
33 |
60 // --------------------------------------------------------- |
34 // --------------------------------------------------------- |
61 // LoadSkinL |
35 // LoadSkinL |
62 // --------------------------------------------------------- |
36 // --------------------------------------------------------- |
63 // |
37 // |
117 } |
91 } |
118 } |
92 } |
119 return icon; |
93 return icon; |
120 } |
94 } |
121 |
95 |
122 // --------------------------------------------------------- |
|
123 // GetIconL |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 LOCAL_C CAknIcon* GetIconL( TFileName aFilename, int aBitmapId, int aMaskId ) |
|
127 { |
|
128 CAknIcon* icon = NULL; |
|
129 if( aFilename.Length() > 0 && aBitmapId >= 0 && aMaskId >= 0 ) |
|
130 { |
|
131 CFbsBitmap* bitmap( 0 ); |
|
132 CFbsBitmap* mask( 0 ); |
|
133 |
|
134 RBuf pathBuf; |
|
135 pathBuf.CleanupClosePushL(); |
|
136 ParseIconFilePathL( aFilename, pathBuf ); |
|
137 |
|
138 AknIconUtils::CreateIconLC( bitmap, mask, pathBuf, aBitmapId, |
|
139 aMaskId ); |
|
140 icon = CAknIcon::NewL(); |
|
141 icon->SetBitmap( bitmap ); |
|
142 icon->SetMask( mask ); |
|
143 CleanupStack::Pop( 2 ); |
|
144 CleanupStack::PopAndDestroy( &pathBuf ); |
|
145 } |
|
146 return icon; |
|
147 } |
|
148 |
96 |
149 // --------------------------------------------------------- |
97 // --------------------------------------------------------- |
150 // GetDefaultSkinL |
98 // GetDefaultSkinL |
151 // --------------------------------------------------------- |
99 // --------------------------------------------------------- |
152 // |
100 // |
189 else if( aItem.GetEntryTypeName().Compare( KCaTypeWidget ) == KErrNone ) |
137 else if( aItem.GetEntryTypeName().Compare( KCaTypeWidget ) == KErrNone ) |
190 { |
138 { |
191 icon = GetSkinL( KAknsIIDQgnIndiBrowserTbFeeds.iMajor, |
139 icon = GetSkinL( KAknsIIDQgnIndiBrowserTbFeeds.iMajor, |
192 KAknsIIDQgnIndiBrowserTbFeeds.iMinor ); |
140 KAknsIIDQgnIndiBrowserTbFeeds.iMinor ); |
193 } |
141 } |
|
142 else if( aItem.GetEntryTypeName().Compare( KCaTypeTemplatedApp ) == KErrNone ) |
|
143 { |
|
144 TInt uid; |
|
145 TLex lex (aItem.GetIcon().iApplicationId); |
|
146 lex.Val(uid); |
|
147 TUid appUid( TUid::Uid( uid ) ); |
|
148 icon = GetAppSkinL( appUid ); |
|
149 if( !icon ) |
|
150 { |
|
151 icon = GetSkinL( KAknsIIDQgnMenuUnknownLst.iMajor, |
|
152 KAknsIIDQgnMenuUnknownLst.iMinor ); |
|
153 } |
|
154 } |
|
155 |
194 return icon; |
156 return icon; |
195 } |
157 } |
196 |
158 |
197 // ================= MEMBER FUNCTIONS ======================= |
159 // ================= MEMBER FUNCTIONS ======================= |
198 |
160 |
203 EXPORT_C CAknIcon* CaMenuIconUtility::GetItemIcon( |
165 EXPORT_C CAknIcon* CaMenuIconUtility::GetItemIcon( |
204 const CCaInnerEntry &aEntry ) |
166 const CCaInnerEntry &aEntry ) |
205 { |
167 { |
206 CAknIcon* icon = NULL; |
168 CAknIcon* icon = NULL; |
207 CCaInnerEntry::TIconAttributes iconAttributes( aEntry.GetIcon() ); |
169 CCaInnerEntry::TIconAttributes iconAttributes( aEntry.GetIcon() ); |
208 // Try to get the skin of the item |
170 TRAP_IGNORE( icon = GetDefaultSkinL( aEntry ) ); |
209 TRAP_IGNORE(icon = GetSkinL( iconAttributes.iSkinMajorId, |
|
210 iconAttributes.iSkinMinorId ) ); |
|
211 if( !icon ) |
|
212 { |
|
213 // Try to get the icon of the item (skin failed) |
|
214 TRAP_IGNORE( icon = GetIconL( iconAttributes.iFileName, |
|
215 iconAttributes.iBitmapId, |
|
216 iconAttributes.iMaskId ) ); |
|
217 if( !icon ) |
|
218 { |
|
219 // Return a default (skin and icon failed) |
|
220 TRAP_IGNORE( icon = GetDefaultSkinL( aEntry ) ); |
|
221 } |
|
222 } |
|
223 return icon; |
171 return icon; |
224 } |
172 } |