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