|
1 /* |
|
2 * Copyright (c) 2006 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: Application UI class required by AVKON application architecture. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <fbs.h> |
|
19 #include <mpxlog.h> |
|
20 #include "mpxcommoncontainertexturemanager2.h" |
|
21 |
|
22 // CONSTANTS |
|
23 |
|
24 // ---------------------------------------------------------------------------- |
|
25 // Constructor. |
|
26 // ---------------------------------------------------------------------------- |
|
27 // |
|
28 CMPXCommonContainerTextureManager2::CMPXCommonContainerTextureManager2() |
|
29 { |
|
30 } |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // Destructor |
|
34 // ---------------------------------------------------------------------------- |
|
35 // |
|
36 CMPXCommonContainerTextureManager2::~CMPXCommonContainerTextureManager2() |
|
37 { |
|
38 ClearCache(); |
|
39 } |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // Creates texture from the specified bitmap |
|
43 // ---------------------------------------------------------------------------- |
|
44 void CMPXCommonContainerTextureManager2::CreateTextureL( |
|
45 TInt aItemIndex, TMPXItemId aItemId, CFbsBitmap* aBitmap ) |
|
46 { |
|
47 MPX_FUNC("CMPXCommonContainerTextureManager2::CreateTextureL()"); |
|
48 if ( iTextureMap.Find(aItemIndex) ) |
|
49 { |
|
50 CFbsBitmap* const* item = iTextureMap.Find(aItemIndex); |
|
51 if(item) |
|
52 { |
|
53 delete *item; |
|
54 } |
|
55 } |
|
56 iTextureMap.InsertL( aItemIndex, aBitmap ); |
|
57 iTextureIndexMap.InsertL( (TInt32)aItemId, aItemIndex ); |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // Returns the texture id for the specified item |
|
62 // ---------------------------------------------------------------------------- |
|
63 TBool CMPXCommonContainerTextureManager2::TextureExist( TMPXItemId aItemId ) const |
|
64 { |
|
65 MPX_FUNC("CMPXCommonContainerTextureManager2::TextureExist()"); |
|
66 |
|
67 const TInt *ret = iTextureIndexMap.Find( (TInt32)aItemId ); |
|
68 if ( ret ) |
|
69 return ETrue; |
|
70 else |
|
71 return EFalse; |
|
72 } |
|
73 |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // Clears the texture cache array |
|
77 // ---------------------------------------------------------------------------- |
|
78 void CMPXCommonContainerTextureManager2::ClearCache() |
|
79 { |
|
80 MPX_FUNC("CMPXCommonContainerTextureManager2::ClearCache"); |
|
81 |
|
82 THashMapIter<TInt, CFbsBitmap*> iter(iTextureMap); |
|
83 CFbsBitmap* const* bitmap2 = iter.CurrentValue(); |
|
84 if (bitmap2) |
|
85 { |
|
86 delete bitmap2; |
|
87 } |
|
88 while ( CFbsBitmap* const* bitmap = iter.NextValue() ) |
|
89 { |
|
90 delete *bitmap; |
|
91 iter.RemoveCurrent(); |
|
92 } |
|
93 iTextureMap.Close(); |
|
94 iTextureIndexMap.Close(); |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // Returns the bitmap |
|
99 // ---------------------------------------------------------------------------- |
|
100 CFbsBitmap* CMPXCommonContainerTextureManager2::ProvideBitmapL( TInt aIndex ) |
|
101 { |
|
102 MPX_FUNC("CMPXCommonContainerTextureManager2::ProvideBitmapL()"); |
|
103 |
|
104 CFbsBitmap* const* item = iTextureMap.Find(aIndex); |
|
105 |
|
106 if ( item ) |
|
107 { |
|
108 return *item; |
|
109 } |
|
110 else |
|
111 { |
|
112 return NULL; |
|
113 } |
|
114 } |
|
115 |
|
116 //End of file |