stmm-games-doc  0.32.0
Public Member Functions | Protected Member Functions | List of all members
stmg::ThemeWidget Class Referenceabstract
Inheritance diagram for stmg::ThemeWidget:
Inheritance graph
[legend]

Public Member Functions

virtual ~ThemeWidget () noexcept=default
 
virtual NSize getSize () const noexcept=0
 The size of the widget. More...
 
virtual NPoint getPos () const noexcept=0
 The position of the widget. More...
 
virtual bool canChange () const noexcept=0
 Whether the widget's appearance (or one of its parents) can change. More...
 
virtual bool drawIfChanged (const Cairo::RefPtr< Cairo::Context > &refCc) noexcept=0
 Deep draws a widget if it changed. More...
 
virtual void draw (const Cairo::RefPtr< Cairo::Context > &refCc) noexcept=0
 Draws a widget. More...
 
virtual void drawDeep (const Cairo::RefPtr< Cairo::Context > &refCc) noexcept
 Deep draws a widget. More...
 
bool isContainer () const noexcept
 Tells Whether the widget is a container. More...
 
const shared_ptr< GameWidget > & getModel () const noexcept
 The game widget used to generate the theme widget. More...
 
ThemeContainerWidgetgetParent () const noexcept
 The parent container of the widget. More...
 
virtual const std::pair< SegmentedFunction, SegmentedFunction > & getSizeFunctions (int32_t nLayoutConfig) const noexcept=0
 Gets the width and height functions that take the tile width as parameter. More...
 
virtual void placeAndMaybeResizeIn (const NRect &oRect) noexcept=0
 Places and possibly resizes the widget within the given area. More...
 
virtual void dump (int32_t nIndentSpaces, bool bHeader) const noexcept
 Writes object contents to std::cout. More...
 
void dump (int32_t nIndentSpaces) const noexcept
 Writes object contents to std::cout (header included). More...
 
void dump () const noexcept
 Writes contents to std::cout without indentation. More...
 

Protected Member Functions

ThemeLayoutthemeLayout () noexcept
 The theme layout. More...
 
const ThemeLayoutthemeLayout () const noexcept
 The constant theme layout. More...
 
virtual void onAssignedToLayout () noexcept
 Signal that widget was added to a layout. More...
 
virtual void onRecalcSizeFunctions (ThemeWidget *p0ReferenceThemeWidget) noexcept
 Signal the widget should define its size functions. More...
 
virtual void sizeAndConfig (int32_t nTileW, int32_t nLayoutConfig) noexcept=0
 Sets the tile size of the widget and its configuration. More...
 
 ThemeWidget (const shared_ptr< GameWidget > &refModel) noexcept
 Constructs the theme widget. More...
 
void reInit (const shared_ptr< GameWidget > &refModel) noexcept
 Reinitializes the theme widget. More...
 

Constructor & Destructor Documentation

◆ ~ThemeWidget()

virtual stmg::ThemeWidget::~ThemeWidget ( )
virtualdefaultnoexcept

◆ ThemeWidget()

stmg::ThemeWidget::ThemeWidget ( const shared_ptr< GameWidget > &  refModel)
inlineexplicitprotectednoexcept

Constructs the theme widget.

Parameters
refModelThe model. Cannot be null.

Member Function Documentation

◆ canChange()

virtual bool stmg::ThemeWidget::canChange ( ) const
pure virtualnoexcept

Whether the widget's appearance (or one of its parents) can change.

This is a static property of the widget calculated when it is already inserted in its final layout and shouldn't change during its lifetime. If a call to drawIfChanged() might return true this function returns true, false otherwise.

Returns
Whether the widget can change.

Implemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, and stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >.

◆ draw()

virtual void stmg::ThemeWidget::draw ( const Cairo::RefPtr< Cairo::Context > &  refCc)
pure virtualnoexcept

Draws a widget.

The draw is shallow, so it can assume that the parent was already drawn to the context.

When this function is called this instance can assume that the parent was modified. For mutable widgets this could for example mean they should invalidate their cache if they have one.

If a widget has no parents it must draw completely opaquely.

Parameters
refCcThe context to draw to. Cannot be null.

Implemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, and stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >.

◆ drawDeep()

virtual void stmg::ThemeWidget::drawDeep ( const Cairo::RefPtr< Cairo::Context > &  refCc)
virtualnoexcept

Deep draws a widget.

The default implementation calls drawDeep of the parent (if it has one) clipped to this widget boundaries and then draw() for this instance.

This should be overridden for example if a widget knows it is completely opaque and drawing all the ancestors first is unnecessary.

Parameters
refCcThe context to draw to. Cannot be null.

◆ drawIfChanged()

virtual bool stmg::ThemeWidget::drawIfChanged ( const Cairo::RefPtr< Cairo::Context > &  refCc)
pure virtualnoexcept

Deep draws a widget if it changed.

If this is a ThemeContainerWidget it doesn't draw the children, just itself possibly on top of its parent (clipped to this widget).

See also
draw().
Parameters
refCcThe context to conditionally draw to. Cannot be null.
Returns
Whether the widget area was drawn.

Implemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, and stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >.

◆ dump() [1/3]

virtual void stmg::ThemeWidget::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
virtualnoexcept

