How to bind component while using ComponentDragger.?

I have a parent component, In which have a lot of child components(Which will be Rectangle) each one of them can be dragged around and thus have its own member ComponentDragger that it's called in its mouseDown and mouseDrag. Now when i drag any of my child component i don't want my child to go out of bounds of parent component. 

i tried like creating instance of 

ComponentBoundsConstrainer* con = new ComponentBoundsConstrainer();

con->applyBoundsToComponent(this, parentcomponentBounds); 

Passed this con to dragComponent(... , ... , con); this is not working properly. how do i achive constrainedWithin(parentComponent) like feature of Rectangle using ComponentDragger.?