2019-01-20 06:49:48 +03:00
|
|
|
#pragma once
|
|
|
|
|
2019-03-28 17:30:29 +03:00
|
|
|
#include <LibGUI/GFrame.h>
|
|
|
|
#include <SharedGraphics/TextAlignment.h>
|
2019-02-12 17:23:07 +03:00
|
|
|
|
|
|
|
class GraphicsBitmap;
|
2019-01-20 06:49:48 +03:00
|
|
|
|
2019-04-26 15:16:17 +03:00
|
|
|
class GLabel : public GFrame {
|
2019-01-20 06:49:48 +03:00
|
|
|
public:
|
2019-04-08 19:58:44 +03:00
|
|
|
explicit GLabel(GWidget* parent = nullptr);
|
2019-06-02 15:58:02 +03:00
|
|
|
GLabel(const StringView& text, GWidget* parent = nullptr);
|
2019-01-20 06:49:48 +03:00
|
|
|
virtual ~GLabel() override;
|
|
|
|
|
|
|
|
String text() const { return m_text; }
|
2019-06-02 15:58:02 +03:00
|
|
|
void set_text(const StringView&);
|
2019-01-20 06:49:48 +03:00
|
|
|
|
2019-07-11 16:52:15 +03:00
|
|
|
void set_icon(GraphicsBitmap*);
|
2019-02-12 17:23:07 +03:00
|
|
|
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; }
|
|
|
|
|
2019-03-22 06:20:48 +03:00
|
|
|
bool should_stretch_icon() const { return m_should_stretch_icon; }
|
|
|
|
void set_should_stretch_icon(bool b) { m_should_stretch_icon = b; }
|
|
|
|
|
2019-03-21 00:01:02 +03:00
|
|
|
void size_to_fit();
|
|
|
|
|
2019-03-16 14:57:04 +03:00
|
|
|
virtual const char* class_name() const override { return "GLabel"; }
|
|
|
|
|
2019-01-20 06:49:48 +03:00
|
|
|
private:
|
2019-01-21 02:46:08 +03:00
|
|
|
virtual void paint_event(GPaintEvent&) override;
|
2019-01-20 06:49:48 +03:00
|
|
|
|
|
|
|
String m_text;
|
2019-06-21 19:37:47 +03:00
|
|
|
RefPtr<GraphicsBitmap> m_icon;
|
2019-02-12 17:23:07 +03:00
|
|
|
TextAlignment m_text_alignment { TextAlignment::Center };
|
2019-03-22 06:20:48 +03:00
|
|
|
bool m_should_stretch_icon { false };
|
2019-01-20 06:49:48 +03:00
|
|
|
};
|