GToolBar.h 843 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include <AK/NonnullOwnPtrVector.h>
  3. #include <LibGUI/GWidget.h>
  4. class GAction;
  5. class GToolBar : public GWidget {
  6. C_OBJECT(GToolBar)
  7. public:
  8. virtual ~GToolBar() override;
  9. void add_action(GAction&);
  10. void add_separator();
  11. bool has_frame() const { return m_has_frame; }
  12. void set_has_frame(bool has_frame) { m_has_frame = has_frame; }
  13. protected:
  14. explicit GToolBar(GWidget* parent);
  15. explicit GToolBar(Orientation, int button_size, GWidget* parent);
  16. virtual void paint_event(GPaintEvent&) override;
  17. private:
  18. struct Item {
  19. enum Type {
  20. Invalid,
  21. Separator,
  22. Action
  23. };
  24. Type type { Invalid };
  25. RefPtr<GAction> action;
  26. };
  27. NonnullOwnPtrVector<Item> m_items;
  28. int m_button_size { 16 };
  29. bool m_has_frame { true };
  30. };