FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::Widget Class Referenceabstract

#include <widget.hpp>

Inheritance diagram for fcn::Widget:
fcn::BarGraph fcn::Button fcn::Container fcn::CurveGraph fcn::DropDown fcn::Icon fcn::IconProgressBar fcn::ImageProgressBar fcn::Label fcn::LineGraph fcn::ListBox fcn::PieGraph fcn::PointGraph fcn::ScrollArea fcn::Slider fcn::Spacer fcn::TabbedArea fcn::TextBox fcn::TextField

Public Types

enum class  SelectionMode : uint8_t { None = 0 , Border = 1 , Background = 2 }

Public Member Functions

virtual void _draw (Graphics *graphics)
virtual FocusHandler_getFocusHandler ()
virtual std::list< FocusListener * > const & _getFocusListeners ()
virtual FocusHandler_getInternalFocusHandler ()
virtual std::list< KeyListener * > const & _getKeyListeners ()
virtual std::list< MouseListener * > const & _getMouseListeners ()
virtual void _logic ()
virtual void _setFocusHandler (FocusHandler *focusHandler)
virtual void _setParent (Widget *parent)
void adaptLayout ()
virtual void adaptLayout (bool top)
void addActionListener (ActionListener *actionListener)
void addDeathListener (DeathListener *deathListener)
void addFocusListener (FocusListener *focusListener)
void addKeyListener (KeyListener *keyListener)
void addMouseListener (MouseListener *mouseListener)
void addWidgetListener (WidgetListener *widgetListener)
virtual void adjustSize ()
virtual void draw (Graphics *graphics)=0
virtual void drawBorder (Graphics *graphics)
virtual void drawOutline (Graphics *graphics)
virtual void drawSelectionFrame (Graphics *graphics)
void expandContent ()
virtual void expandContent (bool recursion)
virtual void focusNext ()
virtual void focusPrevious ()
virtual void fontChanged ()
virtual void getAbsolutePosition (int &x, int &y) const
std::string const & getActionEventId () const
Color const & getBackgroundColor () const
Color const & getBaseColor () const
Color const & getBorderColor () const
unsigned int getBorderSize () const
virtual Rectangle getChildrenArea ()
unsigned int getChildrenCount () const
Rectangle const & getDimension () const
Size const & getFixedSize () const
FontgetFont () const
Color const & getForegroundColor () const
int getHeight () const
std::string const & getId () const
void getLastPosition (int &x, int &y) const
int getMarginBottom () const
int getMarginLeft () const
int getMarginRight () const
int getMarginTop () const
Size const & getMaxSize () const
Size const & getMinSize () const
Color const & getOutlineColor () const
unsigned int getOutlineSize () const
unsigned int getPaddingBottom () const
unsigned int getPaddingLeft () const
unsigned int getPaddingRight () const
unsigned int getPaddingTop () const
virtual WidgetgetParent () const
Color const & getSelectionColor () const
SelectionMode getSelectionMode () const
virtual WidgetgetTop () const
unsigned int getVisibleChildrenCount () const
WidgetgetWidgetAt (int x, int y)
virtual WidgetgetWidgetAt (int x, int y, Widget *exclude)
std::list< Widget * > getWidgetsIn (Rectangle const &area)
virtual std::list< Widget * > getWidgetsIn (Rectangle const &area, Widget *ignore)
int getWidth () const
int getX () const
int getY () const
bool isEnabled () const
bool isFixedSize () const
bool isFocusable () const
virtual bool isFocused () const
bool isHorizontalExpand () const
bool isLastPositionSet () const
virtual bool isLayouted ()
virtual bool isModalFocusable () const
virtual bool isModalFocused () const
virtual bool isModalMouseInputFocusable () const
virtual bool isModalMouseInputFocused () const
bool isSetVisible () const
bool isTabInEnabled () const
bool isTabOutEnabled () const
bool isVerticalExpand () const
bool isVisible () const
virtual void logic ()
virtual void moveToBottom (Widget *widget)
virtual void moveToTop (Widget *widget)
Widgetoperator= (Widget &&)=delete
Widgetoperator= (Widget const &)=delete
virtual void releaseModalFocus ()
virtual void releaseModalMouseInputFocus ()
void removeActionListener (ActionListener *actionListener)
void removeDeathListener (DeathListener *deathListener)
void removeFocusListener (FocusListener *focusListener)
void removeKeyListener (KeyListener *keyListener)
void removeMouseListener (MouseListener *mouseListener)
void removeWidgetListener (WidgetListener *widgetListener)
virtual void requestFocus ()
virtual void requestModalFocus ()
virtual void requestModalMouseInputFocus ()
virtual void requestMoveToBottom ()
virtual void requestMoveToTop ()
void resizeToContent ()
virtual void resizeToContent (bool recursion)
void setActionEventId (std::string const &actionEventId)
virtual void setBackgroundColor (Color const &color)
virtual void setBaseColor (Color const &color)
virtual void setBorderColor (Color const &color)
void setBorderSize (unsigned int size)
void setDimension (Rectangle const &dimension)
void setEnabled (bool enabled)
void setFixedSize (Size const &size)
void setFocusable (bool focusable)
virtual void setFont (Font *font)
virtual void setForegroundColor (Color const &color)
void setHeight (int height)
void setHorizontalExpand (bool expand)
void setId (std::string const &id)
void setInternalFocusHandler (FocusHandler *internalFocusHandler)
void setLastPosition (int x, int y)
void setMargin (int margin)
void setMarginBottom (int margin)
void setMarginLeft (int margin)
void setMarginRight (int margin)
void setMarginTop (int margin)
void setMaxSize (Size const &size)
void setMinSize (Size const &size)
virtual void setOutlineColor (Color const &color)
void setOutlineSize (unsigned int size)
void setPadding (unsigned int padding)
void setPaddingBottom (unsigned int padding)
void setPaddingLeft (unsigned int padding)
void setPaddingRight (unsigned int padding)
void setPaddingTop (unsigned int padding)
void setPosition (int x, int y)
virtual void setSelectionColor (Color const &color)
virtual void setSelectionMode (SelectionMode mode)
void setSize (int width, int height)
void setTabInEnabled (bool enabled)
void setTabOutEnabled (bool enabled)
void setVerticalExpand (bool expand)
void setVisible (bool visible)
void setWidth (int width)
void setX (int x)
void setY (int y)
virtual void showPart (Rectangle rectangle)
virtual void showWidgetPart (Widget *widget, Rectangle area)
 Widget ()
 Widget (Widget &&)=delete
 Widget (Widget const &)=delete

Static Public Member Functions

static DeathListener_getGuiDeathListener ()
static VisibilityEventHandler_getVisibilityEventHandler ()
static void _setGuiDeathListener (DeathListener *deathListener)
static void _setVisibilityEventHandler (VisibilityEventHandler *visibilityEventHandler)
static void setGlobalFont (Font *font)
static bool widgetExists (Widget const *widget)

Protected Member Functions

void add (Widget *widget)
void calculateSize ()
void distributeActionEvent ()
void distributeAncestorHiddenEvent (Widget *ancestor)
void distributeAncestorMovedEvent (Widget *ancestor)
void distributeAncestorShownEvent (Widget *ancestor)
void distributeHiddenEvent ()
void distributeMovedEvent ()
void distributeResizedEvent ()
void distributeShownEvent ()
virtual WidgetfindWidgetById (std::string const &id)
std::list< Widget * > const & getChildren () const
virtual void remove (Widget *widget)
virtual void removeAllChildren ()
void resizeToChildren ()

Protected Attributes

std::string mActionEventId
std::list< ActionListener * > mActionListeners
Color mBackgroundColor {0xf9fafb}
Color mBaseColor {0xe5e7eb}
Color mBorderColor {0xd1d5db}
unsigned int mBorderSize {0}
std::list< Widget * > mChildren
FontmCurrentFont {nullptr}
std::list< DeathListener * > mDeathListeners
Rectangle mDimension
bool mEnabled {true}
Size mFixedSize {-1, -1}
bool mFixedSizeUsed {false}
bool mFocusable {false}
FocusHandlermFocusHandler {nullptr}
std::list< FocusListener * > mFocusListeners
Color mForegroundColor {0x1f2933}
bool mHExpand {false}
std::string mId
FocusHandlermInternalFocusHandler {nullptr}
std::list< KeyListener * > mKeyListeners
int mLastX {0}
int mLastY {0}
int mMarginBottom {0}
int mMarginLeft {0}
int mMarginRight {0}
int mMarginTop {0}
Size mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()}
Size mMinSize {0, 0}
std::list< MouseListener * > mMouseListeners
Rectangle mOffsetRect
Color mOutlineColor {0x9ca3af}
unsigned int mOutlineSize {0}
unsigned int mPaddingBottom {0}
unsigned int mPaddingLeft {0}
unsigned int mPaddingRight {0}
unsigned int mPaddingTop {0}
WidgetmParent {nullptr}
Color mSelectionColor {0x3b82f6}
SelectionMode mSelectionMode {SelectionMode::None}
bool mTabIn {true}
bool mTabOut {true}
bool mVExpand {false}
bool mVisible {true}
std::list< WidgetListener * > mWidgetListeners

Static Protected Attributes

static DefaultFont mDefaultFont
static FontmGlobalFont = nullptr
static DeathListenermGuiDeathListener = nullptr
static VisibilityEventHandlermVisibilityEventHandler = nullptr
static std::list< Widget * > mWidgetInstances

Detailed Description

Abstract base class defining the common behavior, properties, and lifecycle of all GUI elements.

It contains basic functions every widget should have.

NOTE: Functions beginning with underscore "_" should not be overloaded unless you know what you are doing.

Definition at line 44 of file widget.hpp.

Member Enumeration Documentation

◆ SelectionMode

enum class fcn::Widget::SelectionMode : uint8_t
strong

Selection mode.

Definition at line 50 of file widget.hpp.

Constructor & Destructor Documentation

◆ Widget()

fcn::Widget::Widget ( )

Constructor.

Resets member variables. Notably, a widget is not focusable as default, therefore, widgets that are supposed to be focusable should override this default in their own constructor.

Definition at line 36 of file widget.cpp.

References mWidgetInstances.

Referenced by _setParent(), fcn::TabbedArea::action(), adaptLayout(), fcn::Container::add(), fcn::Container::add(), add(), fcn::TabbedArea::addTab(), fcn::Container::addWidget(), fcn::Container::addWidget(), fcn::ScrollArea::adjustSize(), fcn::Container::Container(), distributeAncestorHiddenEvent(), distributeAncestorMovedEvent(), distributeAncestorShownEvent(), fcn::Container::distributeWidgetAddedEvent(), fcn::Container::distributeWidgetRemovedEvent(), fcn::ScrollArea::expandContent(), fcn::Container::findWidgetById(), findWidgetById(), fcn::Container::getBackgroundWidget(), fcn::TabbedArea::getBackgroundWidget(), fcn::Container::getChild(), fcn::ScrollArea::getContent(), getParent(), getTop(), fcn::ScrollArea::getWidgetAt(), getWidgetAt(), getWidgetAt(), getWidgetsIn(), fcn::TextBox::keyPressed(), fcn::TabbedArea::mousePressed(), moveToBottom(), moveToTop(), fcn::Container::remove(), remove(), removeAllChildren(), resizeToChildren(), fcn::ScrollArea::resizeToContent(), fcn::ScrollArea::ScrollArea(), fcn::ScrollArea::ScrollArea(), fcn::Container::setBackgroundWidget(), fcn::TabbedArea::setBackgroundWidget(), fcn::ScrollArea::setContent(), fcn::ScrollArea::setDimension(), fcn::ScrollArea::setHeight(), fcn::ScrollArea::setWidth(), fcn::ScrollArea::showWidgetPart(), showWidgetPart(), and widgetExists().

