FifeGUI 0.3.0
A C++ GUI library designed for games.
widget.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_WIDGET_HPP_
6#define INCLUDE_FIFECHAN_WIDGET_HPP_
7
8// Standard library includes
9#include <limits>
10#include <list>
11#include <string>
12#include <type_traits>
13
14// Platform config include
15#include "fifechan/platform.hpp"
16
17// Project headers (subdirs before local)
18#include "fifechan/color.hpp"
19#include "fifechan/events/dragevent.hpp"
20#include "fifechan/listeners/widgetlistener.hpp"
21#include "fifechan/rectangle.hpp"
22#include "fifechan/size.hpp"
23
24namespace fcn
25{
26 class ActionListener;
27 class DeathListener;
28 class DefaultFont;
29 class FocusHandler;
30 class FocusListener;
31 class Font;
32 class Graphics;
33 class KeyInput;
34 class KeyListener;
35 class MouseEvent;
36 class TextInputEvent;
37 class MouseInput;
38 class MouseListener;
40 class WidgetListener;
42
55 class FIFEGUI_API Widget
56 {
57 public:
61 enum BorderSide : uint8_t
62 {
63 BORDER_NONE = 0,
64 BORDER_LEFT = 1 << 0,
65 BORDER_TOP = 1 << 1,
66 BORDER_RIGHT = 1 << 2,
67 BORDER_BOTTOM = 1 << 3,
68 BORDER_ALL = BORDER_LEFT | BORDER_TOP | BORDER_RIGHT | BORDER_BOTTOM
69 };
70
74 enum BorderStyle : uint8_t
75 {
76 BORDER_STYLE_BEVEL = 0,
77 BORDER_STYLE_FLAT = 1
78 };
79
82 enum class SelectionMode : uint8_t
83 {
84 None = 0,
85 Border = 1,
86 Background = 2
87 };
88
96 Widget();
97
98 virtual ~Widget();
99
100 Widget(Widget const &) = delete;
101 Widget& operator=(Widget const &) = delete;
102 Widget(Widget&&) = delete;
103 Widget& operator=(Widget&&) = delete;
104
105 friend class DragHandler;
106
125 virtual void draw(Graphics* graphics) = 0;
126
146 virtual void drawOutline(Graphics* graphics);
147
154 virtual void drawBorder(Graphics* graphics);
155
160 void drawBorder(Graphics* graphics, unsigned int sides) const;
161
169 virtual void drawSelectionFrame(Graphics* graphics);
170
186 void setOutlineSize(unsigned int size);
187
203 unsigned int getOutlineSize() const;
216 void setBorderSize(unsigned int size);
217
229 unsigned int getBorderSize() const;
230
235 void setBorderSides(unsigned int sides);
236
240 unsigned int getBorderSides() const;
241
245 void setBorderStyle(unsigned int style);
246
250 unsigned int getBorderStyle() const;
251
256 void setBorderTop(unsigned int size, unsigned int style);
257
262 void setBorderBottom(unsigned int size, unsigned int style);
263
274 void setMargin(int margin);
275
286 void setMarginTop(int margin);
287
298 int getMarginTop() const;
299
310 void setMarginRight(int margin);
311
322 int getMarginRight() const;
323
334 void setMarginBottom(int margin);
335
346 int getMarginBottom() const;
347
358 void setMarginLeft(int margin);
359
369 int getMarginLeft() const;
370
379 void setPadding(unsigned int padding);
380
389 void setPaddingTop(unsigned int padding);
390
399 unsigned int getPaddingTop() const;
400
409 void setPaddingRight(unsigned int padding);
410
419 unsigned int getPaddingRight() const;
420
429 void setPaddingBottom(unsigned int padding);
430
439 unsigned int getPaddingBottom() const;
440
449 void setPaddingLeft(unsigned int padding);
450
459 unsigned int getPaddingLeft() const;
460
467 virtual void logic()
468 {
469 }
470
479 virtual void textInput(TextInputEvent& event)
480 {
481 }
482
489 virtual Widget* getParent() const;
490
497 virtual Widget* getTop() const;
498
506 virtual void setWidth(int width);
507
515 int getWidth() const;
516
524 virtual void setHeight(int height);
525
533 int getHeight() const;
534
542 bool contains(int x, int y) const;
543
550 bool isMouseInside(MouseEvent const & mouseEvent) const;
551
560 virtual void setSize(int width, int height);
561
569 void setX(int x);
570
578 int getX() const;
579
587 void setY(int y);
588
596 int getY() const;
597
606 void setPosition(int x, int y);
607
615 virtual void setDimension(Rectangle const & dimension);
616
624 Rectangle const & getDimension() const;
625
631 unsigned int getChildrenCount() const;
632
638 unsigned int getVisibleChildrenCount() const;
639
646 void setMinSize(Size const & size);
647
654 Size const & getMinSize() const;
655
662 void setMaxSize(Size const & size);
663
670 Size const & getMaxSize() const;
671
679 void setFixedSize(Size const & size);
680
687 Size const & getFixedSize() const;
688
695 bool isFixedSize() const;
696
704 void setFocusable(bool focusable);
705
712 bool isFocusable() const;
713
719 virtual bool isFocused() const;
720
731 virtual void setFocused(bool focused);
732
741 void setEnabled(bool enabled);
742
750 bool isEnabled() const;
751
758 void setVisible(bool visible);
759
766 bool isVisible() const;
767
773 bool isSetVisible() const;
774
781 virtual void setBaseColor(Color const & color);
782
789 Color const & getBaseColor() const;
790
797 virtual void setForegroundColor(Color const & color);
798
804 Color const & getForegroundColor() const;
805
812 virtual void setBackgroundColor(Color const & color);
813
819 Color const & getBackgroundColor() const;
820
827 virtual void setSelectionColor(Color const & color);
828
835 Color const & getSelectionColor() const;
836
843 virtual void setOutlineColor(Color const & color);
844
851 Color const & getOutlineColor() const;
852
859 virtual void setBorderColor(Color const & color);
860
867 Color const & getBorderColor() const;
868
875 virtual void setSelectionMode(SelectionMode mode);
876
883 SelectionMode getSelectionMode() const;
884
890 virtual void requestFocus();
891
896 virtual void requestMoveToTop();
897
902 virtual void requestMoveToBottom();
903
913 virtual void _draw(Graphics* graphics);
914
923 virtual void _logic();
924
935 virtual void _setFocusHandler(FocusHandler* focusHandler);
936
947 virtual FocusHandler* _getFocusHandler();
948
957 void addActionListener(ActionListener* actionListener);
958
965 void removeActionListener(ActionListener* actionListener);
966
975 void addDeathListener(DeathListener* deathListener);
976
983 void removeDeathListener(DeathListener* deathListener);
984
993 void addMouseListener(MouseListener* mouseListener);
994
1001 void removeMouseListener(MouseListener* mouseListener);
1002
1011 void addKeyListener(KeyListener* keyListener);
1012
1019 void removeKeyListener(KeyListener* keyListener);
1020
1029 void addFocusListener(FocusListener* focusListener);
1030
1037 void removeFocusListener(FocusListener* focusListener);
1038
1047 void addWidgetListener(WidgetListener* widgetListener);
1048
1055 void removeWidgetListener(WidgetListener* widgetListener);
1056
1064 void addDropTargetListener(DropTargetListener* listener);
1065
1072 void removeDropTargetListener(DropTargetListener* listener);
1073
1086 void setActionEventId(std::string const & actionEventId);
1087
1094 std::string const & getActionEventId() const;
1095
1102 virtual void getAbsolutePosition(int& x, int& y) const;
1103
1114 virtual void _setParent(Widget* parent);
1115
1124 Font* getFont() const;
1125
1135 static void setGlobalFont(Font* font);
1136
1143 static void resetGlobalFont();
1144
1152 virtual void setFont(Font* font);
1153
1160 virtual void fontChanged()
1161 {
1162 }
1163
1169 virtual void onFocusGained()
1170 {
1171 }
1172
1178 virtual void onFocusLost()
1179 {
1180 }
1181
1187 virtual void onFocusChanged()
1188 {
1189 }
1190
1198 static bool widgetExists(Widget const * widget);
1199
1209 bool isTabInEnabled() const;
1210
1220 void setTabInEnabled(bool enabled);
1221
1231 bool isTabOutEnabled() const;
1232
1244 void setTabOutEnabled(bool enabled);
1245
1251 virtual bool isModalFocusable() const;
1252
1258 virtual bool isModalMouseInputFocusable() const;
1259
1265 virtual bool isModalFocused() const;
1266
1272 virtual bool isUnderMouseModal() const;
1273
1287 Widget* getWidgetAt(int x, int y)
1288 {
1289 return getWidgetAt(x, y, nullptr);
1290 }
1291
1301 virtual Widget* getWidgetAt(int x, int y, Widget* exclude);
1302
1312 std::list<Widget*> getWidgetsIn(Rectangle const & area)
1313 {
1314 return getWidgetsIn(area, nullptr);
1315 }
1316
1327 virtual std::list<Widget*> getWidgetsIn(Rectangle const & area, Widget* ignore);
1328
1334 virtual std::list<MouseListener*> const & _getMouseListeners();
1335
1341 virtual std::list<KeyListener*> const & _getKeyListeners();
1342
1348 virtual std::list<FocusListener*> const & _getFocusListeners();
1349
1371 virtual Rectangle getChildrenArea();
1372
1380 virtual FocusHandler* _getInternalFocusHandler();
1381
1392 void setInternalFocusHandler(FocusHandler* internalFocusHandler);
1393
1404 virtual void moveToTop(Widget* widget);
1405
1416 virtual void moveToBottom(Widget* widget);
1417
1423 virtual void focusNext();
1424
1430 virtual void focusPrevious();
1431
1440 virtual void showWidgetPart(Widget* widget, Rectangle area);
1441
1452 void setId(std::string const & id);
1453
1464 std::string const & getId() const;
1465
1476 virtual void showPart(Rectangle rectangle);
1477
1491 static void _setVisibilityEventHandler(VisibilityEventHandler* visibilityEventHandler);
1492
1504 static VisibilityEventHandler* _getVisibilityEventHandler();
1505
1511 static void _setGuiDeathListener(DeathListener* deathListener);
1512
1518 static DeathListener* _getGuiDeathListener();
1519
1526 void setVerticalExpand(bool expand);
1527
1534 bool isVerticalExpand() const;
1535
1542 void setHorizontalExpand(bool expand);
1543
1550 bool isHorizontalExpand() const;
1551
1561 {
1562 adaptLayout(true);
1563 }
1564
1570 virtual void adaptLayout(bool top);
1571
1580 virtual void resizeToContent(bool recursion = true)
1581 {
1582 }
1583
1587 virtual void adjustSize()
1588 {
1589 }
1590
1598 {
1599 expandContent(true);
1600 }
1601
1607 virtual void expandContent(bool recursion)
1608 {
1609 }
1610
1614 virtual bool isLayouted()
1615 {
1616 return false;
1617 }
1618
1625 void getLastPosition(int& x, int& y) const;
1626
1633 void setLastPosition(int x, int y);
1634
1640 bool isLastPositionSet() const;
1641
1649 bool captureMouse();
1650
1658 void releaseMouse();
1659
1666 static Widget* getMouseCapture();
1667
1674 bool hasMouseCapture() const;
1675
1686 bool isDescendantOf(Widget const * ancestor) const noexcept;
1687
1696 bool isInsideActiveMouseModal() const noexcept;
1697
1698 protected:
1702 void distributeActionEvent();
1703
1707 void distributeResizedEvent();
1708
1712 void distributeMovedEvent();
1713
1717 void distributeHiddenEvent();
1718
1722 void distributeShownEvent();
1723
1730 void distributeAncestorMovedEvent(Widget* ancestor);
1731
1738 void distributeAncestorHiddenEvent(Widget* ancestor);
1739
1746 void distributeAncestorShownEvent(Widget* ancestor);
1747
1757 void add(Widget* widget);
1758
1768 virtual void remove(Widget* widget);
1769
1778 virtual void removeAllChildren();
1779
1789 virtual Widget* findWidgetById(std::string const & id);
1790
1795 void resizeToChildren();
1796
1802 void calculateSize();
1803
1809 std::list<Widget*> const & getChildren() const;
1810
1812 bool distributeDragEnter(DragEvent& event);
1813
1815 void distributeDragLeave(DragEvent& event);
1816
1818 void distributeDragHover(DragEvent& event);
1819
1821 void distributeDragDrop(DragEvent& event);
1822
1827
1832
1837
1842
1847
1852
1857
1862
1867
1872
1877
1882
1887
1892
1898
1903 Widget* mParent{nullptr};
1904
1909
1914
1918 unsigned int mOutlineSize{0};
1919
1923 unsigned int mBorderSize{0};
1924
1930 unsigned int mBorderSides{BORDER_ALL};
1931
1937 unsigned int mBorderStyle{BORDER_STYLE_FLAT};
1938
1942 SelectionMode mSelectionMode{SelectionMode::None};
1943
1948
1953
1958
1963
1967 unsigned int mPaddingTop{0};
1968
1972 unsigned int mPaddingRight{0};
1973
1977 unsigned int mPaddingBottom{0};
1978
1982 unsigned int mPaddingLeft{0};
1983
1987 std::string mActionEventId;
1988
1992 bool mFocusable{false};
1993
1997 bool mFocused{false};
1998
2002 bool mVisible{true};
2003
2007 bool mTabIn{true};
2008
2012 bool mTabOut{true};
2013
2017 bool mEnabled{true};
2018
2022 std::string mId;
2023
2028
2035 Size mMaxSize{std::numeric_limits<int>::max(), std::numeric_limits<int>::max()};
2036
2041
2045 bool mFixedSizeUsed{false};
2046
2050 bool mVExpand{false};
2051
2055 bool mHExpand{false};
2056
2061
2066
2071
2075 static std::list<Widget*> mWidgetInstances;
2076
2085
2090
2095
2099 std::list<Widget*> mChildren;
2100
2102 int mLastX{0};
2103
2105 int mLastY{0};
2106 };
2107} // namespace fcn
2108
2109// Bitwise operators for Widget::SelectionMode (enum class)
2110namespace fcn
2111{
2118 {
2119 using T = std::underlying_type_t<Widget::SelectionMode>;
2120 return static_cast<Widget::SelectionMode>(static_cast<T>(a) | static_cast<T>(b));
2121 }
2122
2127 {
2128 using T = std::underlying_type_t<Widget::SelectionMode>;
2129 return static_cast<Widget::SelectionMode>(static_cast<T>(a) & static_cast<T>(b));
2130 }
2131
2136 {
2137 a = a | b;
2138 return a;
2139 }
2140
2145 {
2146 a = a & b;
2147 return a;
2148 }
2149
2150} // namespace fcn
2151
2152#endif // INCLUDE_FIFECHAN_WIDGET_HPP_
Interface for listening to action events from widgets.
Color.
Definition color.hpp:58
Interface for listening to widget destruction events.
A basic font implementation capable only of drawing rectangles (placeholder).
Drag and drop event type container.
Definition dragevent.hpp:23
Manages drag and drop operations for a Gui instance.
Definition dragdrop.hpp:217
Listener interface for widgets that accept dragged payloads.
Manages focus navigation and assignment among widgets within a Gui instance.
Interface for listening to focus gain/loss events.
Abstract interface for font rendering.
Definition font.hpp:26
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:58
Internal class representing raw keyboard input data.
Definition keyinput.hpp:32
Interface for listening to keyboard events.
Represents a mouse event.
Internal class representing raw mouse input data.
Interface for listening to mouse events.
Represents a rectangular area (X, Y, Width, Height).
Definition rectangle.hpp:22
Represents dimensions defined by width and height.
Definition size.hpp:21
Text input event for IME (input method editor) composition, dead keys, and pasted text.
Handles changes in widget visibility states.
Interface for receiving generic events from widgets.
Abstract base class defining the common behavior, properties, and lifecycle of all GUI elements.
Definition widget.hpp:56
std::list< FocusListener * > mFocusListeners
Holds the focus listeners of the widget.
Definition widget.hpp:1846
bool mHExpand
True if the widget can be horizontal expanded.
Definition widget.hpp:2055
unsigned int mBorderSides
Which sides to draw the border on (bitmask of BorderSide).
Definition widget.hpp:1930
void setMargin(int margin)
Sets all 4 margins to one value.
Definition widget.cpp:513
Widget * mParent
Holds the parent of the widget.
Definition widget.hpp:1903
bool mFocused
True if the widget has focus, false otherwise.
Definition widget.hpp:1997
std::list< DeathListener * > mDeathListeners
Holds the death listeners of the widget.
Definition widget.hpp:1841
virtual void onFocusGained()
Called when the widget gains focus.
Definition widget.hpp:1169
virtual void fontChanged()
Called when the font has changed.
Definition widget.hpp:1160
static DefaultFont mDefaultFont
Holds the default font used by the widget.
Definition widget.hpp:2065
virtual void onFocusLost()
Called when the widget loses focus.
Definition widget.hpp:1178
FocusHandler * mFocusHandler
Holds the focus handler used by the widget.
Definition widget.hpp:1891
virtual void adjustSize()
Resizes the widget's size to fit the content exactly.
Definition widget.hpp:1587
Size mMinSize
Holds the min size.
Definition widget.hpp:2027
int mMarginTop
Holds the top margin of the widget.
Definition widget.hpp:1947
virtual void drawOutline(Graphics *graphics)
Called when a widget is given a chance to draw a outline around itself.
Definition widget.cpp:133
virtual bool isLayouted()
Helper function to decide if we need to layout.
Definition widget.hpp:1614
void setBorderSize(unsigned int size)
Sets the size of the widget's border.
Definition widget.cpp:469
int mLastY
Last stored Y coordinate used for layout and event calculations.
Definition widget.hpp:2105
std::list< KeyListener * > mKeyListeners
Holds the key listeners of the widget.
Definition widget.hpp:1831
std::list< ActionListener * > mActionListeners
Holds the action listeners of the widget.
Definition widget.hpp:1836
void setOutlineSize(unsigned int size)
Sets the size of the widget's outline.
Definition widget.cpp:459
SelectionMode
Selection mode.
Definition widget.hpp:83
void setBorderSides(unsigned int sides)
Select which sides the border should be drawn on.
Definition widget.cpp:479
void setMarginTop(int margin)
Sets the top margin.
Definition widget.cpp:521
unsigned int getOutlineSize() const
Gets the size of the widget's outline.
Definition widget.cpp:464
static std::list< Widget * > mWidgetInstances
Holds a list of all instances of widgets.
Definition widget.hpp:2075
virtual void logic()
Called for all widgets in the GUI each time Gui::logic is called.
Definition widget.hpp:467
unsigned int mPaddingTop
Holds the top padding of the widget.
Definition widget.hpp:1967
Rectangle mDimension
Holds the dimension of the widget.
Definition widget.hpp:1908
void setMarginRight(int margin)
Sets the right margin.
Definition widget.cpp:531
bool mTabOut
True if the widget has tab in enabled, false otherwise.
Definition widget.hpp:2012
unsigned int getPaddingLeft() const
Gets the left padding.
Definition widget.cpp:604
Color mForegroundColor
Holds the foreground color of the widget.
Definition widget.hpp:1861
std::string mActionEventId
Holds the action event of the widget.
Definition widget.hpp:1987
int getMarginBottom() const
Gets the bottom margin.
Definition widget.cpp:546
Widget()
Constructor.
Definition widget.cpp:52
void expandContent()
Expands the child widgets to the size of this widget, calls recursively all childs.
Definition widget.hpp:1597
void setPaddingTop(unsigned int padding)
Sets the top padding.
Definition widget.cpp:569
Color mOutlineColor
Holds the outline color of the widget.
Definition widget.hpp:1881
Color mBorderColor
Holds the border color of the widget.
Definition widget.hpp:1886
void setBorderStyle(unsigned int style)
Set border drawing style (bevel or flat).
Definition widget.cpp:489
void setPaddingRight(unsigned int padding)
Sets the right padding.
Definition widget.cpp:579
std::list< WidgetListener * > mWidgetListeners
Holds the widget listeners of the widget.
Definition widget.hpp:1851
virtual void textInput(TextInputEvent &event)
Called when text input (IME, dead-key, paste) is received.
Definition widget.hpp:479
Size mFixedSize
Holds the fixed size.
Definition widget.hpp:2040
FocusHandler * mInternalFocusHandler
Holds the focus handler used by the widget.
Definition widget.hpp:1897
Widget * getWidgetAt(int x, int y)
Gets a widget at a certain position in the widget.
Definition widget.hpp:1287
unsigned int getBorderStyle() const
Get the current border drawing style.
Definition widget.cpp:494
virtual void expandContent(bool recursion)
Expands child widgets to fit this widget's size.
Definition widget.hpp:1607
SelectionMode mSelectionMode
Holds the selection mode.
Definition widget.hpp:1942
int getMarginLeft() const
Gets the left margin.
Definition widget.cpp:556
std::list< MouseListener * > mMouseListeners
Holds the mouse listeners of the widget.
Definition widget.hpp:1826
void adaptLayout()
Execute the layouting.
Definition widget.hpp:1560
unsigned int mBorderSize
Holds the border size of the widget.
Definition widget.hpp:1923
unsigned int mPaddingRight
Holds the right padding of the widget.
Definition widget.hpp:1972
int getMarginRight() const
Gets the right margin.
Definition widget.cpp:536
static Widget * sMouseCapture
Holds the widget that currently has mouse capture.
Definition widget.hpp:2094
unsigned int mBorderStyle
Border drawing style (see BorderStyle).
Definition widget.hpp:1937
virtual void onFocusChanged()
Called when the widget focus changes.
Definition widget.hpp:1187
void setBorderTop(unsigned int size, unsigned int style)
Convenience helper: set a top-only border with size and style.
Definition widget.cpp:499
void setPaddingLeft(unsigned int padding)
Sets the left padding.
Definition widget.cpp:599
BorderSide
Border side flags for flexible border drawing.
Definition widget.hpp:62
unsigned int mPaddingBottom
Holds the bottom padding of the widget.
Definition widget.hpp:1977
int mLastX
Last stored X coordinate used for layout and event calculations.
Definition widget.hpp:2102
int mMarginRight
Holds the top right of the widget.
Definition widget.hpp:1952
std::list< DropTargetListener * > mDropTargetListeners
Holds the drop target listeners of the widget.
Definition widget.hpp:1856
virtual void drawBorder(Graphics *graphics)
Called when a widget have a border.
Definition widget.cpp:156
static DeathListener * mGuiDeathListener
Holds the death listener used by the widgets.
Definition widget.hpp:2089
static Font * mGlobalFont
Holds the global font used by the widget.
Definition widget.hpp:2070
unsigned int getPaddingTop() const
Gets the top padding.
Definition widget.cpp:574
unsigned int getBorderSize() const
Gets the size of the widget's border.
Definition widget.cpp:474
virtual void drawSelectionFrame(Graphics *graphics)
Called when a widget is "active" and the selection mode is Frame or FrameWithBackground.
Definition widget.cpp:217
std::list< Widget * > mChildren
Holds all children of the widget.
Definition widget.hpp:2099
std::list< Widget * > getWidgetsIn(Rectangle const &area)
Gets all widgets inside a certain area of the widget.
Definition widget.hpp:1312
bool mEnabled
True if the widget is enabled, false otherwise.
Definition widget.hpp:2017
unsigned int mOutlineSize
Holds the outline size of the widget.
Definition widget.hpp:1918
Color mBaseColor
Holds the base color of the widget.
Definition widget.hpp:1871
bool mVisible
True if the widget visible, false otherwise.
Definition widget.hpp:2002
Rectangle mOffsetRect
Holds the offset dimension of the widget.
Definition widget.hpp:1913
int getMarginTop() const
Gets the top margin.
Definition widget.cpp:526
BorderStyle
Border drawing style.
Definition widget.hpp:75
unsigned int getPaddingBottom() const
Gets the bottom padding.
Definition widget.cpp:594
Color mSelectionColor
Holds the selection color of the widget.
Definition widget.hpp:1876
bool mVExpand
True if the widget can be vertical expanded.
Definition widget.hpp:2050
unsigned int mPaddingLeft
Holds the left padding of the widget.
Definition widget.hpp:1982
void setBorderBottom(unsigned int size, unsigned int style)
Convenience helper: set a bottom-only border with size and style.
Definition widget.cpp:506
Font * mCurrentFont
Holds the font used by the widget.
Definition widget.hpp:2060
bool mFocusable
True if the widget focusable, false otherwise.
Definition widget.hpp:1992
Color mBackgroundColor
Holds the background color of the widget.
Definition widget.hpp:1866
int mMarginLeft
Holds the left margin of the widget.
Definition widget.hpp:1962
int mMarginBottom
Holds the bottom margin of the widget.
Definition widget.hpp:1957
virtual void draw(Graphics *graphics)=0
Draws the widget.
virtual void resizeToContent(bool recursion=true)
Resizes the widget's size to fit the content exactly, calls recursively all childs.
Definition widget.hpp:1580
bool mFixedSizeUsed
True if the widget used a fixed size.
Definition widget.hpp:2045
void setMarginLeft(int margin)
Sets the left margin.
Definition widget.cpp:551
void setPaddingBottom(unsigned int padding)
Sets the bottom padding.
Definition widget.cpp:589
bool mTabIn
True if the widget has tab in enabled, false otherwise.
Definition widget.hpp:2007
std::string mId
Holds the id of the widget.
Definition widget.hpp:2022
void setMarginBottom(int margin)
Sets the bottom margin.
Definition widget.cpp:541
unsigned int getPaddingRight() const
Gets the right padding.
Definition widget.cpp:584
void setPadding(unsigned int padding)
Sets all 4 paddings to one value.
Definition widget.cpp:561
Size mMaxSize
Holds the max size.
Definition widget.hpp:2035
static VisibilityEventHandler * mVisibilityEventHandler
Holds the visibility event handler used by the widgets.
Definition widget.hpp:2084
unsigned int getBorderSides() const
Get the currently selected border sides.
Definition widget.cpp:484
Used replacement tokens by configure_file():
constexpr Widget::SelectionMode operator|(Widget::SelectionMode a, Widget::SelectionMode b) noexcept
Bitwise OR operator for Widget::SelectionMode.
Definition widget.hpp:2117
constexpr Widget::SelectionMode & operator|=(Widget::SelectionMode &a, Widget::SelectionMode b) noexcept
Bitwise and for selection modes.
Definition widget.hpp:2135
constexpr Widget::SelectionMode & operator&=(Widget::SelectionMode &a, Widget::SelectionMode b) noexcept
Bitwise or assign for selection modes.
Definition widget.hpp:2144
constexpr Widget::SelectionMode operator&(Widget::SelectionMode a, Widget::SelectionMode b) noexcept
Bitwise or for selection modes.
Definition widget.hpp:2126