2019-02-10 11:07:13 +01:00
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-06-07 11:46:02 +02:00
|
|
|
#include <LibGUI/GLabel.h>
|
2019-03-28 17:19:56 +01:00
|
|
|
#include <LibGUI/GPainter.h>
|
2019-05-03 01:38:24 +02:00
|
|
|
#include <LibGUI/GResizeCorner.h>
|
2019-06-07 11:46:02 +02:00
|
|
|
#include <LibGUI/GStatusBar.h>
|
2019-07-18 10:15:00 +02:00
|
|
|
#include <LibDraw/StylePainter.h>
|
2019-02-10 11:07:13 +01:00
|
|
|
|
|
|
|
|
GStatusBar::GStatusBar(GWidget* parent)
|
|
|
|
|
: GWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
2019-07-20 22:39:24 +02: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-09-21 14:19:05 +02:00
|
|
|
m_label = GLabel::construct(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-05-03 01:38:24 +02:00
|
|
|
|
2019-09-21 15:43:52 +02:00
|
|
|
m_corner = GResizeCorner::construct(this);
|
2019-02-10 11:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GStatusBar::~GStatusBar()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-02 14:58:02 +02:00
|
|
|
void GStatusBar::set_text(const StringView& text)
|
2019-02-10 11:07:13 +01:00
|
|
|
{
|
2019-05-12 14:57:15 +02:00
|
|
|
m_label->set_text(text);
|
2019-02-10 11:07:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|