mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
a599317624
This macro goes at the top of every CObject-derived class like so: class SomeClass : public CObject { C_OBJECT(SomeClass) public: ... At the moment, all it does is create an override for the class_name() getter but in the future this will be used to automatically insert member functions into these classes.
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <LibGUI/GFrame.h>
|
|
#include <LibDraw/TextAlignment.h>
|
|
|
|
class GraphicsBitmap;
|
|
|
|
class GLabel : public GFrame {
|
|
C_OBJECT(GLabel)
|
|
public:
|
|
explicit GLabel(GWidget* parent = nullptr);
|
|
GLabel(const StringView& text, GWidget* parent = nullptr);
|
|
virtual ~GLabel() override;
|
|
|
|
String text() const { return m_text; }
|
|
void set_text(const StringView&);
|
|
|
|
void set_icon(GraphicsBitmap*);
|
|
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
|
GraphicsBitmap* icon() { return m_icon.ptr(); }
|
|
|
|
TextAlignment text_alignment() const { return m_text_alignment; }
|
|
void set_text_alignment(TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
|
|
|
bool should_stretch_icon() const { return m_should_stretch_icon; }
|
|
void set_should_stretch_icon(bool b) { m_should_stretch_icon = b; }
|
|
|
|
void size_to_fit();
|
|
|
|
private:
|
|
virtual void paint_event(GPaintEvent&) override;
|
|
|
|
String m_text;
|
|
RefPtr<GraphicsBitmap> m_icon;
|
|
TextAlignment m_text_alignment { TextAlignment::Center };
|
|
bool m_should_stretch_icon { false };
|
|
};
|