uiacceltk/hitchcock/ServerCore/Src/alfnodes.cpp
changeset 13 8f67d927ea57
parent 0 15bf7259bb7c
child 14 83d2d132aa58
equal deleted inserted replaced
0:15bf7259bb7c 13:8f67d927ea57
    59         {
    59         {
    60         iWindow->SetNodeTracking( aValue );
    60         iWindow->SetNodeTracking( aValue );
    61         }
    61         }
    62     }
    62     }
    63 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    64 // OrphonMe
    64 // OrphanMe
    65 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    66 //
    66 //
    67 CAlfNode* CAlfNode::OrphonMe()
    67 CAlfNode* CAlfNode::OrphanMe()
    68     {
    68 
    69     __ALFLOGSTRING1("CAlfNode::OrphonMe %d", iId);
    69     {
    70 	// this window will not be used anymore by wserv and cannot be drawn into. Thus destroying the
    70     __ALFLOGSTRING1("CAlfNode::OrphanMe %d", iId);
    71 	// visual representing this node is safe.
    71     // Parent node has been deleted. Orphan the node: remove the parent/sibling relationship.
    72     if ( iWindow && iModel )
       
    73         {
       
    74         iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
       
    75         iWindow = NULL;
       
    76         }
       
    77 
       
    78     CAlfNode* sibling = iSibling;
    72     CAlfNode* sibling = iSibling;
    79     iSibling = NULL;
    73     iSibling = NULL;
    80     iParent = NULL;
    74     iParent = NULL;
    81     return sibling;
    75     return sibling;
    82     }
    76     }
   253         {
   247         {
   254         case MWsWindowTreeNode::EWinTreeNodeClient:
   248         case MWsWindowTreeNode::EWinTreeNodeClient:
   255             {
   249             {
   256             CAlfNode* parentNode = iModel->FindNode( iParent->iId );
   250             CAlfNode* parentNode = iModel->FindNode( iParent->iId );
   257             __ASSERT_DEBUG(parentNode, USER_INVARIANT());
   251             __ASSERT_DEBUG(parentNode, USER_INVARIANT());
   258             if (parentNode->HasChildren())
   252             if (parentNode  && parentNode->HasChildren())
   259                 {
   253                 {
   260                 // parent node is not added to the list
   254                 // parent node is not added to the list
   261                 // the anims, cursor and sprites directly in this parent are added to the list
   255                 // 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
   256                 // 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 */);
   257                 TraverseNodeTree( parentNode, nodes, EFalse /* list all for this node */, EFalse /* dont add me */);
   836         {
   830         {
   837         return NULL; // return NULL, if I was the first child
   831         return NULL; // return NULL, if I was the first child
   838         }
   832         }
   839     // starting from the first child, loop until this one is found.
   833     // starting from the first child, loop until this one is found.
   840     
   834     
   841     while( previousSibling->iSibling != this)
   835     while( previousSibling && previousSibling->iSibling != this)
   842         {
   836         {
   843         previousSibling = previousSibling->iSibling;
   837         previousSibling = previousSibling->iSibling;
   844         }
   838         }
   845     
   839     
   846     return previousSibling; // return the previous child. return NULL, if this was the first child
   840     return previousSibling; // return the previous child. return NULL, if this was the first child
   877         // NO need to deliver fades for root
   871         // NO need to deliver fades for root
   878         return;
   872         return;
   879         }
   873         }
   880     if (iFadeState != iPostedFadeState)
   874     if (iFadeState != iPostedFadeState)
   881         {
   875         {
   882         iModel->Server().Bridge()->AddData( EAlfDSSetFadeEffect, iId , iFadeState);
   876         iModel->Server().Bridge()->AddData( EAlfDSSetFadeEffect, iId , iFadeState, (TAny*)iType);
   883         iPostedFadeState = iFadeState;
   877         iPostedFadeState = iFadeState;
   884         }
   878         }
   885     }
   879     }
   886 
   880 
   887 // ---------------------------------------------------------------------------
   881 // ---------------------------------------------------------------------------
  1172 // ---------------------------------------------------------------------------
  1166 // ---------------------------------------------------------------------------
  1173 // 
  1167 // 
  1174 CAlfNode::~CAlfNode()
  1168 CAlfNode::~CAlfNode()
  1175     {
  1169     {
  1176     __ALFLOGSTRING1("CAlfNode::~CAlfNode %d", iId);
  1170     __ALFLOGSTRING1("CAlfNode::~CAlfNode %d", iId);
       
  1171 	if ( iWindow && iModel ) // just in case: the window should be deleted already
       
  1172         {
       
  1173         iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
       
  1174         iWindow = NULL;
       
  1175         }
  1177     }
  1176     }
  1178 
  1177 
  1179 // ---------------------------------------------------------------------------
  1178 // ---------------------------------------------------------------------------
  1180 // HasChildren
  1179 // HasChildren
  1181 // ---------------------------------------------------------------------------
  1180 // ---------------------------------------------------------------------------
  1231     else
  1230     else
  1232         {
  1231         {
  1233         __ALFLOGSTRING1("My parent says, that I'm not his child :..( or no parent %d ", iParent );
  1232         __ALFLOGSTRING1("My parent says, that I'm not his child :..( or no parent %d ", iParent );
  1234         }
  1233         }
  1235     
  1234     
  1236     // Orphon all the children
  1235     // Orphan all the children
  1237     CAlfNode* child = iChild; 
  1236     CAlfNode* child = iChild; 
  1238     while( child )
  1237     while( child )
  1239         {
  1238         {
  1240         child = child->OrphonMe();
  1239         child = child->OrphanMe();
  1241         }
  1240         }
  1242     iChild = NULL;
  1241     iChild = NULL;
  1243     if ( iModel )
  1242     if ( iModel )
  1244         {    
  1243         {    
  1245         iModel->RemoveNode( iId );
  1244         iModel->RemoveNode( iId );
  1678 CAlfNodeVisual::~CAlfNodeVisual()
  1677 CAlfNodeVisual::~CAlfNodeVisual()
  1679     {
  1678     {
  1680     if ( iWindow && iModel )
  1679     if ( iWindow && iModel )
  1681         {
  1680         {
  1682         iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
  1681         iModel->Server().WindowMgr()->DestroyWindow( *iWindow );
       
  1682 		iWindow = NULL; // make sure there is no double deletion
  1683         }
  1683         }
  1684     }
  1684     }
  1685 
  1685 
  1686 // ---------------------------------------------------------------------------
  1686 // ---------------------------------------------------------------------------
  1687 // Constructor
  1687 // Constructor
  1942         windowAttributes->iScreenNumber = iScreenNumber; 
  1942         windowAttributes->iScreenNumber = iScreenNumber; 
  1943 
  1943 
  1944         iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
  1944         iModel->Server().Bridge()->AddData( EAlfDSDestroyWindow, 
  1945                 iGroupId, 
  1945                 iGroupId, 
  1946                 iId, 
  1946                 iId, 
  1947                 (TAny*)offset );                
  1947                 (TAny*)offset );
       
  1948         iWindow = 0; // just in case
  1948         }
  1949         }
  1949     RemoveDependencies( iParent->iChild );
  1950     RemoveDependencies( iParent->iChild );
  1950     };
  1951     };
  1951 
  1952 
  1952 // ---------------------------------------------------------------------------
  1953 // ---------------------------------------------------------------------------