|
1 /* |
|
2 * Copyright (c) 2002 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 loading from MIF files. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef AKN_ICON_LOADER_H |
|
22 #define AKN_ICON_LOADER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32std.h> |
|
26 #include <f32file.h> |
|
27 #include <fbs.h> |
|
28 #include <mifheader.cdl.h> |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 static const TInt32 KUidAvkonMultiIconFile( 0x034232342 ); |
|
33 static const TInt32 KUidAvkonMultiIcon( 0x034232343 ); |
|
34 static const TInt32 KMifFirstSupportedVersion( 1 ); |
|
35 static const TInt32 KMifLastSupportedVersion( 3 ); |
|
36 static const TInt32 KMifIconFirstSupportedVersion( 1 ); |
|
37 static const TInt32 KMifIconLastSupportedVersion( 1 ); |
|
38 |
|
39 struct TMifFileHeaderV1 |
|
40 { |
|
41 TInt32 iUid; |
|
42 TInt32 iVersion; // this determines how many fields of header are valid |
|
43 TInt32 iArrayOffset; |
|
44 TInt32 iArrayLength; // array length in items of TMifBitmapOffsetElement |
|
45 }; |
|
46 |
|
47 struct TMifFileHeaderV3 |
|
48 { |
|
49 TInt32 iIndexDllUid; |
|
50 }; |
|
51 |
|
52 struct TMifFileHeader |
|
53 { |
|
54 TMifFileHeaderV1 iV1; |
|
55 // since version 3 |
|
56 TMifFileHeaderV3 iV3; |
|
57 // since version 4 |
|
58 // This is extensible by upgrading iVersion! |
|
59 }; |
|
60 |
|
61 struct TMifIconHeader |
|
62 { |
|
63 TInt32 iUid; |
|
64 TInt32 iVersion; |
|
65 // since version 1 |
|
66 TInt32 iDataOffset; // offset to icon data (from beginning of icon) |
|
67 TInt32 iDataLength; // length of icon data in bytes |
|
68 TInt32 iType; // type, e.g. svg |
|
69 TInt32 iDepth; // depth of bitmap the content will be rendered to |
|
70 TInt32 iAnimated; // whether icon is animated |
|
71 TInt32 iMaskDepth; // depth of mask |
|
72 // since version 2 |
|
73 // this is extensible by upgrading iVersion |
|
74 }; |
|
75 |
|
76 // FORWARD DECLARATIONS |
|
77 |
|
78 struct TMifBitmapOffsetElement; |
|
79 class CAknIconLocationInfo; |
|
80 |
|
81 // FUNCTION PROTOTYPES |
|
82 |
|
83 GLREF_C void CleanupFreeIcon( TAny* aObj ); |
|
84 |
|
85 // CLASS DECLARATION |
|
86 |
|
87 /** |
|
88 * CAknIconLoader. |
|
89 */ |
|
90 NONSHARABLE_CLASS(CAknIconLoader) : public CBase |
|
91 { |
|
92 public: // Constructors and destructor |
|
93 |
|
94 static CAknIconLoader* NewL( RFs& aFs, const TDesC& aFileName ); |
|
95 static CAknIconLoader* NewL( RFile& aFile ); // Opened file handle. |
|
96 ~CAknIconLoader(); |
|
97 |
|
98 public: // New methods |
|
99 |
|
100 void OpenFileL( RFs& aFs, const TDesC& aFileName ); |
|
101 void OpenFileL( RFile& aFile ); // Opened file handle. |
|
102 void CloseFile(); |
|
103 |
|
104 TPtrC8 IconL( TInt aId ); |
|
105 TInt32 IconTypeL( TInt aId ); |
|
106 TInt32 IconDepthL( TInt aId ); |
|
107 TInt32 MaskDepthL( TInt aId ); |
|
108 TInt32 IconAnimatedL( TInt aId ); |
|
109 void FreeIcon(); |
|
110 |
|
111 /** |
|
112 * Retrieves the icon location table from the MIF file assigned to this icon loader. |
|
113 * The table is linked with the given icon file name, which of course should match |
|
114 * the file used by this icon loader. |
|
115 * |
|
116 * @param aFileName MIF file name, full path. |
|
117 */ |
|
118 CAknIconLocationInfo* LoadIconLocationInfoL( const TDesC& aFileName ); |
|
119 |
|
120 #ifdef _NGATESTING |
|
121 TInt32 GetDerivedIconTypeL(TInt32 aType, const TDesC & aMifFileName); |
|
122 void SetIconTypeConfig(TInt32 aConfigIconType, const TDesC & aNGATestDirectory); |
|
123 #endif |
|
124 |
|
125 private: // New methods |
|
126 |
|
127 void LoadFileHeaderStructL(); |
|
128 void CheckFileL(); |
|
129 const TMifBitmapOffsetElement* BitmapOffsetsL(); |
|
130 const TMifBitmapOffsetElement* BitmapOffsetsArrayL(); |
|
131 TPtrC8 IconWithHeaderL( TInt aId ); |
|
132 void CheckIconL( TInt aId ); |
|
133 TMifIconHeader* IconHeaderL( TInt aId ); |
|
134 void LoadSharedOffsetsL(); |
|
135 void LoadOffsetsFromMifL(); |
|
136 |
|
137 private: // Private constructors |
|
138 |
|
139 CAknIconLoader(); |
|
140 void ConstructL( RFs& aFs, const TDesC& aFileName ); |
|
141 void ConstructL( RFile& aFile ); |
|
142 |
|
143 private: // Data |
|
144 |
|
145 RFile iFile; |
|
146 TMifFileHeader iHeader; |
|
147 HBufC8* iOffsets; |
|
148 MifHeader::CInstance* iSharedOffsets; |
|
149 TInt iIconId; |
|
150 HBufC8* iIcon; |
|
151 CCdlEngineRef* iCdlEngine; |
|
152 |
|
153 #ifdef _NGATESTING |
|
154 TInt32 iConfigIconType; |
|
155 TFileName iNGADirectory; |
|
156 #endif |
|
157 }; |
|
158 |
|
159 #endif // AKN_ICON_LOADER_H |
|
160 |
|
161 // End of File |