GStatusBar.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <LibGUI/GBoxLayout.h>
  2. #include <LibGUI/GLabel.h>
  3. #include <LibGUI/GPainter.h>
  4. #include <LibGUI/GResizeCorner.h>
  5. #include <LibGUI/GStatusBar.h>
  6. #include <LibDraw/StylePainter.h>
  7. GStatusBar::GStatusBar(GWidget* parent)
  8. : GWidget(parent)
  9. {
  10. set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
  11. set_preferred_size(0, 20);
  12. set_layout(make<GBoxLayout>(Orientation::Horizontal));
  13. layout()->set_margins({ 2, 2, 2, 2 });
  14. layout()->set_spacing(2);
  15. m_label = GLabel::construct(this);
  16. m_label->set_frame_shadow(FrameShadow::Sunken);
  17. m_label->set_frame_shape(FrameShape::Panel);
  18. m_label->set_frame_thickness(1);
  19. m_label->set_text_alignment(TextAlignment::CenterLeft);
  20. m_corner = GResizeCorner::construct(this);
  21. }
  22. GStatusBar::~GStatusBar()
  23. {
  24. }
  25. void GStatusBar::set_text(const StringView& text)
  26. {
  27. m_label->set_text(text);
  28. }
  29. String GStatusBar::text() const
  30. {
  31. return m_label->text();
  32. }
  33. void GStatusBar::paint_event(GPaintEvent& event)
  34. {
  35. GPainter painter(*this);
  36. painter.add_clip_rect(event.rect());
  37. StylePainter::paint_surface(painter, rect(), !spans_entire_window_horizontally());
  38. }