summaryrefslogtreecommitdiff
path: root/LibGUI/GStatusBar.cpp
blob: 77e38090be4eb0e8302c5f95829a900e8e3627d0 (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
#include <LibGUI/GStatusBar.h>
#include <LibGUI/GLabel.h>
#include <LibGUI/GBoxLayout.h>
#include <SharedGraphics/Painter.h>

GStatusBar::GStatusBar(GWidget* parent)
    : GWidget(parent)
{
    set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
    set_preferred_size({ 0, 16 });
    set_layout(make<GBoxLayout>(Orientation::Horizontal));
    m_label = new GLabel(this);
    m_label->set_text_alignment(TextAlignment::CenterLeft);
    m_label->set_fill_with_background_color(false);
}

GStatusBar::~GStatusBar()
{
}

void GStatusBar::set_text(String&& text)
{
    m_label->set_text(move(text));
}

String GStatusBar::text() const
{
    return m_label->text();
}

void GStatusBar::paint_event(GPaintEvent&)
{
    Painter painter(*this);
    painter.fill_rect({ 0, 1, width(), height() - 1 }, Color::LightGray);
    painter.draw_line({ 0, 0 }, { width() - 1, 0 }, Color::DarkGray);
}