1 /* |
|
2 * Copyright (c) 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: Utility class for loading Application Icons |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <AknsUtils.h> |
|
21 #include <gulicon.h> |
|
22 #include <fbs.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 #include <s32mem.h> |
|
25 #include <SVGEngineInterfaceImpl.h> |
|
26 #include <AknUtils.h> |
|
27 #include <aknlayoutscalable_avkon.cdl.h> |
|
28 #include <aknlayout2def.h> |
|
29 #include <lcicons.mbg> |
|
30 |
|
31 // USER INCLUDES |
|
32 #include "lciconloader.h" |
|
33 #include "lcipcparams.h" |
|
34 |
|
35 |
|
36 // CONSTANT DEFINITION |
|
37 _LIT( KLcDefaultIconFileName, "lcicons.mif" ); |
|
38 |
|
39 // ========================= MEMBER FUNCTIONS ================================ |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // EXPORT_C CGulIcon* LcIconLoader::LoadApplicationIconL |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CGulIcon* LcIconLoader::LoadApplicationIconL( const TUid aAppUid ) |
|
46 { |
|
47 CGulIcon* icon = NULL; |
|
48 TRAPD( error, icon = LoadIconfromUIDL( aAppUid )); |
|
49 if( error ) |
|
50 { |
|
51 icon = LoadDefaultIconL(); |
|
52 } |
|
53 |
|
54 return icon; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // EXPORT_C CGulIcon* LcIconLoader::LoadMifFileIconL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CGulIcon* LcIconLoader::LoadMifFileIconL( |
|
62 const TDesC& aAppIconFile, |
|
63 TInt aFrameNo ) |
|
64 { |
|
65 CGulIcon* icon = NULL; |
|
66 TRAPD( error, icon = LoadIconFromMifFileL( aAppIconFile, aFrameNo )); |
|
67 if( error ) |
|
68 { |
|
69 icon = LoadDefaultIconL(); |
|
70 } |
|
71 return icon; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // EXPORT_C CGulIcon* LcIconLoader::LoadDefaultIconL |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 EXPORT_C CGulIcon* LcIconLoader::LoadDefaultIconL() |
|
79 { |
|
80 TFileName dllFileName; |
|
81 Dll::FileName( dllFileName ); |
|
82 |
|
83 TParse parse; |
|
84 User::LeaveIfError( parse.Set( KLcDefaultIconFileName, &KDC_APP_BITMAP_DIR, &dllFileName )); |
|
85 TFileName fileName( parse.FullName()); |
|
86 |
|
87 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
88 AknsUtils::SkinInstance(), |
|
89 KAknsIIDQgnPropSetDeviceSub, |
|
90 fileName, |
|
91 EMbmLciconsQgn_menu_am_sis, |
|
92 EMbmLciconsQgn_menu_am_sis_mask ); |
|
93 |
|
94 return icon; |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CGulIcon* LcIconLoader::LoadIconFromFileL |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CGulIcon* LcIconLoader::LoadIconfromUIDL( const TUid aAppUid ) |
|
102 { |
|
103 // Create the Icon and the mask for the Application using AknUtils |
|
104 CFbsBitmap* bitmap = NULL; |
|
105 CFbsBitmap* mask = NULL; |
|
106 AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(), |
|
107 aAppUid, |
|
108 EAknsAppIconTypeList, |
|
109 bitmap, |
|
110 mask ); |
|
111 |
|
112 User::LeaveIfNull( bitmap ); |
|
113 User::LeaveIfNull( mask ); |
|
114 |
|
115 // If the bitmap and the mask exists then make it into a GulIcon |
|
116 // which can then be retured. |
|
117 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
118 icon->SetBitmapsOwnedExternally( EFalse ); |
|
119 |
|
120 // Not specifying the order because we dont know the order in which they |
|
121 // would be created. Though its generally, the bitmap first and then the |
|
122 // mask, we should be speculating. |
|
123 CleanupStack::Pop( 2 ); |
|
124 return icon; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CGulIcon* LcIconLoader::LoadIconFromMifFileL |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 CGulIcon* LcIconLoader::LoadIconFromMifFileL( const TDesC& aAppIconFile, |
|
132 TInt aFrameNo ) |
|
133 { |
|
134 // Create the Icon and the mask for the Application using AknUtils |
|
135 CFbsBitmap* bitmap = NULL; |
|
136 CFbsBitmap* mask = NULL; |
|
137 |
|
138 AknIconUtils::CreateIconLC( bitmap, mask, aAppIconFile, aFrameNo, aFrameNo + 1 ); |
|
139 |
|
140 User::LeaveIfNull( bitmap ); |
|
141 User::LeaveIfNull( mask ); |
|
142 |
|
143 // If the bitmap and the mask exists then make it into a GulIcon |
|
144 // which can then be retured. |
|
145 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
146 icon->SetBitmapsOwnedExternally( EFalse ); |
|
147 |
|
148 // Not specifying the order because we dont know the order in which they |
|
149 // would be created. Though its generally, the bitmap first and then the |
|
150 // mask, we should be speculating. |
|
151 CleanupStack::Pop( 2 ); |
|
152 return icon; |
|
153 } |
|
154 |
|