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