mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
1682f0b760
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGUI/Frame.h>
|
|
#include <LibGfx/TextAlignment.h>
|
|
|
|
namespace GUI {
|
|
|
|
class Label : public Frame {
|
|
C_OBJECT(Label);
|
|
|
|
public:
|
|
virtual ~Label() override;
|
|
|
|
String text() const { return m_text; }
|
|
void set_text(String);
|
|
|
|
void set_icon(const Gfx::Bitmap*);
|
|
const Gfx::Bitmap* icon() const { return m_icon.ptr(); }
|
|
Gfx::Bitmap* icon() { return m_icon.ptr(); }
|
|
|
|
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
|
void set_text_alignment(Gfx::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; }
|
|
|
|
bool is_autosize() const { return m_autosize; }
|
|
void set_autosize(bool);
|
|
|
|
bool is_word_wrap() const { return m_word_wrap; }
|
|
void set_word_wrap(bool);
|
|
|
|
Gfx::IntRect text_rect(size_t line = 0) const;
|
|
|
|
protected:
|
|
explicit Label(String text = {});
|
|
|
|
virtual void paint_event(PaintEvent&) override;
|
|
virtual void did_change_text() { }
|
|
|
|
private:
|
|
void size_to_fit();
|
|
void wrap_text();
|
|
|
|
String m_text;
|
|
RefPtr<Gfx::Bitmap> m_icon;
|
|
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
|
bool m_should_stretch_icon { false };
|
|
bool m_autosize { false };
|
|
bool m_word_wrap { false };
|
|
Vector<String> m_lines;
|
|
};
|
|
|
|
}
|