API Documentation
Public Member Functions | List of all members
nkWinUi::ComponentUtils Class Referenceabstract

Offers many utilities to deal with the components, specialized for its windowing system. More...

Public Member Functions

 ComponentUtils () noexcept
 
virtual ~ComponentUtils ()
 
virtual nkMaths::Rectangle getComponentSize (const Component *component)=0
 
virtual nkMaths::Rectangle getScreenDimensions ()=0
 
virtual nkMaths::Point getComponentCoordFromScreenCoord (const Component *component, nkMaths::Point screenCoord)=0
 
virtual nkMaths::Point getScreenCoordFromComponentCoord (const Component *component, nkMaths::Point componentCoord)=0
 
virtual nkMaths::Rectangle getComponentDimensions (const Component *component)=0
 
virtual void setComponentPosition (Component *component, float x, float y)=0
 
virtual void setComponentSize (Component *component, float width, float height)=0
 
virtual void setComponentDimensions (Component *component, float x, float y, float width, float height)=0
 
virtual bool getComponentVisibility (const Component *component)=0
 
virtual void setComponentVisibility (Component *component, bool visibleOrNot)=0
 
virtual bool isComponentEnabled (const Component *component)=0
 
virtual void setComponentEnabled (Component *component, bool enabledOrNot)=0
 
virtual void setComponentFocus (Component *component)=0
 
virtual bool isComponentInForeground (const Component *component)=0
 
virtual void setComponentInForeground (Component *component)=0
 
virtual void setComponentLabel (Component *component, nkMemory::StringView label)=0
 
virtual void updateComponent (Component *component)=0
 
virtual void freezeComponentPainting (Component *component, bool value)=0
 
virtual nkImages::Image paintToImage (Component *component, bool withFrame)=0
 
virtual nkMaths::Point getCursorPosition ()=0
 
virtual void setCursorPosition (nkMaths::Point absPos)=0
 
virtual nkMemory::BufferCast< nkMemory::StringgetAvailableFontFaces ()=0
 
virtual nkMemory::BufferCast< unsigned int > getCharactersWidth (nkMemory::BufferView< char > characters, Font *font)=0
 

Detailed Description

Offers many utilities to deal with the components, specialized for its windowing system.

Constructor & Destructor Documentation

◆ ComponentUtils()

nkWinUi::ComponentUtils::ComponentUtils ( )
noexcept

Constructor.

Remarks
The object's lifetime is managed by its parent windowing system.

◆ ~ComponentUtils()

virtual nkWinUi::ComponentUtils::~ComponentUtils ( )
virtual

Destructor.

Remarks
The object's lifetime is managed by its parent windowing system.

Member Function Documentation

◆ getComponentSize()

virtual nkMaths::Rectangle nkWinUi::ComponentUtils::getComponentSize ( const Component component)
pure virtual
Parameters
componentThe component to check for.
Returns
The component's size, in pixels.
Remarks
This method is used internally. For client code, it is usually easier to call Component::getWidth() or Component::getHeight().

◆ getScreenDimensions()

virtual nkMaths::Rectangle nkWinUi::ComponentUtils::getScreenDimensions ( )
pure virtual
Returns
The screen dimensions, in pixels.

◆ getComponentCoordFromScreenCoord()

virtual nkMaths::Point nkWinUi::ComponentUtils::getComponentCoordFromScreenCoord ( const Component component,
nkMaths::Point  screenCoord 
)
pure virtual

Converts component relative coordinates to absolute coordinates on screen.

Parameters
componentThe component to work with.
screenCoordThe absolute coordinates to convert, in pixels.
Returns
The converted coordinates, in pixels, relative to the component.
Remarks
This method is used internally. For client code, it is usually easier to call Component::getCoordAbsoluteFromRelative().

◆ getScreenCoordFromComponentCoord()

virtual nkMaths::Point nkWinUi::ComponentUtils::getScreenCoordFromComponentCoord ( const Component component,
nkMaths::Point  componentCoord 
)
pure virtual

Converts absolute screen coordinates to relative coordinates within a component.

Parameters
componentThe component to work with.
componentCoordThe absolute coordinates to convert, in pixels.
Returns
The converted coordinates, in pixels, relative to the component.
Remarks
This method is used internally. For client code, it is usually easier to call Component::getCoordAbsoluteFromRelative().

◆ getComponentDimensions()

virtual nkMaths::Rectangle nkWinUi::ComponentUtils::getComponentDimensions ( const Component component)
pure virtual
Parameters
componentThe component to check for.
Returns
The dimensions, in pixels, of the component, absolute on screen.
Remarks
This method is used internally. For client code, it is usually easier to call Component::getWidth() and Component::getHeight().

◆ setComponentPosition()

virtual void nkWinUi::ComponentUtils::setComponentPosition ( Component component,
float  x,
float  y 
)
pure virtual

Sets the position of the component.

Parameters
componentThe component to work on.
xThe x coordinate, in pixels, within the parent component.
yThe y coordinate, in pixels, within the parent component.
Remarks
This method is used internally. For client code, it is usually easier to call Component::setPositionInParent() or Component::setPositionInScreen().

◆ setComponentSize()

virtual void nkWinUi::ComponentUtils::setComponentSize ( Component component,
float  width,
float  height 
)
pure virtual

Sets a component's size.

Parameters
componentThe component to work on.
widthThe width in pixels.
heightThe height in pixels.
Remarks
This method is used internally. For client code, it is usually easier to call Component::setSize().

◆ setComponentDimensions()

