Rectangle challenged


I am trying to gain a better understanding of rectangles in order to accomplish the following.

1 - Restricting a user from dragging an object outside another rectangle, lets call it the main rectangle.
2 - I need to find out where the dragged object ended up in relation the main rectangle.
How many pixels from the top and the left of the main rectangle.
3 - Add a new object to the main rectangle either from a button or drag another object from outside the main rectangle.
4 - How to center horizontally or vertically inside the main rectangle


I would suggest that you start with the draggraybox statement and the rectangletweak( function.