Writes object contents to std::cout.

Should only do it in debug mode. The function is also exposed in release mode because it is virtual.

Parameters
nIndentSpacesNumber of spaces put in front of each output line.
bHeaderWhether the header of the object should be displayed.

Reimplemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >, stmg::InputBoxThWidget, stmg::LevelShowThemeWidget, stmg::ActionsBoxThWidget, and stmg::ThemeContainerWidget.

◆ dump() [2/3]

void stmg::ThemeWidget::dump ( int32_t  nIndentSpaces) const
inlinenoexcept

Writes object contents to std::cout (header included).

Parameters
nIndentSpacesNumber of spaces put in front of each output line.

◆ dump() [3/3]

void stmg::ThemeWidget::dump ( ) const
inlinenoexcept

Writes contents to std::cout without indentation.

◆ getModel()

const shared_ptr<GameWidget>& stmg::ThemeWidget::getModel ( ) const
inlinenoexcept

The game widget used to generate the theme widget.

Returns
The model. Cannot be null;

◆ getParent()

ThemeContainerWidget* stmg::ThemeWidget::getParent ( ) const
inlinenoexcept

The parent container of the widget.

Returns
The parent or null if layout's root widget.

◆ getPos()

virtual NPoint stmg::ThemeWidget::getPos ( ) const
pure virtualnoexcept

◆ getSize()

virtual NSize stmg::ThemeWidget::getSize ( ) const
pure virtualnoexcept

◆ getSizeFunctions()

virtual const std::pair<SegmentedFunction, SegmentedFunction>& stmg::ThemeWidget::getSizeFunctions ( int32_t  nLayoutConfig) const
pure virtualnoexcept

◆ isContainer()

bool stmg::ThemeWidget::isContainer ( ) const
inlinenoexcept

Tells Whether the widget is a container.

Returns
Whether the widget is subclass of ThemeContainerWidget.

◆ onAssignedToLayout()

virtual void stmg::ThemeWidget::onAssignedToLayout ( )
inlineprotectedvirtualnoexcept

Signal that widget was added to a layout.

When the theme widget tree is added to the theme layout this function is called for all its widgets. Container widgets don't need to call their children's onAssignedToLayout().

The default implementation does nothing.

Reimplemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >, and stmg::InputBoxThWidget.

◆ onRecalcSizeFunctions()

virtual void stmg::ThemeWidget::onRecalcSizeFunctions ( ThemeWidget p0ReferenceThemeWidget)
protectedvirtualnoexcept

Signal the widget should define its size functions.

The reference widget can be used to determine this widget's size functions.

Container widgets don't need to call their children's onRecalcSizeFunctions(), since it is done by the layout itself.

See also
getSizeFunctions().
Parameters
p0ReferenceThemeWidgetThe reference theme widget. Cannot be null.

Reimplemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, and stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >.

◆ placeAndMaybeResizeIn()

virtual void stmg::ThemeWidget::placeAndMaybeResizeIn ( const NRect oRect)
pure virtualnoexcept

Places and possibly resizes the widget within the given area.

The placement and resizing depends on align value returned by the model's functions GameWidget::getWidgetAxisFitHoriz() and GameWidget::getWidgetAxisFitVert().

The width and height should be bigger or equal the size of the widget as defined by its size functions with the parameters passed to sizeAndConfig().

Container widgets must recursively call the placeAndMaybeResizeIn() of their children (they are responsible for their positioning).

Parameters
oRectThe rectangle where the widget should be placed.

Implemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, and stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >.

◆ reInit()

void stmg::ThemeWidget::reInit ( const shared_ptr< GameWidget > &  refModel)
inlineprotectednoexcept

Reinitializes the theme widget.

Parameters
refModelThe model. Cannot be null.

◆ sizeAndConfig()

virtual void stmg::ThemeWidget::sizeAndConfig ( int32_t  nTileW,
int32_t  nLayoutConfig 
)
protectedpure virtualnoexcept

Sets the tile size of the widget and its configuration.

The widget should evaluate and set the actual size of the widget through its size functions.

This function is called when the layout has determined the best tile size and layout config in order to maximize the tile size itself.

Parameters
nTileWThe tile width. Must be >0.
nLayoutConfigThe layout config.

Implemented in stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >, stmg::BoxThemeWidget< InputBoxThWidgetFactory, InputBoxThWidget, InputBoxWidget >, stmg::BoxThemeWidget< ActionsBoxThWidgetFactory, ActionsBoxThWidget, ActionsBoxWidget >, stmg::BoxThemeWidget< BoxThWidgetFactory, BoxThWidget, BoxWidget >, and stmg::ActionsBoxThWidget.

◆ themeLayout() [1/2]

ThemeLayout& stmg::ThemeWidget::themeLayout ( )
protectednoexcept

The theme layout.

This function can only be called if the widget is already added to a layout.

Subclasses that call this function must include themelayout.h header file.

Returns
The theme layout.

◆ themeLayout() [2/2]

const ThemeLayout& stmg::ThemeWidget::themeLayout ( ) const
protectednoexcept

The constant theme layout.

This function can only be called if the widget is already added to a layout.

Subclasses that call this function must include themelayout.h header file.

Returns
The constant theme layout.