virtual void nkWinUi::ComponentUtils::setComponentDimensions ( Component component,
float  x,
float  y,
float  width,
float  height 
)
pure virtual

Sets a component's dimensions.

Parameters
componentThe component to work on.
xThe x position, in pixels, within its parent.
yThe y position, in pixels, within its parent.
widthThe width in pixels.
heightThe height in pixels.
Remarks
This method is used internally. For client code, it is usually easier to call Component::setAreaInParent() or Component::setAreaInScreen().

◆ getComponentVisibility()

virtual bool nkWinUi::ComponentUtils::getComponentVisibility ( const Component component)
pure virtual
Parameters
componentThe component to check.
Returns
Whether the component is visible (true) or not (false).
Remarks
This method is used internally. For client code, it is usually easier to call Component::getVisibility().

◆ setComponentVisibility()

virtual void nkWinUi::ComponentUtils::setComponentVisibility ( Component component,
bool  visibleOrNot 
)
pure virtual

Sets a component's visibility status.

Parameters
componentThe component to work on.
visibleOrNotWhether the component should be visible (true) or not (false).
Remarks
This method is used internally. For client code, it is usually easier to call Component::setVisibility().

◆ isComponentEnabled()

virtual bool nkWinUi::ComponentUtils::isComponentEnabled ( const Component component)
pure virtual
Parameters
componentThe component to check.
Returns
Whether the component is enabled (true) or not (false).
Remarks
This method is used internally. For client code, it is usually easier to call Component::isEnabled().

◆ setComponentEnabled()

virtual void nkWinUi::ComponentUtils::setComponentEnabled ( Component component,
bool  enabledOrNot 
)
pure virtual

Allows to enable or disable a component.

Parameters
componentThe component to work on.
enabledOrNotWhether the component should be enabled (true) or not (false).
Remarks
This method is used internally. For client code, it is usually easier to call Component::setEnabled().

◆ setComponentFocus()

virtual void nkWinUi::ComponentUtils::setComponentFocus ( Component component)
pure virtual

Sets the focus to a component.

Parameters
componentThe component to set the focus to.
Remarks
This method is used internally. For client code, it is usually easier to call Component::focusWindow().

◆ isComponentInForeground()

virtual bool nkWinUi::ComponentUtils::isComponentInForeground ( const Component component)
pure virtual
Parameters
componentThe component to check for.
Returns
Whether the component is in the foreground (true) or not (false).
Remarks
This method is used internally. For client code, it is usually easier to call Component::isForegroundWindow().

◆ setComponentInForeground()

virtual void nkWinUi::ComponentUtils::setComponentInForeground ( Component component)
pure virtual

Sets a component to the foreground.

Parameters
componentThe component to bring to the foreground.
Remarks
This method is used internally. For client code, it is usually easier to call Component::bringToForeground().

◆ setComponentLabel()

virtual void nkWinUi::ComponentUtils::setComponentLabel ( Component component,
nkMemory::StringView  label 
)
pure virtual

Sets a component's label.

Parameters
componentThe target component.
labelThe label to set.
Remarks
This method is used internally. For client code, it is usually easier to call Component::setLabel().

◆ updateComponent()

virtual void nkWinUi::ComponentUtils::updateComponent ( Component component)
pure virtual

Forces the update of a component.

Parameters
componentThe component to update.
Remarks
This method is used internally. For client code, it is usually easier to call Component::updateWindow().

◆ freezeComponentPainting()

virtual void nkWinUi::ComponentUtils::freezeComponentPainting ( Component component,
bool  value 
)
pure virtual

Prevents a component from being painted or updated.

Parameters
componentThe component to freeze.
valueWhether to freeze it (true) or not (false).
Remarks
Depending on the windowing system, only one component can be frozen at a time.

◆ paintToImage()

virtual nkImages::Image nkWinUi::ComponentUtils::paintToImage ( Component component,
bool  withFrame 
)
pure virtual

Allows to paint a component into an image.

Parameters
componentThe component to paint.
withFrameWhether the component's frame should also be painted (true) or not (false).
Returns
The image the component has been painted in.
Remarks
This method is used internally. For client code, it is usually easier to call Component::paintToImage().

◆ getCursorPosition()

virtual nkMaths::Point nkWinUi::ComponentUtils::getCursorPosition ( )
pure virtual
Returns
The current cursor absolute position on screen, in pixels.

◆ setCursorPosition()

virtual void nkWinUi::ComponentUtils::setCursorPosition ( nkMaths::Point  absPos)
pure virtual

Sets the cursor position, on screen.

Parameters
absPosThe absolute position, in pixels, the cursor should move to.

◆ getAvailableFontFaces()

virtual nkMemory::BufferCast<nkMemory::String> nkWinUi::ComponentUtils::getAvailableFontFaces ( )
pure virtual

Abstraction of the font face retrieval method. For more information, see FontUtils::getAvailableFontFaces().

Returns
The available font faces on the system created.

◆ getCharactersWidth()

virtual nkMemory::BufferCast<unsigned int> nkWinUi::ComponentUtils::getCharactersWidth ( nkMemory::BufferView< char >  characters,
Font font 
)
pure virtual

Abstraction of the character width method. For more information, see FontUtils::getCharactersWidth().

Parameters
charactersAn array of the characters to retrieve the width from.
fontThe font to use for width retrieval. If left to nullptr, will use the default font.
Returns
An array of pixel width, each index corresponding to their character's index in the input array.

The documentation for this class was generated from the following file: