5#include "fifechan/widgets/window.hpp"
10#include "fifechan/exception.hpp"
11#include "fifechan/font.hpp"
12#include "fifechan/graphics.hpp"
13#include "fifechan/mouseinput.hpp"
25 Window::Window(std::string
const & caption)
34 Window::~Window() =
default;
82 highlightColor = faceColor + 0x303030;
83 highlightColor.
a = alpha;
84 shadowColor = faceColor - 0x303030;
85 shadowColor.
a = alpha;
95 graphics->
drawLine(x + i, y + i, width - i, y + i);
96 graphics->
drawLine(x + i, y + i + 1, x + i, height - i - 1);
98 graphics->
drawLine(width - i, y + i + 1, width - i, height - i);
99 graphics->
drawLine(x + i, height - i, width - i - 1, height - i);
106 Color highlightColor;
109 highlightColor = faceColor + 0x303030;
110 highlightColor.
a = alpha;
111 shadowColor = faceColor - 0x303030;
112 shadowColor.
a = alpha;
146 case Graphics::Alignment::Left:
149 case Graphics::Alignment::Center:
152 case Graphics::Alignment::Right:
156 throwException(
"Unknown alignment.");
uint8_t a
Alpha color component (0-255).
bool mOpaque
True if the container is opaque, false otherwise.
Widget * mBackgroundWidget
Optional widget that is rendered behind other children as the container background.
Widget * getSource() const
Gets the source widget of the event.
virtual int getHeight() const =0
Gets the height of the glyphs in the font.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Alignment
Alignments for text drawing.
virtual void popClipArea()
Removes the top most clip area from the stack.
void drawText(std::string const &text, int x, int y)
Draws text with a default left alignment.
virtual bool pushClipArea(Rectangle area)
Pushes a clip area onto the stack.
virtual void setFont(Font *font)
Sets the font to use when drawing text.
virtual void drawLine(int x1, int y1, int x2, int y2)=0
Draws a line.
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.
Represents a mouse event.
int getX() const
Gets the x coordinate of the mouse event.
int getY() const
Gets the y coordinate of the mouse event.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
void adjustSize() override
Adjust the size of the container after layout computations.
bool mMoved
True if the window is being moved, false otherwise.
bool mMovable
True if the window is movable, false otherwise.
unsigned int getTitleBarHeight() const
Gets the title bar height.
unsigned int mTitleBarHeight
Holds the title bar height of the window.
void setMovable(bool movable)
Sets the window to be movable or not.
void setTitleBarHeight(unsigned int height)
Sets the title bar height.
void setAlignment(Graphics::Alignment alignment)
Sets the alignment of the caption.
unsigned int getInnerBorderSize() const
Get the size of the inner border (pixels).
Graphics::Alignment mAlignment
Holds the alignment of the caption.
std::string mCaption
Holds the caption of the window.
bool isMovable() const
Checks if the window is movable.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
void mouseReleased(MouseEvent &mouseEvent) override
Called when a mouse button has been released on the widget area.
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
bool isOpaque() const override
Checks if the window is opaque.
int mDragOffsetX
Holds a drag offset as an x coordinate where the drag of the window started if the window is being dr...
void setInnerBorderSize(unsigned int border)
Set the size of the inner border (pixels).
virtual void drawInnerBorder(Graphics *graphics)
Draw the inner border (override to customize appearance).
void draw(Graphics *graphics) override
Draws the widget.
unsigned int mInnerBorderSize
Holds the size of the inner border.
std::string const & getCaption() const
Gets the caption of the window.
void setCaption(std::string const &caption)
Sets the caption of the window.
Graphics::Alignment getAlignment() const
Gets the alignment of the caption.
int mDragOffsetY
Holds a drag offset as an y coordinate where the drag of the window started if the window is being dr...
void setOpaque(bool opaque) override
Sets the window to be opaque or not.