boxes.hpp 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _UI_BOXES_H_
  2. #define _UI_BOXES_H_
  3. #include <gtkmm.h>
  4. namespace ui
  5. {
  6. class BoxWidget: public Gtk::Box
  7. {
  8. public:
  9. BoxWidget(Gtk::Orientation orientation, int spacing):
  10. Gtk::Box(orientation, spacing) {}
  11. BoxWidget & add(Gtk::Widget & w)
  12. {
  13. append(w);
  14. return *this;
  15. }
  16. };
  17. BoxWidget & HBox(int spacing)
  18. {
  19. auto box = Gtk::manage(
  20. new BoxWidget(Gtk::Orientation::HORIZONTAL, spacing));
  21. return *box;
  22. }
  23. BoxWidget & VBox(int spacing)
  24. {
  25. auto box = Gtk::manage(
  26. new BoxWidget(Gtk::Orientation::VERTICAL, spacing));
  27. return *box;
  28. }
  29. BoxWidget & BoundingBox(int margin)
  30. {
  31. auto box = Gtk::manage(
  32. new BoxWidget(Gtk::Orientation::VERTICAL, 0));
  33. box->set_margin_top(margin);
  34. box->set_margin_bottom(margin);
  35. box->set_margin_start(margin);
  36. box->set_margin_end(margin);
  37. return *box;
  38. }
  39. }
  40. #endif