/* This function removes a child from the linked list of contained shapes. */ void containerRemoveFrom(Container *parentPtr, Drawable *childPtr) { Drawable *iterator; Boolean childFound = FALSE; assert(childPtr != NULL); assert(parentPtr != NULL); if (childPtr == parentPtr->containedListPtr) { /* link is the first on the chain and so is treated differently */ parentPtr->containedListPtr = childPtr->nextContainedPtr; childFound = TRUE; } else { iterator = parentPtr->containedListPtr; while (iterator != NULL) { if (iterator->nextContainedPtr == childPtr) { /* We have found the link to be removed */ iterator->nextContainedPtr = iterator->nextContainedPtr->nextContainedPtr; iterator = NULL; /*set to NULL to end the loop */ childFound=TRUE; } else { iterator = iterator->nextContainedPtr; } } /* end for */ } /* end else */ if (!childFound) { /* child was not in this container so simply return */ return; } childPtr->nextContainedPtr = NULL; childPtr->parentPtr = NULL; if ((childPtr->type == CONTAINER) && (parentPtr->visible == TRUE)) { /* The visible flag must be set to FALSE since it is now disconnected from the root */ containerSetVisibleFlag((Container *)childPtr, FALSE); } drawableDirty(childPtr); }