core_window.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <gtkmm.h>
  2. #include <iostream>
  3. #include "strings.hpp"
  4. #include "config.hpp"
  5. #include "core_window.hpp"
  6. #include "buttons.hpp"
  7. namespace cx_light {
  8. core_window::core_window() {
  9. this->set_title(__(WINDOW_TITLE));
  10. this->set_default_size(400, 200);
  11. this->init_default();
  12. this->show_all();
  13. }
  14. core_window::~core_window() {
  15. delete this->add_light;
  16. delete this->lights_list;
  17. delete this->lights_list_frame;
  18. delete this->content;
  19. }
  20. void core_window::init_default() {
  21. this->create_lights_list();
  22. this->content = new Gtk::Grid();
  23. this->content->attach(*this->lights_list_frame, 0, 0);
  24. this->add(*this->content);
  25. }
  26. void core_window::create_lights_list() {
  27. this->add_light = new add_light_button();
  28. this->lights_list_frame = new Gtk::Frame();
  29. this->lights_list_frame->set_label(__(LIGHTS_LIST));
  30. this->set_margin(this->lights_list_frame, DEFAULT_MARGIN);
  31. this->lights_list = new Gtk::ListBox();
  32. this->set_margin(this->lights_list, DEFAULT_MARGIN);
  33. this->lights_list_frame->add(*this->lights_list);
  34. this->lights_list->append(*this->add_light);
  35. }
  36. void core_window::set_margin(Gtk::Widget *target, unsigned int margin) {
  37. target->set_margin_top(margin);
  38. target->set_margin_left(margin);
  39. target->set_margin_right(margin);
  40. target->set_margin_bottom(margin);
  41. }
  42. void core_window::set_margin(
  43. Gtk::Widget *target,
  44. unsigned int margin_top,
  45. unsigned int margin_side
  46. ) {
  47. target->set_margin_top(margin_top);
  48. target->set_margin_left(margin_side);
  49. target->set_margin_right(margin_side);
  50. target->set_margin_bottom(margin_top);
  51. }
  52. }