| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include <gtkmm/widget.h>
- #include <gtkmm/button.h>
- #include <gtkmm/window.h>
- #include <gtkmm/box.h>
- #include <gtkmm/frame.h>
- #include <gtkmm/orientable.h>
- #include <gtkmm/widget.h>
- #include <iostream>
- #include "strings.hpp"
- #include "config.hpp"
- #include "core_window.hpp"
- #include "lights_list.hpp"
- #include "light_adder.hpp"
- #include "welcome.hpp"
- #include "control.hpp"
- #include "editor.hpp"
- namespace cx_light {
- core_window::core_window() {
- this->current_visible = NULL;
-
- this->set_title(__(WINDOW_TITLE));
- this->set_default_size(600, 200);
- this->init_default();
- }
- core_window::~core_window() {
- delete this->center;
- delete this->current;
- delete this->lights;
- delete this->current_frame;
- if (this->current_visible != NULL) {
- delete this->current_visible;
- }
- }
- void core_window::init_default() {
- this->center = new Gtk::Box();
- this->center->set_orientation(Gtk::Orientation::HORIZONTAL);
- this->set_child(*this->center);
- this->current = new Gtk::Box();
- this->current->set_margin(DEFAULT_MARGIN);
- this->current_frame = new Gtk::Frame();
- this->current_frame->set_margin(DEFAULT_MARGIN);
- this->current_frame->set_child(*this->current);
- this->create_lights_list();
- this->center->append(*this->current_frame);
- this->set_view(new welcome());
- }
- void core_window::create_lights_list() {
- this->lights = new lights_list();
- this->center->append(*this->lights);
-
- this->lights->set_add_light_callback([&] () {
- this->set_view(new light_adder());
- });
- this->lights->set_edit_light_callback([&] (light *target) {
- this->set_view(new editor(target));
- });
- this->lights->set_show_light_callback([&] (light *target) {
- this->set_view(new control(target));
- });
- }
- void core_window::set_view(Gtk::Widget *target) {
- if (this->current_visible != NULL) {
- this->current->remove(*this->current_visible);
- delete this->current_visible;
- }
- this->current_visible = target;
- this->current->append(*target);
- }
- }
|