◆ ~Widget()

fcn::Widget::~Widget ( )
virtual

Definition at line 41 of file widget.cpp.

Member Function Documentation

◆ _draw()

void fcn::Widget::_draw ( Graphics * graphics)
virtual

Called whenever a widget should draw itself.

The function will set up clip areas and call the draw function for this widget and for all its children.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Definition at line 1372 of file widget.cpp.

References draw(), drawOutline(), getChildrenArea(), fcn::Rectangle::height, fcn::Rectangle::isIntersecting(), mChildren, mDimension, mOutlineSize, fcn::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::Rectangle::width, fcn::Rectangle::x, and fcn::Rectangle::y.

◆ _getFocusHandler()

FocusHandler * fcn::Widget::_getFocusHandler ( )
virtual

Gets the focus handler used.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Returns
The focus handler used.
See also
_setFocusHandler

Definition at line 689 of file widget.cpp.

References mFocusHandler.

Referenced by add(), and setInternalFocusHandler().

◆ _getFocusListeners()

std::list< FocusListener * > const & fcn::Widget::_getFocusListeners ( )
virtual

Gets the focus listeners of the widget.

Returns
The focus listeners of the widget.

Definition at line 987 of file widget.cpp.

References mFocusListeners.

Referenced by fcn::FocusHandler::distributeFocusGainedEvent(), and fcn::FocusHandler::distributeFocusLostEvent().

◆ _getGuiDeathListener()

DeathListener * fcn::Widget::_getGuiDeathListener ( )
static

Get the global GUI death listener.

Returns
The current DeathListener or nullptr if none is set.

Definition at line 709 of file widget.cpp.

References mGuiDeathListener.

◆ _getInternalFocusHandler()

FocusHandler * fcn::Widget::_getInternalFocusHandler ( )
virtual

Gets the internal focus handler used.

Returns
the internalFocusHandler used. If no internal focus handler is used, Nullptr will be returned.
See also
setInternalFocusHandler

Definition at line 997 of file widget.cpp.

References mInternalFocusHandler.

Referenced by fcn::Gui::getKeyEventSource().

◆ _getKeyListeners()

std::list< KeyListener * > const & fcn::Widget::_getKeyListeners ( )
virtual

Gets the key listeners of the widget.

Returns
The key listeners of the widget.

Definition at line 982 of file widget.cpp.

References mKeyListeners.

Referenced by fcn::Gui::distributeKeyEvent().

◆ _getMouseListeners()

std::list< MouseListener * > const & fcn::Widget::_getMouseListeners ( )
virtual

Gets the mouse listeners of the widget.

Returns
The mouse listeners of the widget.

Definition at line 977 of file widget.cpp.

References mMouseListeners.

Referenced by fcn::Gui::distributeMouseEvent().

◆ _getVisibilityEventHandler()

VisibilityEventHandler * fcn::Widget::_getVisibilityEventHandler ( )
static

Gets the visibility event handler of this widget.

WARNING: This function is used internally and should not be called unless you know what you are doing.

FIXME We don't like the visibility handler being static but we leave it as is for the moment, until we come up a better solution.

Definition at line 699 of file widget.cpp.

References mVisibilityEventHandler.

Referenced by add(), distributeAncestorHiddenEvent(), distributeAncestorShownEvent(), remove(), removeAllChildren(), and setVisible().

◆ _logic()

void fcn::Widget::_logic ( )
virtual

Called whenever a widget should perform logic.

The function will call the logic function for this widget and for all its children.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Definition at line 1405 of file widget.cpp.

References logic(), and mChildren.

◆ _setFocusHandler()

void fcn::Widget::_setFocusHandler ( FocusHandler * focusHandler)
virtual

Sets the focus handler to be used.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters
focusHandlerThe focus handler to use.
See also
_getFocusHandler

Definition at line 661 of file widget.cpp.

References fcn::FocusHandler::add(), mChildren, mFocusHandler, mInternalFocusHandler, releaseModalFocus(), releaseModalMouseInputFocus(), and widgetExists().

Referenced by add(), remove(), removeAllChildren(), and fcn::Gui::setTop().

◆ _setGuiDeathListener()

void fcn::Widget::_setGuiDeathListener ( DeathListener * deathListener)
static

Set the global GUI death listener used to observe widget deletions.

Parameters
deathListenerPointer to a DeathListener instance (ownership not transferred).

Definition at line 704 of file widget.cpp.

References mGuiDeathListener.

◆ _setParent()

void fcn::Widget::_setParent ( Widget * parent)
virtual

Sets the parent of the widget.

A parent must be a Container.

WARNING: This function is used internally and should not be called or overloaded unless you know what you are doing.

Parameters
parentThe parent of the widget.
See also
getParent

Definition at line 152 of file widget.cpp.

References mParent, and Widget().

Referenced by add(), remove(), and removeAllChildren().

◆ _setVisibilityEventHandler()

void fcn::Widget::_setVisibilityEventHandler ( VisibilityEventHandler * visibilityEventHandler)
static

Sets the visibility event handler to be used.

WARNING: This function is used internally and should not be called unless you know what you are doing.

FIXME We don't like the visibility handler being static but we leave it as is for the moment, until we come up a better solution.

Parameters
visibilityEventHandlerThe visibility event handler to be used.

Definition at line 694 of file widget.cpp.

References mVisibilityEventHandler.

◆ adaptLayout() [1/2]

void fcn::Widget::adaptLayout ( )
inline

Execute the layouting.

In case you want to relayout a visible widget. This function will automatically perform the layout adaption from the widget.

This is a convenience wrapper that calls adaptLayout(true).

Definition at line 1399 of file widget.hpp.

References adaptLayout().

Referenced by adaptLayout(), fcn::TabbedArea::addTab(), fcn::TabbedArea::removeTab(), and fcn::TabbedArea::setSelectedTab().

◆ adaptLayout() [2/2]

void fcn::Widget::adaptLayout ( bool top)
virtual

Execute the layouting for this widget.

Parameters
topIf true, perform top-level layout adaptations as well.

Definition at line 352 of file widget.cpp.

References expandContent(), getParent(), isLayouted(), resizeToContent(), and Widget().

◆ add()

void fcn::Widget::add ( Widget * widget)
protected

Adds a child to the widget.

THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION INSIDE ANY LISTER FUNCTIONS!

Parameters
widgetThe widget to add.
See also
remove, clear

Definition at line 1272 of file widget.cpp.

References _getFocusHandler(), _getVisibilityEventHandler(), _setFocusHandler(), _setParent(), mChildren, mInternalFocusHandler, setLastPosition(), Widget(), and fcn::VisibilityEventHandler::widgetShown().

Referenced by fcn::Container::add(), fcn::Container::add(), fcn::DropDown::DropDown(), and fcn::ScrollArea::setContent().

◆ addActionListener()

void fcn::Widget::addActionListener ( ActionListener * actionListener)

Adds an action listener to the widget.

When an action event is fired by the widget the action listeners of the widget will get notified.

Parameters
actionListenerThe action listener to add.
See also
removeActionListener

Definition at line 714 of file widget.cpp.

References mActionListeners.

Referenced by fcn::TabbedArea::addTab().

◆ addDeathListener()

void fcn::Widget::addDeathListener ( DeathListener * deathListener)

Adds a death listener to the widget.

When a death event is fired by the widget the death listeners of the widget will get notified.

Parameters
deathListenerThe death listener to add.
See also
removeDeathListener

Definition at line 724 of file widget.cpp.

References mDeathListeners.

◆ addFocusListener()

void fcn::Widget::addFocusListener ( FocusListener * focusListener)

Adds a focus listener to the widget.

When a focus event is fired by the widget the key listeners of the widget will get notified.

Parameters
focusListenerThe focus listener to add.
See also
removeFocusListener

Definition at line 744 of file widget.cpp.

References mFocusListeners.

Referenced by fcn::Button::Button(), and fcn::DropDown::DropDown().

◆ addKeyListener()

void fcn::Widget::addKeyListener ( KeyListener * keyListener)

Adds a key listener to the widget.

When a key event is fired by the widget the key listeners of the widget will get notified.

Parameters
keyListenerThe key listener to add.
See also
removeKeyListener

Definition at line 734 of file widget.cpp.

References mKeyListeners.

Referenced by fcn::Button::Button(), fcn::DropDown::DropDown(), fcn::ListBox::ListBox(), fcn::Slider::Slider(), fcn::TextBox::TextBox(), and fcn::TextField::TextField().

◆ addMouseListener()

void fcn::Widget::addMouseListener ( MouseListener * mouseListener)

Adds a mouse listener to the widget.

When a mouse event is fired by the widget the mouse listeners of the widget will get notified.

Parameters
mouseListenerThe mouse listener to add.
See also
removeMouseListener

Definition at line 754 of file widget.cpp.

References mMouseListeners.

Referenced by fcn::Button::Button(), fcn::DropDown::DropDown(), fcn::ListBox::ListBox(), fcn::ScrollArea::ScrollArea(), fcn::ScrollArea::ScrollArea(), fcn::Slider::Slider(), fcn::TextBox::TextBox(), fcn::TextField::TextField(), and fcn::Window::Window().

◆ addWidgetListener()

void fcn::Widget::addWidgetListener ( WidgetListener * widgetListener)

Adds a widget listener to the widget.

When a widget event is fired by the widget the key listeners of the widget will get notified.

Parameters
widgetListenerThe widget listener to add.
See also
removeWidgetListener

Definition at line 764 of file widget.cpp.

References mWidgetListeners.

Referenced by fcn::Button::Button().

◆ adjustSize()

virtual void fcn::Widget::adjustSize ( )
inlinevirtual

◆ calculateSize()

void fcn::Widget::calculateSize ( )
protected

Checks the size against the size constraints.

Used by setDimension.

Definition at line 314 of file widget.cpp.

References mDimension, mFixedSize, mFixedSizeUsed, mMaxSize, and mMinSize.

Referenced by setDimension(), setFixedSize(), setMaxSize(), and setMinSize().

◆ distributeActionEvent()

◆ distributeAncestorHiddenEvent()

void fcn::Widget::distributeAncestorHiddenEvent ( Widget * ancestor)
protected

Distributes ancestor hidden events to all of the widget's listeners.

All children will also distribute the same event.

