core_window.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <gtkmm/widget.h>
  2. #include <gtkmm/button.h>
  3. #include <gtkmm/window.h>
  4. #include <gtkmm/box.h>
  5. #include <gtkmm/frame.h>
  6. #include <gtkmm/orientable.h>
  7. #include <gtkmm/widget.h>
  8. #include <iostream>
  9. #include "strings.hpp"
  10. #include "config.hpp"
  11. #include "core_window.hpp"
  12. #include "lights_list.hpp"
  13. #include "light_adder.hpp"
  14. namespace cx_light {
  15. core_window::core_window() {
  16. this->current_visible = NULL;
  17. this->set_title(__(WINDOW_TITLE));
  18. this->set_default_size(400, 200);
  19. this->init_default();
  20. }
  21. core_window::~core_window() {
  22. delete this->center;
  23. delete this->current;
  24. delete this->lights;
  25. delete this->adder;
  26. }
  27. void core_window::init_default() {
  28. this->center = new Gtk::Box();
  29. this->center->set_orientation(Gtk::Orientation::HORIZONTAL);
  30. this->set_child(*this->center);
  31. this->current = new Gtk::Box();
  32. this->current->set_margin(DEFAULT_MARGIN);
  33. this->current_frame = new Gtk::Frame();
  34. this->current_frame->set_margin(DEFAULT_MARGIN);
  35. this->current_frame->set_child(*this->current);
  36. this->create_lights_list();
  37. this->center->append(*this->current_frame);
  38. this->create_light_adder();
  39. }
  40. void core_window::create_lights_list() {
  41. this->lights = new lights_list();
  42. this->center->append(*this->lights);
  43. }
  44. void core_window::create_light_adder() {
  45. this->adder = new light_adder();
  46. this->set_view(this->adder);
  47. }
  48. void core_window::set_view(Gtk::Widget *target) {
  49. if (this->current_visible != NULL) {
  50. this->current->remove(*this->current_visible);
  51. }
  52. this->current_visible = target;
  53. this->current->append(*target);
  54. }
  55. }