GSpinBox.h 826 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <LibGUI/GWidget.h>
  3. class GButton;
  4. class GTextEditor;
  5. class GSpinBox : public GWidget {
  6. C_OBJECT(GSpinBox)
  7. public:
  8. GSpinBox(GWidget* parent = nullptr);
  9. virtual ~GSpinBox() override;
  10. int value() const { return m_value; }
  11. void set_value(int);
  12. int min() const { return m_min; }
  13. int max() const { return m_max; }
  14. void set_min(int min) { set_range(min, max()); }
  15. void set_max(int max) { set_range(min(), max); }
  16. void set_range(int min, int max);
  17. Function<void(int value)> on_change;
  18. protected:
  19. virtual void resize_event(GResizeEvent&) override;
  20. private:
  21. GTextEditor* m_editor { nullptr };
  22. GButton* m_increment_button { nullptr };
  23. GButton* m_decrement_button { nullptr };
  24. int m_min { 0 };
  25. int m_max { 100 };
  26. int m_value { 0 };
  27. };