Widget.paintContent

Responsible for drawing the content as the theme engine is responsible for other elements.

If you override paint, this method may never be used as it is only called from inside the default implementation of paint.
class Widget
paintContent

Parameters

painter WidgetPainter

your painter (forwarded from paint) for drawing on the widget. The clip rectangle and coordinate translation are prepared for you ahead of time so you can use widget coordinates. It also has the theme foreground preloaded into the painter outline color, the theme font preloaded as the painter's active font, and the theme background preloaded as the painter's fill color.

bounds Rectangle

the bounds, inside the widget, where your content should be drawn. This is the rectangle inside the border and padding (if any). The stuff outside is not clipped - it is still part of your widget - but you should respect these bounds for visual consistency and respecting the theme's area.

If you do want to clip it, you can of course call auto oldClip = painter.setClipRectangle(bounds); scope(exit) painter.setClipRectangle(oldClip); to modify it and return to the previous setting when you return.

Return Value

Type: Rectangle

The rectangle representing your actual content. Typically, this is simply return bounds;. The theme engine uses this return value to determine where the outline and overlay should be.

Meta

History

Added May 15, 2021