5#include "fifechan/widgets/menuitem.hpp"
14#include "fifechan/font.hpp"
15#include "fifechan/graphics.hpp"
38 if (popup !=
nullptr) {
39 mType = Type::Submenu;
123 assert(
"graphics must not be null" && graphics !=
nullptr);
126 if (
mType == Type::Separator) {
147 unsigned char const first =
static_cast<unsigned char>(
mIconGlyph.at(0));
148 if (first >= 0xF0 || first == 0xE2) {
156 }
else if (
mIcon !=
nullptr) {
180 Graphics::Alignment::Right);
184 if (
mType == Type::Submenu) {
203 }
else if (
mIcon !=
nullptr) {
205 textX +=
mIcon->getWidth() + 4;
230 graphics->
drawText(
"[x]", 4, textY, Graphics::Alignment::Left);
234 if (
mType == Type::Submenu) {
248 if (
mType == Type::Separator) {
254 if (
mIcon !=
nullptr) {
262 }
else if (
mType == Type::Checkable) {
264 m.
iconW = font.getWidth(
"[x]");
278 if (
mType == Type::Submenu) {
279 m.
arrowW = font.getWidth(
" >") + 8;
283 int contentH = font.getHeight();
284 if (
mIcon !=
nullptr) {
285 contentH = std::max(contentH,
mIcon->getHeight());
289 contentH = std::max(contentH, iconFontH);
293 m.
height = contentH + vpad;
Abstract interface for font rendering.
virtual int getWidth(std::string const &text) const =0
Gets the width of a string.
virtual int getHeight() const =0
Gets the height of the glyphs in the font.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual void drawImage(Image const *image, int srcX, int srcY, int dstX, int dstY, int width, int height)=0
Draws a part of an image.
void drawText(std::string const &text, int x, int y)
Draws text with a default left alignment.
virtual void setFont(Font *font)
Sets the font to use when drawing text.
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
virtual void fillRectangle(Rectangle const &rectangle)=0
Draws a filled rectangle.
Abstract holder for image data.
Represents a rectangular area (X, Y, Width, Height).
Used replacement tokens by configure_file():
Column layout specification passed to items for rendering.