83
|
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: Icon cache
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "tsfswiconcache.h"
|
|
20 |
#include <fbs.h>
|
|
21 |
#include <AknsUtils.h>
|
|
22 |
#include <gulicon.h>
|
|
23 |
#include <avkon.mbg>
|
|
24 |
|
|
25 |
// size for the created app icons
|
|
26 |
const TInt KAppIconWidth = 300;
|
|
27 |
const TInt KAppIconHeight = 300;
|
|
28 |
|
|
29 |
// --------------------------------------------------------------------------
|
|
30 |
// CTsFswIconCache::NewL
|
|
31 |
// --------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CTsFswIconCache* CTsFswIconCache::NewL()
|
|
34 |
{
|
|
35 |
CTsFswIconCache* self = new (ELeave) CTsFswIconCache;
|
|
36 |
CleanupStack::PushL (self );
|
|
37 |
self->ConstructL ( );
|
|
38 |
CleanupStack::Pop ( self );
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
// --------------------------------------------------------------------------
|
|
43 |
// CTsFswIconCache::CTsFswIconCache
|
|
44 |
// --------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
CTsFswIconCache::CTsFswIconCache()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// --------------------------------------------------------------------------
|
|
51 |
// CTsFswIconCache::~CTsFswIconCache
|
|
52 |
// --------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
CTsFswIconCache::~CTsFswIconCache( )
|
|
55 |
{
|
|
56 |
THashMapIter<TInt, STsBitmapPair> iter( iAppIcons );
|
|
57 |
while ( const TInt* key = iter.NextKey() )
|
|
58 |
{
|
|
59 |
STsBitmapPair* value = iter.CurrentValue();
|
|
60 |
delete value->iBitmap;
|
|
61 |
delete value->iMask;
|
|
62 |
}
|
|
63 |
iAppIcons.Close();
|
|
64 |
delete iDefaultIcon;
|
|
65 |
}
|
|
66 |
|
|
67 |
// --------------------------------------------------------------------------
|
|
68 |
// CTsFswIconCache::ConstructL
|
|
69 |
// --------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
void CTsFswIconCache::ConstructL()
|
|
72 |
{
|
|
73 |
iDefaultIcon = AknsUtils::CreateGulIconL(
|
|
74 |
AknsUtils::SkinInstance(),
|
|
75 |
KAknsIIDQgnMenuUnknownCxt,
|
|
76 |
AknIconUtils::AvkonIconFileName(),
|
|
77 |
EMbmAvkonQgn_menu_unknown_cxt,
|
|
78 |
EMbmAvkonQgn_menu_unknown_cxt_mask );
|
|
79 |
TSize sz( KAppIconWidth, KAppIconHeight );
|
|
80 |
AknIconUtils::SetSize( iDefaultIcon->Bitmap(), sz );
|
|
81 |
AknIconUtils::SetSize( iDefaultIcon->Mask(), sz );
|
|
82 |
}
|
|
83 |
|
|
84 |
// --------------------------------------------------------------------------
|
|
85 |
// CTsFswIconCache::GetAppIconL
|
|
86 |
// --------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CTsFswIconCache::GetAppIconL( const TUid& aAppUid,
|
|
89 |
CFbsBitmap*& aBitmap, CFbsBitmap*& aMask )
|
|
90 |
{
|
|
91 |
aBitmap = aMask = 0;
|
|
92 |
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
|
|
93 |
if ( skinInstance )
|
|
94 |
{
|
|
95 |
AknsUtils::CreateAppIconLC( skinInstance, aAppUid, EAknsAppIconTypeList,
|
|
96 |
aBitmap, aMask );
|
|
97 |
// The CreateAppIconLC method leaves both the bitmaps in the cleanup stack.
|
|
98 |
// The order in which they are pushed into the stack and types of
|
|
99 |
// the items in the stack are both undefined.
|
|
100 |
CleanupStack::Pop( 2 ); // codescanner::cleanup
|
|
101 |
TSize sz( KAppIconWidth, KAppIconHeight );
|
|
102 |
AknIconUtils::SetSize( aBitmap, sz );
|
|
103 |
AknIconUtils::SetSize( aMask, sz );
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
// --------------------------------------------------------------------------
|
|
108 |
// CTsFswIconCache::GetIconL
|
|
109 |
// --------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CTsFswIconCache::GetIconL( const TUid& aAppUid,
|
|
112 |
CFbsBitmap*& aBitmap, CFbsBitmap*& aMask )
|
|
113 |
{
|
|
114 |
aBitmap = aMask = 0;
|
|
115 |
STsBitmapPair* bp = iAppIcons.Find( aAppUid.iUid );
|
|
116 |
if ( bp )
|
|
117 |
{
|
|
118 |
// ownership stays with the hash table
|
|
119 |
aBitmap = bp->iBitmap;
|
|
120 |
aMask = bp->iMask;
|
|
121 |
}
|
|
122 |
else
|
|
123 |
{
|
|
124 |
GetAppIconL( aAppUid, aBitmap, aMask ); // ownership of the bitmap is ours
|
|
125 |
// insert to hash table and pass ownership
|
|
126 |
iAppIcons.InsertL( aAppUid.iUid, STsBitmapPair( aBitmap, aMask ) );
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
// --------------------------------------------------------------------------
|
|
131 |
// CTsFswIconCache::DefaultIcon
|
|
132 |
// --------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CTsFswIconCache::DefaultIcon( CFbsBitmap*& aBitmap, CFbsBitmap*& aMask )
|
|
135 |
{
|
|
136 |
aBitmap = iDefaultIcon->Bitmap();
|
|
137 |
aMask = iDefaultIcon->Mask();
|
|
138 |
}
|
|
139 |
|
|
140 |
|
|
141 |
// end of file
|