/* When a container, or its parent moves, it is important to update its absolute position. The absolute position of any container can be calculated from the parent's absolute position and its location within that container. */ void containerUpdateAbsolutePosition(Container * containerPtr) { Drawable *iterator; /* absolute position is meaningless if there is no parent so just return; */ if (containerPtr->drawable.parentPtr == NULL) { return; } containerPtr->absoluteLeft = containerPtr->drawable.parentPtr->absoluteLeft + containerPtr->drawable.area.left; containerPtr->absoluteTop = containerPtr->drawable.parentPtr->absoluteTop + containerPtr->drawable.area.top; /* We must update the absolute position of any sub-containers */ for(iterator = containerPtr->containedListPtr; iterator != NULL; iterator = iterator->nextContainedPtr) { if (drawableIsContainer(iterator)) { containerUpdateAbsolutePosition((Container *) iterator); } } }