1 /* |
|
2 * Copyright (c) 2008 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: The API supports requesting raw bitmaps |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32base.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <satdomainpskeys.h> |
|
22 #include <e32property.h> |
|
23 #include <apgcli.h> |
|
24 #include <AknInternalIconUtils.h> |
|
25 #include "cadef.h" |
|
26 #include "cautils.h" |
|
27 #include "cainnerentry.h" |
|
28 #include "camenuiconutility.h" |
|
29 #include "caarraycleanup.inl" |
|
30 #include "casathandler.h" |
|
31 |
|
32 // ================= LOCAL FUNCTIONS ======================== |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // LoadSkinL |
|
36 // --------------------------------------------------------- |
|
37 // |
|
38 LOCAL_C CAknIcon* GetSkinL( TInt majorId, TInt minorId ) |
|
39 { |
|
40 CAknIcon* icon = NULL; |
|
41 if( majorId >= 0 && minorId >= 0 ) |
|
42 { |
|
43 CFbsBitmap* bitmap( 0 ); |
|
44 CFbsBitmap* mask( 0 ); |
|
45 |
|
46 TAknsItemID skinId; |
|
47 skinId.Set( majorId, minorId ); |
|
48 |
|
49 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
50 if( skinInstance ) |
|
51 { |
|
52 AknsUtils::CreateIconLC( skinInstance, skinId, bitmap, mask, |
|
53 KNullDesC, KErrNotFound, KErrNotFound ); |
|
54 icon = CAknIcon::NewL(); |
|
55 icon->SetBitmap( bitmap ); |
|
56 icon->SetMask( mask ); |
|
57 } |
|
58 |
|
59 // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order |
|
60 CleanupStack::Pop( 2 ); |
|
61 } |
|
62 |
|
63 return icon; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // GetAppSkinL |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 LOCAL_C CAknIcon* GetAppSkinL( TUid& aAppUid ) |
|
71 { |
|
72 CAknIcon* icon = NULL; |
|
73 CFbsBitmap* bitmap( 0 ); |
|
74 CFbsBitmap* mask( 0 ); |
|
75 |
|
76 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
77 if( skin ) |
|
78 { |
|
79 TRAPD( err, |
|
80 { |
|
81 AknsUtils::CreateAppIconLC( skin, aAppUid, |
|
82 EAknsAppIconTypeList, bitmap, mask ); |
|
83 CleanupStack::Pop(2); //for trap |
|
84 } |
|
85 ); |
|
86 if( err == KErrNone ) |
|
87 { |
|
88 icon = CAknIcon::NewL(); |
|
89 icon->SetBitmap( bitmap ); |
|
90 icon->SetMask( mask ); |
|
91 } |
|
92 } |
|
93 return icon; |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // GetDefaultSkinL |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 LOCAL_C CAknIcon* GetDefaultSkinL( const CCaInnerEntry &aItem ) |
|
102 { |
|
103 CAknIcon* icon = NULL; |
|
104 if( aItem.GetEntryTypeName().Compare( KCaTypeApp ) == KErrNone ) |
|
105 { |
|
106 TUid appUid( TUid::Uid( aItem.GetUid() ) ); |
|
107 if( appUid == KSatUid ) |
|
108 { |
|
109 CCaSatHandler* satHandler = CCaSatHandler::NewL(); |
|
110 CleanupStack::PushL( satHandler ); |
|
111 icon = satHandler->LoadIconL(); |
|
112 CleanupStack::PopAndDestroy( satHandler ); |
|
113 } |
|
114 if( !icon ) |
|
115 { |
|
116 icon = GetAppSkinL( appUid ); |
|
117 } |
|
118 if( !icon ) |
|
119 { |
|
120 icon = GetSkinL( KAknsIIDQgnMenuUnknownLst.iMajor, |
|
121 KAknsIIDQgnMenuUnknownLst.iMinor ); |
|
122 } |
|
123 } |
|
124 else if( aItem.GetEntryTypeName().Compare( KCaTypeFolder ) == KErrNone |
|
125 || aItem.GetEntryTypeName().Compare( KCaTypeCollection ) |
|
126 == KErrNone || aItem.GetEntryTypeName().Compare( |
|
127 KCaTypeCollectionDownload ) == KErrNone ) |
|
128 { |
|
129 icon = GetSkinL( KAknsIIDQgnPropFolderAppsMedium.iMajor, |
|
130 KAknsIIDQgnPropFolderAppsMedium.iMinor ); |
|
131 } |
|
132 else if( aItem.GetEntryTypeName().Compare( KCaTypeUrl ) == KErrNone ) |
|
133 { |
|
134 icon = GetSkinL( KAknsIIDQgnPropPbCommUrl.iMajor, |
|
135 KAknsIIDQgnPropPbCommUrl.iMinor ); |
|
136 } |
|
137 else if( aItem.GetEntryTypeName().Compare( KCaTypeWidget ) == KErrNone ) |
|
138 { |
|
139 icon = GetSkinL( KAknsIIDQgnIndiBrowserTbFeeds.iMajor, |
|
140 KAknsIIDQgnIndiBrowserTbFeeds.iMinor ); |
|
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 |
|
156 return icon; |
|
157 } |
|
158 |
|
159 // ================= MEMBER FUNCTIONS ======================= |
|
160 |
|
161 // --------------------------------------------------------- |
|
162 // MenuIconUtility::GetItemIcon |
|
163 // --------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C CAknIcon* CaMenuIconUtility::GetItemIcon( |
|
166 const CCaInnerEntry &aEntry ) |
|
167 { |
|
168 CAknIcon* icon = NULL; |
|
169 CCaInnerEntry::TIconAttributes iconAttributes( aEntry.GetIcon() ); |
|
170 TRAP_IGNORE( icon = GetDefaultSkinL( aEntry ) ); |
|
171 return icon; |
|
172 } |
|