If (OBJECT.X - OBJECT.Width/2) + MIN_VIEW > 0 |
If (OBJECT.X + OBJECT.Width/2) - MIN_VIEW < WindowWidth |
If (OBJECT.Y - OBJECT.Height/2) + MIN_VIEW > 0 |
If (OBJECT.Y + OBJECT.Height/2) - MIN_VIEW < WindowWidth |
where MIN_VIEW is the minimum amount of Pixels you want inside the window.
Note: This is untested so try it yourself first and tell me how it goes.