Parameters
ancestorAncestor widget that was hidden.

Definition at line 1071 of file widget.cpp.

References _getVisibilityEventHandler(), mChildren, mWidgetListeners, Widget(), and fcn::VisibilityEventHandler::widgetHidden().

◆ distributeAncestorMovedEvent()

void fcn::Widget::distributeAncestorMovedEvent ( Widget * ancestor)
protected

Distributes ancestor moved events to all of the widget's listeners.

All children will also distribute the same event.

Parameters
ancestorAncestor widget that was moved.

Definition at line 1053 of file widget.cpp.

References mChildren, mWidgetListeners, and Widget().

◆ distributeAncestorShownEvent()

void fcn::Widget::distributeAncestorShownEvent ( Widget * ancestor)
protected

Distributes ancestor shown events to all of the widget's listeners.

All children will also distribute the same event.

Parameters
ancestorAncestor widget that was shown.

Definition at line 1092 of file widget.cpp.

References _getVisibilityEventHandler(), mChildren, mWidgetListeners, Widget(), and fcn::VisibilityEventHandler::widgetShown().

◆ distributeHiddenEvent()

void fcn::Widget::distributeHiddenEvent ( )
protected

Distributes hidden events to all of the widget's listeners.

Definition at line 1044 of file widget.cpp.

References mWidgetListeners.

Referenced by setVisible().

◆ distributeMovedEvent()

void fcn::Widget::distributeMovedEvent ( )
protected

Distributes moved events to all of the widget's listeners.

Definition at line 1035 of file widget.cpp.

References mWidgetListeners.

Referenced by setDimension().

◆ distributeResizedEvent()

void fcn::Widget::distributeResizedEvent ( )
protected

Distributes resized events to all of the widget's listeners.

Definition at line 1026 of file widget.cpp.

References mWidgetListeners.

Referenced by setDimension().

◆ distributeShownEvent()

void fcn::Widget::distributeShownEvent ( )
protected

Distributes shown events to all of the widget's listeners.

Definition at line 1122 of file widget.cpp.

References mWidgetListeners.

Referenced by setVisible().

◆ draw()

virtual void fcn::Widget::draw ( Graphics * graphics)
pure virtual

Draws the widget.

The call to draw is initiated by the widget's parent. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension. If a widget has children, the parent's draw function will always be called before the children's draw functions are called.

NOTE: A widget with children won't draw its children unless the children area given by Widget::getChildrenArea returns a none empty rectangle inside the widgets dimension. The children area is considered relative to the widget's position.

Parameters
Graphics & RenderingA graphics object to draw with.
See also
getChildrenArea, drawOutline, drawBorder

Implemented in fcn::BarGraph, fcn::Button, fcn::CheckBox, fcn::Container, fcn::CurveGraph, fcn::DropDown, fcn::Icon, fcn::IconProgressBar, fcn::ImageButton, fcn::ImageProgressBar, fcn::Label, fcn::LineGraph, fcn::ListBox, fcn::PieGraph, fcn::PointGraph, fcn::ScrollArea, fcn::Slider, fcn::Spacer, fcn::Tab, fcn::TabbedArea, fcn::TextBox, fcn::TextField, and fcn::Window.

References drawBorder(), drawOutline(), drawSelectionFrame(), getOutlineSize(), setBorderSize(), and setOutlineSize().

Referenced by _draw().

◆ drawBorder()

◆ drawOutline()

void fcn::Widget::drawOutline ( Graphics * graphics)
virtual

Called when a widget is given a chance to draw a outline around itself.

The outline is not considered as part of the widget, it only allows a outline to be drawn around the widget, thus a outline will never be included when calculating if a widget should receive events from user input. Also a widget's outline will never be included when calculating a widget's position.

The size of the outline is calculated using the widget's outline size. If a widget has a outline size of 10 pixels than the area the drawOutline function can draw to will be the size of the widget with an additional extension of 10 pixels in each direction.

An example when drawOutline is a useful function is if a widget needs a glow around itself.

Parameters
Graphics & RenderingA graphics object to draw with.
See also
setOutlineSize, getOutlineSize

Definition at line 88 of file widget.cpp.

References fcn::Color::a, fcn::Graphics::drawLine(), getBaseColor(), getHeight(), getOutlineColor(), getOutlineSize(), getWidth(), and fcn::Graphics::setColor().

Referenced by _draw(), and draw().

◆ drawSelectionFrame()

void fcn::Widget::drawSelectionFrame ( Graphics * graphics)
virtual

Called when a widget is "active" and the selection mode is Frame or FrameWithBackground.

Currently the size of the border is used, so it will replace the border with the frame.

Parameters
Graphics & RenderingA graphics object to draw with.
See also
setSelectionMode, getSelectionMode, setSelectionColor, getSelectionColor

Definition at line 135 of file widget.cpp.

References fcn::Graphics::drawLine(), getBorderSize(), getHeight(), getSelectionColor(), getWidth(), and fcn::Graphics::setColor().

Referenced by fcn::BarGraph::draw(), fcn::Button::draw(), fcn::Container::draw(), fcn::CurveGraph::draw(), fcn::Icon::draw(), fcn::IconProgressBar::draw(), fcn::ImageButton::draw(), fcn::ImageProgressBar::draw(), fcn::Label::draw(), fcn::LineGraph::draw(), fcn::PieGraph::draw(), fcn::PointGraph::draw(), draw(), and fcn::CheckBox::drawBox().

◆ expandContent() [1/2]

void fcn::Widget::expandContent ( )
inline

Expands the child widgets to the size of this widget, calls recursively all childs.

This is a convenience wrapper that calls expandContent(true).

Definition at line 1440 of file widget.hpp.

References expandContent().

Referenced by adaptLayout(), fcn::Container::Container(), fcn::ScrollArea::expandContent(), and expandContent().

◆ expandContent() [2/2]

virtual void fcn::Widget::expandContent ( bool recursion)
inlinevirtual

Expands child widgets to fit this widget's size.

Parameters
recursionIf true, call expandContent recursively on children.

Reimplemented in fcn::AdjustingContainer, fcn::Container, fcn::FlowContainer, fcn::ScrollArea, and fcn::TabbedArea.

Definition at line 1450 of file widget.hpp.

◆ findWidgetById()

Widget * fcn::Widget::findWidgetById ( std::string const & id)
protectedvirtual

Finds a widget by id.

This function can be useful when implementing a GUI generator, such as the ability to create a GUI from an XML file.

Parameters
idThe id to find a widget by.
Returns
The widget with the corresponding id, Nullptr if no widget is found.

Reimplemented in fcn::Container.

Definition at line 1184 of file widget.cpp.

References findWidgetById(), getId(), mChildren, and Widget().

Referenced by fcn::Container::findWidgetById(), and findWidgetById().

◆ focusNext()

void fcn::Widget::focusNext ( )
virtual

Focuses the next widget in the widget.

See also
moveToBottom

Definition at line 1316 of file widget.cpp.

References mChildren.

◆ focusPrevious()

void fcn::Widget::focusPrevious ( )
virtual

Focuses the previous widget in the widget.

See also
moveToBottom

Definition at line 1343 of file widget.cpp.

References mChildren.

◆ fontChanged()

virtual void fcn::Widget::fontChanged ( )
inlinevirtual

Called when the font has changed.

If the change is global, this function will only be called if the widget doesn't have a font already set.

Reimplemented in fcn::Button, and fcn::TextBox.

Definition at line 999 of file widget.hpp.

Referenced by setFont().

◆ getAbsolutePosition()

void fcn::Widget::getAbsolutePosition ( int & x,
int & y ) const
virtual

◆ getActionEventId()

std::string const & fcn::Widget::getActionEventId ( ) const

Gets the action event identifier of the widget.

Returns
The action event identifier of the widget.
See also
setActionEventId

Definition at line 487 of file widget.cpp.

References mActionEventId.

◆ getBackgroundColor()

◆ getBaseColor()

◆ getBorderColor()

Color const & fcn::Widget::getBorderColor ( ) const

Gets the border color.

Returns
The border color.
See also
setBorderColor

Definition at line 646 of file widget.cpp.

References mBorderColor.

Referenced by drawBorder().

◆ getBorderSize()

unsigned int fcn::Widget::getBorderSize ( ) const

◆ getChildren()

std::list< Widget * > const & fcn::Widget::getChildren ( ) const
protected

Gets the children of the widget.

Returns
A list of the widgets children.

Definition at line 1415 of file widget.cpp.

References mChildren.

Referenced by fcn::Container::getChild().

◆ getChildrenArea()

Rectangle fcn::Widget::getChildrenArea ( )
virtual

Gets the area of the widget occupied by the widget's children.

By default this method returns an empty rectangle as not all widgets are containers. If you want to make a container this method should return the area where the children resides. This method is used when drawing children of a widget when computing clip rectangles for the children.

NOTE: The returned rectangle should be relative to the widget, i.e a rectangle with x and y coordinate (0,0) and with width and height the same as the widget will let the children draw themselves in the whole widget.

An example of a widget that overloads this method is ScrollArea. A ScrollArea has a view of its constant and that view is the children area. The size of a ScrollArea's children area might vary depending on if the scroll bars of the ScrollArea is shown or not.

Returns
The area of the widget occupied by the widget's children.

Reimplemented in fcn::AdjustingContainer, fcn::Container, fcn::DropDown, fcn::ScrollArea, fcn::Tab, fcn::TabbedArea, and fcn::Window.

Definition at line 992 of file widget.cpp.

Referenced by _draw(), fcn::DropDown::adjustHeight(), getAbsolutePosition(), getWidgetAt(), fcn::TextBox::keyPressed(), and showWidgetPart().

◆ getChildrenCount()

unsigned int fcn::Widget::getChildrenCount ( ) const

Gets how many childs the widget have.

Returns
The children count of the widget.

Definition at line 247 of file widget.cpp.

References mChildren.

Referenced by fcn::Container::getChild().

◆ getDimension()

Rectangle const & fcn::Widget::getDimension ( ) const

Gets the dimension of the widget.

The dimension is relative to the widget's parent.

Returns
The dimension of the widget.
See also
getDimension, setX, getX, setY, getY, setPosition

Definition at line 482 of file widget.cpp.

References mDimension.

Referenced by fcn::FlowContainer::adjustContent(), getWidgetAt(), getWidgetsIn(), and fcn::Container::resizeToContent().

◆ getFixedSize()

Size const & fcn::Widget::getFixedSize ( ) const

Gets the fixed size of the widget.

Returns
The fixed size of the widget.
See also
setFixedSize, isFixedSize

Definition at line 304 of file widget.cpp.

References mFixedSize.

◆ getFont()

◆ getForegroundColor()

◆ getHeight()

int fcn::Widget::getHeight ( ) const

Gets the height of the widget.

Returns
The height of the widget.
See also
setHeight, setWidth, getWidth, setSize, setDimension, getDimension

Definition at line 183 of file widget.cpp.

References mDimension.

