CheckBoxRenderer Class Referenceabstract

#include <Pt/Forms/CheckBoxStyler.h>

Renders the look of a check box. More...

Inherits Renderer.

Public Member Functions

 CheckBoxRenderer (std::size_t refs=0)
 Constructs a renderer with reference count refs.
virtual ~CheckBoxRenderer ()
 Destroys the renderer.
CheckBoxRenderercreate () const
 Creates a new default-constructed instance that the caller owns.
Gfx::SizeF measureIndicator (PaintSurface &surface)
 Returns the natural size of the check indicator on surface.
Gfx::SizeF measureContent (PaintSurface &surface, const Gfx::SizeF &indicatorSize, const Gfx::SizeF &textSize)
 Returns the combined content size for indicator and text.
Gfx::SizeF measureFrame (PaintSurface &surface, const Gfx::SizeF &contentSize)
 Returns the outer size including frame for the given content size.
Gfx::RectF layoutFrame (PaintSurface &surface, const Gfx::RectF &frameRect)
 Returns the content rectangle within the outer frame rect.
void layoutContent (PaintSurface &surface, const Gfx::RectF &contentRect, const Gfx::SizeF &indicatorSize, const Gfx::SizeF &textSize, Gfx::RectF &indicatorRect, Gfx::RectF &textRect)
 Partitions the content rect into indicator and text sub-rectangles.
Gfx::RectF layoutMnemonic (PaintSurface &surface, const String &text, const Gfx::PointF &textPos, const Gfx::FontMetrics &fontMetrics, String::size_type mnemonicIndex)
 Computes the underline rectangle for the mnemonic character.
const PaintertextPainter (PaintSurface &surface)
 Returns a painter with the current font and text color applied.
void renderChrome (PaintContext &context, const Gfx::RectF &rect, const Gfx::RectF &boxRect, const CheckBoxState &state)
 Draws the check indicator chrome within the widget rect.
void renderText (PaintContext &context, const Gfx::RectF &textRect, const String &text, const Gfx::PointF &pos, const CheckBoxState &state)
 Draws text at pos, clipped to the text rect.
void renderMnemonic (PaintContext &context, const Gfx::RectF &rect, const Gfx::RectF &mnemonic, const CheckBoxState &state)
 Draws the mnemonic underline within mnemonic, clipped to the widget rect.
const std::type_info & typeId () const
 Returns the dynamic type used as the registry key.
void ref ()
 Adds one reference.
std::size_t unref ()
 Removes one reference and returns the remaining count.
void reset (const StyleOptions &options)
 Resets this facet with options.

Protected Member Functions

virtual CheckBoxRendereronCreate () const =0
 Creates a new instance of the same concrete type.
virtual void onReset (const StyleOptions &options)=0
 Resets this facet with options.
virtual Gfx::SizeF onMeasureIndicator (PaintSurface &surface)=0
 Returns the natural size of the checkable area.
virtual Gfx::SizeF onMeasureContent (PaintSurface &surface, const Gfx::SizeF &indicatorSize, const Gfx::SizeF &textSize)=0
 Returns the combined size of the checkable area and caption.
virtual Gfx::SizeF onMeasureFrame (PaintSurface &surface, const Gfx::SizeF &contentSize)=0
 Measures the frame enclosing contentSize.
virtual Gfx::RectF onLayoutFrame (PaintSurface &surface, const Gfx::RectF &frameRect)=0
 Returns the content rectangle within frameRect.
virtual void onLayoutContent (PaintSurface &surface, const Gfx::RectF &contentRect, const Gfx::SizeF &indicatorSize, const Gfx::SizeF &textSize, Gfx::RectF &indicatorRect, Gfx::RectF &textRect)=0
 Partitions contentRect into checkable area and caption.
virtual Gfx::RectF onLayoutMnemonic (PaintSurface &surface, const String &text, const Gfx::PointF &textPos, const Gfx::FontMetrics &fontMetrics, String::size_type mnemonicIndex)=0
 Returns the mnemonic underline rectangle.
virtual const PainteronGetTextPainter (PaintSurface &surface)=0
 Returns a painter with the current font and text color.
virtual void onRenderChrome (PaintContext &context, const Gfx::RectF &rect, const Gfx::RectF &boxRect, const CheckBoxState &state)=0
 Paints the checkable area for state.
virtual void onRenderText (PaintContext &context, const Gfx::RectF &textRect, const String &text, const Gfx::PointF &pos, const CheckBoxState &state)=0
 Paints text at pos for state.
virtual void onRenderMnemonic (PaintContext &context, const Gfx::RectF &rect, const Gfx::RectF &mnemonic, const CheckBoxState &state)=0
 Paints the mnemonic underline for state.

Detailed Description

A CheckBoxRenderer is a Style::Facet for the check-box family. Named measure methods run inside-out: indicator, content, then frame. Named layout methods run outside-in: frame, then content and mnemonic. Named render methods paint prepared rectangles. The widget owns geometry and orchestrates those passes. The renderer does not mutate widget geometry.

Derive a renderer to change the look of check boxes. Register it on a Style, or assign it to a widget with CheckBox::setRenderer().

Member Function Documentation

◆ onReset()

virtual void onReset ( const StyleOptions & options)
protectedpure virtual

Resolves tokens from options and stores the painter and metric state used later by measure, layout, and render. Shared facets are reset when the application applies global options.

Reimplemented from Style::Facet.