1 /* |
|
2 * Copyright (c) 2007-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: CoverFlow templates Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // Include Files |
|
19 |
|
20 // Class Headers |
|
21 #include "mulcoverflowcontrol.h" |
|
22 |
|
23 // DUI headers for xml parser |
|
24 #include <uimodel/duinode.h> |
|
25 #include <dui/duiproperty.h> |
|
26 #include <uimodel/duixmlattributelist.h> |
|
27 |
|
28 // Local Headers |
|
29 #include "mulutility.h" |
|
30 #include "mulbaseelement.h" |
|
31 #include "mulcoverflowenhancedtemplate.h" |
|
32 #include "mulcoverflowdefinitions.h" //defines all the strings |
|
33 #include "mullog.h" |
|
34 |
|
35 using namespace duiuimodel; |
|
36 |
|
37 namespace Alf |
|
38 { |
|
39 |
|
40 struct TMulCoverFlowEnhancedTemplateImpl |
|
41 { |
|
42 |
|
43 TMulCoverFlowEnhancedTemplateImpl() |
|
44 { |
|
45 } |
|
46 |
|
47 //Structure used to store the position and sizes of the counter. |
|
48 TMulCoverFlowItem mEnhancedMinSize; // minimum size of images in enhanced mode |
|
49 TMulCoverFlowItem mEnhancedMaxSize; // maximum size of images in enhanced mode |
|
50 TMulCoverFlowItem mEnhacedCounterPos; // The position and size of the counter in enhaced mode |
|
51 UString mEnhancedBorderImagePath; |
|
52 |
|
53 ~TMulCoverFlowEnhancedTemplateImpl() |
|
54 { |
|
55 } |
|
56 }; |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // MulCoverFlowEnhancedTemplate |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 MulCoverFlowEnhancedTemplate::MulCoverFlowEnhancedTemplate(MulCoverFlowControl &aControl, |
|
63 UString &aTemplateID, MulXmlUtility& aMulXmlUtility,DuiNode* aRootNode):MulCoverFlowBaseTemplate( |
|
64 aControl, aTemplateID, aMulXmlUtility,aRootNode ) |
|
65 { |
|
66 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::MulCoverFlowEnhancedTemplate"); |
|
67 mData.reset(new (EMM)TMulCoverFlowEnhancedTemplateImpl); |
|
68 |
|
69 // Parses the xml from the oreientation node. |
|
70 ParseNode( *GetOrientationNode() ); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // ~MulCoverFlowWidget |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 MulCoverFlowEnhancedTemplate::~MulCoverFlowEnhancedTemplate() |
|
78 { |
|
79 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::~MulCoverFlowEnhancedTemplate"); |
|
80 //Nothing to delete . |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // EnhancedMaxSize |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 const TMulCoverFlowItem& MulCoverFlowEnhancedTemplate::EnhancedMaxSize() |
|
88 { |
|
89 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::EnhancedMaxSize"); |
|
90 return mData->mEnhancedMaxSize; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // EnhancedMinSize |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 const TMulCoverFlowItem& MulCoverFlowEnhancedTemplate::EnhancedMinSize() |
|
98 { |
|
99 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::EnhancedMinSize"); |
|
100 return mData->mEnhancedMinSize; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // EnhacedCounterPos |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 const TMulCoverFlowItem& MulCoverFlowEnhancedTemplate::EnhacedCounterPos() |
|
108 { |
|
109 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::EnhacedCounterPos"); |
|
110 return mData->mEnhacedCounterPos; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // EnhancedBorderImagePath |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 const UString& MulCoverFlowEnhancedTemplate::EnhancedBorderImagePath() |
|
118 { |
|
119 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::EnhancedBorderImagePath"); |
|
120 return mData->mEnhancedBorderImagePath; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // ParseNode |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void MulCoverFlowEnhancedTemplate::ParseNode( DuiNode& aNode ) |
|
128 { |
|
129 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::ParseNode"); |
|
130 int nChildCount = aNode.childCount (); |
|
131 for (int index = 0; index < nChildCount; index++) |
|
132 { |
|
133 DuiNode& item = aNode.child (index); |
|
134 |
|
135 //parse the elements |
|
136 if ( !item.type().compare(KElement) ) |
|
137 { |
|
138 if( !item.nodeId().compare(KEnhancedSize) ) |
|
139 { |
|
140 ParseEnhancedTag( item ); |
|
141 } |
|
142 else if( !item.nodeId().compare(KCounter) ) |
|
143 { |
|
144 ParseCounterTag( item ); |
|
145 } |
|
146 } |
|
147 } |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // ParseEnhancedTag |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void MulCoverFlowEnhancedTemplate::ParseEnhancedTag( DuiNode& aNode ) |
|
155 { |
|
156 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::ParseEnhancedTag"); |
|
157 int totalitems = aNode.childCount(); |
|
158 for( int index = 0; index < totalitems; index++ ) |
|
159 { |
|
160 DuiNode& childItem = aNode.child(index); |
|
161 if( !childItem.type().compare(KSize) ) |
|
162 { |
|
163 // for enhanced mode xmls. |
|
164 ProcessSizeTag( childItem ); |
|
165 } |
|
166 else |
|
167 { |
|
168 bool pathFound = GetStaticImagePath(childItem, mData->mEnhancedBorderImagePath); |
|
169 TPtrC8 src((TUint8*)mData->mEnhancedBorderImagePath.getUtf8()); |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // ParseCounterTag |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void MulCoverFlowEnhancedTemplate::ParseCounterTag( DuiNode& aNode ) |
|
179 { |
|
180 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::ParseCounterTag"); |
|
181 int totalItems = aNode.childCount(); |
|
182 for( int index = 0; index < totalItems; index++ ) |
|
183 { |
|
184 DuiNode& childItem = aNode.child(index); |
|
185 if( !childItem.type().compare(KSize) ) |
|
186 { |
|
187 // for enhanced mode xmls. |
|
188 ProcessSizeTag( childItem ); |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // ProcessSizeTag |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void MulCoverFlowEnhancedTemplate::ProcessSizeTag( DuiNode& aNode ) |
|
198 { |
|
199 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowEnhancedTemplate::ProcessSizeTag"); |
|
200 int totalitems = aNode.childCount(); |
|
201 |
|
202 auto_ptr<TMulCoverFlowItem> itemstruct = ProcessItemPos( aNode ); |
|
203 if( !aNode.nodeId().compare(KMinSize) ) |
|
204 { |
|
205 // Store the maximum and minimum sizes for enhanced mode. |
|
206 mData->mEnhancedMinSize = *itemstruct; |
|
207 } |
|
208 else if( !aNode.nodeId().compare(KMaxSize) ) |
|
209 { |
|
210 // Store the maximum and minimum sizes for enhanced mode. |
|
211 mData->mEnhancedMaxSize = *itemstruct; |
|
212 } |
|
213 else if( !aNode.nodeId().compare(KCounterSize) ) |
|
214 { |
|
215 // Store the position and sizes for the counter in enhanced mode. |
|
216 mData->mEnhacedCounterPos = *itemstruct; |
|
217 } |
|
218 //delete itemstruct; |
|
219 } |
|
220 //----------------------------------------------------------------------------- |
|
221 // GetStaticImagePath |
|
222 //----------------------------------------------------------------------------- |
|
223 // |
|
224 bool MulCoverFlowEnhancedTemplate::GetStaticImagePath(DuiNode& aNode, UString& aPath) |
|
225 { |
|
226 MUL_LOG_ENTRY_EXIT("aakash::MulXmlTemplate::GetStaticImagePath"); |
|
227 |
|
228 int aAttrSetterCount = aNode.childCount (); |
|
229 |
|
230 for (int index = 0; index < aAttrSetterCount; index++) |
|
231 { |
|
232 DuiNode& attrSetterNode = aNode.child (index); |
|
233 const UString& aNodeType = attrSetterNode.type (); |
|
234 |
|
235 DuiXmlAttributeList& attSetterList = attrSetterNode.attributeList (); |
|
236 const UString& attrName = attSetterList.attributeValue (UString (attributesetter::KName)); |
|
237 const UString& category = attSetterList.attributeValue (UString (KCategory)); |
|
238 |
|
239 if ( aNodeType == nodetypes::KAttributeSetter ) |
|
240 { |
|
241 if ( attrName == duiuimodel::imagevisualattributes::KImagePath && category == attributesetter::typevalues::KStatic ) |
|
242 { |
|
243 aPath = attSetterList.attributeValue(UString(attributesetter::KTargetValue)); |
|
244 MulUtility::AbsolutePath(aPath); |
|
245 return true; |
|
246 } |
|
247 } |
|
248 } |
|
249 return false; |
|
250 } |
|
251 |
|
252 }//namespace Alf |
|
253 |
|
254 // End of file. |
|
255 |
|