Referenced by fcn::TextField::adjustHeight(), fcn::AdjustingContainer::adjustSize(), fcn::Container::adjustSize(), fcn::TabbedArea::adjustSize(), fcn::Window::adjustSize(), fcn::CheckBox::adjustSizeImpl(), fcn::ImageButton::adjustSizeImpl(), fcn::Label::adjustSizeImpl(), fcn::TabbedArea::adjustTabPositions(), fcn::ScrollArea::checkPolicies(), fcn::BarGraph::draw(), fcn::Button::draw(), fcn::CheckBox::draw(), fcn::Container::draw(), fcn::CurveGraph::draw(), fcn::DropDown::draw(), fcn::Icon::draw(), fcn::IconProgressBar::draw(), fcn::ImageButton::draw(), fcn::ImageProgressBar::draw(), fcn::Label::draw(), fcn::LineGraph::draw(), fcn::ListBox::draw(), fcn::PieGraph::draw(), fcn::PointGraph::draw(), fcn::ScrollArea::draw(), fcn::Slider::draw(), fcn::Tab::draw(), fcn::TabbedArea::draw(), fcn::TextBox::draw(), fcn::TextField::draw(), fcn::Window::draw(), drawBorder(), fcn::CheckBox::drawBox(), fcn::TextBox::drawCaret(), fcn::Window::drawInnerBorder(), fcn::Slider::drawMarker(), drawOutline(), fcn::CheckBox::drawRhombus(), drawSelectionFrame(), fcn::DropDown::dropDown(), fcn::ScrollArea::expandContent(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::DropDown::getChildrenArea(), fcn::ScrollArea::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getDownButtonDimension(), fcn::ScrollArea::getHorizontalBarDimension(), fcn::ScrollArea::getLeftButtonDimension(), fcn::ScrollArea::getRightButtonDimension(), fcn::ScrollArea::getVerticalBarDimension(), fcn::ScrollArea::getVerticalMarkerDimension(), fcn::ScrollArea::getVerticalMaxScroll(), fcn::Gui::handleHiddenWidgets(), fcn::Gui::handleShownWidgets(), fcn::Slider::markerPositionToValue(), fcn::Slider::mouseDragged(), fcn::DropDown::mousePressed(), fcn::Slider::mousePressed(), fcn::DropDown::mouseReleased(), resizeToChildren(), fcn::FlowContainer::resizeToContent(), fcn::Spacer::resizeToContent(), fcn::ScrollArea::setDimension(), fcn::ScrollArea::setHeight(), and fcn::Slider::valueToMarkerPosition().

◆ getId()

std::string const & fcn::Widget::getId ( ) const

Gets the id of a widget.

An id can be useful if a widget needs to be identified in a container. For example, if widgets are created by an XML document, a certain widget can be retrieved given that the widget has an id.

Returns
The id of the widget.
See also
setId, Container::findWidgetById

Definition at line 1021 of file widget.cpp.

References mId.

Referenced by findWidgetById().

◆ getLastPosition()

void fcn::Widget::getLastPosition ( int & x,
int & y ) const

Retrieves the last stored position used by layout or event logic.

Parameters
xOutput parameter receiving the last x coordinate.
yOutput parameter receiving the last y coordinate.

Definition at line 1420 of file widget.cpp.

References mLastX, and mLastY.

◆ getMarginBottom()

int fcn::Widget::getMarginBottom ( ) const

Gets the bottom margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Returns
The bottom margin of the widget.
See also
setMarginBottom

Definition at line 419 of file widget.cpp.

References mMarginBottom.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::FlowContainer::resizeToContent().

◆ getMarginLeft()

int fcn::Widget::getMarginLeft ( ) const

Gets the left margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Returns
The left margin of the widget.
See also
setMarginLeft

Definition at line 429 of file widget.cpp.

References mMarginLeft.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::FlowContainer::resizeToContent().

◆ getMarginRight()

int fcn::Widget::getMarginRight ( ) const

Gets the right margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Returns
The right margin of the widget.
See also
setMarginRight

Definition at line 409 of file widget.cpp.

References mMarginRight.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::FlowContainer::resizeToContent().

◆ getMarginTop()

int fcn::Widget::getMarginTop ( ) const

Gets the top margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Returns
The top margin of the widget.
See also
setMarginTop

Definition at line 399 of file widget.cpp.

References mMarginTop.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::FlowContainer::resizeToContent().

◆ getMaxSize()

Size const & fcn::Widget::getMaxSize ( ) const

Gets the maximal dimension of the widget.

Returns
The maximal size of the widget.
See also
setMaxSize

Definition at line 288 of file widget.cpp.

References mMaxSize.

◆ getMinSize()

Size const & fcn::Widget::getMinSize ( ) const

Gets the minimal dimension of the widget.

Returns
The minimal size of the widget.
See also
setMinSize

Definition at line 277 of file widget.cpp.

References mMinSize.

Referenced by fcn::ScrollArea::adjustSize(), fcn::FlowContainer::resizeToContent(), fcn::ScrollArea::resizeToContent(), and fcn::Spacer::resizeToContent().

◆ getOutlineColor()

Color const & fcn::Widget::getOutlineColor ( ) const

Gets the outline color.

Returns
The outline color.
See also
setOutlineColor

Definition at line 636 of file widget.cpp.

References mOutlineColor.

Referenced by drawOutline().

◆ getOutlineSize()

unsigned int fcn::Widget::getOutlineSize ( ) const

Gets the size of the widget's outline.

The outline is not considered as part of the widget, it only allows a outline to be drawn around the widget, thus a outline will never be included when calculating if a widget should receive events from user input. Also a widget's outline will never be included when calculating a widget's position.

A outline size of 0 means that the widget has no outline. The default outline size is 0.

Returns
The size of the widget's outline.
See also
setOutlineSize, drawOutline

Definition at line 371 of file widget.cpp.

References mOutlineSize.

Referenced by draw(), and drawOutline().

◆ getPaddingBottom()

◆ getPaddingLeft()

◆ getPaddingRight()

◆ getPaddingTop()

◆ getParent()

Widget * fcn::Widget::getParent ( ) const
virtual

◆ getSelectionColor()

◆ getSelectionMode()

◆ getTop()

Widget * fcn::Widget::getTop ( ) const
virtual

Gets the top widget, or top parent, of this widget.

Returns
The top widget, or top parent, for this widget. Nullptr if no top widget exists (this widget doesn't have a parent).

Definition at line 1138 of file widget.cpp.

References getParent(), and Widget().

◆ getVisibleChildrenCount()

unsigned int fcn::Widget::getVisibleChildrenCount ( ) const

Gets how many visible childs the widget have.

Returns
The visible children count of the widget.

Definition at line 258 of file widget.cpp.

References isVisible(), and mChildren.

◆ getWidgetAt() [1/2]

Widget * fcn::Widget::getWidgetAt ( int x,
int y )
inline

Gets a widget at a certain position in the widget.

This function is used to decide which gets mouse input, thus it can be overloaded to change that behaviour.

NOTE: This always returns Nullptr if the widget is not a container.

Parameters
xThe x coordinate of the widget to get.
yThe y coordinate of the widget to get.
Returns
The widget at the specified coordinate, Nullptr if no widget is found.

Definition at line 1135 of file widget.hpp.

References getWidgetAt(), and Widget().

Referenced by fcn::Gui::getWidgetAt(), getWidgetAt(), and fcn::Gui::getWidgetsAt().

◆ getWidgetAt() [2/2]

Widget * fcn::Widget::getWidgetAt ( int x,
int y,
Widget * exclude )
virtual

Variant of getWidgetAt that allows excluding a specific widget from the hit-test.

Parameters
xThe x coordinate of the widget to get.
yThe y coordinate of the widget to get.
excludeWidget to exclude from search, if Nullptr no widgets get excluded.
Returns
The widget at the specified coordinate, Nullptr if no widget is found.

Definition at line 954 of file widget.cpp.

References getChildrenArea(), getDimension(), fcn::Rectangle::isContaining(), isVisible(), mChildren, Widget(), fcn::Rectangle::x, and fcn::Rectangle::y.

◆ getWidgetsIn() [1/2]

std::list< Widget * > fcn::Widget::getWidgetsIn ( Rectangle const & area)
inline

Gets all widgets inside a certain area of the widget.

NOTE: This always returns an emtpy list if the widget is not a container.

Parameters
areaThe area to check.
Returns
A list of widgets. An empty list if no widgets was found.

Definition at line 1160 of file widget.hpp.

References getWidgetsIn().

Referenced by getWidgetsIn().

◆ getWidgetsIn() [2/2]

std::list< Widget * > fcn::Widget::getWidgetsIn ( Rectangle const & area,
Widget * ignore )
virtual

Gets all widgets inside a certain area of the widget.

NOTE: This always returns an empty list if the widget is not a container.

Parameters
areaThe area to check.
ignoreOptional widget pointer to exclude from the results.
Returns
A list of widgets found inside area. Empty list if none.

Definition at line 1155 of file widget.cpp.

References getDimension(), fcn::Rectangle::isIntersecting(), mChildren, and Widget().

◆ getWidth()

int fcn::Widget::getWidth ( ) const

Gets the width of the widget.

Returns
The width of the widget.
See also
setWidth, setHeight, getHeight, setSize, setDimension, getDimension

Definition at line 170 of file widget.cpp.

References mDimension.

Referenced by fcn::DropDown::adjustHeight(), fcn::AdjustingContainer::adjustSize(), fcn::Container::adjustSize(), fcn::TabbedArea::adjustSize(), fcn::Window::adjustSize(), fcn::ImageButton::adjustSizeImpl(), fcn::Label::adjustSizeImpl(), fcn::ListBox::adjustSizeImpl(), fcn::TabbedArea::adjustTabPositions(), fcn::ScrollArea::checkPolicies(), fcn::BarGraph::draw(), fcn::Button::draw(), fcn::Container::draw(), fcn::CurveGraph::draw(), fcn::DropDown::draw(), fcn::Icon::draw(), fcn::IconProgressBar::draw(), fcn::ImageButton::draw(), fcn::ImageProgressBar::draw(), fcn::Label::draw(), fcn::LineGraph::draw(), fcn::ListBox::draw(), fcn::PieGraph::draw(), fcn::PointGraph::draw(), fcn::ScrollArea::draw(), fcn::Slider::draw(), fcn::Tab::draw(), fcn::TabbedArea::draw(), fcn::TextBox::draw(), fcn::TextField::draw(), fcn::Window::draw(), drawBorder(), fcn::CheckBox::drawBox(), fcn::Window::drawInnerBorder(), fcn::Slider::drawMarker(), drawOutline(), fcn::CheckBox::drawRhombus(), drawSelectionFrame(), fcn::ScrollArea::expandContent(), fcn::TextField::fixScroll(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::DropDown::getChildrenArea(), fcn::ScrollArea::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getDownButtonDimension(), fcn::ScrollArea::getHorizontalBarDimension(), fcn::ScrollArea::getHorizontalMarkerDimension(), fcn::ScrollArea::getHorizontalMaxScroll(), fcn::ScrollArea::getRightButtonDimension(), fcn::ScrollArea::getUpButtonDimension(), fcn::ScrollArea::getVerticalBarDimension(), fcn::Gui::handleHiddenWidgets(), fcn::Gui::handleShownWidgets(), fcn::Slider::markerPositionToValue(), fcn::DropDown::mousePressed(), fcn::Slider::mousePressed(), fcn::DropDown::mouseReleased(), resizeToChildren(), fcn::FlowContainer::resizeToContent(), fcn::Spacer::resizeToContent(), fcn::ScrollArea::setDimension(), fcn::ScrollArea::setWidth(), and fcn::Slider::valueToMarkerPosition().

◆ getX()

int fcn::Widget::getX ( ) const

Gets the x coordinate of the widget.

The coordinate is relative to the widget's parent.

Returns
The x coordinate of the widget.
See also
setX, setY, getY, setPosition, setDimension, getDimension

Definition at line 196 of file widget.cpp.

References mDimension.

Referenced by fcn::Window::mouseDragged(), resizeToChildren(), fcn::ScrollArea::showWidgetPart(), and showWidgetPart().

◆ getY()

int fcn::Widget::getY ( ) const

Gets the y coordinate of the widget.

The coordinate is relative to the widget's parent.

Returns
The y coordinate of the widget.
See also
setY, setX, getX, setPosition, setDimension, getDimension

Definition at line 209 of file widget.cpp.

References mDimension.

Referenced by fcn::DropDown::adjustHeight(), fcn::ListBox::draw(), fcn::Window::mouseDragged(), resizeToChildren(), fcn::ScrollArea::showWidgetPart(), and showWidgetPart().

◆ isEnabled()

bool fcn::Widget::isEnabled ( ) const

Checks if the widget is enabled.

A disabled widget will never receive mouse or key events.

Returns
True if widget is enabled, false otherwise.
See also
setEnabled

Definition at line 869 of file widget.cpp.

References isVisible(), and mEnabled.

Referenced by fcn::Gui::distributeKeyEvent(), fcn::Gui::distributeMouseEvent(), fcn::Gui::handleHiddenWidgets(), fcn::Gui::handleShownWidgets(), and isFocusable().

◆ isFixedSize()

bool fcn::Widget::isFixedSize ( ) const

Gets if the widget use a fixed size.

Returns
True if the widget use a fixed size, otherwise false.
See also
setFixedSize, getFixedSize

Definition at line 309 of file widget.cpp.

References mFixedSizeUsed.

◆ isFocusable()

bool fcn::Widget::isFocusable ( ) const

Checks if a widget is focusable.

Returns
True if the widget should be focusable, false otherwise.
See also
setFocusable

Definition at line 515 of file widget.cpp.

References isEnabled(), isVisible(), and mFocusable.

Referenced by fcn::TabbedArea::mousePressed(), and requestFocus().

◆ isFocused()

◆ isHorizontalExpand()

bool fcn::Widget::isHorizontalExpand ( ) const

Gets if widget is horizontal expandable.

Returns
True if the widget can be horizontal expanded, otherwise false.
See also
setHorizontalExpand

Definition at line 347 of file widget.cpp.

References mHExpand.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::Container::expandContent().

◆ isLastPositionSet()

bool fcn::Widget::isLastPositionSet ( ) const

Returns whether a last position has been stored for this widget.

Returns
True if a last position is set, false otherwise.

Definition at line 1432 of file widget.cpp.

References mLastX, and mLastY.

Referenced by getAbsolutePosition().

◆ isLayouted()

virtual bool fcn::Widget::isLayouted ( )
inlinevirtual

Helper function to decide if we need to layout.

Reimplemented in fcn::Container.

Definition at line 1455 of file widget.hpp.

Referenced by adaptLayout().

◆ isModalFocusable()

bool fcn::Widget::isModalFocusable ( ) const
virtual

Checks if a widget is modal focusable.

Returns
True if no other widget is modal focused, false otherwise.
See also
requestModalFocus, releaseModalFocus

Definition at line 874 of file widget.cpp.

References mFocusHandler.

◆ isModalFocused()

bool fcn::Widget::isModalFocused ( ) const
virtual

Checks if the widget or it's parent has modal focus.

Returns
True if the widget has modal focus, false otherwise.
See also
requestModalFocus, releaseModalFocus

Definition at line 928 of file widget.cpp.

References getParent(), isModalFocused(), and mFocusHandler.

Referenced by fcn::Gui::distributeKeyEvent(), fcn::Gui::distributeMouseEvent(), fcn::Gui::handleMousePressed(), and isModalFocused().

◆ isModalMouseInputFocusable()

bool fcn::Widget::isModalMouseInputFocusable ( ) const
virtual

Checks if a widget is modal mouse input focusable.

Returns
True if no other widget is modal mouse input focused, false otherwise.
See also
requestModalMouseInputFocus, releaseModalMouseInputFocus

Definition at line 883 of file widget.cpp.

References mFocusHandler.

◆ isModalMouseInputFocused()

bool fcn::Widget::isModalMouseInputFocused ( ) const
virtual

Checks if the widget or it's parent has modal mouse input focus.

Returns
True if the widget has modal mouse input focus, false otherwise.
See also
requestModalMouseInputFocus, releaseModalMouseInputFocus

Definition at line 941 of file widget.cpp.

References getParent(), isModalMouseInputFocused(), and mFocusHandler.

Referenced by fcn::Gui::distributeMouseEvent(), fcn::Gui::getMouseEventSource(), fcn::Gui::handleMouseMoved(), isModalMouseInputFocused(), and fcn::DropDown::mouseReleased().

◆ isSetVisible()

bool fcn::Widget::isSetVisible ( ) const

Checks if the widget setting is visible.

Returns
True if widget setting is be visible, false otherwise.

Definition at line 586 of file widget.cpp.

References mVisible.

◆ isTabInEnabled()

bool fcn::Widget::isTabInEnabled ( ) const

Checks if tab in is enabled.

Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the focus handler will skip this widget and focus the next in its focus order.

Returns
True if tab in is enabled, false otherwise.
See also
setTabInEnabled

Definition at line 835 of file widget.cpp.

References mTabIn.

◆ isTabOutEnabled()

bool fcn::Widget::isTabOutEnabled ( ) const

Checks if tab out is enabled.

Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Returns
True if tab out is enabled, false otherwise.
See also
setTabOutEnabled

Definition at line 845 of file widget.cpp.

References mTabOut.

◆ isVerticalExpand()

bool fcn::Widget::isVerticalExpand ( ) const

Gets if widget is vertical expandable.

Returns
True if the widget can be vertical expanded, otherwise false.
See also
setVerticalExpand

Definition at line 337 of file widget.cpp.

References mVExpand.

Referenced by fcn::FlowContainer::adjustContent(), and fcn::Container::expandContent().

◆ isVisible()

bool fcn::Widget::isVisible ( ) const

Checks if the widget is visible.

Returns
True if widget is be visible, false otherwise.
See also
setVisible

Definition at line 578 of file widget.cpp.

References getParent(), isVisible(), and mVisible.

Referenced by fcn::FlowContainer::adjustContent(), getVisibleChildrenCount(), getWidgetAt(), isEnabled(), isFocusable(), and isVisible().

◆ logic()

virtual void fcn::Widget::logic ( )
inlinevirtual

Called for all widgets in the gui each time Gui::logic is called.

You can do logic stuff here like playing an animation.

See also
Gui::logic

Reimplemented in fcn::ListBox, and fcn::ScrollArea.

Definition at line 378 of file widget.hpp.

Referenced by _logic(), and fcn::ScrollArea::logic().

◆ moveToBottom()

void fcn::Widget::moveToBottom ( Widget * widget)
virtual

Moves a widget in this widget to the bottom of this widget.

The moved widget will be drawn below all other widgets in this widget.

This method is safe to call at any time.

Parameters
widgetThe widget to move to the bottom.
See also
moveToTop

Definition at line 1303 of file widget.cpp.

References mChildren, and Widget().

◆ moveToTop()

void fcn::Widget::moveToTop ( Widget * widget)
virtual

Moves a widget to the top of this widget.

The moved widget will be drawn above all other widgets in this widget.

This method is safe to call at any time.

Parameters
widgetThe widget to move to the top.
See also
moveToBottom

Definition at line 1290 of file widget.cpp.

References mChildren, and Widget().

Referenced by fcn::DropDown::dropDown(), and fcn::Window::mousePressed().

◆ releaseModalFocus()

void fcn::Widget::releaseModalFocus ( )
virtual

Releases modal focus.

Modal focus will only be released if the widget has modal focus.

See also
requestModalFocus, isModalFocused

Definition at line 910 of file widget.cpp.

References mFocusHandler.

Referenced by _setFocusHandler().

◆ releaseModalMouseInputFocus()

void fcn::Widget::releaseModalMouseInputFocus ( )
virtual

Releases modal mouse input focus.

Modal mouse input focus will only be released if the widget has modal mouse input focus.

See also
requestModalMouseInputFocus, isModalMouseInputFocused

Definition at line 919 of file widget.cpp.

References mFocusHandler.

Referenced by _setFocusHandler(), fcn::DropDown::action(), fcn::DropDown::mousePressed(), and fcn::DropDown::mouseReleased().

◆ remove()

void fcn::Widget::remove ( Widget * widget)
protectedvirtual

Removes a specific child from the widget.

THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION INSIDE ANY LISTER FUNCTIONS!

Parameters
widgetThe widget to remove.
See also
removeAllChildren

Reimplemented in fcn::AdjustingContainer, and fcn::Container.

Definition at line 1248 of file widget.cpp.

References _getVisibilityEventHandler(), _setFocusHandler(), _setParent(), getAbsolutePosition(), mChildren, setLastPosition(), Widget(), and fcn::VisibilityEventHandler::widgetHidden().

Referenced by fcn::Container::remove().

◆ removeActionListener()

void fcn::Widget::removeActionListener ( ActionListener * actionListener)

Removes an added action listener from the widget.

Parameters
actionListenerThe action listener to remove.
See also
addActionListener

Definition at line 719 of file widget.cpp.

References mActionListeners.

◆ removeAllChildren()

void fcn::Widget::removeAllChildren ( )
protectedvirtual

Remvoes all children from the widget.

THIS METHOD IS NOT SAFE TO CALL INSIDE A WIDGETS LOGIC FUNCTION INSIDE ANY LISTER FUNCTIONS!

See also
remove

Reimplemented in fcn::AdjustingContainer, and fcn::Container.

Definition at line 1228 of file widget.cpp.

References _getVisibilityEventHandler(), _setFocusHandler(), _setParent(), getAbsolutePosition(), mChildren, setLastPosition(), Widget(), and fcn::VisibilityEventHandler::widgetHidden().

Referenced by fcn::Container::removeAllChildren(), and fcn::ScrollArea::setContent().

◆ removeDeathListener()

void fcn::Widget::removeDeathListener ( DeathListener * deathListener)

Removes an added death listener from the widget.

Parameters
deathListenerThe death listener to remove.
See also
addDeathListener

Definition at line 729 of file widget.cpp.

References mDeathListeners.

◆ removeFocusListener()

void fcn::Widget::removeFocusListener ( FocusListener * focusListener)

Removes an added focus listener from the widget.

Parameters
focusListenerThe focus listener to remove.
See also
addFocusListener

Definition at line 749 of file widget.cpp.

References mFocusListeners.

◆ removeKeyListener()

void fcn::Widget::removeKeyListener ( KeyListener * keyListener)

Removes an added key listener from the widget.

Parameters
keyListenerThe key listener to remove.
See also
addKeyListener

Definition at line 739 of file widget.cpp.

References mKeyListeners.

◆ removeMouseListener()

void fcn::Widget::removeMouseListener ( MouseListener * mouseListener)

Removes an added mouse listener from the widget.

Parameters
mouseListenerThe mouse listener to remove.
See also
addMouseListener

Definition at line 759 of file widget.cpp.

References mMouseListeners.

◆ removeWidgetListener()

void fcn::Widget::removeWidgetListener ( WidgetListener * widgetListener)

Removes an added widget listener from the widget.

Parameters
widgetListenerThe widget listener to remove.
See also
addWidgetListener

Definition at line 769 of file widget.cpp.

References mWidgetListeners.

◆ requestFocus()

void fcn::Widget::requestFocus ( )
virtual

Requests focus for the widget.

A widget will only receive focus if it is focusable.

Definition at line 520 of file widget.cpp.

References isFocusable(), and mFocusHandler.

Referenced by fcn::Gui::handleMousePressed(), and fcn::TabbedArea::mousePressed().

◆ requestModalFocus()

void fcn::Widget::requestModalFocus ( )
virtual

Requests modal focus.

When a widget has modal focus, only that widget and it's children may receive input.

Exceptions
Exceptionif another widget already has modal focus.
See also
releaseModalFocus, isModalFocused

Definition at line 892 of file widget.cpp.

References mFocusHandler.

◆ requestModalMouseInputFocus()

void fcn::Widget::requestModalMouseInputFocus ( )
virtual

Requests modal mouse input focus.

When a widget has modal input focus that widget will be the only widget receiving input even if the input occurs outside of the widget and no matter what the input is.

Exceptions
Exceptionif another widget already has modal focus.
See also
releaseModalMouseInputFocus, isModalMouseInputFocused

Definition at line 901 of file widget.cpp.

References mFocusHandler.

Referenced by fcn::DropDown::mousePressed().

◆ requestMoveToBottom()

void fcn::Widget::requestMoveToBottom ( )
virtual

Requests a move to the bottom in the parent widget.

Definition at line 538 of file widget.cpp.

References mParent.

◆ requestMoveToTop()

void fcn::Widget::requestMoveToTop ( )
virtual

Requests a move to the top in the parent widget.

Definition at line 531 of file widget.cpp.

References mParent.

◆ resizeToChildren()

void fcn::Widget::resizeToChildren ( )
protected

Resizes the widget to fit it's children exactly.

Definition at line 1170 of file widget.cpp.

References getHeight(), getWidth(), getX(), getY(), mChildren, setSize(), and Widget().

Referenced by fcn::Container::adjustSize(), fcn::Window::adjustSize(), and fcn::TabbedArea::resizeToContent().

◆ resizeToContent() [1/2]

void fcn::Widget::resizeToContent ( )
inline

Resizes the widget's size to fit the content exactly, calls recursively all childs.

This is a convenience wrapper that calls resizeToContent(true).

Definition at line 1417 of file widget.hpp.

References resizeToContent().

Referenced by adaptLayout(), fcn::Container::Container(), fcn::ScrollArea::resizeToContent(), and resizeToContent().

◆ resizeToContent() [2/2]

virtual void fcn::Widget::resizeToContent ( bool recursion)
inlinevirtual

Resize this widget to fit its content.

Parameters
recursionIf true, perform the resize operation recursively on children.

Reimplemented in fcn::AdjustingContainer, fcn::Button, fcn::Container, fcn::DropDown, fcn::FlowContainer, fcn::Icon, fcn::IconProgressBar, fcn::ImageButton, fcn::ImageProgressBar, fcn::Label, fcn::ListBox, fcn::ScrollArea, fcn::Spacer, fcn::TabbedArea, fcn::TextBox, and fcn::TextField.

Definition at line 1427 of file widget.hpp.

◆ setActionEventId()

void fcn::Widget::setActionEventId ( std::string const & actionEventId)

Sets the action event identifier of the widget.

The identifier is used to be able to identify which action has occurred.

NOTE: An action event identifier should not be used to identify a certain widget but rather a certain event in your application. Several widgets can have the same action event identifier.

Parameters
actionEventIdThe action event identifier.
See also
getActionEventId

Definition at line 492 of file widget.cpp.

References mActionEventId.

◆ setBackgroundColor()

void fcn::Widget::setBackgroundColor ( Color const & color)
virtual

Sets the background color.

Parameters
colorThe background Color.
See also
setBackgroundColor

Reimplemented in fcn::DropDown.

Definition at line 611 of file widget.cpp.

References mBackgroundColor.

Referenced by fcn::DropDown::setBackgroundColor().

◆ setBaseColor()

void fcn::Widget::setBaseColor ( Color const & color)
virtual

Sets the base color of the widget.

Parameters
colorThe base color.
See also
getBaseColor

Reimplemented in fcn::DropDown, and fcn::TabbedArea.

Definition at line 591 of file widget.cpp.

References mBaseColor.

Referenced by fcn::TabbedArea::addTab(), fcn::DropDown::setBaseColor(), and fcn::TabbedArea::setBaseColor().

◆ setBorderColor()

void fcn::Widget::setBorderColor ( Color const & color)
virtual

Sets the border color.

Parameters
colorThe border color.
See also
getBorderColor

Definition at line 641 of file widget.cpp.

References mBorderColor.

◆ setBorderSize()

void fcn::Widget::setBorderSize ( unsigned int size)

Sets the size of the widget's border.

The border is considered as part of the widget.

A border size of 0 means that the widget has no border. The default border size is 0.

Parameters
sizeThe size of the widget's border.
See also
getBorderSize, drawBorder

Definition at line 376 of file widget.cpp.

References mBorderSize.

Referenced by draw(), fcn::Slider::Slider(), and fcn::Window::Window().

◆ setDimension()

void fcn::Widget::setDimension ( Rectangle const & dimension)

Sets the dimension of the widget.

The dimension is relative to the widget's parent.

Parameters
dimensionThe dimension of the widget.
See also
getDimension, setX, getX, setY, getY, setPosition

Definition at line 223 of file widget.cpp.

References calculateSize(), distributeMovedEvent(), distributeResizedEvent(), fcn::Rectangle::height, mChildren, mDimension, fcn::Rectangle::width, fcn::Rectangle::x, and fcn::Rectangle::y.

Referenced by fcn::ScrollArea::setDimension(), fcn::TabbedArea::setDimension(), setHeight(), setPosition(), setSize(), setWidth(), setX(), and setY().

◆ setEnabled()

void fcn::Widget::setEnabled ( bool enabled)

Sets the widget to enabled, or not.

A disabled widget will never receive mouse or key events.

Parameters
enabledTrue if widget should be enabled, false otherwise.
See also
isEnabled

Definition at line 864 of file widget.cpp.

References mEnabled.

◆ setFixedSize()

void fcn::Widget::setFixedSize ( Size const & size)

Sets the dimension of the widget to a fixed size.

To disable it, provide a size with negative values.

Parameters
sizeThe fixed size of the widget.
See also
getFixedSize, isFixedSize

Definition at line 293 of file widget.cpp.

References calculateSize(), mFixedSize, and mFixedSizeUsed.

◆ setFocusable()

void fcn::Widget::setFocusable ( bool focusable)

Sets the widget to be focusable, or not.

Parameters
focusableTrue if the widget should be focusable, false otherwise.
See also
isFocusable

Definition at line 506 of file widget.cpp.

References isFocused(), mFocusable, and mFocusHandler.

Referenced by fcn::Button::Button(), fcn::DropDown::DropDown(), fcn::ListBox::ListBox(), fcn::Slider::Slider(), fcn::TextBox::TextBox(), and fcn::TextField::TextField().

◆ setFont()

void fcn::Widget::setFont ( Font * font)
virtual

Sets the font for the widget.

If Nullptr is passed, the global font will be used.

Parameters
fontThe font to set for the widget.
See also
getFont

Reimplemented in fcn::DropDown.

Definition at line 821 of file widget.cpp.

References fontChanged(), and mCurrentFont.

Referenced by fcn::DropDown::setFont().

◆ setForegroundColor()

void fcn::Widget::setForegroundColor ( Color const & color)
virtual

Sets the foreground color.

Parameters
colorThe foreground color.
See also
getForegroundColor

Reimplemented in fcn::DropDown.

Definition at line 601 of file widget.cpp.

References mForegroundColor.

Referenced by fcn::DropDown::setForegroundColor().

◆ setGlobalFont()

void fcn::Widget::setGlobalFont ( Font * font)
static

Sets the global font to be used by default for all widgets.

Parameters
fontThe global font.
See also
getGlobalFont

Definition at line 809 of file widget.cpp.

References mGlobalFont, and mWidgetInstances.

Referenced by fcn::Gui::setGlobalFont().

◆ setHeight()

void fcn::Widget::setHeight ( int height)

◆ setHorizontalExpand()

void fcn::Widget::setHorizontalExpand ( bool expand)

Sets the widget to horizontal expandable.

Parameters
expandTrue if the widget can be horizontal expanded, otherwise false.
See also
isHorizontalExpand

Definition at line 342 of file widget.cpp.

References mHExpand.

Referenced by fcn::Spacer::Spacer().

◆ setId()

void fcn::Widget::setId ( std::string const & id)

Sets an id of a widget.

An id can be useful if a widget needs to be identified in a container. For example, if widgets are created by an XML document, a certain widget can be retrieved given that the widget has an id.

Parameters
idThe id to set to the widget.
See also
getId, Container::findWidgetById

Definition at line 1016 of file widget.cpp.

References mId.

◆ setInternalFocusHandler()

void fcn::Widget::setInternalFocusHandler ( FocusHandler * internalFocusHandler)

Sets the internal focus handler.

An internal focus handler is needed if both a widget in the widget and the widget itself should be focused at the same time.

Parameters
internalFocusHandlerThe internal focus handler to be used.
See also
getInternalFocusHandler

Definition at line 1002 of file widget.cpp.

References _getFocusHandler(), mChildren, and mInternalFocusHandler.

Referenced by fcn::DropDown::DropDown().

◆ setLastPosition()

void fcn::Widget::setLastPosition ( int x,
int y )

Stores the last known position for this widget.

Parameters
xThe x coordinate to store.
yThe y coordinate to store.

Definition at line 1426 of file widget.cpp.

References mLastX, and mLastY.

Referenced by add(), remove(), and removeAllChildren().

◆ setMargin()

void fcn::Widget::setMargin ( int margin)

Sets all 4 margins to one value.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Parameters
marginThe margin of the widget.
See also
setMarginTop, setMarginRight, setMarginBottom, setMarginRight

Definition at line 386 of file widget.cpp.

References mMarginBottom, mMarginLeft, mMarginRight, and mMarginTop.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setMarginBottom()

void fcn::Widget::setMarginBottom ( int margin)

Sets the bottom margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Parameters
marginThe bottom margin of the widget.
See also
getMarginBottom

Definition at line 414 of file widget.cpp.

References mMarginBottom.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setMarginLeft()

void fcn::Widget::setMarginLeft ( int margin)

Sets the left margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Parameters
marginThe left margin of the widget.
See also
getMarginLeft

Definition at line 424 of file widget.cpp.

References mMarginLeft.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setMarginRight()

void fcn::Widget::setMarginRight ( int margin)

Sets the right margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Parameters
marginThe right margin of the widget.
See also
getMarginRight

Definition at line 404 of file widget.cpp.

References mMarginRight.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setMarginTop()

void fcn::Widget::setMarginTop ( int margin)

Sets the top margin.

The margin clears an area around an element (outside the border). The margin does not have a background color, and is completely transparent. It is also possible to use negative values, to overlap content.

Parameters
marginThe top margin of the widget.
See also
getMarginTop

Definition at line 394 of file widget.cpp.

References mMarginTop.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setMaxSize()

void fcn::Widget::setMaxSize ( Size const & size)

Sets the maximal dimension of the widget.

Parameters
sizeThe maximal size of the widget.
See also
getMaxSize

Definition at line 282 of file widget.cpp.

References calculateSize(), and mMaxSize.

◆ setMinSize()

void fcn::Widget::setMinSize ( Size const & size)

Sets the minimal dimension of the widget.

Parameters
sizeThe minimal size of the widget.
See also
getMinSize

Definition at line 271 of file widget.cpp.

References calculateSize(), and mMinSize.

◆ setOutlineColor()

void fcn::Widget::setOutlineColor ( Color const & color)
virtual

Sets the outline color.

Parameters
colorThe outline color.
See also
getOutlineColor

Definition at line 631 of file widget.cpp.

References mOutlineColor.

◆ setOutlineSize()

void fcn::Widget::setOutlineSize ( unsigned int size)

Sets the size of the widget's outline.

The outline is not considered as part of the widget, it only allows a outline to be drawn around the widget, thus a outline will never be included when calculating if a widget should receive events from user input. Also a widget's outline will never be included when calculating a widget's position.

A outline size of 0 means that the widget has no outline. The default outline size is 0.

Parameters
sizeThe size of the widget's outline.
See also
getOutlineSize, drawOutline

Definition at line 366 of file widget.cpp.

References mOutlineSize.

Referenced by draw().

◆ setPadding()

void fcn::Widget::setPadding ( unsigned int padding)

Sets all 4 paddings to one value.

The padding clears an area around the content (inside the border) of an element. The padding is affected by the background color of the element.

Parameters
paddingThe top padding of the widget.
See also
setPaddingTop, setPaddingRight, setPaddingBottom, setPaddingLeft

Definition at line 434 of file widget.cpp.

References mPaddingBottom, mPaddingLeft, mPaddingRight, and mPaddingTop.

Referenced by fcn::FlowContainer::resizeToContent(), and fcn::Window::Window().

◆ setPaddingBottom()

void fcn::Widget::setPaddingBottom ( unsigned int padding)

Sets the bottom padding.

The padding clears an area around the content (inside the border) of an element. The padding is affected by the background color of the element.

Parameters
paddingThe bottom padding of the widget.
See also
getPaddingBottom

Definition at line 462 of file widget.cpp.

References mPaddingBottom.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setPaddingLeft()

void fcn::Widget::setPaddingLeft ( unsigned int padding)

Sets the left padding.

The padding clears an area around the content (inside the border) of an element. The padding is affected by the background color of the element.

Parameters
paddingThe left padding of the widget.
See also
getPaddingLeft

Definition at line 472 of file widget.cpp.

References mPaddingLeft.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setPaddingRight()

void fcn::Widget::setPaddingRight ( unsigned int padding)

Sets the right padding.

The padding clears an area around the content (inside the border) of an element. The padding is affected by the background color of the element.

Parameters
paddingThe right padding of the widget.
See also
getPaddingRight

Definition at line 452 of file widget.cpp.

References mPaddingRight.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setPaddingTop()

void fcn::Widget::setPaddingTop ( unsigned int padding)

Sets the top padding.

The padding clears an area around the content (inside the border) of an element. The padding is affected by the background color of the element.

Parameters
paddingThe top padding of the widget.
See also
getPaddingTop

Definition at line 442 of file widget.cpp.

References mPaddingTop.

Referenced by fcn::FlowContainer::resizeToContent().

◆ setPosition()

void fcn::Widget::setPosition ( int x,
int y )

Sets position of the widget.

The position is relative to the widget's parent.

Parameters
xThe x coordinate of the widget.
yThe y coordinate of the widget.
See also
setX, getX, setY, getY, setDimension, getDimension

Definition at line 214 of file widget.cpp.

References mDimension, setDimension(), fcn::Rectangle::x, and fcn::Rectangle::y.

Referenced by fcn::Container::add(), fcn::TabbedArea::adjustTabPositions(), fcn::ScrollArea::logic(), fcn::Window::mouseDragged(), and fcn::ScrollArea::setContent().

◆ setSelectionColor()

void fcn::Widget::setSelectionColor ( Color const & color)
virtual

Sets the selection color.

Parameters
colorThe selection color.
See also
getSelectionColor

Reimplemented in fcn::DropDown.

Definition at line 621 of file widget.cpp.

References mSelectionColor.

Referenced by fcn::DropDown::setSelectionColor().

◆ setSelectionMode()

void fcn::Widget::setSelectionMode ( SelectionMode mode)
virtual

Sets the selection mode.

Parameters
modeThe selection mode that is used when the widget is "active".
See also
getSelectionMode

Definition at line 651 of file widget.cpp.

References mSelectionMode.

◆ setSize()

◆ setTabInEnabled()

void fcn::Widget::setTabInEnabled ( bool enabled)

Sets tab in enabled, or not.

Tab in means that you can set focus to this widget by pressing the tab button. If tab in is disabled then the FocusHandler will skip this widget and focus the next in its focus order.

Parameters
enabledTrue if tab in should be enabled, false otherwise.
See also
isTabInEnabled

Definition at line 840 of file widget.cpp.

References mTabIn.

◆ setTabOutEnabled()

void fcn::Widget::setTabOutEnabled ( bool enabled)

Sets tab out enabled.

Tab out means that you can lose focus to this widget by pressing the tab button. If tab out is disabled then the FocusHandler ignores tabbing and focus will stay with this widget.

Parameters
enabledTrue if tab out should be enabled, false otherwise.
See also
isTabOutEnabled

Definition at line 850 of file widget.cpp.

References mTabOut.

◆ setVerticalExpand()

void fcn::Widget::setVerticalExpand ( bool expand)

Sets the widget to vertical expandable.

Parameters
expandTrue if the widget can be vertical expanded, otherwise false.
See also
isVerticalExpand

Definition at line 332 of file widget.cpp.

References mVExpand.

Referenced by fcn::Spacer::Spacer().

◆ setVisible()

void fcn::Widget::setVisible ( bool visible)

Sets the widget to be visible, or not.

Parameters
visibleTrue if widget should be visible, false otherwise.
See also
isVisible

Definition at line 545 of file widget.cpp.

References _getVisibilityEventHandler(), distributeHiddenEvent(), distributeShownEvent(), isFocused(), mChildren, mFocusHandler, mVisible, fcn::VisibilityEventHandler::widgetHidden(), and fcn::VisibilityEventHandler::widgetShown().

◆ setWidth()

◆ setX()

void fcn::Widget::setX ( int x)

Sets the x coordinate of the widget.

The coordinate is relative to the widget's parent.

Parameters
xThe x coordinate of the widget.
See also
getX, setY, getY, setPosition, setDimension, getDimension

Definition at line 188 of file widget.cpp.

References mDimension, setDimension(), and fcn::Rectangle::x.

Referenced by showWidgetPart().

◆ setY()

void fcn::Widget::setY ( int y)

Sets the y coordinate of the widget.

The coordinate is relative to the widget's parent.

Parameters
yThe y coordinate of the widget.
See also
setY, setX, getX, setPosition, setDimension, getDimension

Definition at line 201 of file widget.cpp.

References mDimension, setDimension(), and fcn::Rectangle::y.

Referenced by showWidgetPart().

◆ showPart()

void fcn::Widget::showPart ( Rectangle rectangle)
virtual

Shows a certain part of a widget in the widget's parent.

Used when widgets want a specific part to be visible in its parent. An example is a TextArea that wants a specific part of its text to be visible when a TextArea is a child of a ScrollArea.

Parameters
rectangleThe rectangle to be shown.

Definition at line 1131 of file widget.cpp.

References mParent.

Referenced by fcn::TextBox::scrollToCaret(), and fcn::ListBox::setSelected().

◆ showWidgetPart()

void fcn::Widget::showWidgetPart ( Widget * widget,
Rectangle area )
virtual

Tries to show a specific part of a widget by moving it.

Used if the widget should act as a container.

Parameters
widgetThe target widget.
areaThe area to show.

Reimplemented in fcn::ScrollArea.

Definition at line 1204 of file widget.cpp.

References getChildrenArea(), getX(), getY(), fcn::Rectangle::height, setX(), setY(), Widget(), fcn::Rectangle::width, fcn::Rectangle::x, and fcn::Rectangle::y.

Referenced by fcn::ScrollArea::showWidgetPart().

◆ widgetExists()

bool fcn::Widget::widgetExists ( Widget const * widget)
static

Checks if a widget exists or not, that is if it still exists an instance of the object.

Parameters
widgetThe widget to check.
Returns
True if an instance of the widget exists, false otherwise.

Definition at line 827 of file widget.cpp.

References mWidgetInstances, and Widget().

Referenced by _setFocusHandler(), fcn::Gui::distributeKeyEvent(), fcn::Gui::distributeMouseEvent(), and fcn::Gui::handleHiddenWidgets().

Member Data Documentation

◆ mActionEventId

std::string fcn::Widget::mActionEventId
protected

Holds the action event of the widget.

Definition at line 1740 of file widget.hpp.

Referenced by distributeActionEvent(), getActionEventId(), and setActionEventId().

◆ mActionListeners

std::list<ActionListener*> fcn::Widget::mActionListeners
protected

Holds the action listeners of the widget.

Definition at line 1608 of file widget.hpp.

Referenced by addActionListener(), distributeActionEvent(), and removeActionListener().

◆ mBackgroundColor

Color fcn::Widget::mBackgroundColor {0xf9fafb}
protected

Holds the background color of the widget.

Definition at line 1633 of file widget.hpp.

Referenced by getBackgroundColor(), and setBackgroundColor().

◆ mBaseColor

Color fcn::Widget::mBaseColor {0xe5e7eb}
protected

Holds the base color of the widget.

Definition at line 1638 of file widget.hpp.

Referenced by getBaseColor(), and setBaseColor().

◆ mBorderColor

Color fcn::Widget::mBorderColor {0xd1d5db}
protected

Holds the border color of the widget.

Definition at line 1653 of file widget.hpp.

Referenced by getBorderColor(), and setBorderColor().

◆ mBorderSize

unsigned int fcn::Widget::mBorderSize {0}
protected

Holds the border size of the widget.

Definition at line 1690 of file widget.hpp.

Referenced by getBorderSize(), and setBorderSize().

◆ mChildren

◆ mCurrentFont

Font* fcn::Widget::mCurrentFont {nullptr}
protected

Holds the font used by the widget.

Definition at line 1808 of file widget.hpp.

Referenced by getFont(), and setFont().

◆ mDeathListeners

std::list<DeathListener*> fcn::Widget::mDeathListeners
protected

Holds the death listeners of the widget.

Definition at line 1613 of file widget.hpp.

Referenced by addDeathListener(), and removeDeathListener().

◆ mDefaultFont

DefaultFont fcn::Widget::mDefaultFont
staticprotected

Holds the default font used by the widget.

Definition at line 1813 of file widget.hpp.

Referenced by getFont().

◆ mDimension

◆ mEnabled

bool fcn::Widget::mEnabled {true}
protected

True if the widget is enabled, false otherwise.

Definition at line 1765 of file widget.hpp.

Referenced by isEnabled(), and setEnabled().

◆ mFixedSize

Size fcn::Widget::mFixedSize {-1, -1}
protected

Holds the fixed size.

Definition at line 1788 of file widget.hpp.

Referenced by calculateSize(), getFixedSize(), and setFixedSize().

◆ mFixedSizeUsed

bool fcn::Widget::mFixedSizeUsed {false}
protected

True if the widget used a fixed size.

Definition at line 1793 of file widget.hpp.

Referenced by calculateSize(), isFixedSize(), and setFixedSize().

◆ mFocusable

bool fcn::Widget::mFocusable {false}
protected

True if the widget focusable, false otherwise.

Definition at line 1745 of file widget.hpp.

Referenced by isFocusable(), and setFocusable().

◆ mFocusHandler

◆ mFocusListeners

std::list<FocusListener*> fcn::Widget::mFocusListeners
protected

Holds the focus listeners of the widget.

Definition at line 1618 of file widget.hpp.

Referenced by _getFocusListeners(), addFocusListener(), and removeFocusListener().

◆ mForegroundColor

Color fcn::Widget::mForegroundColor {0x1f2933}
protected

Holds the foreground color of the widget.

Definition at line 1628 of file widget.hpp.

Referenced by getForegroundColor(), and setForegroundColor().

◆ mGlobalFont

Font * fcn::Widget::mGlobalFont = nullptr
staticprotected

Holds the global font used by the widget.

Definition at line 1818 of file widget.hpp.

Referenced by getFont(), and setGlobalFont().

◆ mGuiDeathListener

DeathListener * fcn::Widget::mGuiDeathListener = nullptr
staticprotected

Holds the death listener used by the widgets.

Definition at line 1837 of file widget.hpp.

Referenced by _getGuiDeathListener(), and _setGuiDeathListener().

◆ mHExpand

bool fcn::Widget::mHExpand {false}
protected

True if the widget can be horizontal expanded.

Definition at line 1803 of file widget.hpp.

Referenced by isHorizontalExpand(), and setHorizontalExpand().

◆ mId

std::string fcn::Widget::mId
protected

Holds the id of the widget.

Definition at line 1770 of file widget.hpp.

Referenced by getId(), and setId().

◆ mInternalFocusHandler

FocusHandler* fcn::Widget::mInternalFocusHandler {nullptr}
protected

Holds the focus handler used by the widget.

Nullptr if no internal focus handler is used.

Definition at line 1664 of file widget.hpp.

Referenced by _getInternalFocusHandler(), _setFocusHandler(), add(), and setInternalFocusHandler().

◆ mKeyListeners

std::list<KeyListener*> fcn::Widget::mKeyListeners
protected

Holds the key listeners of the widget.

Definition at line 1603 of file widget.hpp.

Referenced by _getKeyListeners(), addKeyListener(), and removeKeyListener().

◆ mLastX

int fcn::Widget::mLastX {0}
protected

Last stored X coordinate used for layout and event calculations.

Definition at line 1845 of file widget.hpp.

Referenced by getAbsolutePosition(), getLastPosition(), isLastPositionSet(), and setLastPosition().

◆ mLastY

int fcn::Widget::mLastY {0}
protected

Last stored Y coordinate used for layout and event calculations.

Definition at line 1848 of file widget.hpp.

Referenced by getAbsolutePosition(), getLastPosition(), isLastPositionSet(), and setLastPosition().

◆ mMarginBottom

int fcn::Widget::mMarginBottom {0}
protected

Holds the bottom margin of the widget.

Definition at line 1710 of file widget.hpp.

Referenced by getMarginBottom(), setMargin(), and setMarginBottom().

◆ mMarginLeft

int fcn::Widget::mMarginLeft {0}
protected

Holds the left margin of the widget.

Definition at line 1715 of file widget.hpp.

Referenced by getMarginLeft(), setMargin(), and setMarginLeft().

◆ mMarginRight

int fcn::Widget::mMarginRight {0}
protected

Holds the top right of the widget.

Definition at line 1705 of file widget.hpp.

Referenced by getMarginRight(), setMargin(), and setMarginRight().

◆ mMarginTop

int fcn::Widget::mMarginTop {0}
protected

Holds the top margin of the widget.

Definition at line 1700 of file widget.hpp.

Referenced by getMarginTop(), setMargin(), and setMarginTop().

◆ mMaxSize

Size fcn::Widget::mMaxSize {std::numeric_limits<int>::max(), std::numeric_limits<int>::max()}
protected

Holds the max size.

Default to a very large value so widgets are not clamped to zero when the user does not explicitly set a max size.

Definition at line 1783 of file widget.hpp.

Referenced by calculateSize(), getMaxSize(), and setMaxSize().

◆ mMinSize

Size fcn::Widget::mMinSize {0, 0}
protected

Holds the min size.

Definition at line 1775 of file widget.hpp.

Referenced by calculateSize(), getMinSize(), and setMinSize().

◆ mMouseListeners

std::list<MouseListener*> fcn::Widget::mMouseListeners
protected

Holds the mouse listeners of the widget.

Definition at line 1598 of file widget.hpp.

Referenced by _getMouseListeners(), addMouseListener(), and removeMouseListener().

◆ mOffsetRect

Rectangle fcn::Widget::mOffsetRect
protected

Holds the offset dimension of the widget.

Definition at line 1680 of file widget.hpp.

◆ mOutlineColor

Color fcn::Widget::mOutlineColor {0x9ca3af}
protected

Holds the outline color of the widget.

Definition at line 1648 of file widget.hpp.

Referenced by getOutlineColor(), and setOutlineColor().

◆ mOutlineSize

unsigned int fcn::Widget::mOutlineSize {0}
protected

Holds the outline size of the widget.

Definition at line 1685 of file widget.hpp.

Referenced by _draw(), getOutlineSize(), and setOutlineSize().

◆ mPaddingBottom

unsigned int fcn::Widget::mPaddingBottom {0}
protected

Holds the bottom padding of the widget.

Definition at line 1730 of file widget.hpp.

Referenced by fcn::AdjustingContainer::adjustSize(), getPaddingBottom(), setPadding(), and setPaddingBottom().

◆ mPaddingLeft

unsigned int fcn::Widget::mPaddingLeft {0}
protected

Holds the left padding of the widget.

Definition at line 1735 of file widget.hpp.

Referenced by fcn::AdjustingContainer::adjustContent(), fcn::AdjustingContainer::adjustSize(), getPaddingLeft(), setPadding(), and setPaddingLeft().

◆ mPaddingRight

unsigned int fcn::Widget::mPaddingRight {0}
protected

Holds the right padding of the widget.

Definition at line 1725 of file widget.hpp.

Referenced by fcn::AdjustingContainer::adjustSize(), getPaddingRight(), setPadding(), and setPaddingRight().

◆ mPaddingTop

unsigned int fcn::Widget::mPaddingTop {0}
protected

Holds the top padding of the widget.

Definition at line 1720 of file widget.hpp.

Referenced by fcn::AdjustingContainer::adjustContent(), fcn::AdjustingContainer::adjustSize(), getPaddingTop(), setPadding(), and setPaddingTop().

◆ mParent

Widget* fcn::Widget::mParent {nullptr}
protected

Holds the parent of the widget.

Nullptr if the widget has no parent.

Definition at line 1670 of file widget.hpp.

Referenced by _setParent(), getParent(), requestMoveToBottom(), requestMoveToTop(), and showPart().

◆ mSelectionColor

Color fcn::Widget::mSelectionColor {0x3b82f6}
protected

Holds the selection color of the widget.

Definition at line 1643 of file widget.hpp.

Referenced by getSelectionColor(), and setSelectionColor().

◆ mSelectionMode

SelectionMode fcn::Widget::mSelectionMode {SelectionMode::None}
protected

Holds the selection mode.

Definition at line 1695 of file widget.hpp.

Referenced by getSelectionMode(), and setSelectionMode().

◆ mTabIn

bool fcn::Widget::mTabIn {true}
protected

True if the widget has tab in enabled, false otherwise.

Definition at line 1755 of file widget.hpp.

Referenced by isTabInEnabled(), and setTabInEnabled().

◆ mTabOut

bool fcn::Widget::mTabOut {true}
protected

True if the widget has tab in enabled, false otherwise.

Definition at line 1760 of file widget.hpp.

Referenced by isTabOutEnabled(), and setTabOutEnabled().

◆ mVExpand

bool fcn::Widget::mVExpand {false}
protected

True if the widget can be vertical expanded.

Definition at line 1798 of file widget.hpp.

Referenced by isVerticalExpand(), and setVerticalExpand().

◆ mVisibilityEventHandler

VisibilityEventHandler * fcn::Widget::mVisibilityEventHandler = nullptr
staticprotected

Holds the visibility event handler used by the widgets.

TODO: FIXME We don't like the visibility handler being static but we leave it as is for the moment, until we come up a better solution.

Definition at line 1832 of file widget.hpp.

Referenced by _getVisibilityEventHandler(), and _setVisibilityEventHandler().

◆ mVisible

bool fcn::Widget::mVisible {true}
protected

True if the widget visible, false otherwise.

Definition at line 1750 of file widget.hpp.

Referenced by isSetVisible(), isVisible(), and setVisible().

◆ mWidgetInstances

std::list< Widget * > fcn::Widget::mWidgetInstances
staticprotected

Holds a list of all instances of widgets.

Definition at line 1823 of file widget.hpp.

Referenced by setGlobalFont(), Widget(), and widgetExists().

◆ mWidgetListeners


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