GProgressBar.h 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <LibGUI/GFrame.h>
  3. class GProgressBar : public GFrame {
  4. C_OBJECT(GProgressBar)
  5. public:
  6. virtual ~GProgressBar() override;
  7. void set_range(int min, int max);
  8. void set_min(int min) { set_range(min, max()); }
  9. void set_max(int max) { set_range(min(), max); }
  10. void set_value(int);
  11. int value() const { return m_value; }
  12. int min() const { return m_min; }
  13. int max() const { return m_max; }
  14. String caption() const { return m_caption; }
  15. void set_caption(const StringView& caption) { m_caption = caption; }
  16. enum Format {
  17. NoText,
  18. Percentage,
  19. ValueSlashMax
  20. };
  21. Format format() const { return m_format; }
  22. void set_format(Format format) { m_format = format; }
  23. protected:
  24. explicit GProgressBar(GWidget* parent);
  25. virtual void paint_event(GPaintEvent&) override;
  26. private:
  27. Format m_format { Percentage };
  28. int m_min { 0 };
  29. int m_max { 100 };
  30. int m_value { 0 };
  31. String m_caption;
  32. };