application.hpp 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef _UI_APPLICATION_H_
  2. #define _UI_APPLICATION_H_
  3. #include <gtkmm.h>
  4. #include "button.hpp"
  5. #include "window.hpp"
  6. namespace ui
  7. {
  8. class Application: public Gtk::Application
  9. {
  10. int win_w = 1;
  11. int win_h = 1;
  12. void (*setup)(Window *) = nullptr;
  13. public:
  14. Application(int window_width, int window_height, void (*setup_fn)(Window *)):
  15. Gtk::Application(""),
  16. win_w(window_width),
  17. win_h(window_height),
  18. setup(setup_fn) {}
  19. void on_activate()
  20. {
  21. auto hidden_window = Gtk::manage(new Window());
  22. add_window(*hidden_window);
  23. auto window = Gtk::manage(new Window());
  24. add_window(*window);
  25. window->set_transient_for(*hidden_window);
  26. window->set_default_size(win_w, win_h);
  27. window->set_resizable(false);
  28. window->set_decorated(false);
  29. window->set_modal(true);
  30. setup(window);
  31. }
  32. };
  33. }
  34. #endif