2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_MARGIN_H
|
|
|
|
#define TAG_PARSER_MARGIN_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2016-08-29 15:43:05 +02:00
|
|
|
#include "./global.h"
|
|
|
|
|
2017-01-27 21:27:24 +01:00
|
|
|
#include <c++utilities/conversion/stringbuilder.h>
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
#include <cstdint>
|
2015-04-22 19:22:01 +02:00
|
|
|
#include <string>
|
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The Margin class defines the four margins of a rectangle.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT Margin {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
2020-12-05 20:48:57 +01:00
|
|
|
constexpr explicit Margin(std::uint32_t top = 0, std::uint32_t left = 0, std::uint32_t bottom = 0, std::uint32_t right = 0);
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t top() const;
|
|
|
|
void setTop(std::uint32_t top);
|
|
|
|
constexpr std::uint32_t left() const;
|
|
|
|
void setLeft(std::uint32_t left);
|
|
|
|
constexpr std::uint32_t bottom() const;
|
|
|
|
void setBottom(std::uint32_t bottom);
|
|
|
|
constexpr std::uint32_t right() const;
|
|
|
|
void setRight(std::uint32_t right);
|
2015-04-22 19:22:01 +02:00
|
|
|
constexpr bool isNull() const;
|
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
private:
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint32_t m_top;
|
|
|
|
std::uint32_t m_left;
|
|
|
|
std::uint32_t m_bottom;
|
|
|
|
std::uint32_t m_right;
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs a Margin.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr Margin::Margin(std::uint32_t top, std::uint32_t left, std::uint32_t bottom, std::uint32_t right)
|
2018-03-07 01:17:50 +01:00
|
|
|
: m_top(top)
|
|
|
|
, m_left(left)
|
|
|
|
, m_bottom(bottom)
|
|
|
|
, m_right(right)
|
|
|
|
{
|
|
|
|
}
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the top margin.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Margin::top() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the top margin to \a top.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Margin::setTop(std::uint32_t top)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_top = top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the left margin.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Margin::left() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_left;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the left margin to \a left.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Margin::setLeft(std::uint32_t left)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_left = left;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the bottom margin.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Margin::bottom() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the bottom margin to \a bottom.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Margin::setBottom(std::uint32_t bottom)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_bottom = bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the right margin.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Margin::right() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_right;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the right margin to \a right.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Margin::setRight(std::uint32_t right)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_right = right;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns true if all margins are is 0; otherwise returns false;
|
|
|
|
*/
|
2017-08-17 18:15:03 +02:00
|
|
|
constexpr bool Margin::isNull() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_top == 0 && m_left == 0 && m_bottom == 0 && m_right == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns a string representation of the margin.
|
|
|
|
*/
|
|
|
|
inline std::string Margin::toString() const
|
|
|
|
{
|
2019-06-10 22:49:11 +02:00
|
|
|
return CppUtilities::argsToString("top: ", m_top, "; left: ", m_left, "; bottom: ", m_bottom, "; right: ", m_right);
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_MARGIN_H
|