2019-02-10 11:07:13 +01:00
|
|
|
#include <LibGUI/GStatusBar.h>
|
|
|
|
|
#include <LibGUI/GLabel.h>
|
|
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-03-28 17:32:38 +01:00
|
|
|
#include <SharedGraphics/StylePainter.h>
|
2019-03-28 17:19:56 +01:00
|
|
|
#include <LibGUI/GPainter.h>
|
2019-02-10 11:07:13 +01:00
|
|
|
|
|
|
|
|
GStatusBar::GStatusBar(GWidget* parent)
|
|
|
|
|
: GWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
2019-03-04 10:47:54 +01:00
|
|
|
set_preferred_size({ 0, 20 });
|
2019-02-10 11:07:13 +01:00
|
|
|
set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
2019-03-29 02:20:22 +01:00
|
|
|
layout()->set_margins({ 2, 2, 2, 2 });
|
2019-03-30 13:12:59 +01:00
|
|
|
layout()->set_spacing(2);
|
2019-02-10 11:07:13 +01:00
|
|
|
m_label = new GLabel(this);
|
2019-04-10 03:43:46 +02:00
|
|
|
m_label->set_frame_shadow(FrameShadow::Sunken);
|
|
|
|
|
m_label->set_frame_shape(FrameShape::Panel);
|
2019-03-28 15:30:29 +01:00
|
|
|
m_label->set_frame_thickness(1);
|
2019-02-12 15:23:07 +01:00
|
|
|
m_label->set_text_alignment(TextAlignment::CenterLeft);
|
2019-02-10 11:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GStatusBar::~GStatusBar()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GStatusBar::set_text(String&& text)
|
|
|
|
|
{
|
|
|
|
|
m_label->set_text(move(text));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String GStatusBar::text() const
|
|
|
|
|
{
|
|
|
|
|
return m_label->text();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 18:57:36 +01:00
|
|
|
void GStatusBar::paint_event(GPaintEvent& event)
|
2019-02-10 11:07:13 +01:00
|
|
|
{
|
2019-03-28 17:19:56 +01:00
|
|
|
GPainter painter(*this);
|
2019-03-29 15:01:54 +01:00
|
|
|
painter.add_clip_rect(event.rect());
|
2019-04-03 16:50:08 +02:00
|
|
|
StylePainter::paint_surface(painter, rect(), !spans_entire_window_horizontally());
|
2019-02-10 11:07:13 +01:00
|
|
|
}
|