Support  contents margins in custom widgets

This updates the size hint and paint handlers to support contents
margins on the widgets.