|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Layout calculation and UI rendering mechanism implementations. |
|
15 * |
|
16 */ |
|
17 |
|
18 // User includes |
|
19 #include "xnuiengineappif.h" |
|
20 #include "xnuiengine.h" |
|
21 #include "xnnode.h" |
|
22 #include "xnodt.h" |
|
23 #include "xndomdocument.h" |
|
24 #include "xnpointerarray.h" |
|
25 #include "xneditor.h" |
|
26 #include "xnnodeappif.h" |
|
27 #include "xnviewdata.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // TXnUiEngineAppIf::TXnUiEngineAppIf |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 TXnUiEngineAppIf::TXnUiEngineAppIf( CXnUiEngine& aUiEngine ) |
|
38 { |
|
39 iUiEngine = &aUiEngine; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // TXnUiEngineAppIf::RootNode |
|
44 // Forwards the call to the ui engine implementation |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CXnNodeAppIf& TXnUiEngineAppIf::RootNodeL() |
|
48 { |
|
49 return iUiEngine->RootNode()->AppIfL(); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // TXnUiEngineAppIf::FindNodeByIdL |
|
54 // Forwards the call to the ui engine implementation |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FindNodeByIdL( |
|
58 const TDesC& aNodeId, |
|
59 const TDesC& aNamespace ) |
|
60 { |
|
61 CXnNode* node( iUiEngine->FindNodeByIdL( aNodeId, aNamespace ) ); |
|
62 |
|
63 if ( node ) |
|
64 { |
|
65 return &( node->AppIfL() ); |
|
66 } |
|
67 |
|
68 return NULL; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // TXnUiEngineAppIf::FindNodeByIdL |
|
73 // Forwards the call to the ui engine implementation |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FindNodeByIdL( |
|
77 const TDesC8& aNodeId, |
|
78 const TDesC8& aNamespace ) |
|
79 { |
|
80 CXnNode* node( iUiEngine->FindNodeByIdL( aNodeId, aNamespace ) ); |
|
81 |
|
82 if ( node ) |
|
83 { |
|
84 return &( node->AppIfL() ); |
|
85 } |
|
86 |
|
87 return NULL; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // TXnUiEngineAppIf::FindNodeByClassL |
|
92 // Forwards the call to the ui engine implementation |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindNodeByClassL( |
|
96 const TDesC& aClassId, const TDesC& aNamespace ) |
|
97 { |
|
98 CXnPointerArray* array = iUiEngine->FindNodeByClassL( |
|
99 aClassId, aNamespace ); |
|
100 CleanupStack::PushL( array ); |
|
101 RPointerArray< CXnNodeAppIf > interfaceArray; |
|
102 CleanupClosePushL( interfaceArray ); |
|
103 const TInt count = array->Container().Count(); |
|
104 interfaceArray.ReserveL( count ); |
|
105 for ( TInt i = 0; i < count; ++i ) |
|
106 { |
|
107 CXnNode* node = static_cast< CXnNode* >( array->Container()[i] ); |
|
108 // Append cannot fail because ReserveL call before this loop has |
|
109 // allocated the array buffer |
|
110 interfaceArray.Append( &( node->AppIfL() ) ); |
|
111 } |
|
112 CleanupStack::Pop( &interfaceArray ); |
|
113 CleanupStack::PopAndDestroy( array ); |
|
114 return interfaceArray; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CXnUiEngine::FindNodeByClassL |
|
119 // Forwards the call to the ui engine implementation |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindNodeByClassL( |
|
123 const TDesC8& aClassId, const TDesC8& aNamespace ) |
|
124 { |
|
125 CXnPointerArray* array = iUiEngine->FindNodeByClassL( |
|
126 aClassId, aNamespace ); |
|
127 CleanupStack::PushL( array ); |
|
128 RPointerArray< CXnNodeAppIf > interfaceArray; |
|
129 CleanupClosePushL( interfaceArray ); |
|
130 const TInt count = array->Container().Count(); |
|
131 interfaceArray.ReserveL( count ); |
|
132 for ( TInt i = 0; i < count; ++i ) |
|
133 { |
|
134 CXnNode* node = static_cast< CXnNode* >( array->Container()[i] ); |
|
135 // Append cannot fail because ReserveL call before this loop has |
|
136 // allocated the array buffer |
|
137 interfaceArray.Append( &( node->AppIfL() ) ); |
|
138 } |
|
139 CleanupStack::Pop( &interfaceArray ); |
|
140 CleanupStack::PopAndDestroy( array ); |
|
141 return interfaceArray; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CXnUiEngine::FindNodeByClassL |
|
146 // Forwards the call to the ui engine implementation |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindContentSourceNodesL( |
|
150 const TDesC8& aNamespace ) |
|
151 { |
|
152 RPointerArray< CXnNodeAppIf > interfaceArray; |
|
153 CleanupClosePushL( interfaceArray ); |
|
154 |
|
155 CXnViewManager* manager( iUiEngine->ViewManager() ); |
|
156 |
|
157 CXnPluginData* data( manager->ActiveViewData().Plugin( aNamespace ) ); |
|
158 |
|
159 if ( data ) |
|
160 { |
|
161 RPointerArray< CXnNode > nodes; |
|
162 CleanupClosePushL( nodes ); |
|
163 |
|
164 data->ContentSourceNodesL( nodes ); |
|
165 |
|
166 for ( TInt i = 0; i < nodes.Count(); i++ ) |
|
167 { |
|
168 interfaceArray.AppendL( &nodes[i]->AppIfL() ); |
|
169 } |
|
170 |
|
171 CleanupStack::PopAndDestroy( &nodes ); |
|
172 } |
|
173 |
|
174 CleanupStack::Pop( &interfaceArray ); |
|
175 |
|
176 return interfaceArray; |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // TXnUiEngineAppIf::RenderUIL |
|
181 // Forwards the call to the ui engine implementation |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C void TXnUiEngineAppIf::RenderUIL( CXnNodeAppIf* aNode ) |
|
185 { |
|
186 CXnNode* node = NULL; |
|
187 if ( aNode != NULL ) |
|
188 { |
|
189 node = &( aNode->Node() ); |
|
190 } |
|
191 iUiEngine->RenderUIL( node ); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // TXnUiEngineAppIf::StringPool |
|
196 // Forwards the call to the ui engine implementation |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C CXnDomStringPool& TXnUiEngineAppIf::StringPool() |
|
200 { |
|
201 return iUiEngine->ODT()->DomDocument().StringPool(); |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // TXnUiEngineAppIf::ActivateViewL |
|
206 // Activate a view |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 EXPORT_C void TXnUiEngineAppIf::ActivateViewL( CXnNodeAppIf& aViewNode ) |
|
210 { |
|
211 iUiEngine->ActivateViewL( aViewNode.Node() ); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // TXnUiEngineAppIf::ActiveView |
|
216 // Return the active view |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::ActiveView() |
|
220 { |
|
221 CXnNodeAppIf* ret( NULL ); |
|
222 TRAP_IGNORE( ret = &( iUiEngine->ActiveView()->AppIfL() ) ); |
|
223 return ret; |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // TXnUiEngineAppIf::RefreshMenuL |
|
228 // Refresh current menu |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 EXPORT_C void TXnUiEngineAppIf::RefreshMenuL() |
|
232 { |
|
233 iUiEngine->RefreshMenuL(); |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // TXnUiEngineAppIf::IsMenuDisplaying |
|
238 // Checks whether the menu is displaying or not. |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 EXPORT_C TBool TXnUiEngineAppIf::IsMenuDisplaying() |
|
242 { |
|
243 return iUiEngine->IsMenuDisplaying(); |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 EXPORT_C TInt TXnUiEngineAppIf::GetPluginNodeArrayL( |
|
250 RPointerArray< CXnNodeAppIf >& aArray ) |
|
251 { |
|
252 aArray.Reset(); |
|
253 RPointerArray< CXnNode >* plugins = iUiEngine->Plugins(); |
|
254 if ( !plugins ) |
|
255 { |
|
256 return 0; |
|
257 } |
|
258 TInt count( plugins->Count() ); |
|
259 for ( TInt i = 0; i < count; ++i ) |
|
260 { |
|
261 CXnNode* tmp = ( *plugins )[i]; |
|
262 aArray.AppendL( &( tmp->AppIfL() ) ); |
|
263 } |
|
264 return count; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // TXnUiEngineAppIf::FocusedNode |
|
269 // Gets the currently focused node |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FocusedNode() |
|
273 { |
|
274 CXnNode* focused( iUiEngine->FocusedNode() ); |
|
275 CXnNodeAppIf* ret( NULL ); |
|
276 |
|
277 if ( focused ) |
|
278 { |
|
279 TRAP_IGNORE( ret = &( focused->AppIfL() ) ); |
|
280 } |
|
281 |
|
282 return ret; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // TXnUiEngineAppIf::IsEditMode |
|
287 // Returns ETrue if the current mode is edit, otherwise EFalse. |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C TBool TXnUiEngineAppIf::IsEditMode() |
|
291 { |
|
292 return ( iUiEngine->IsEditMode() ); |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C void TXnUiEngineAppIf::SetUiEngine( CXnUiEngine* aUiEngine ) |
|
299 { |
|
300 iUiEngine = aUiEngine; |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 EXPORT_C TInt TXnUiEngineAppIf::GetThemeResource( |
|
307 const TDesC& aPath, RFile& aFile ) |
|
308 { |
|
309 return iUiEngine->GetThemeResource( aPath, aFile ); |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 EXPORT_C TBool TXnUiEngineAppIf::WidgetsVisible() const |
|
316 { |
|
317 return iUiEngine->Editor()->WidgetsVisible(); |
|
318 } |