FifeGUI 0.2.0
A C++ GUI library designed for games.
label.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_WIDGETS_LABEL_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_LABEL_HPP_
7
8#include <string>
9
10#include "fifechan/graphics.hpp"
11#include "fifechan/platform.hpp"
12#include "fifechan/widget.hpp"
13
14namespace fcn
15{
21 class FIFEGUI_API Label : public Widget
22 {
23 public:
24 Label();
25
32 explicit Label(std::string caption);
33
40 std::string const & getCaption() const;
41
50 void setCaption(std::string const & caption);
51
59 void setAlignment(Graphics::Alignment alignment);
60
69
70 // Inherited from Widget
71
73
74 void resizeToContent(bool recursion) override;
75 void adjustSize() override;
76 void draw(Graphics* graphics) override;
77
78 protected:
88 void adjustSizeImpl();
89
93 std::string mCaption;
94
99 };
100} // namespace fcn
101
102#endif // INCLUDE_FIFECHAN_WIDGETS_LABEL_HPP_
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:57
Alignment
Alignments for text drawing.
Definition graphics.hpp:63
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
Definition label.cpp:47
void draw(Graphics *graphics) override
Draws the widget.
Definition label.cpp:66
void setAlignment(Graphics::Alignment alignment)
Sets the alignment of the caption.
Definition label.cpp:37
void adjustSize() override
Resizes the widget's size to fit the content exactly.
Definition label.cpp:54
std::string const & getCaption() const
Gets the caption of the label.
Definition label.cpp:26
Graphics::Alignment getAlignment() const
Gets the alignment of the caption.
Definition label.cpp:42
void setCaption(std::string const &caption)
Sets the caption of the label.
Definition label.cpp:31
Graphics::Alignment mAlignment
Holds the alignment of the caption.
Definition label.hpp:98
std::string mCaption
Holds the caption of the label.
Definition label.hpp:93
void adjustSizeImpl()
Adjusts the size of the label to fit the caption.
Definition label.cpp:59
Widget()
Constructor.
Definition widget.cpp:36
void resizeToContent()
Resizes the widget's size to fit the content exactly, calls recursively all childs.
Definition widget.hpp:1417