2019-01-20 04:49:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "GWidget.h"
|
|
|
|
|
#include <AK/AKString.h>
|
2019-02-12 15:23:07 +01:00
|
|
|
#include <SharedGraphics/Painter.h>
|
|
|
|
|
|
|
|
|
|
class GraphicsBitmap;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
|
|
|
|
class GLabel final : public GWidget {
|
|
|
|
|
public:
|
|
|
|
|
explicit GLabel(GWidget* parent);
|
2019-03-10 13:16:36 +01:00
|
|
|
GLabel(const String& text, GWidget* parent);
|
2019-01-20 04:49:48 +01:00
|
|
|
virtual ~GLabel() override;
|
|
|
|
|
|
|
|
|
|
String text() const { return m_text; }
|
2019-03-10 12:34:44 +01:00
|
|
|
void set_text(const String&);
|
2019-01-20 04:49:48 +01:00
|
|
|
|
2019-02-12 15:23:07 +01:00
|
|
|
void set_icon(RetainPtr<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; }
|
|
|
|
|
|
2019-03-20 22:01:02 +01:00
|
|
|
void size_to_fit();
|
|
|
|
|
|
2019-03-16 12:57:04 +01:00
|
|
|
virtual const char* class_name() const override { return "GLabel"; }
|
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
private:
|
2019-01-21 00:46:08 +01:00
|
|
|
virtual void paint_event(GPaintEvent&) override;
|
2019-01-20 04:49:48 +01:00
|
|
|
|
|
|
|
|
String m_text;
|
2019-02-12 15:23:07 +01:00
|
|
|
RetainPtr<GraphicsBitmap> m_icon;
|
|
|
|
|
TextAlignment m_text_alignment { TextAlignment::Center };
|
2019-01-20 04:49:48 +01:00
|
|
|
};
|
|
|
|
|
|