|
1 /* |
|
2 * Copyright (c) 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <uiacceltk/HuiCanvasVisual.h> |
|
19 #include <alfwindowstructs.h> |
|
20 |
|
21 #include "huiwscanvascommands.h" |
|
22 #include "alfnodes.h" |
|
23 #include "alfhierarchymodel.h" |
|
24 #include "alfstreamerserver.h" |
|
25 #include "alfwindowmanager.h" |
|
26 #include "alfwindow.h" |
|
27 #include "alfwindowdata.h" |
|
28 |
|
29 #ifdef ALF_DEBUG_PRINT_NODE_INFO |
|
30 #define _ALF_LOGGING |
|
31 #include "alflogger.h" |
|
32 #undef _ALF_LOGGING |
|
33 #else |
|
34 #include "alflogger.h" |
|
35 #endif |
|
36 // --------------------------------------------------------------------------- |
|
37 // Constructor |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CAlfNode::CAlfNode( ) : |
|
41 iVisible( ETrue ) |
|
42 { |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // ConstructL |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 void CAlfNode::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
50 { |
|
51 iModel = aModel; |
|
52 iId = aStream->ReadInt32L(); |
|
53 } |
|
54 |
|
55 void CAlfNode::SetTracking( TBool aValue ) |
|
56 { |
|
57 iTrackNode = aValue; |
|
58 if ( iWindow ) |
|
59 { |
|
60 iWindow->SetNodeTracking( aValue ); |
|
61 } |
|
62 } |
|
63 // --------------------------------------------------------------------------- |
|
64 // OrphonMe |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CAlfNode* CAlfNode::OrphonMe() |
|
68 { |
|
69 __ALFLOGSTRING1("CAlfNode::OrphonMe %d", iId); |
|
70 // this window will not be used anymore by wserv and cannot be drawn into. Thus destroying the |
|
71 // visual representing this node is safe. |
|
72 if ( iWindow && iModel ) |
|
73 { |
|
74 iModel->Server().WindowMgr()->DestroyWindow( *iWindow ); |
|
75 iWindow = NULL; |
|
76 } |
|
77 |
|
78 CAlfNode* sibling = iSibling; |
|
79 iSibling = NULL; |
|
80 iParent = NULL; |
|
81 return sibling; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // ResolveParentL |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CAlfNode::ResolveParent( TUint32 aParentId, TInt aMyId ) |
|
89 { |
|
90 CAlfNode* tmp = iModel->FindNode( aParentId ); |
|
91 if ( tmp ) |
|
92 { |
|
93 // 1. set parent, if there is one (root node is the only exception ) |
|
94 iParent = tmp; |
|
95 // Possible sprite, textcursor, anim and child windows have different lists on the node |
|
96 switch( iType ) |
|
97 { |
|
98 default: |
|
99 { |
|
100 SetFirstChild(); |
|
101 break; |
|
102 } |
|
103 case MWsWindowTreeNode::EWinTreeNodeAnim: |
|
104 { |
|
105 SetFirstAnim(); |
|
106 break; |
|
107 } |
|
108 case MWsWindowTreeNode::EWinTreeNodeSprite: |
|
109 { |
|
110 SetFirstSprite(); |
|
111 break; |
|
112 } |
|
113 case MWsWindowTreeNode::EWinTreeNodeStandardTextCursor: |
|
114 { |
|
115 ASSERT( !iParent->iTextCursor ); |
|
116 __ALFLOGSTRING1("parent->iTextCursor %d", iParent->iTextCursor ); |
|
117 iParent->iTextCursor = (CAlfNodeTextCursor*)this; |
|
118 __ALFLOGSTRING1("parent->iTextCursor %d", iParent->iTextCursor ); |
|
119 break; |
|
120 } |
|
121 } |
|
122 } |
|
123 iId = aMyId; |
|
124 iModel->InsertNode( iId, this ); |
|
125 ASSERT( iParent != NULL || iType == MWsWindowTreeNode::EWinTreeNodeRoot); |
|
126 |
|
127 if ( iType == MWsWindowTreeNode::EWinTreeNodeGroup ) |
|
128 { |
|
129 iGroupId = iId; |
|
130 } |
|
131 else |
|
132 { |
|
133 iGroupId = FindParentGroup(); |
|
134 } |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // SetFirstChild |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CAlfNode::SetFirstChild() |
|
142 { |
|
143 if ( iParent->iChild ) |
|
144 { |
|
145 // pass over the previous first child and make it my sibling |
|
146 iSibling = iParent->iChild; |
|
147 } |
|
148 // jealously make me the first child |
|
149 iParent->iChild = this; |
|
150 } |
|
151 // --------------------------------------------------------------------------- |
|
152 // SetFirstChild |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CAlfNode::SetFirstAnim() |
|
156 { |
|
157 if ( iParent->iAnimChild ) |
|
158 { |
|
159 // pass over the previous first child and make it my sibling |
|
160 iSibling = iParent->iAnimChild; |
|
161 } |
|
162 // jealously make me the first child |
|
163 iParent->iAnimChild = (CAlfNodeAnim*)this; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // SetFirstChild |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CAlfNode::SetFirstSprite() |
|
171 { |
|
172 if ( iParent->iSpriteChild ) |
|
173 { |
|
174 // pass over the previous first child and make it my sibling |
|
175 iSibling = iParent->iSpriteChild; |
|
176 } |
|
177 // jealously make me the first child |
|
178 iParent->iSpriteChild = (CAlfNodeSprite*)this; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // FindParentGroup |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 TUint32 CAlfNode::FindParentGroup() |
|
186 { |
|
187 // go back in parents, until a group node is found. return its id. |
|
188 if ( iType == MWsWindowTreeNode::EWinTreeNodeSprite ) |
|
189 { |
|
190 if ( iParent->iType == MWsWindowTreeNode::EWinTreeNodeRoot ) |
|
191 { |
|
192 return 0; |
|
193 } |
|
194 else |
|
195 { |
|
196 return iParent->iId; // TODO: THIS IS ROOT, MIGHT NOT BE ALWAYS |
|
197 } |
|
198 } |
|
199 |
|
200 |
|
201 if ( iType == MWsWindowTreeNode::EWinTreeNodeRoot ) |
|
202 { |
|
203 return 0; |
|
204 } |
|
205 ASSERT( iParent ); |
|
206 CAlfNode* parent = iParent; |
|
207 while( parent->iType != MWsWindowTreeNode::EWinTreeNodeGroup ) |
|
208 { |
|
209 parent = parent->iParent; |
|
210 } |
|
211 return parent->iId; |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // GetAllChildrenInGroup |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CAlfNode::GetAllChildrenInGroup( RPointerArray<CAlfNode>& aNodes, TUint32 aParentId ) |
|
219 { |
|
220 if ( iParent->iType != MWsWindowTreeNode::EWinTreeNodeRoot) |
|
221 { |
|
222 CAlfNode* parentGroupNode = iModel->FindNode( aParentId ); |
|
223 for (CAlfNode::TIter iter( parentGroupNode ); iter.Current() != NULL; iter.Next()) |
|
224 { |
|
225 aNodes.Append(iter.Current()); |
|
226 } |
|
227 } |
|
228 else |
|
229 { |
|
230 CAlfNode* child = iParent->iChild; |
|
231 do |
|
232 { |
|
233 aNodes.Append( child ); |
|
234 child = child->iSibling; |
|
235 } |
|
236 while( child ); |
|
237 } |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // OrdinalPosition |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 TInt CAlfNode::OrdinalPosition() |
|
245 { |
|
246 //_LIT( KText, "OrdinalPosition"); |
|
247 __ALFLOGSTRING("CAlfNode::OrdinalPosition"); |
|
248 // __ALFLOGSTRING1("CAlfNode::OrdinalPosition - Looking for me %d", iId ); |
|
249 RPointerArray<CAlfNode> nodes; |
|
250 TBool hasOrdinalPosition = ETrue; |
|
251 |
|
252 switch(iParent->iType) |
|
253 { |
|
254 case MWsWindowTreeNode::EWinTreeNodeClient: |
|
255 { |
|
256 CAlfNode* parentNode = iModel->FindNode( iParent->iId ); |
|
257 __ASSERT_DEBUG(parentNode, USER_INVARIANT()); |
|
258 if (parentNode->HasChildren()) |
|
259 { |
|
260 // parent node is not added to the list |
|
261 // the anims, cursor and sprites directly in this parent are added to the list |
|
262 // siblings are added to the list, but their anims, cursors and sprites are not added |
|
263 TraverseNodeTree( parentNode, nodes, EFalse /* list all for this node */, EFalse /* dont add me */); |
|
264 } |
|
265 break; |
|
266 } |
|
267 case MWsWindowTreeNode::EWinTreeNodeGroup: |
|
268 { |
|
269 TUint32 parentId = FindParentGroup(); |
|
270 CAlfNode* parentGroupNode = iModel->FindNode( parentId ); |
|
271 //__ALFLOGSTRING1("CAlfNode::OrdinalPosition - My parent %d", parentId ); |
|
272 CAlfNode* current; |
|
273 if ( parentGroupNode ) |
|
274 { |
|
275 current = parentGroupNode->iChild; |
|
276 TraverseNodeTree( current, nodes, ETrue /* list siblings only */, ETrue /* add me */ ); |
|
277 } |
|
278 |
|
279 break; |
|
280 } |
|
281 |
|
282 |
|
283 case MWsWindowTreeNode::EWinTreeNodeRoot: |
|
284 { |
|
285 // Window group ordinal position calculation (their parent is EWinTreeNodeRoot) |
|
286 |
|
287 // Root node can have window groups, sprites and perhaps anims as children. |
|
288 // However, sprites & anims do not have ordinal position concept, but window groups do. |
|
289 // These sprites & anims are placed to floating sprite control group in alfbridge side |
|
290 // and so they are excluded from ordinal position calculation. |
|
291 CAlfNode* child = iParent->iChild; |
|
292 if ( this == iParent->iTextCursor ) |
|
293 { |
|
294 hasOrdinalPosition = EFalse; |
|
295 } |
|
296 |
|
297 if ( hasOrdinalPosition && iParent->iSpriteChild ) |
|
298 { |
|
299 CAlfNode* animnode = iParent->iSpriteChild ; |
|
300 while ( animnode ) |
|
301 { |
|
302 if ( this == animnode ) |
|
303 { |
|
304 hasOrdinalPosition = EFalse; |
|
305 break; |
|
306 } |
|
307 animnode = animnode->iSibling; |
|
308 } |
|
309 } |
|
310 |
|
311 if( hasOrdinalPosition && iParent->iAnimChild ) |
|
312 { |
|
313 CAlfNode* animnode = iParent->iAnimChild ; |
|
314 while ( animnode ) |
|
315 { |
|
316 if ( this == animnode ) |
|
317 { |
|
318 hasOrdinalPosition = EFalse; |
|
319 break; |
|
320 } |
|
321 animnode = animnode->iSibling; |
|
322 } |
|
323 } |
|
324 |
|
325 if ( child ) |
|
326 { |
|
327 do |
|
328 { |
|
329 nodes.Append( child ); |
|
330 child = child->iSibling; |
|
331 } |
|
332 while( child ); |
|
333 } |
|
334 break; |
|
335 } |
|
336 } |
|
337 |
|
338 TInt ordinalPosition = -1; |
|
339 if ( hasOrdinalPosition ) |
|
340 { |
|
341 TInt i = nodes.Count(); |
|
342 // __ALFLOGSTRING1("Node count: %d", i ); |
|
343 // return my position in the node array |
|
344 while( --i >=0 && nodes[i] != this ) |
|
345 { |
|
346 } |
|
347 if ( i < 0) |
|
348 { |
|
349 __ALFLOGSTRING1("Node %d not found!", iId); |
|
350 __ASSERT_DEBUG( 0, USER_INVARIANT() ); |
|
351 //USER_INVARIANT(); |
|
352 } |
|
353 else |
|
354 { |
|
355 __ALFLOGSTRING2("Found %d at ordinal position %d!", nodes[i]->iId, i ); |
|
356 } |
|
357 ordinalPosition = i; |
|
358 } |
|
359 |
|
360 nodes.Close(); |
|
361 return ordinalPosition; |
|
362 } |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // CAlfNode::TraverseNodeTree |
|
366 // Traverse through node tree and fill node array |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 |
|
370 // --------------------------------------------------------------------------- |
|
371 // CAlfNode::TraverseNodeTree |
|
372 // Traverse through node tree and fill node array |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 |
|
376 void CAlfNode::TraverseNodeTree( CAlfNode* node, RPointerArray<CAlfNode>& nodes, TBool aTraverseOnlySiblings, TBool aAddMe) |
|
377 { |
|
378 // Exit if we've already finished walking the tree. |
|
379 if ( node == NULL) |
|
380 { |
|
381 __ALFLOGSTRING(" returning NULL"); |
|
382 return; |
|
383 } |
|
384 if (!aTraverseOnlySiblings) |
|
385 { |
|
386 if ( node->iSpriteChild ) |
|
387 { |
|
388 CAlfNode* spritenode = node->iSpriteChild ; |
|
389 while ( spritenode ) |
|
390 { |
|
391 nodes.Append( spritenode ); |
|
392 spritenode = spritenode->iSibling; |
|
393 } |
|
394 } |
|
395 |
|
396 if( node->iTextCursor ) |
|
397 { |
|
398 nodes.Append(node->iTextCursor ); |
|
399 } |
|
400 |
|
401 if( node->iAnimChild ) |
|
402 { |
|
403 CAlfNode* animnode = node->iAnimChild ; |
|
404 while ( animnode ) |
|
405 { |
|
406 nodes.Append( animnode ); |
|
407 animnode = animnode->iSibling; |
|
408 } |
|
409 } |
|
410 |
|
411 if ( node->iChild) |
|
412 { |
|
413 TraverseNodeTree(node->iChild , nodes, EFalse, ETrue); |
|
414 } |
|
415 } |
|
416 |
|
417 if (aAddMe) |
|
418 { |
|
419 nodes.Append( node ); |
|
420 } |
|
421 |
|
422 if ( node->iSibling ) |
|
423 { |
|
424 TraverseNodeTree(node->iSibling, nodes, ETrue, ETrue); |
|
425 } |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // OrdinalPosition |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 #ifdef ALF_DEBUG_PRINT_NODE_INFO |
|
433 TInt CAlfNode::PrintOrdinalPositions() |
|
434 { |
|
435 TInt i = 0; |
|
436 __ALFLOGSTRING("CAlfNode::PrintOrdinalPositions - "); |
|
437 |
|
438 RPointerArray<CAlfNode> nodes; |
|
439 if ( iParent->iType != MWsWindowTreeNode::EWinTreeNodeRoot) |
|
440 { |
|
441 TUint32 parentId = FindParentGroup(); |
|
442 CAlfNode* parentGroupNode = iModel->FindNode( parentId ); |
|
443 for (CAlfNode::TIter iter( parentGroupNode ); iter.Current() != NULL; iter.Next()) |
|
444 { |
|
445 nodes.Append(iter.Current()); |
|
446 } |
|
447 } |
|
448 else |
|
449 { |
|
450 CAlfNode* child = iParent->iChild; |
|
451 do |
|
452 { |
|
453 nodes.Append( child ); |
|
454 } |
|
455 while( ( child = child->iSibling) != NULL ); |
|
456 } |
|
457 |
|
458 i = nodes.Count(); |
|
459 // return my position in the node arr |
|
460 TInt groupLevel = 0; |
|
461 while( --i >=0 ) |
|
462 { |
|
463 CAlfNodeVisual* node = (CAlfNodeVisual*)nodes[i]; |
|
464 _LIT(KText, "PrintOrdinalPositions"); |
|
465 // PrintInfo( i, node, TPtrC(KText), 0); |
|
466 } |
|
467 nodes.Close(); |
|
468 return i; |
|
469 } |
|
470 |
|
471 void CAlfNode::PrintInfo( CAlfNode* aNode, TInt aHighLightNode, TInt aDepth) |
|
472 { |
|
473 HBufC16* buffer = HBufC16::NewL(256); |
|
474 TPtr iDebugText = buffer->Des(); |
|
475 iDebugText.Format( _L("")); |
|
476 MWsWindowTreeNode::TType type = aNode->Type(); |
|
477 |
|
478 for(TInt i = 0; i < aDepth; i++) |
|
479 { |
|
480 iDebugText.AppendFormat(_L(" ")); |
|
481 } |
|
482 |
|
483 // Print the parent id in front of every children. For debugging the debugging code... |
|
484 //CAlfNode* parent = aNode->iParent; |
|
485 //if (parent) |
|
486 // { |
|
487 // iDebugText.AppendFormat(_L("[0x%x] "), parent->iId); |
|
488 // } |
|
489 if ( aHighLightNode == aNode->iId ) |
|
490 { |
|
491 iDebugText.AppendFormat( _L("\n-- MODIFIED NODE -- \n")); |
|
492 } |
|
493 |
|
494 switch ( type ) |
|
495 { |
|
496 case MWsWindowTreeNode::EWinTreeNodeRoot: |
|
497 { |
|
498 iDebugText.AppendFormat( _L("Root 0x%x"), aNode->iId); |
|
499 break; |
|
500 } |
|
501 case MWsWindowTreeNode::EWinTreeNodeClient: |
|
502 { |
|
503 CAlfNodeVisual* nodeVisual = (CAlfNodeVisual*)aNode; |
|
504 iDebugText.AppendFormat(_L("Client 0x%x: iTl: (%3d,%3d), size (%3dx%3d)"), nodeVisual->iId, nodeVisual->iOrigin.iX, nodeVisual->iOrigin.iY, nodeVisual->iSize.iWidth, nodeVisual->iSize.iHeight ); |
|
505 |
|
506 break; |
|
507 } |
|
508 case MWsWindowTreeNode::EWinTreeNodeGroup: |
|
509 { |
|
510 CAlfNodeGroup* nodeGroup = (CAlfNodeGroup*)aNode; |
|
511 iDebugText.AppendFormat(_L("Group (%d) 0x%x: SecureId: 0x%x"), nodeGroup->iGroupId, nodeGroup->iId, nodeGroup->SecureId()); |
|
512 break; |
|
513 } |
|
514 case MWsWindowTreeNode::EWinTreeNodeAnim: |
|
515 { |
|
516 CAlfNodeVisual* nodeVisual = (CAlfNodeVisual*)aNode; |
|
517 iDebugText.AppendFormat(_L("Anim 0x%x: iTl: (%3d,%3d), size (%3dx%3d)"), nodeVisual->iId, nodeVisual->iOrigin.iX, nodeVisual->iOrigin.iY,nodeVisual->iSize.iWidth, nodeVisual->iSize.iHeight ); |
|
518 break; |
|
519 } |
|
520 case MWsWindowTreeNode::EWinTreeNodeSprite: |
|
521 { |
|
522 CAlfNodeVisual* nodeVisual = (CAlfNodeVisual*)aNode; |
|
523 iDebugText.AppendFormat(_L("Sprite 0x%x: iTl: (%3d,%3d), size (%3dx%3d)"), nodeVisual->iId, nodeVisual->iOrigin.iX, nodeVisual->iOrigin.iY,nodeVisual->iSize.iWidth, nodeVisual->iSize.iHeight ); |
|
524 break; |
|
525 } |
|
526 case MWsWindowTreeNode::EWinTreeNodeStandardTextCursor: |
|
527 { |
|
528 // TODO, add more cursor info |
|
529 CAlfNodeVisual* nodeVisual = (CAlfNodeVisual*)aNode; |
|
530 iDebugText.AppendFormat(_L("Cursor 0x%x: iTl: (%3d,%3d), size (%3dx%3d)"), nodeVisual->iId, nodeVisual->iOrigin.iX, nodeVisual->iOrigin.iY,nodeVisual->iSize.iWidth, nodeVisual->iSize.iHeight ); |
|
531 break; |
|
532 } |
|
533 } |
|
534 switch( type ) |
|
535 { |
|
536 case MWsWindowTreeNode::EWinTreeNodeStandardTextCursor: |
|
537 case MWsWindowTreeNode::EWinTreeNodeSprite: |
|
538 case MWsWindowTreeNode::EWinTreeNodeAnim: |
|
539 case MWsWindowTreeNode::EWinTreeNodeClient: |
|
540 { |
|
541 CAlfNodeVisual* nodeVisual = (CAlfNodeVisual*)aNode; |
|
542 iDebugText.AppendFormat(_L("\t\t\t")); |
|
543 if (nodeVisual->NonFading()) |
|
544 { |
|
545 iDebugText.AppendFormat(_L("(NON FADING)")); |
|
546 } |
|
547 |
|
548 if (nodeVisual->Visible()) |
|
549 { |
|
550 iDebugText.AppendFormat(_L("(VISIBLE)")); |
|
551 } |
|
552 |
|
553 if (nodeVisual->Faded()) |
|
554 { |
|
555 iDebugText.AppendFormat(_L("(FADED)")); |
|
556 } |
|
557 |
|
558 if (nodeVisual->Activated()) |
|
559 { |
|
560 iDebugText.AppendFormat(_L("(ACTIVATED)")); |
|
561 } |
|
562 } |
|
563 } |
|
564 RDebug::Print(_L("%S"), &iDebugText); |
|
565 delete buffer; |
|
566 } |
|
567 |
|
568 void CAlfNode::PrintNodeTree( |
|
569 CAlfNodeRoot* aNode, |
|
570 TInt aHighlightNode) |
|
571 { |
|
572 if (!aNode->iLogging) // Change this value during run-time. This produces A LOT of output |
|
573 { |
|
574 return; |
|
575 } |
|
576 TInt depth(0); |
|
577 CAlfNode::PrintSubTree((CAlfNode*)aNode,aHighlightNode, depth); |
|
578 } |
|
579 |
|
580 void CAlfNode::PrintSubTree( CAlfNode* aNode, TInt aHighlightNode, TInt& aDepth ) |
|
581 { |
|
582 aDepth++; |
|
583 CAlfNode::PrintInfo(aNode, aHighlightNode, aDepth); |
|
584 |
|
585 CAlfNode* node = (CAlfNode*)aNode->iSpriteChild; |
|
586 while( node ) |
|
587 { |
|
588 CAlfNode::PrintInfo( node, aHighlightNode, aDepth + 1); |
|
589 node = node->iSibling; |
|
590 } |
|
591 node = (CAlfNode*)aNode->iAnimChild; |
|
592 while( node ) |
|
593 { |
|
594 CAlfNode::PrintInfo(node, aHighlightNode, aDepth + 1); |
|
595 node = node->iSibling; |
|
596 } |
|
597 if ( aNode->iTextCursor ) |
|
598 { |
|
599 CAlfNode::PrintInfo( aNode->iTextCursor, aHighlightNode, aDepth + 1); |
|
600 } |
|
601 node = (CAlfNode*)aNode->iChild; |
|
602 while ( node ) |
|
603 { |
|
604 node->PrintSubTree( node, aHighlightNode, aDepth ); |
|
605 node = node->iSibling; |
|
606 } |
|
607 aDepth--; |
|
608 } |
|
609 |
|
610 #endif |
|
611 // --------------------------------------------------------------------------- |
|
612 // TIter::TIter |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 CAlfNode::TIter::TIter(CAlfNode* aTopNode) |
|
616 : iTopNode(aTopNode) |
|
617 , iCurrentNode(aTopNode), |
|
618 iState( ESearchingSprites ) |
|
619 { |
|
620 // Find the first node |
|
621 while(iCurrentNode->iChild!=NULL) |
|
622 { |
|
623 iCurrentNode=iCurrentNode->iChild; |
|
624 } |
|
625 |
|
626 iCurrentSibling=iCurrentNode->iSibling; // De-reference iCurrent so it can be destroyed by caller |
|
627 iCurrentParent=iCurrentNode->iParent; |
|
628 } |
|
629 |
|
630 // --------------------------------------------------------------------------- |
|
631 // TIter::Current |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 CAlfNode* CAlfNode::TIter::Current() |
|
635 { |
|
636 return iCurrentNode; |
|
637 } |
|
638 |
|
639 // --------------------------------------------------------------------------- |
|
640 // TIter::Next |
|
641 // --------------------------------------------------------------------------- |
|
642 // |
|
643 CAlfNode* CAlfNode::TIter::Next() |
|
644 { |
|
645 // Exit if we've already finished walking the tree. Do not return the group node |
|
646 if (iCurrentNode == iTopNode || iCurrentNode == NULL) |
|
647 { |
|
648 __ALFLOGSTRING("Iter returning NULL"); |
|
649 iCurrentNode = NULL; |
|
650 iState = ESearchingSprites; |
|
651 return NULL; |
|
652 } |
|
653 |
|
654 //Diagram shows visit order with parent (/) and sibling relationships (>) |
|
655 // |
|
656 // - 14 - |
|
657 // / \ |
|
658 // 6 > 13 |
|
659 // / \ / | \ |
|
660 // 3 > 5 10 > 11 > 12 |
|
661 // / \ \ / | \ |
|
662 // 1 > 2 4 7 > 8 > 9 |
|
663 // |
|
664 // |
|
665 // Todo. |
|
666 // Return sprites in order |
|
667 |
|
668 |
|
669 if ( iState == ESearchingSprites ) |
|
670 { |
|
671 iMasterNode = iCurrentNode; |
|
672 |
|
673 if ( iCurrentNode->iSpriteChild ) |
|
674 { |
|
675 // TODO: As long as we are putting sprites into their own group, we cannot count their ordinals |
|
676 //iCurrentNode = (CAlfNode*)iCurrentNode->iSpriteChild; |
|
677 //iState = ESearchMoreSprites; |
|
678 //return iCurrentNode; |
|
679 iState = ESearchingTextCursor; |
|
680 } |
|
681 else |
|
682 { |
|
683 iState = ESearchingTextCursor; |
|
684 } |
|
685 } |
|
686 |
|
687 if ( iState == ESearchMoreSprites ) |
|
688 { |
|
689 if ( iCurrentNode->iSibling ) |
|
690 { |
|
691 iCurrentNode = iCurrentNode->iSibling; |
|
692 return iCurrentNode; |
|
693 |
|
694 } |
|
695 else |
|
696 { |
|
697 iCurrentNode = iMasterNode; |
|
698 iState = ESearchingTextCursor; |
|
699 } |
|
700 } |
|
701 |
|
702 if ( iState == ESearchingTextCursor ) |
|
703 { |
|
704 if ( iMasterNode->iTextCursor ) |
|
705 { |
|
706 iCurrentNode = iMasterNode->iTextCursor; |
|
707 iState = ESearchingMoreTextCursor; |
|
708 return iCurrentNode; |
|
709 } |
|
710 else |
|
711 { |
|
712 iState = ESearchingAnims; |
|
713 } |
|
714 } |
|
715 |
|
716 if ( iState == ESearchingMoreTextCursor ) |
|
717 { |
|
718 iCurrentNode = iMasterNode; |
|
719 iState = ESearchingAnims; |
|
720 return iCurrentNode; |
|
721 |
|
722 } |
|
723 |
|
724 if ( iState == ESearchingAnims ) |
|
725 { |
|
726 if ( iCurrentNode->iAnimChild ) |
|
727 { |
|
728 iCurrentNode = (CAlfNode*)iCurrentNode->iAnimChild; |
|
729 iState = ESearchMoreAnims; |
|
730 return iCurrentNode; |
|
731 } |
|
732 else |
|
733 { |
|
734 iState = ESearchingChildWindows; |
|
735 iChildrenProcessed = ETrue; |
|
736 iCurrentSibling = iMasterNode->iSibling; |
|
737 } |
|
738 } |
|
739 |
|
740 if ( iState == ESearchMoreAnims ) |
|
741 { |
|
742 if ( iCurrentNode->iSibling ) // anim sibling |
|
743 { |
|
744 iCurrentNode = iCurrentNode->iSibling; |
|
745 return iCurrentNode; |
|
746 |
|
747 } |
|
748 else |
|
749 { |
|
750 iCurrentNode = iMasterNode; |
|
751 |
|
752 iState = ESearchingChildWindows; |
|
753 // if this node is having children windows, then we need to go to them |
|
754 if ( iCurrentNode->iChild ) |
|
755 { |
|
756 iCurrentSibling = iCurrentNode->iChild; |
|
757 // Look the deepest child |
|
758 iCurrentNode=iCurrentSibling; |
|
759 while(iCurrentNode->iChild!=NULL) |
|
760 { |
|
761 iCurrentNode=iCurrentNode->iChild; |
|
762 } |
|
763 |
|
764 iState = ESearchingSprites; |
|
765 return iCurrentNode; |
|
766 } |
|
767 else |
|
768 { |
|
769 // if no children windows, then this node is done and it should be returned |
|
770 return iCurrentNode; |
|
771 } |
|
772 } |
|
773 } |
|
774 |
|
775 if ( iState == ESearchingChildWindows ) |
|
776 { |
|
777 if (iCurrentSibling!=NULL) |
|
778 { |
|
779 iCurrentNode=iCurrentSibling; |
|
780 while(iCurrentNode->iChild!=NULL) |
|
781 { |
|
782 iCurrentNode=iCurrentNode->iChild; |
|
783 } |
|
784 } |
|
785 else |
|
786 { |
|
787 iCurrentNode = iCurrentParent; |
|
788 iChildrenProcessed = EFalse; |
|
789 } |
|
790 |
|
791 iCurrentSibling=iCurrentNode->iSibling; // De-reference iCurrent so it can be destroyed by caller |
|
792 iChildrenProcessed = EFalse; |
|
793 iState = ESearchingSprites; |
|
794 iCurrentParent=iCurrentNode->iParent; |
|
795 if ( iCurrentNode == iTopNode ) |
|
796 { |
|
797 iCurrentNode = NULL; |
|
798 } |
|
799 return iCurrentNode; |
|
800 } |
|
801 return NULL; |
|
802 } |
|
803 |
|
804 // --------------------------------------------------------------------------- |
|
805 // FindPreviousChild |
|
806 // --------------------------------------------------------------------------- |
|
807 // |
|
808 CAlfNode* CAlfNode::FindPreviousChild() |
|
809 { |
|
810 CAlfNode* previousSibling = NULL; |
|
811 switch ( iType ) |
|
812 { |
|
813 default: |
|
814 { |
|
815 previousSibling = iParent->iChild; |
|
816 break; |
|
817 } |
|
818 case MWsWindowTreeNode::EWinTreeNodeAnim: |
|
819 { |
|
820 previousSibling = iParent->iAnimChild; |
|
821 break; |
|
822 } |
|
823 case MWsWindowTreeNode::EWinTreeNodeSprite: |
|
824 { |
|
825 previousSibling = iParent->iSpriteChild; |
|
826 break; |
|
827 } |
|
828 case MWsWindowTreeNode::EWinTreeNodeStandardTextCursor: |
|
829 { |
|
830 previousSibling = iParent->iTextCursor; |
|
831 break; |
|
832 } |
|
833 } |
|
834 |
|
835 if ( previousSibling == this ) |
|
836 { |
|
837 return NULL; // return NULL, if I was the first child |
|
838 } |
|
839 // starting from the first child, loop until this one is found. |
|
840 |
|
841 while( previousSibling->iSibling != this) |
|
842 { |
|
843 previousSibling = previousSibling->iSibling; |
|
844 } |
|
845 |
|
846 return previousSibling; // return the previous child. return NULL, if this was the first child |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------------------------- |
|
850 // FadeCountChanged |
|
851 // Fade count changes are sent also to Anim, Sprite and text cursor nodes. |
|
852 // --------------------------------------------------------------------------- |
|
853 // |
|
854 void CAlfNode::FadeCountChanged( TInt aFadeCount ) |
|
855 { |
|
856 RArray<CAlfNode*> children; |
|
857 ListOffspring(children, EFalse); // EFalse = dont list chilren, only sprites, anims and textcursor |
|
858 TBool fade = aFadeCount ? ETrue : EFalse; |
|
859 |
|
860 for(TInt i=0;i<children.Count(); i++) |
|
861 { |
|
862 children[i]->SetFaded(fade); |
|
863 } |
|
864 children.Close(); |
|
865 iFadeCount = aFadeCount; |
|
866 } |
|
867 |
|
868 // --------------------------------------------------------------------------- |
|
869 // SetFaded |
|
870 // --------------------------------------------------------------------------- |
|
871 // |
|
872 void CAlfNode::SetFaded( TBool aFaded ) |
|
873 { |
|
874 iFadeState = aFaded && ( !iNonFading ); |
|
875 if (Type()== MWsWindowTreeNode::EWinTreeNodeRoot) |
|
876 { |
|
877 // NO need to deliver fades for root |
|
878 return; |
|
879 } |
|
880 if (iFadeState != iPostedFadeState) |
|
881 { |
|
882 iModel->Server().Bridge()->AddData( EAlfDSSetFadeEffect, iId , iFadeState); |
|
883 iPostedFadeState = iFadeState; |
|
884 } |
|
885 } |
|
886 |
|
887 // --------------------------------------------------------------------------- |
|
888 // FadeAllChildren |
|
889 // --------------------------------------------------------------------------- |
|
890 // |
|
891 void CAlfNode::FadeAllChildren( TBool aFaded ) |
|
892 { |
|
893 SetFaded(aFaded); |
|
894 |
|
895 CAlfNode* node = (CAlfNode*)iSpriteChild; |
|
896 while( node ) |
|
897 { |
|
898 node->SetFaded( iFadeState ); |
|
899 node = node->iSibling; |
|
900 } |
|
901 node = (CAlfNode*)iAnimChild; |
|
902 while( node ) |
|
903 { |
|
904 node->SetFaded( iFadeState ); |
|
905 node = node->iSibling; |
|
906 } |
|
907 if ( iTextCursor ) |
|
908 { |
|
909 iTextCursor->SetFaded( iFadeState ); |
|
910 } |
|
911 node = (CAlfNode*)iChild; |
|
912 while ( node ) |
|
913 { |
|
914 node->FadeAllChildren( iFadeState ); |
|
915 node = node->iSibling; |
|
916 } |
|
917 } |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // ListOffspring |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 void CAlfNode::ListOffspring( RArray<CAlfNode*>& aList, TBool aListChildren) |
|
924 { |
|
925 aList.Append(this); |
|
926 |
|
927 CAlfNode* node = (CAlfNode*)iSpriteChild; |
|
928 while( node ) |
|
929 { |
|
930 aList.Append(node); |
|
931 node = node->iSibling; |
|
932 } |
|
933 node = (CAlfNode*)iAnimChild; |
|
934 while( node ) |
|
935 { |
|
936 aList.Append(node); |
|
937 node = node->iSibling; |
|
938 } |
|
939 if ( iTextCursor ) |
|
940 { |
|
941 aList.Append(iTextCursor); |
|
942 } |
|
943 if (aListChildren) |
|
944 { |
|
945 node = (CAlfNode*)iChild; |
|
946 while ( node ) |
|
947 { |
|
948 node->ListOffspring( aList ); |
|
949 node = node->iSibling; |
|
950 } |
|
951 } |
|
952 } |
|
953 // --------------------------------------------------------------------------- |
|
954 // FlagChanged |
|
955 // --------------------------------------------------------------------------- |
|
956 // |
|
957 void CAlfNode::FlagChanged( MWsWindowTreeObserver::TFlags aFlag, TBool aNewValue ) |
|
958 { |
|
959 switch( aFlag ) |
|
960 { |
|
961 case MWsWindowTreeObserver::EVisible: |
|
962 { |
|
963 // TODO: Do something!!!! |
|
964 iVisible = aNewValue; |
|
965 break; |
|
966 } |
|
967 case MWsWindowTreeObserver::ENonFading: |
|
968 { |
|
969 iNonFading = aNewValue; |
|
970 FadeAllChildren(iFadeState); |
|
971 break; |
|
972 } |
|
973 case MWsWindowTreeObserver::EAlphaChannelTransparencyEnabled: |
|
974 { |
|
975 iAlphaChannelTransparencyEnabled = aNewValue; |
|
976 break; |
|
977 } |
|
978 case MWsWindowTreeObserver::ECursorClipRectSet: |
|
979 { |
|
980 // TODO: take into account with cursor |
|
981 // ECursorClipRectSet |
|
982 break; |
|
983 } |
|
984 } |
|
985 } |
|
986 |
|
987 // --------------------------------------------------------------------------- |
|
988 // CreateWindowAttributes |
|
989 // --------------------------------------------------------------------------- |
|
990 // |
|
991 TAny* CAlfNode::CreateWindowAttributes(TInt& aIndex, TInt aSize ) |
|
992 { |
|
993 TAny* attributes = NULL; |
|
994 TRAP_IGNORE(attributes = (TAny*)iModel->Server().Bridge()->AppendVarDataL( aSize, aIndex )) |
|
995 Mem::FillZ( (TUint8*)attributes, aSize ); // Initialize the returned memory area to 0 |
|
996 return attributes; |
|
997 } |
|
998 |
|
999 // --------------------------------------------------------------------------- |
|
1000 // SiblingOrderChanged |
|
1001 // --------------------------------------------------------------------------- |
|
1002 // |
|
1003 void CAlfNode::SiblingOrderChanged( TInt aNewPos ) |
|
1004 { |
|
1005 // __ALFLOGSTRING1("CAlfNode::SiblingOrderChanged - Id %d, Old ordinal position: %d"), iId, OrdinalPosition()); |
|
1006 ASSERT( iType != MWsWindowTreeNode::EWinTreeNodeRoot); |
|
1007 ASSERT( iType != MWsWindowTreeNode::EWinTreeNodeSprite); |
|
1008 ASSERT( iType != MWsWindowTreeNode::EWinTreeNodeAnim); |
|
1009 ASSERT( iType != MWsWindowTreeNode::EWinTreeNodeStandardTextCursor); |
|
1010 ASSERT( iType == MWsWindowTreeNode::EWinTreeNodeGroup || iType == MWsWindowTreeNode::EWinTreeNodeClient ); |
|
1011 ASSERT(iParent != NULL); |
|
1012 ASSERT(iParent->iChild != NULL); |
|
1013 CAlfNode* previous = FindPreviousChild(); |
|
1014 ASSERT( previous || this == iParent->iChild ); |
|
1015 |
|
1016 |
|
1017 // Need to find the previous node to this node (oldPrevNode) |
|
1018 // and the node previous to aNewPos (newPrevNode) |
|
1019 // Then link oldPrevNode->iSibling to this->iSibling (unlink this node from the chain) |
|
1020 // And link this->iSibling to newPrevNode->iSibling (link the right hand side of this node back in) |
|
1021 // And link newPrevNode->iSibling to this (link the left hand side of this node back in) |
|
1022 |
|
1023 // Will point to the prev node for the current/old position |
|
1024 CAlfNode* oldPrevNode = NULL; |
|
1025 // Will point to the prev node for the new position |
|
1026 CAlfNode* newPrevNode = NULL; |
|
1027 |
|
1028 // parent |
|
1029 // | |
|
1030 // | 0 1 2 3 4 |
|
1031 // +-->A ->B ->C ->D ->E ->null |
|
1032 // ^^^ |
|
1033 // position 0 is a special case... |
|
1034 // if the new position is 0 then newPrevNode is the parent |
|
1035 // if this is the leftmost sibling then oldPrevNode is the parent |
|
1036 |
|
1037 TInt iterNodePosition=0; |
|
1038 CAlfNode* iterPrevNode = iParent; |
|
1039 CAlfNode* iterNode = iParent->iChild; |
|
1040 |
|
1041 while (oldPrevNode == NULL || newPrevNode == NULL) |
|
1042 { |
|
1043 // Have we found the current/old position? |
|
1044 if (iterNode == this) |
|
1045 { |
|
1046 oldPrevNode = iterPrevNode; |
|
1047 |
|
1048 if (newPrevNode == NULL && iterNodePosition != aNewPos) |
|
1049 { |
|
1050 // Found the old position first |
|
1051 // and not at the new position yet |
|
1052 // so "this" will be moving to the right |
|
1053 // which will cause the following nodes to move left by one |
|
1054 // so we need to compensate by adding one to the target position |
|
1055 // |
|
1056 // 0 1 2 3 4 |
|
1057 // p ->A ->B ->C ->D ->E ->n if we are moving B to position 3 then need to find D->E link (iterPrevNode->iterNode) |
|
1058 // p ->A ->C ->D ->B ->E ->n but because C and D will be moving left, |
|
1059 // D->E is actually position at 4. |
|
1060 ++aNewPos; |
|
1061 } |
|
1062 } |
|
1063 |
|
1064 // Have we found the new position? |
|
1065 if (iterNodePosition == aNewPos) |
|
1066 { |
|
1067 newPrevNode = iterPrevNode; |
|
1068 } |
|
1069 |
|
1070 // Move onto the next node - if there is one |
|
1071 if (iterNode != NULL) |
|
1072 { |
|
1073 // move to next node |
|
1074 iterPrevNode = iterNode; |
|
1075 iterNode = iterNode->iSibling; |
|
1076 ++iterNodePosition; |
|
1077 } |
|
1078 else |
|
1079 { |
|
1080 // parent |
|
1081 // | |
|
1082 // | 0 1 2 3 4 |
|
1083 // +-->A ->B ->C ->D ->E ->null |
|
1084 // ^^^ |
|
1085 // if iterNode gets to NULL, then we must have found both matches |
|
1086 // - i.e. either the new or current/old position is the rightmost node |
|
1087 ASSERT(oldPrevNode!=NULL && newPrevNode!=NULL); |
|
1088 } |
|
1089 |
|
1090 ASSERT(iterPrevNode!=NULL); |
|
1091 } // end while loop |
|
1092 |
|
1093 if (newPrevNode == oldPrevNode) |
|
1094 { |
|
1095 // we are being asked to move to our current position |
|
1096 // nothing to do |
|
1097 |
|
1098 return; |
|
1099 } |
|
1100 |
|
1101 // In the following example, oldPrevNode is A, this is B and newPrevNode is D - as discussed above |
|
1102 // |
|
1103 // Unlink this node from the chain (A->B becomes A->C, nothing points to B) |
|
1104 // 0 1 2 3 4 |
|
1105 // p--->A-¬ B-+->C--->D--->E--->n |
|
1106 // \--/ |
|
1107 if (oldPrevNode == iParent) |
|
1108 { |
|
1109 iParent->iChild = iSibling; |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 oldPrevNode->iSibling = iSibling; |
|
1114 } |
|
1115 |
|
1116 // Link the right hand side of this node back in (B->C becomes B->E, B half at position 3) |
|
1117 // 0 1 2 3 4 |
|
1118 // p--->A-------->C--->D-+->E--->n |
|
1119 // B-----/ |
|
1120 if (newPrevNode == iParent) |
|
1121 { |
|
1122 iSibling = iParent->iChild; |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 iSibling = newPrevNode->iSibling; |
|
1127 } |
|
1128 |
|
1129 // Link the left hand side of this node back in (D->E becomes D->B, B fully linked into position 3) |
|
1130 // 0 1 2 3 4 |
|
1131 // p--->A--->C--->D¬ +->E--->n |
|
1132 // \-B-/ |
|
1133 if (newPrevNode == iParent) |
|
1134 { |
|
1135 iParent->iChild = this; |
|
1136 } |
|
1137 else |
|
1138 { |
|
1139 newPrevNode->iSibling = this; |
|
1140 } |
|
1141 |
|
1142 UpdateOrdinalPosition(); |
|
1143 |
|
1144 if (HasChildren()) |
|
1145 { |
|
1146 UpdateChildrenOrdinalPositions(this); |
|
1147 } |
|
1148 |
|
1149 /* |
|
1150 TInt ordinal = OrdinalPosition(); |
|
1151 __ALFLOGSTRING1("New ordinal position: %d"), OrdinalPosition()); |
|
1152 #ifdef _DEBUG |
|
1153 PrintOrdinalPositions(); |
|
1154 #endif |
|
1155 TInt offset; |
|
1156 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes)); |
|
1157 windowAttributes->iOrdinalPosition = ordinal; |
|
1158 windowAttributes->iWindowNodeType = iType; |
|
1159 windowAttributes->iScreenNumber = iScreenNumber; |
|
1160 |
|
1161 iModel->Server().Bridge()->AddData( EAlfDSReorder, |
|
1162 iGroupId, |
|
1163 iId, |
|
1164 (TAny*)offset ); |
|
1165 */ |
|
1166 |
|
1167 |
|
1168 } |
|
1169 |
|
1170 // --------------------------------------------------------------------------- |
|
1171 // destructor |
|
1172 // --------------------------------------------------------------------------- |
|
1173 // |
|
1174 CAlfNode::~CAlfNode() |
|
1175 { |
|
1176 __ALFLOGSTRING1("CAlfNode::~CAlfNode %d", iId); |
|
1177 } |
|
1178 |
|
1179 // --------------------------------------------------------------------------- |
|
1180 // HasChildren |
|
1181 // --------------------------------------------------------------------------- |
|
1182 // |
|
1183 TBool CAlfNode::HasChildren() |
|
1184 { |
|
1185 return iSpriteChild || iAnimChild || iTextCursor || iChild; |
|
1186 } |
|
1187 |
|
1188 // --------------------------------------------------------------------------- |
|
1189 // RemoveDependencies |
|
1190 // --------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CAlfNode::RemoveDependencies( CAlfNode* aFirstChildOfMyType ) |
|
1193 { |
|
1194 // if I have siblings, then make my previous sibling's next sibling, that used to be my next sibling |
|
1195 /*if ( iParent ) |
|
1196 { |
|
1197 __ALFLOGSTRING1( "%d %d %d %d"), iParent->iChild , iParent->iSpriteChild , iParent->iAnimChild, iParent->iTextCursor ); |
|
1198 }*/ |
|
1199 |
|
1200 if ( iModel && iParent && aFirstChildOfMyType ) |
|
1201 { |
|
1202 CAlfNode* previousSibling = FindPreviousChild(); |
|
1203 if ( previousSibling ) |
|
1204 { |
|
1205 previousSibling->iSibling = iSibling; |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 // If we do not have previous sibling |
|
1210 switch ( iType ) |
|
1211 { |
|
1212 default: |
|
1213 { |
|
1214 iParent->iChild = iSibling; // Parent's child needs to change ONLY IF I was the first one. |
|
1215 break; |
|
1216 } |
|
1217 case MWsWindowTreeNode::EWinTreeNodeAnim: |
|
1218 { |
|
1219 iParent->iAnimChild = (CAlfNodeAnim*)iSibling; |
|
1220 break; |
|
1221 } |
|
1222 case MWsWindowTreeNode::EWinTreeNodeSprite: |
|
1223 { |
|
1224 iParent->iSpriteChild = (CAlfNodeSprite*)iSibling; |
|
1225 break; |
|
1226 } |
|
1227 } |
|
1228 |
|
1229 } |
|
1230 } |
|
1231 else |
|
1232 { |
|
1233 __ALFLOGSTRING1("My parent says, that I'm not his child :..( or no parent %d ", iParent ); |
|
1234 } |
|
1235 |
|
1236 // Orphon all the children |
|
1237 CAlfNode* child = iChild; |
|
1238 while( child ) |
|
1239 { |
|
1240 child = child->OrphonMe(); |
|
1241 } |
|
1242 iChild = NULL; |
|
1243 if ( iModel ) |
|
1244 { |
|
1245 iModel->RemoveNode( iId ); |
|
1246 } |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // Constructor |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 CAlfNodeVisual::CAlfNodeVisual() |
|
1254 { |
|
1255 iWindow = NULL; |
|
1256 }; |
|
1257 |
|
1258 // --------------------------------------------------------------------------- |
|
1259 // Constructor |
|
1260 // --------------------------------------------------------------------------- |
|
1261 // |
|
1262 void CAlfNodeVisual::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
1263 { |
|
1264 CAlfNode::ConstructL( aModel, aStream ); |
|
1265 aStream->ReadL( (TUint8*)&iOrigin, sizeof(TPoint)); |
|
1266 aStream->ReadL( (TUint8*)&iSize, sizeof(TSize)); |
|
1267 } |
|
1268 |
|
1269 // --------------------------------------------------------------------------- |
|
1270 // ReadEndMarkerL |
|
1271 // --------------------------------------------------------------------------- |
|
1272 // |
|
1273 void CAlfNodeVisual::ReadEndMarkerL( RMemReadStream& aStream ) |
|
1274 { |
|
1275 TUint8 marker = aStream.ReadInt8L(); |
|
1276 ASSERT( marker == EAlfCommandEndMarker ) ; // endmarker |
|
1277 } |
|
1278 |
|
1279 // --------------------------------------------------------------------------- |
|
1280 // UpdateOrdinalPosition |
|
1281 // --------------------------------------------------------------------------- |
|
1282 // |
|
1283 void CAlfNode::UpdateOrdinalPosition() |
|
1284 { |
|
1285 TInt ordinal = OrdinalPosition(); |
|
1286 if ( ordinal >= 0 ) |
|
1287 { |
|
1288 if ( iWindow ) |
|
1289 { |
|
1290 iWindow->Move( ordinal ); |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 //!!!! There is no window??? |
|
1295 // position must be updated, because it not necessary the first drawn. |
|
1296 TInt offset; |
|
1297 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes)); |
|
1298 windowAttributes->iOrdinalPosition = ordinal; |
|
1299 windowAttributes->iWindowNodeType = iType; |
|
1300 windowAttributes->iScreenNumber = iScreenNumber; |
|
1301 // for updating window group ordinals |
|
1302 iModel->Server().Bridge()->AddData( EAlfDSReorder, |
|
1303 iGroupId, |
|
1304 iId, |
|
1305 (TAny*)offset ); |
|
1306 } |
|
1307 } |
|
1308 } |
|
1309 |
|
1310 // --------------------------------------------------------------------------- |
|
1311 // UpdateChildrenOrdinalPositions |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // |
|
1314 void CAlfNode::UpdateChildrenOrdinalPositions(CAlfNode* aNode) |
|
1315 { |
|
1316 CAlfNode* node = (CAlfNode*)aNode->iSpriteChild; |
|
1317 while( node ) |
|
1318 { |
|
1319 node->UpdateOrdinalPosition(); |
|
1320 node = node->iSibling; |
|
1321 } |
|
1322 node = (CAlfNode*)aNode->iAnimChild; |
|
1323 while( node ) |
|
1324 { |
|
1325 node->UpdateOrdinalPosition(); |
|
1326 node = node->iSibling; |
|
1327 } |
|
1328 if ( aNode->iTextCursor ) |
|
1329 { |
|
1330 (aNode->iTextCursor)->UpdateOrdinalPosition(); |
|
1331 } |
|
1332 node = (CAlfNode*)aNode->iChild; |
|
1333 while ( node ) |
|
1334 { |
|
1335 node->UpdateChildrenOrdinalPositions(node); |
|
1336 node->UpdateOrdinalPosition(); |
|
1337 node = node->iSibling; |
|
1338 } |
|
1339 |
|
1340 } |
|
1341 |
|
1342 // --------------------------------------------------------------------------- |
|
1343 // CommitCommandsL |
|
1344 // --------------------------------------------------------------------------- |
|
1345 // |
|
1346 void CAlfNodeVisual::CommitCommands( TInt aCurrentPos, TInt aFrameSize, TBool aPartial, TBool aLastPart, TInt aChunkInUse ) |
|
1347 { |
|
1348 // __ALFLOGSTRING1("CAlfNodeVisual::CommitCommandsL, Id/Group: %d/%d Type: %d, Pos: %d, Size: %d, last part %d"), iId, iGroupId, iType, aCurrentPos, aFrameSize, aLastPart ); |
|
1349 if ( !iWindow ) |
|
1350 { |
|
1351 __ALFLOGSTRING("CAlfHierarchyModel::CommitCommandsL Discarding window commands"); |
|
1352 return; |
|
1353 } |
|
1354 |
|
1355 if ( !aFrameSize ) |
|
1356 { |
|
1357 __ALFLOGSTRING3("CAlfHierarchyModel::CommitCommandsL empty frame Pos: %d, Size: %d, last part %d ", aCurrentPos, aFrameSize, aLastPart ); |
|
1358 return; |
|
1359 } |
|
1360 |
|
1361 TBool emptyBuffer = EFalse; |
|
1362 |
|
1363 TInt nodeFlags = 0; |
|
1364 |
|
1365 // By default nodes are always opaque, unless they are sprites (or anims?) or |
|
1366 // transparency has been enabled in the window. |
|
1367 if (iType != MWsWindowTreeNode::EWinTreeNodeSprite && |
|
1368 iType != MWsWindowTreeNode::EWinTreeNodeAnim && |
|
1369 iType != MWsWindowTreeNode::EWinTreeNodeStandardTextCursor && |
|
1370 !iAlphaChannelTransparencyEnabled) |
|
1371 { |
|
1372 nodeFlags |= EAlfWinNodeFlagOpaque; |
|
1373 } |
|
1374 |
|
1375 if ( iType == MWsWindowTreeNode::EWinTreeNodeStandardTextCursor ) |
|
1376 { |
|
1377 emptyBuffer = ETrue; |
|
1378 } |
|
1379 |
|
1380 iWindow->PostPartialBuffer( iModel->ChunkBase(aChunkInUse) + aCurrentPos, aFrameSize, aPartial, aLastPart , emptyBuffer, nodeFlags ); |
|
1381 } |
|
1382 |
|
1383 // --------------------------------------------------------------------------- |
|
1384 // DrawWindowFrameL |
|
1385 // --------------------------------------------------------------------------- |
|
1386 void CAlfNodeVisual::DrawWindowFrameL( RMemReadStream& aStream ) |
|
1387 { |
|
1388 TInt32 chunkInUse = aStream.ReadInt32L(); |
|
1389 TInt nextFramePos = aStream.ReadInt32L(); |
|
1390 |
|
1391 // jump to the next frame |
|
1392 if ( nextFramePos == 12345678 ) |
|
1393 { |
|
1394 __ALFLOGSTRING("CAlfHierarchyModel::PostBufferL, Address of the frame has not been initialized!"); |
|
1395 } |
|
1396 // read frame flags. For offscreen content, we'll add the complete packets |
|
1397 // as partial, if they have not been implicitly flushed |
|
1398 |
|
1399 TUint8 command = aStream.ReadInt8L(); |
|
1400 __ASSERT_DEBUG( command == EAlfFrameFlags, USER_INVARIANT() ); |
|
1401 TInt32 frameFlags = aStream.ReadInt32L(); |
|
1402 |
|
1403 TUint8 padding = aStream.ReadInt8L(); |
|
1404 ReadEndMarkerL( aStream ); |
|
1405 while( padding--) |
|
1406 { |
|
1407 aStream.ReadInt8L(); |
|
1408 } |
|
1409 |
|
1410 TInt currentPos = aStream.Source()->TellL( MStreamBuf::ERead ).Offset(); |
|
1411 aStream.Source()->SeekL( MStreamBuf::ERead, TStreamPos(nextFramePos)); |
|
1412 TSgcCanvasCommands packetState = (TSgcCanvasCommands)aStream.ReadInt8L(); |
|
1413 TInt frameSize = nextFramePos - currentPos; |
|
1414 #ifdef _DEBUG |
|
1415 ASSERT( currentPos % 8 == 0 ); |
|
1416 #endif |
|
1417 |
|
1418 //__ALFLOGSTRING1("CAlfHierarchyModel::PostBufferL endMarker: %d partial: %d"), endMarker, iReadingPartialBuffer ); |
|
1419 switch( packetState ) |
|
1420 { |
|
1421 case EAlfPacketReady: |
|
1422 { |
|
1423 if ( frameFlags & EAlfTransparentContent ) |
|
1424 { |
|
1425 if ( frameFlags & EAlfTransparentContentFlush ) |
|
1426 { |
|
1427 CommitCommands( currentPos, frameSize, !iReadingPartialBuffer /*partial*/, ETrue /*lastpart*/, chunkInUse ); |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 CommitCommands( currentPos, frameSize, ETrue /*partial*/, EFalse/*not lastpart*/, chunkInUse ); |
|
1432 } |
|
1433 } |
|
1434 else |
|
1435 { |
|
1436 CommitCommands( currentPos, frameSize, iReadingPartialBuffer, ETrue, chunkInUse ); |
|
1437 } |
|
1438 iReadingPartialBuffer = EFalse; |
|
1439 |
|
1440 break; |
|
1441 } |
|
1442 case EAlfPacketNotReady: |
|
1443 { |
|
1444 __ASSERT_DEBUG( nextFramePos % 8 == 0, USER_INVARIANT() ); |
|
1445 __ASSERT_DEBUG( frameSize % 8 == 0, USER_INVARIANT() ); |
|
1446 iReadingPartialBuffer = ETrue; |
|
1447 CommitCommands( currentPos, frameSize, iReadingPartialBuffer, EFalse, chunkInUse ); |
|
1448 break; |
|
1449 } |
|
1450 default: |
|
1451 { |
|
1452 __ALFLOGSTRING1("CAlfHierarchyModel::PostBufferL endMarker: %d ", packetState); |
|
1453 break; |
|
1454 } |
|
1455 } |
|
1456 } |
|
1457 |
|
1458 |
|
1459 // --------------------------------------------------------------------------- |
|
1460 // FlagChanged |
|
1461 // --------------------------------------------------------------------------- |
|
1462 // |
|
1463 void CAlfNodeVisual::FlagChanged( MWsWindowTreeObserver::TFlags aFlag, TBool aNewValue ) |
|
1464 { |
|
1465 switch( aFlag ) |
|
1466 { |
|
1467 case MWsWindowTreeObserver::EVisible: |
|
1468 { |
|
1469 iVisible = aNewValue; |
|
1470 if ( iWindow ) |
|
1471 { |
|
1472 if ( iVisible && iNodeActivated ) |
|
1473 { |
|
1474 iWindow->SetActive( ETrue ); |
|
1475 } |
|
1476 else |
|
1477 { |
|
1478 iWindow->SetActive( EFalse ); |
|
1479 } |
|
1480 } |
|
1481 break; |
|
1482 } |
|
1483 case MWsWindowTreeObserver::ENonFading: |
|
1484 { |
|
1485 iNonFading = aNewValue; |
|
1486 SetFaded(iFadeState); |
|
1487 break; |
|
1488 } |
|
1489 case MWsWindowTreeObserver::EAlphaChannelTransparencyEnabled: |
|
1490 { |
|
1491 iAlphaChannelTransparencyEnabled = aNewValue; |
|
1492 break; |
|
1493 } |
|
1494 } |
|
1495 if ( aFlag == MWsWindowTreeObserver::ENonFading && HasChildren() ) |
|
1496 { |
|
1497 UpdateChildrenFlags( aFlag, iFadeState ); |
|
1498 } |
|
1499 } |
|
1500 |
|
1501 // --------------------------------------------------------------------------- |
|
1502 // UpdateChildrenFlags |
|
1503 // --------------------------------------------------------------------------- |
|
1504 // |
|
1505 void CAlfNodeVisual::UpdateChildrenFlags( MWsWindowTreeObserver::TFlags aFlag, TBool aNewValue ) |
|
1506 { |
|
1507 CAlfNode* node = (CAlfNode*)iSpriteChild; |
|
1508 while( node ) |
|
1509 { |
|
1510 node->FlagChanged( aFlag, aNewValue ); |
|
1511 node = node->iSibling; |
|
1512 } |
|
1513 node = (CAlfNode*)iAnimChild; |
|
1514 while( node ) |
|
1515 { |
|
1516 node->FlagChanged( aFlag, aNewValue ); |
|
1517 node = node->iSibling; |
|
1518 } |
|
1519 if ( iTextCursor ) |
|
1520 { |
|
1521 iTextCursor->FlagChanged( aFlag, aNewValue ); |
|
1522 } |
|
1523 node = (CAlfNode*)iChild; |
|
1524 while ( node ) |
|
1525 |
|
1526 { |
|
1527 node->FlagChanged( aFlag, aNewValue ); // causes recursion on children |
|
1528 node = node->iSibling; |
|
1529 } |
|
1530 } |
|
1531 |
|
1532 // --------------------------------------------------------------------------- |
|
1533 // SetExtent |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // |
|
1536 void CAlfNodeVisual::SetExtent( TRect& aRect ) |
|
1537 { |
|
1538 // aRect is in screen coordinates whereas iOrigin and iSize are relative. |
|
1539 if ( iSize != aRect.Size() ) |
|
1540 { |
|
1541 iSize = aRect.Size(); |
|
1542 if ( iWindow) |
|
1543 { |
|
1544 iWindow->SetSize(iSize,0); |
|
1545 } |
|
1546 } |
|
1547 // Recursively, TODO, check this with flash example |
|
1548 TPoint parentPosition; |
|
1549 CAlfNodeVisual* parent = (CAlfNodeVisual*)iParent; |
|
1550 while(parent) |
|
1551 { |
|
1552 if(parent->Type() != MWsWindowTreeNode::EWinTreeNodeGroup) |
|
1553 { // parent |
|
1554 parentPosition += parent->iOrigin; |
|
1555 parent = (CAlfNodeVisual*)parent->iParent; |
|
1556 } |
|
1557 else |
|
1558 { |
|
1559 break; |
|
1560 } |
|
1561 |
|
1562 } |
|
1563 |
|
1564 TPoint newOrigin = aRect.iTl - parentPosition; |
|
1565 if ( iOrigin != newOrigin ) |
|
1566 { |
|
1567 iOrigin = newOrigin; |
|
1568 if (iWindow) |
|
1569 { |
|
1570 iWindow->SetPos(iOrigin, 0 ); |
|
1571 /*if (HasChildren()) |
|
1572 { |
|
1573 UpdateChildrenExtents(posDelta); |
|
1574 }*/ |
|
1575 // __ALFLOGSTRING1("CAlfNodeVisual, SetPos %d,%d, iType %d"), iOrigin.iX, iOrigin.iY, iType ); |
|
1576 } |
|
1577 } |
|
1578 // __ALFLOGSTRING1("CAlfNodeVisual, SetExtent iSize: %d,%d ; iPosition %d,%d "), iSize.iWidth, iSize.iHeight, iOrigin.iX, iOrigin.iY ); |
|
1579 } |
|
1580 |
|
1581 void CAlfNodeVisual::UpdateParentPosition(TPoint aPosDelta) |
|
1582 { |
|
1583 // iParentPosition = aRect.iTl; |
|
1584 // iParentSize = aRect.Size(); |
|
1585 |
|
1586 // Todo, size change? |
|
1587 if (iWindow) |
|
1588 { |
|
1589 iOrigin += aPosDelta; |
|
1590 iWindow->SetPos( iOrigin, 0 ); |
|
1591 UpdateChildrenExtents(aPosDelta); |
|
1592 // __ALFLOGSTRING1("CAlfNodeVisual, SetPos %d,%d, iType %d"), iOrigin.iX, iOrigin.iY, iType ); |
|
1593 } |
|
1594 |
|
1595 } |
|
1596 |
|
1597 void CAlfNodeVisual::UpdateChildrenExtents(TPoint aPosDelta) |
|
1598 { |
|
1599 CAlfNode* node = (CAlfNode*)iSpriteChild; |
|
1600 while( node ) |
|
1601 { |
|
1602 ((CAlfNodeVisual*)node)->UpdateParentPosition(aPosDelta); |
|
1603 node = node->iSibling; |
|
1604 } |
|
1605 node = (CAlfNodeVisual*)iAnimChild; |
|
1606 while( node ) |
|
1607 { |
|
1608 ((CAlfNodeVisual*)node)->UpdateParentPosition(aPosDelta); |
|
1609 node = node->iSibling; |
|
1610 } |
|
1611 if ( iTextCursor ) |
|
1612 { |
|
1613 ((CAlfNodeVisual*)iTextCursor)->UpdateParentPosition(aPosDelta); |
|
1614 } |
|
1615 node = (CAlfNodeVisual*)iChild; |
|
1616 while ( node ) |
|
1617 { |
|
1618 ((CAlfNodeVisual*)node)->UpdateChildrenExtents(aPosDelta); |
|
1619 ((CAlfNodeVisual*)node)->UpdateParentPosition(aPosDelta); |
|
1620 |
|
1621 node = node->iSibling; |
|
1622 } |
|
1623 } |
|
1624 |
|
1625 // --------------------------------------------------------------------------- |
|
1626 // ActivateNodeL |
|
1627 // --------------------------------------------------------------------------- |
|
1628 // |
|
1629 void CAlfNodeVisual::ActivateNode() |
|
1630 { |
|
1631 if ( !iNodeActivated) |
|
1632 { |
|
1633 iNodeActivated = ETrue; |
|
1634 |
|
1635 if ( iWindow ) |
|
1636 { |
|
1637 if ( iVisible ) |
|
1638 { |
|
1639 iWindow->SetActive( ETrue ); |
|
1640 } |
|
1641 } |
|
1642 } |
|
1643 else |
|
1644 { |
|
1645 __ALFLOGSTRING("CAlfNodeVisual::ActivateNodeL - Node ALREADY active! "); |
|
1646 } |
|
1647 } |
|
1648 |
|
1649 |
|
1650 // --------------------------------------------------------------------------- |
|
1651 // CreateWindowL |
|
1652 // --------------------------------------------------------------------------- |
|
1653 void CAlfNodeVisual::CreateWindowL(TInt aWindowGroupHandle, TInt aWindowHandle, TInt aParentWindowHandle) |
|
1654 { |
|
1655 TWindowIdentifier windowIdentifier( iGroupId, iId ); |
|
1656 TWindowIdentifier clientSideIdentifier( aWindowGroupHandle, aWindowHandle ); |
|
1657 TWindowIdentifier parentIdentifier( 0, aParentWindowHandle ); // Group id not used, set to zero. |
|
1658 |
|
1659 TAlfWServInfo info; |
|
1660 info.iSize = iSize; |
|
1661 info.iPosition = iOrigin; |
|
1662 info.iRefId = windowIdentifier; // Node ids |
|
1663 info.iClientSideId = clientSideIdentifier; // Client handles |
|
1664 info.iNodeType = iType; |
|
1665 info.iScreenNumber = iScreenNumber; |
|
1666 info.iParentRefId = parentIdentifier; |
|
1667 #ifdef ALF_DEBUG_TRACK_DRAWING |
|
1668 info.iTrackWindow = iTrackNode; |
|
1669 #endif |
|
1670 iWindow = iModel->Server().WindowMgr()->CreateNewWindowL( iId, info ); |
|
1671 iWindow->CommitGc(); |
|
1672 } |
|
1673 |
|
1674 // --------------------------------------------------------------------------- |
|
1675 // destructor |
|
1676 // --------------------------------------------------------------------------- |
|
1677 // |
|
1678 CAlfNodeVisual::~CAlfNodeVisual() |
|
1679 { |
|
1680 if ( iWindow && iModel ) |
|
1681 { |
|
1682 iModel->Server().WindowMgr()->DestroyWindow( *iWindow ); |
|
1683 } |
|
1684 } |
|
1685 |
|
1686 // --------------------------------------------------------------------------- |
|
1687 // Constructor |
|
1688 // --------------------------------------------------------------------------- |
|
1689 // |
|
1690 CAlfNodeWindow::CAlfNodeWindow() |
|
1691 { |
|
1692 iType = MWsWindowTreeNode::EWinTreeNodeClient; |
|
1693 }; |
|
1694 |
|
1695 CAlfNodeWindow::~CAlfNodeWindow() |
|
1696 { |
|
1697 RemoveDependencies( iParent ? iParent->iChild : NULL ); |
|
1698 } |
|
1699 // --------------------------------------------------------------------------- |
|
1700 // ConstructL |
|
1701 // --------------------------------------------------------------------------- |
|
1702 // |
|
1703 void CAlfNodeWindow::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
1704 { |
|
1705 CAlfNodeVisual::ConstructL( aModel, aStream ); |
|
1706 aStream->ReadL( (TUint8*)&iNodeWindowConstructionStruct, sizeof( TNodeWindowConstructionStruct ) ); |
|
1707 iOrdinalPriority = iNodeWindowConstructionStruct.iOrdinalPriority; |
|
1708 ResolveParent( iNodeWindowConstructionStruct.iParentId, iId ); |
|
1709 CreateWindowL( iNodeWindowConstructionStruct.iWindowGroupHandle, iNodeWindowConstructionStruct.iWindowHandle, iNodeWindowConstructionStruct.iParentId ); |
|
1710 UpdateOrdinalPosition(); |
|
1711 } |
|
1712 |
|
1713 // --------------------------------------------------------------------------- |
|
1714 // MoveToWindowGroup |
|
1715 // !!!! THIS METHOD HAS NOT BEEN TESTED AT ALL!!!!!! EXPECT TROUBLE!!!! |
|
1716 // --------------------------------------------------------------------------- |
|
1717 // |
|
1718 void CAlfNodeWindow::MoveToWindowGroup( TUint32 aNewGroupId ) |
|
1719 { |
|
1720 __ALFLOGSTRING("CAlfNodeWindow::MoveToWindowGroup, THIS METHOD IS UNTESTED. EXPECT TROUBLE!"); |
|
1721 CAlfNodeGroup* newGroup = (CAlfNodeGroup*)iModel->FindNode( aNewGroupId ); |
|
1722 if ( newGroup ) |
|
1723 { |
|
1724 // collect my children in my old group |
|
1725 RPointerArray<CAlfNode> myChildNodes; |
|
1726 GetAllChildrenInGroup( myChildNodes, iId ); |
|
1727 |
|
1728 // release old relationships |
|
1729 CAlfNode* previous = FindPreviousChild(); |
|
1730 if ( !previous ) |
|
1731 { |
|
1732 iParent->iChild = iSibling; // I was the first and possibly only child |
|
1733 } |
|
1734 else |
|
1735 { |
|
1736 previous->iSibling = iSibling; // there was the a previous child. update the link to my next sibling (which might be NULL) |
|
1737 } |
|
1738 TUint32 oldGroupId = iParent->iId; |
|
1739 iParent = newGroup; |
|
1740 SetFirstChild(); |
|
1741 |
|
1742 // yippii, new parent, |
|
1743 // add me as the first child of the new group |
|
1744 // TODO: Move the nodes to the new group? |
|
1745 TInt i = myChildNodes.Count(); |
|
1746 while( --i >=0 ) // update groupid and send new location to appui |
|
1747 { |
|
1748 iModel->Server().Bridge()->AddData( EAlfDSMoveWindowToNewGroup, |
|
1749 myChildNodes[i]->iId, |
|
1750 oldGroupId, |
|
1751 (TAny*)aNewGroupId ); |
|
1752 myChildNodes[i]->iGroupId = aNewGroupId; |
|
1753 } |
|
1754 |
|
1755 myChildNodes.Close(); |
|
1756 } |
|
1757 else |
|
1758 { |
|
1759 __ALFLOGSTRING("CAlfNodeWindow::MoveToWindowGroupL, new group does not exists"); |
|
1760 USER_INVARIANT(); |
|
1761 } |
|
1762 } |
|
1763 |
|
1764 // --------------------------------------------------------------------------- |
|
1765 // NewL |
|
1766 // --------------------------------------------------------------------------- |
|
1767 // |
|
1768 CAlfNodeWindow* CAlfNodeWindow::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream, TInt aScreenNumber ) |
|
1769 { |
|
1770 CAlfNodeWindow* self = new(ELeave)CAlfNodeWindow(); |
|
1771 CleanupStack::PushL( self ); |
|
1772 self->iScreenNumber = aScreenNumber; |
|
1773 self->ConstructL( aModel, aStream ); |
|
1774 CleanupStack::Pop( self ); |
|
1775 return self; |
|
1776 } |
|
1777 |
|
1778 // --------------------------------------------------------------------------- |
|
1779 // Construct |
|
1780 // --------------------------------------------------------------------------- |
|
1781 // |
|
1782 CAlfNodeRoot::CAlfNodeRoot( ) |
|
1783 { |
|
1784 iType = MWsWindowTreeNode::EWinTreeNodeRoot; |
|
1785 } |
|
1786 |
|
1787 // --------------------------------------------------------------------------- |
|
1788 // ConstructL |
|
1789 // --------------------------------------------------------------------------- |
|
1790 // |
|
1791 void CAlfNodeRoot::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
1792 { |
|
1793 CAlfNodeVisual::ConstructL( aModel, aStream ); |
|
1794 |
|
1795 // TODO: |
|
1796 ResolveParent( 0, iId ); |
|
1797 CreateWindowL(0,0,0); // Currently renderstage does not deliver ws/wg handles |
|
1798 } |
|
1799 |
|
1800 // --------------------------------------------------------------------------- |
|
1801 // NewL |
|
1802 // --------------------------------------------------------------------------- |
|
1803 // |
|
1804 CAlfNodeRoot* CAlfNodeRoot::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream, TInt aScreenNumber ) |
|
1805 { |
|
1806 CAlfNodeRoot* self = new(ELeave)CAlfNodeRoot(); |
|
1807 CleanupStack::PushL( self ); |
|
1808 self->iScreenNumber = aScreenNumber; |
|
1809 self->ConstructL( aModel, aStream ); |
|
1810 CleanupStack::Pop( self ); |
|
1811 return self; |
|
1812 } |
|
1813 |
|
1814 // --------------------------------------------------------------------------- |
|
1815 // destructor |
|
1816 // --------------------------------------------------------------------------- |
|
1817 // |
|
1818 CAlfNodeRoot::~CAlfNodeRoot( ) |
|
1819 { |
|
1820 // TODO: destroy all children nodes? |
|
1821 RemoveDependencies( NULL ); |
|
1822 } |
|
1823 |
|
1824 // --------------------------------------------------------------------------- |
|
1825 // Constructor |
|
1826 // --------------------------------------------------------------------------- |
|
1827 // |
|
1828 CAlfNodeGroup::CAlfNodeGroup() |
|
1829 { |
|
1830 iType = MWsWindowTreeNode::EWinTreeNodeGroup; |
|
1831 } |
|
1832 |
|
1833 // --------------------------------------------------------------------------- |
|
1834 // ConstructL |
|
1835 // --------------------------------------------------------------------------- |
|
1836 // |
|
1837 void CAlfNodeGroup::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
1838 { |
|
1839 CAlfNode::ConstructL( aModel, aStream ); |
|
1840 TInt32 clientHandle = aStream->ReadUint32L(); |
|
1841 iSecureId = aStream->ReadUint32L(); |
|
1842 TInt32 parentId = aStream->ReadUint32L(); |
|
1843 |
|
1844 ResolveParent( parentId, iId ); |
|
1845 |
|
1846 TInt offset; |
|
1847 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes)); |
|
1848 windowAttributes->iWindowNodeType = iType; |
|
1849 windowAttributes->iClientHandle = clientHandle; |
|
1850 windowAttributes->iScreenNumber = iScreenNumber; |
|
1851 windowAttributes->iSecureId = iSecureId; |
|
1852 windowAttributes->iParentNodeId = parentId; |
|
1853 |
|
1854 iModel->Server().Bridge()->AddData( EAlfDSNewWindow, |
|
1855 iGroupId, |
|
1856 iId, |
|
1857 (TAny*)offset ); |
|
1858 } |
|
1859 |
|
1860 // --------------------------------------------------------------------------- |
|
1861 // NewL |
|
1862 // --------------------------------------------------------------------------- |
|
1863 // |
|
1864 CAlfNodeGroup* CAlfNodeGroup::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream , TInt aScreenNumber ) |
|
1865 { |
|
1866 CAlfNodeGroup* self = new(ELeave)CAlfNodeGroup(); |
|
1867 CleanupStack::PushL( self ); |
|
1868 self->iScreenNumber = aScreenNumber; |
|
1869 self->ConstructL( aModel, aStream ); |
|
1870 CleanupStack::Pop( self ); |
|
1871 return self; |
|
1872 } |
|
1873 |
|
1874 // --------------------------------------------------------------------------- |
|
1875 // WindowGroupChainedL |
|
1876 // --------------------------------------------------------------------------- |
|
1877 // |
|
1878 void CAlfNodeGroup::WindowGroupChained( TUint32 aChainedGroup ) |
|
1879 { |
|
1880 iChainedTo = (CAlfNodeGroup*)iModel->FindNode( aChainedGroup ); |
|
1881 if ( iChainedTo ) |
|
1882 { |
|
1883 iChainedTo->iChainedFrom = this; |
|
1884 } |
|
1885 else |
|
1886 { |
|
1887 USER_INVARIANT(); |
|
1888 } |
|
1889 |
|
1890 if (iModel) |
|
1891 { |
|
1892 iModel->Server().Bridge()->AddData( EAlfDSGroupChained, |
|
1893 iId, |
|
1894 aChainedGroup, |
|
1895 (TAny*)iScreenNumber |
|
1896 ); |
|
1897 } |
|
1898 } |
|
1899 |
|
1900 // --------------------------------------------------------------------------- |
|
1901 // GroupChainBrokenAfter |
|
1902 // --------------------------------------------------------------------------- |
|
1903 // |
|
1904 void CAlfNodeGroup::GroupChainBrokenAfter( ) |
|
1905 { |
|
1906 if ( iChainedTo ) |
|
1907 { |
|
1908 iChainedTo->iChainedFrom = NULL; |
|
1909 iChainedTo = NULL; |
|
1910 } |
|
1911 if (iModel) |
|
1912 { |
|
1913 iModel->Server().Bridge()->AddData( EAlfDSGroupChainBroken, |
|
1914 iId, |
|
1915 0, |
|
1916 (TAny*)iScreenNumber ); |
|
1917 } |
|
1918 |
|
1919 } |
|
1920 |
|
1921 |
|
1922 // --------------------------------------------------------------------------- |
|
1923 // destructor |
|
1924 // --------------------------------------------------------------------------- |
|
1925 // |
|
1926 CAlfNodeGroup::~CAlfNodeGroup() |
|
1927 { |
|
1928 if ( iChainedTo ) |
|
1929 { |
|
1930 GroupChainBrokenAfter(); |
|
1931 } |
|
1932 if ( iChainedFrom ) |
|
1933 { |
|
1934 iChainedFrom->iChainedTo = NULL; |
|
1935 } |
|
1936 |
|
1937 if (iModel) |
|
1938 { |
|
1939 TInt offset; |
|
1940 TAlfWindowAttributes* windowAttributes = (TAlfWindowAttributes*)CreateWindowAttributes(offset, sizeof(TAlfWindowAttributes)); |
|
1941 windowAttributes->iWindowNodeType = iType; |
|
1942 windowAttributes->iScreenNumber = iScreenNumber; |
|
1943 |
|
1944 iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, |
|
1945 iGroupId, |
|
1946 iId, |
|
1947 (TAny*)offset ); |
|
1948 } |
|
1949 RemoveDependencies( iParent->iChild ); |
|
1950 }; |
|
1951 |
|
1952 // --------------------------------------------------------------------------- |
|
1953 // constructor |
|
1954 // --------------------------------------------------------------------------- |
|
1955 // |
|
1956 CAlfNodeAnim::CAlfNodeAnim( ) |
|
1957 { |
|
1958 iType = MWsWindowTreeNode::EWinTreeNodeAnim; |
|
1959 } |
|
1960 |
|
1961 CAlfNodeAnim::~CAlfNodeAnim( ) |
|
1962 { |
|
1963 if ( iParent ) |
|
1964 { |
|
1965 RemoveDependencies( iParent->iAnimChild ); |
|
1966 } |
|
1967 } |
|
1968 |
|
1969 // --------------------------------------------------------------------------- |
|
1970 // ConstructL |
|
1971 // --------------------------------------------------------------------------- |
|
1972 // |
|
1973 void CAlfNodeAnim::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
1974 { |
|
1975 CAlfNodeVisual::ConstructL( aModel, aStream ); |
|
1976 TInt32 parentId = aStream->ReadUint32L(); |
|
1977 |
|
1978 // TODO: |
|
1979 ResolveParent( parentId, iId ); |
|
1980 CreateWindowL(0,0,iParent->iId); // Currently renderstage does not deliver ws/wg handles |
|
1981 UpdateOrdinalPosition(); |
|
1982 } |
|
1983 |
|
1984 // --------------------------------------------------------------------------- |
|
1985 // NewL |
|
1986 // --------------------------------------------------------------------------- |
|
1987 // |
|
1988 CAlfNodeAnim* CAlfNodeAnim::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream, TInt aScreenNumber ) |
|
1989 { |
|
1990 CAlfNodeAnim* self = new(ELeave)CAlfNodeAnim(); |
|
1991 CleanupStack::PushL( self ); |
|
1992 self->iScreenNumber = aScreenNumber; |
|
1993 self->ConstructL( aModel, aStream ); |
|
1994 CleanupStack::Pop( self ); |
|
1995 return self; |
|
1996 } |
|
1997 |
|
1998 |
|
1999 // --------------------------------------------------------------------------- |
|
2000 // constructor |
|
2001 // --------------------------------------------------------------------------- |
|
2002 // |
|
2003 CAlfNodeSprite::CAlfNodeSprite( ) |
|
2004 { |
|
2005 iType = MWsWindowTreeNode::EWinTreeNodeSprite; |
|
2006 } |
|
2007 |
|
2008 CAlfNodeSprite::~CAlfNodeSprite( ) |
|
2009 { |
|
2010 if ( iParent ) |
|
2011 { |
|
2012 RemoveDependencies( iParent->iSpriteChild ); |
|
2013 } |
|
2014 } |
|
2015 // --------------------------------------------------------------------------- |
|
2016 // ConstructL |
|
2017 // --------------------------------------------------------------------------- |
|
2018 // |
|
2019 void CAlfNodeSprite::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
2020 { |
|
2021 CAlfNodeVisual::ConstructL( aModel, aStream ); |
|
2022 TInt32 parentId = aStream->ReadUint32L(); |
|
2023 |
|
2024 // TODO: |
|
2025 ResolveParent( parentId, iId ); |
|
2026 CreateWindowL(0,0,iParent->iId); // Currently renderstage does not deliver ws/wg handles |
|
2027 // Sprite may not be first in its group |
|
2028 UpdateOrdinalPosition(); |
|
2029 } |
|
2030 |
|
2031 // --------------------------------------------------------------------------- |
|
2032 // NewL |
|
2033 // --------------------------------------------------------------------------- |
|
2034 // |
|
2035 CAlfNodeSprite* CAlfNodeSprite::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream, TInt aScreenNumber ) |
|
2036 { |
|
2037 CAlfNodeSprite* self = new(ELeave)CAlfNodeSprite(); |
|
2038 CleanupStack::PushL( self ); |
|
2039 self->iScreenNumber = aScreenNumber; |
|
2040 self->ConstructL( aModel, aStream ); |
|
2041 CleanupStack::Pop( self ); |
|
2042 return self; |
|
2043 } |
|
2044 |
|
2045 // --------------------------------------------------------------------------- |
|
2046 // constructor |
|
2047 // --------------------------------------------------------------------------- |
|
2048 // |
|
2049 CAlfNodeTextCursor::CAlfNodeTextCursor( ) |
|
2050 { |
|
2051 iType = MWsWindowTreeNode::EWinTreeNodeStandardTextCursor; |
|
2052 } |
|
2053 |
|
2054 // --------------------------------------------------------------------------- |
|
2055 // ConstructL |
|
2056 // --------------------------------------------------------------------------- |
|
2057 // |
|
2058 void CAlfNodeTextCursor::ConstructL( CAlfHierarchyModel* aModel, RMemReadStream* aStream ) |
|
2059 { |
|
2060 CAlfNode::ConstructL( aModel, aStream ); |
|
2061 iCursorType = aStream->ReadInt32L(); |
|
2062 aStream->ReadL( (TUint8*)&iRect, sizeof(TRect)); |
|
2063 aStream->ReadL( (TUint8*)&iClipRect, sizeof(TRect)); |
|
2064 iSize = iRect.Size(); |
|
2065 iOrigin = iRect.iTl; |
|
2066 |
|
2067 iFlags = aStream->ReadInt32L(); |
|
2068 iColor = aStream->ReadInt32L(); |
|
2069 iFlashInterval = aStream->ReadInt32L(); |
|
2070 TInt32 parentId = aStream->ReadUint32L(); |
|
2071 |
|
2072 // TODO: |
|
2073 ResolveParent( parentId, iId ); |
|
2074 |
|
2075 CreateWindowL(0,0,iParent->iId); // Currently renderstage does not deliver ws/wg handles |
|
2076 TInt offset; |
|
2077 // pass rest of the cursor data |
|
2078 TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes)); |
|
2079 attributes->iColor = iColor; |
|
2080 attributes->iFlags = iFlags; |
|
2081 attributes->iFlashInterval = iFlashInterval; |
|
2082 attributes->iScreenNumber = iScreenNumber; |
|
2083 |
|
2084 aModel->Server().Bridge()->AddData( EAlfDSSetCursorData, |
|
2085 iGroupId, |
|
2086 iId, |
|
2087 (TAny*)offset ); |
|
2088 |
|
2089 UpdateOrdinalPosition(); |
|
2090 } |
|
2091 |
|
2092 // --------------------------------------------------------------------------- |
|
2093 // NewL |
|
2094 // --------------------------------------------------------------------------- |
|
2095 // |
|
2096 CAlfNodeTextCursor* CAlfNodeTextCursor::NewL( CAlfHierarchyModel* aModel, RMemReadStream* aStream, TInt aScreenNumber ) |
|
2097 { |
|
2098 CAlfNodeTextCursor* self = new(ELeave)CAlfNodeTextCursor(); |
|
2099 CleanupStack::PushL( self ); |
|
2100 self->iScreenNumber = aScreenNumber; |
|
2101 self->ConstructL( aModel, aStream ); |
|
2102 CleanupStack::Pop( self ); |
|
2103 return self; |
|
2104 } |
|
2105 |
|
2106 void CAlfNodeTextCursor::AttributeChangedL( RMemReadStream* aStream ) |
|
2107 { |
|
2108 // TODO: PASS FORWARD!!! |
|
2109 TInt attribute = aStream->ReadInt32L(); |
|
2110 switch ( attribute ) |
|
2111 { |
|
2112 case MWsWindowTreeObserver::ECursorType: |
|
2113 { |
|
2114 iCursorType = aStream->ReadInt32L(); |
|
2115 break; |
|
2116 } |
|
2117 case MWsWindowTreeObserver::ECursorClipRect: |
|
2118 { |
|
2119 aStream->ReadL( (TUint8*)&iClipRect, sizeof(TRect)); |
|
2120 break; |
|
2121 } |
|
2122 |
|
2123 case MWsWindowTreeObserver::ECursorFlags: |
|
2124 { |
|
2125 iFlags = aStream->ReadInt32L(); |
|
2126 break; |
|
2127 } |
|
2128 |
|
2129 case MWsWindowTreeObserver::ECursorColor: |
|
2130 { |
|
2131 iColor = aStream->ReadInt32L(); |
|
2132 break; |
|
2133 } |
|
2134 } |
|
2135 TInt offset; |
|
2136 TAlfCursorDataBufferAttributes* attributes = (TAlfCursorDataBufferAttributes*)CreateWindowAttributes(offset, sizeof(TAlfCursorDataBufferAttributes)); |
|
2137 attributes->iColor = iColor; |
|
2138 attributes->iFlags = iFlags; |
|
2139 attributes->iFlashInterval = iFlashInterval; |
|
2140 attributes->iScreenNumber = iScreenNumber; |
|
2141 __ALFLOGSTRING("Forwarding cursor data"); |
|
2142 iModel->Server().Bridge()->AddData( EAlfDSSetCursorData, |
|
2143 iGroupId, |
|
2144 iId, |
|
2145 (TAny*)offset ); |
|
2146 } |
|
2147 CAlfNodeTextCursor::~CAlfNodeTextCursor( ) |
|
2148 { |
|
2149 // text cursor is the only text cursor in its parent. No need to check siblings. |
|
2150 if(iParent) |
|
2151 { |
|
2152 iParent->iTextCursor = NULL; |
|
2153 } |
|
2154 // RemoveNode is called instead of RemoveDependeciesL, because this node has no depencies. |
|
2155 if(iModel) |
|
2156 { |
|
2157 iModel->RemoveNode( iId ); |
|
2158 } |
|
2159 } |
|
2160 |
|
2161 // end of file |
|
2162 |