The UI uses a coordinate system where the y axis is oriented down. The OpenGL GL_MODELVIEW matrix is saved or restored when rendering a gadget, and the origin is translated to the gadget's origin within the window. The current origin is stored in a variable:
Gadgets must not draw outside of their bounding box, however clipping is not enforced by default, for performance reasons. This can be changed by setting the clipped? slot to t in the gadget's constructor.