|
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 delete *item; |
|
52 } |
|
53 iTextureMap.InsertL( aItemIndex, aBitmap ); |
|
54 iTextureIndexMap.InsertL( (TInt32)aItemId, aItemIndex ); |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // Returns the texture id for the specified item |
|
59 // ---------------------------------------------------------------------------- |
|
60 TBool CMPXCommonContainerTextureManager2::TextureExist( TMPXItemId aItemId ) const |
|
61 { |
|
62 MPX_FUNC("CMPXCommonContainerTextureManager2::TextureExist()"); |
|
63 |
|
64 const TInt *ret = iTextureIndexMap.Find( (TInt32)aItemId ); |
|
65 if ( ret ) |
|
66 return ETrue; |
|
67 else |
|
68 return EFalse; |
|
69 } |
|
70 |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // Clears the texture cache array |
|
74 // ---------------------------------------------------------------------------- |
|
75 void CMPXCommonContainerTextureManager2::ClearCache() |
|
76 { |
|
77 MPX_FUNC("CMPXCommonContainerTextureManager2::ClearCache"); |
|
78 |
|
79 THashMapIter<TInt, CFbsBitmap*> iter(iTextureMap); |
|
80 CFbsBitmap* const* bitmap2 = iter.CurrentValue(); |
|
81 if (bitmap2) |
|
82 { |
|
83 delete bitmap2; |
|
84 } |
|
85 while ( CFbsBitmap* const* bitmap = iter.NextValue() ) |
|
86 { |
|
87 delete *bitmap; |
|
88 iter.RemoveCurrent(); |
|
89 } |
|
90 iTextureMap.Close(); |
|
91 iTextureIndexMap.Close(); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // Returns the bitmap |
|
96 // ---------------------------------------------------------------------------- |
|
97 CFbsBitmap* CMPXCommonContainerTextureManager2::ProvideBitmapL( TInt aIndex ) |
|
98 { |
|
99 MPX_FUNC("CMPXCommonContainerTextureManager2::ProvideBitmapL()"); |
|
100 |
|
101 CFbsBitmap* const* item = iTextureMap.Find(aIndex); |
|
102 |
|
103 if ( item ) |
|
104 { |
|
105 return *item; |
|
106 } |
|
107 else |
|
108 { |
|
109 return NULL; |
|
110 } |
|
111 } |
|
112 |
|
113 //End of file |