stmm-games-doc  0.32.0
Public Member Functions | Protected Member Functions | List of all members
stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget > Class Template Reference

Template class for Box theme widgets. More...

Inheritance diagram for stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >:
Inheritance graph
[legend]

Public Member Functions

 BoxThemeWidget (TOwnerFactory *p1Owner, const shared_ptr< GameWidget > &refGameWidget, TBoxWidget *p0BoxWidget, const std::vector< shared_ptr< ThemeWidget > > &aChildTW, double fTileWHRatio) noexcept
 Constructor. More...
 
void reInit (TOwnerFactory *p1Owner, const shared_ptr< GameWidget > &refGameWidget, TBoxWidget *p0BoxWidget, const std::vector< shared_ptr< ThemeWidget > > &aChildTW, double fTileWHRatio) noexcept
 Reinitialization. More...
 
bool canChange () const noexcept override
 Whether the widget's appearance (or one of its parents) can change. More...
 
NSize getSize () const noexcept override
 The size of the widget. More...
 
NPoint getPos () const noexcept override
 The position of the widget. More...
 
bool drawIfChanged (const Cairo::RefPtr< Cairo::Context > &refCc) noexcept override
 Deep draws a widget if it changed. More...
 
void draw (const Cairo::RefPtr< Cairo::Context > &refCc) noexcept override
 Draws a widget. More...
 
const std::pair< SegmentedFunction, SegmentedFunction > & getSizeFunctions (int32_t nLayoutConfig) const noexcept override
 Gets the width and height functions that take the tile width as parameter. More...
 
void placeAndMaybeResizeIn (const NRect &oRect) noexcept override
 Places and possibly resizes the widget within the given area. More...
 
void dump (int32_t nIndentSpaces, bool bHeader) const noexcept override
 Writes object contents to std::cout. More...
 
- Public Member Functions inherited from stmg::ThemeContainerWidget
const std::vector< shared_ptr< ThemeWidget > > & getChildren () const noexcept
 The child ThemeWidget vector of the container. More...
 
void dump (int32_t nIndentSpaces, bool bHeader) const noexcept override
 Writes object contents to std::cout. More...
 
- Public Member Functions inherited from stmg::ThemeWidget
virtual ~ThemeWidget () noexcept=default
 
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...
 
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

void onAssignedToLayout () noexcept override
 Signal that widget was added to a layout. More...
 
void onRecalcSizeFunctions (ThemeWidget *p0ReferenceThemeWidget) noexcept override
 Signal the widget should define its size functions. More...
 
void sizeAndConfig (int32_t nTileW, int32_t nLayoutConfig) noexcept override
 Sets the tile size of the widget and its configuration. More...
 
TBoxWidget * getBoxWidgetModel () noexcept
 The pointer to the model. More...
 
- Protected Member Functions inherited from stmg::ThemeContainerWidget
void setChildren (const std::vector< shared_ptr< ThemeWidget > > &aChildren) noexcept
 Sets the children of the container. More...
 
 ThemeContainerWidget (const shared_ptr< GameWidget > &refModel) noexcept
 Constructor. More...
 
void reInit (const shared_ptr< GameWidget > &refModel) noexcept
 Reinitialization. More...
 
virtual ~ThemeContainerWidget () noexcept
 
- Protected Member Functions inherited from stmg::ThemeWidget
ThemeLayoutthemeLayout () noexcept
 The theme layout. More...
 
const ThemeLayoutthemeLayout () const noexcept
 The constant theme layout. 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...
 

Detailed Description

template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
class stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >

Template class for Box theme widgets.

Params: TOwnerFactory The class creating instances. TBoxThemeWidget The actual ThemeWidget subclassing this template. TBoxWidget The model box widget.

Constructor & Destructor Documentation

◆ BoxThemeWidget()

template<class TOwnerFactory, class TBoxThemeWidget , class TBoxWidget>
stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::BoxThemeWidget ( TOwnerFactory *  p1Owner,
const shared_ptr< GameWidget > &  refGameWidget,
TBoxWidget *  p0BoxWidget,
const std::vector< shared_ptr< ThemeWidget > > &  aChildTW,
double  fTileWHRatio 
)
noexcept

Constructor.

Parameters
p1OwnerThe factory class creating instance. Cannot be null.
refGameWidgetThe model. Cannot be null.
p0BoxWidgetThe model. Must point to the same object as refGameWidget.
aChildTWThe children.
fTileWHRatioThe tile WH ratio.

Member Function Documentation

◆ canChange()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
bool stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::canChange ( ) const
overridevirtualnoexcept

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.

Implements stmg::ThemeWidget.

◆ draw()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::draw ( const Cairo::RefPtr< Cairo::Context > &  refCc)
overridevirtualnoexcept

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.

Implements stmg::ThemeWidget.

◆ drawIfChanged()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
bool stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::drawIfChanged ( const Cairo::RefPtr< Cairo::Context > &  refCc)
overridevirtualnoexcept

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.

Implements stmg::ThemeWidget.

◆ dump()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::dump ( int32_t  nIndentSpaces,
bool  bHeader 
) const
overridevirtualnoexcept

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 from stmg::ThemeWidget.

◆ getBoxWidgetModel()

template<class TOwnerFactory, class TBoxThemeWidget, class TBoxWidget>
TBoxWidget* stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::getBoxWidgetModel ( )
inlineprotectednoexcept

The pointer to the model.

Returns
The model. Is not null.

◆ getPos()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
NPoint stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::getPos ( ) const
overridevirtualnoexcept

The position of the widget.

Should only be called after the widget has been positioned.

Returns
The position.

Implements stmg::ThemeWidget.

◆ getSize()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
NSize stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::getSize ( ) const
overridevirtualnoexcept

The size of the widget.

Should only be called after the widget has been positioned.

Returns
The size.

Implements stmg::ThemeWidget.

◆ getSizeFunctions()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
const std::pair< SegmentedFunction, SegmentedFunction > & stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::getSizeFunctions ( int32_t  nLayoutConfig) const
overridevirtualnoexcept

Gets the width and height functions that take the tile width as parameter.

Parameters
nLayoutConfigThe layout config.
Returns
The pair of functions.

Implements stmg::ThemeWidget.

◆ onAssignedToLayout()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::onAssignedToLayout ( )
overrideprotectedvirtualnoexcept

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 from stmg::ThemeWidget.

◆ onRecalcSizeFunctions()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::onRecalcSizeFunctions ( ThemeWidget p0ReferenceThemeWidget)
overrideprotectedvirtualnoexcept

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 from stmg::ThemeWidget.

◆ placeAndMaybeResizeIn()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::placeAndMaybeResizeIn ( const NRect oRect)
overridevirtualnoexcept

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.

Implements stmg::ThemeWidget.

◆ reInit()

template<class TOwnerFactory, class TBoxThemeWidget , class TBoxWidget>
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::reInit ( TOwnerFactory *  p1Owner,
const shared_ptr< GameWidget > &  refGameWidget,
TBoxWidget *  p0BoxWidget,
const std::vector< shared_ptr< ThemeWidget > > &  aChildTW,
double  fTileWHRatio 
)
noexcept

Reinitialization.

See constructor.

◆ sizeAndConfig()

template<class TOwnerFactory , class TBoxThemeWidget , class TBoxWidget >
void stmg::BoxThemeWidget< TOwnerFactory, TBoxThemeWidget, TBoxWidget >::sizeAndConfig ( int32_t  nTileW,
int32_t  nLayoutConfig 
)
overrideprotectedvirtualnoexcept

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.

Implements stmg::ThemeWidget.