| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include <vector>
- #include <gtkmm/box.h>
- #include <gtkmm/button.h>
- #include <gtkmm/orientable.h>
- #include "lights_list.hpp"
- #include "light_on_list.hpp"
- #include "strings.hpp"
- #include "config.hpp"
- #include "light.hpp"
- namespace cx_light {
- lights_list::lights_list() {
- this->lights = new std::vector<light_on_list *>;
- this->lights->clear();
-
- this->content = new Gtk::Box();
- this->content->set_size_request(light_on_list::width(), -1);
- this->content->set_orientation(Gtk::Orientation::VERTICAL);
- this->content->set_margin(DEFAULT_MARGIN);
-
- this->set_margin(DEFAULT_MARGIN);
- this->set_child(*this->content);
- this->add_lights_container();
- this->add_create_light_button();
- #ifdef UI_DEBUG
- this->add_light(light("Sample", "1.1.1.1"));
- this->add_light(light("Other", "1.1.1.1"));
- #endif
- }
- lights_list::~lights_list() {
- for (unsigned int count = 0; count < this->lights->size(); ++count) {
- delete this->lights->at(count);
- }
- delete this->create_light;
- delete this->lights;
- delete this->lights_container;
- delete this->content;
- }
- void lights_list::add_lights_container() {
- this->lights_container = new Gtk::Box();
- this->lights_container->set_orientation(Gtk::Orientation::VERTICAL);
- this->lights_container->set_size_request(-1, light_on_list::height());
- this->content->append(*this->lights_container);
- }
- void lights_list::add_create_light_button() {
- this->create_light = new Gtk::Button(__(ADD_LIGHT));
- this->content->append(*this->create_light);
- }
- void lights_list::add_light(light target) {
- light_on_list *current = new light_on_list(target);
-
- this->lights_container->append(*current);
- this->lights->push_back(current);
- }
- }
|