blob: bb8c43ddd186b87e6ca0e8100e8db51bddda28fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#pragma once
#include "GWidget.h"
#include <AK/AKString.h>
#include <SharedGraphics/Painter.h>
class GraphicsBitmap;
class GLabel final : public GWidget {
public:
explicit GLabel(GWidget* parent);
GLabel(const String& text, GWidget* parent);
virtual ~GLabel() override;
String text() const { return m_text; }
void set_text(const String&);
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; }
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();
virtual const char* class_name() const override { return "GLabel"; }
private:
virtual void paint_event(GPaintEvent&) override;
String m_text;
RetainPtr<GraphicsBitmap> m_icon;
TextAlignment m_text_alignment { TextAlignment::Center };
bool m_should_stretch_icon { false };
};
|