ButtonRenderer Class Referenceabstract

#include <Pt/Forms/ButtonStyle.h>

Renders the visual appearance of a push button. More...

Inherits Style::Facet.

Inherited by PlatinumButtonRenderer.

Public Member Functions

ButtonRenderercreate () const
 Creates a new default-constructed instance that the caller owns.
 
void prepare (const StyleOptions &options, const ButtonStyleOptions &buttonOptions)
 Applies the widget-local button style overrides to this renderer. More...
 
Gfx::SizeF measureContent (PaintSurface &surface, Direction direction, const Gfx::SizeF &iconSize, const Gfx::SizeF &textSize)
 Returns the combined content size for icon and text arranged by direction. More...
 
Gfx::SizeF measureFrame (PaintSurface &surface, const Gfx::SizeF &contentSize)
 Returns the outer size including button decoration for contentSize on surface.
 
Gfx::RectF layoutFrame (PaintSurface &surface, const Gfx::RectF &frameRect)
 Returns the content rectangle within the outer frameRect.
 
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 at mnemonicIndex.
 
const PaintertextPainter (PaintSurface &surface)
 Returns a painter with the current font and text color applied for surface.
 
void layoutContent (PaintSurface &surface, const Gfx::RectF &contentRect, Direction direction, const Gfx::SizeF &iconSize, const Gfx::SizeF &textSize, Gfx::RectF &iconRect, Gfx::RectF &textRect)
 Computes the icon and text sub-rectangles within the content rect. More...
 
void prepareIcon (const Gfx::Image &icon, Pixmap &picture, const ButtonState &state) const
 Converts icon to a state-appropriate pixmap written to picture.
 
void renderBackground (PaintContext &context, const Gfx::RectF &rect, const ButtonState &state)
 Paints the background fill within the widget rect. More...
 
void renderChrome (PaintContext &context, const Gfx::RectF &rect, const ButtonState &state)
 Paints the button background and border within the button bounding rect.
 
void renderText (PaintContext &context, const Gfx::RectF &rect, const String &text, const Gfx::PointF &pos, const ButtonState &state)
 Draws text at pos, clipped to the button bounding rect.
 
void renderMnemonic (PaintContext &context, const Gfx::RectF &rect, const Gfx::RectF &mnemonic, const ButtonState &state)
 Draws the mnemonic underline within mnemonic, clipped to the button bounding rect.
 
void renderIcon (PaintContext &context, const Gfx::RectF &rect, const Pixmap &picture, const Gfx::PointF &pos, const ButtonState &state)
 Draws picture at pos, clipped to the button bounding rect.
 
void reset (const StyleOptions &options)
 Resets the facet to the given global style options.
 

Protected Member Functions

virtual void onReset (const StyleOptions &options)
 Resets the shared button renderer to global defaults.
 

Detailed Description

Provides rendering primitives for button surfaces, text, mnemonic underlines, and icons. Subclasses override the protected virtuals.

Member Function Documentation

◆ prepare()

void prepare ( const StyleOptions options,
const ButtonStyleOptions buttonOptions 
)

This is the explicit synchronization point for the button slice. Implementations prepare all renderer-local resources from the supplied StyleOptions and ButtonStyleOptions.

◆ measureContent()

Gfx::SizeF measureContent ( PaintSurface surface,
Direction  direction,
const Gfx::SizeF iconSize,
const Gfx::SizeF textSize 
)

Computes the space needed for icon, text, and spacing between them. Does not include surface decoration (borders/padding).

◆ layoutContent()

void layoutContent ( PaintSurface surface,
const Gfx::RectF contentRect,
Direction  direction,
const Gfx::SizeF iconSize,
const Gfx::SizeF textSize,
Gfx::RectF iconRect,
Gfx::RectF textRect 
)

The content rect is the output of layoutFrame (decoration already stripped). This method partitions it based on direction and sizes.

◆ renderBackground()

void renderBackground ( PaintContext context,
const Gfx::RectF rect,
const ButtonState state 
)

Only fills if an explicit background is needed. Otherwise the call is a no-op, leaving the widget transparent.