Cixo Develop 5 kuukautta sitten
vanhempi
commit
5a8d9d9e6e

+ 9 - 0
cppGTK/source/core_window.cpp

@@ -8,6 +8,7 @@
 #include "strings.hpp"
 #include "config.hpp"
 #include "core_window.hpp"
+#include "lights_list.hpp"
 
 namespace cx_light {
 
@@ -25,6 +26,14 @@ core_window::~core_window() {
 void core_window::init_default() {
     this->center = new Gtk::Box();
     this->center->set_orientation(Gtk::Orientation::HORIZONTAL);
+    this->set_child(*this->center);
+
+    this->create_lights_list();
+}
+
+void core_window::create_lights_list() {
+    this->lights = new lights_list(); 
+    this->center->append(*this->lights);
 }
 
 }

+ 5 - 1
cppGTK/source/core_window.hpp

@@ -7,6 +7,7 @@
 #include <gtkmm/box.h>
 
 #include "strings.hpp"
+#include "lights_list.hpp"
 
 namespace cx_light {
 
@@ -16,8 +17,11 @@ class core_window: public Gtk::Window {
         ~core_window() override;
 
     private:
-        void init_default();
         Gtk::Box *center;
+        lights_list *lights; 
+
+        void init_default();
+        void create_lights_list();
 };
 
 }

+ 26 - 0
cppGTK/source/light_on_list.cpp

@@ -0,0 +1,26 @@
+
+#include <string>
+#include <gtkmm/box.h>
+
+#include "light_on_list.hpp"
+
+namespace cx_light {
+
+light_on_list::light_on_list(std::string name, bool state) {
+    this->name = name;
+    this->state = state;
+}
+
+light_on_list::~light_on_list() {
+     
+}
+
+int light_on_list::width() {
+    return 200;
+}
+
+int light_on_list::height() {
+    return 40;
+}
+
+}

+ 25 - 0
cppGTK/source/light_on_list.hpp

@@ -0,0 +1,25 @@
+#ifndef LIGHT_ON_LIST_HPP_INCLUDED
+#define LIGHT_ON_LIST_HPP_INCLUDED
+
+#include <gtkmm/box.h>
+#include <string>
+
+namespace cx_light {
+
+class light_on_list: public Gtk::Box {
+    public:
+        light_on_list(std::string, bool);
+        ~light_on_list() override;
+       
+        static 
+        static int width();
+        static int height();
+
+    private:
+        bool state;
+        std::string name;
+};
+
+}
+
+#endif

+ 43 - 0
cppGTK/source/lights_list.cpp

@@ -0,0 +1,43 @@
+#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"
+
+namespace cx_light {
+
+lights_list::lights_list() {
+    this->lights = new std::vector<light_on_list *>;
+    this->lights->clear();
+    
+    this->set_size_request(light_on_list::width(), -1);
+    this->set_orientation(Gtk::Orientation::VERTICAL);
+    this->set_margin(DEFAULT_MARGIN);
+
+    this->add_lights_container();
+    this->add_create_light_button();
+}
+
+lights_list::~lights_list() {
+    delete this->create_light;
+    delete this->lights;
+    delete this->lights_container;
+}
+
+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->append(*this->lights_container);
+}
+
+void lights_list::add_create_light_button() {
+    this->create_light = new Gtk::Button(__(ADD_LIGHT));
+    this->append(*this->create_light);
+}
+
+}

+ 28 - 0
cppGTK/source/lights_list.hpp

@@ -0,0 +1,28 @@
+#ifndef LIGHTS_LIST_HPP_INCLUDED
+#define LIGHTS_LIST_HPP_INCLUDED
+
+#include <vector>
+#include <gtkmm/box.h>
+#include <gtkmm/button.h>
+
+#include "light_on_list.hpp"
+
+namespace cx_light {
+
+class lights_list: public Gtk::Box {
+    public:
+        lights_list();
+        ~lights_list() override;
+
+    private:
+        Gtk::Box *lights_container; 
+        Gtk::Button *create_light;
+        std::vector<light_on_list *> *lights;
+
+        void add_create_light_button();
+        void add_lights_container();
+};
+
+}
+
+#endif