]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se agrega una mejora visual para poder ver los colores de todos
authorRicardo Markiewicz <gazer.arg@gmail.com>
Mon, 24 Nov 2003 03:35:27 +0000 (03:35 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Mon, 24 Nov 2003 03:35:27 +0000 (03:35 +0000)
 los componentes al mismo tiempo. Esto ira mejorando en cada
 item con el correr de la semana.

Client/include/item.h
Client/include/item_codo.h
Client/include/item_conduct.h
Client/include/item_exclusa.h
Client/include/item_union.h
Client/src/item.cpp
Client/src/item_codo.cpp
Client/src/item_conduct.cpp
Client/src/item_exclusa.cpp
Client/src/item_union.cpp
Client/src/principal.cpp

index 5a374dd7de63681b354ec2974aa4f3ec8b370794..02e62b95cddea9e46433285036b6f500acd829a4 100644 (file)
@@ -13,6 +13,8 @@ public:
        ViewItem(Glib::ustring _name);
        virtual ~ViewItem();
        
+       virtual bool on_image_expose_event(GdkEventExpose *e);
+       virtual void on_realize();
        inline Glib::ustring get_name() { return name; }
        void set_position(int _x, int _y);
        void set_name(Glib::ustring _name);
@@ -31,7 +33,8 @@ protected:
        Glib::ustring name;
        Gtk::Image image;
        Gdk::Color color;
-       int x, y;
+       Glib::RefPtr<Gdk::GC> gc;
+       int x, y, m_or;
        float actual_flow, extra;
        bool open;
 };
index ccd47af187d9f352f7c5ac5db7faab1ded9eaf8c..87dc16a4188cf10e509db341f48ee3ad5f98bdb2 100644 (file)
@@ -8,6 +8,7 @@ class ViewCodo:public ViewItem {
 public:
        ViewCodo(Glib::ustring _name, int orientacion);
        virtual ~ViewCodo();
+       virtual bool on_image_expose_event(GdkEventExpose *e);
 };
 
 #endif
index 4c0ddfcaa41c6a8bf44f189f85332dd72a654c0a..5157d989adc1698d40c60cefa713797873c2da0c 100644 (file)
@@ -8,6 +8,7 @@ class ViewConduct:public ViewItem {
 public:
        ViewConduct(Glib::ustring _name, int orientacion);
        virtual ~ViewConduct();
+       virtual bool on_image_expose_event(GdkEventExpose *e);
 };
 
 #endif
index 0ca925660008e2e955e7d82f8c22619e84698ebb..522a7ad02b767e0c219ac99b87188bf6b92e07a7 100644 (file)
@@ -12,6 +12,7 @@ public:
        virtual std::string get_cap_flow() { return "Flujo Actual :"; }
        virtual std::string get_cap_extra() { return "Estado : "; }
        virtual std::string get_extra() { return (open)?"Abierta":"Cerrada"; }
+       virtual bool on_image_expose_event(GdkEventExpose *e);
 };
 
 #endif
index e99d4af2ae670adf8a2b92cad1d8694f9288a394..5ec98451dc000a3e5461fc7f14cc9e3d05d74527 100644 (file)
@@ -8,6 +8,7 @@ class ViewUnion:public ViewItem {
 public:
        ViewUnion(Glib::ustring _name, int orientacion);
        virtual ~ViewUnion();
+       virtual bool on_image_expose_event(GdkEventExpose *e);
 };
 
 #endif
index 8fab941621dc4bdb251e67ef44cfc8c3c599a269..6bbaf1d2778debe503b64a1906b5d6c0e17fcdb8 100644 (file)
@@ -9,6 +9,15 @@ ViewItem::ViewItem(Glib::ustring _name):Gtk::EventBox(),image()
        set_events(Gdk::BUTTON_PRESS_MASK);
        actual_flow = -1;
        add(image);
+
+       image.signal_expose_event().connect( SigC::slot(*this, &ViewItem::on_image_expose_event) );
+}
+
+void ViewItem::on_realize()
+{
+       Gtk::EventBox::on_realize();
+       Glib::RefPtr<Gdk::Window> window = get_window();
+       gc = Gdk::GC::create(window);
 }
 
 ViewItem::~ViewItem()
@@ -36,3 +45,12 @@ std::string ViewItem::get_actual_flow()
        return s;
 }
 
+bool ViewItem::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       colormap->alloc_color(color);
+       gc->set_foreground(color);
+       gc->set_background(color);
+       image.get_window()->draw_rectangle(gc, 1, 0, 0, 10, 10);
+}
+
index 639e63566cc37df869f9d728a95e9d32470287b2..621262747bb5c8ad3bc77d956a0cb04eefc4e324 100644 (file)
@@ -16,6 +16,7 @@ ViewCodo::ViewCodo(Glib::ustring _name, int orientacion):ViewItem(_name)
                case 3:
                        image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/codo_s.png");
        }
+       m_or = orientacion;
        image.show();
        set_size_request();
 }
@@ -24,3 +25,29 @@ ViewCodo::~ViewCodo()
 {
 }
 
+bool ViewCodo::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       colormap->alloc_color(color);
+       gc->set_foreground(color);
+       gc->set_background(color);
+       int w,h;
+       w = image.get_width();
+       h = image.get_height();
+       // TODO : hacer que dibuje arcos en el sentido del codo!
+       image.get_window()->draw_rectangle(gc, 1, w/2-5, h/2-5, 10, 10);
+/*     switch (orientacion) {
+               case 0:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-4, 0, 4, h);
+               break;
+               case 1:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-4, 0, 4, h);
+               break;
+               case 2:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-4, 0, 4, h);
+               break;
+               case 3:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-4, 0, 4, h);
+       }*/
+}
+
index 9f46810341677ca3d80663b245a75dd2581807eb..e203b2f06204bffe103e27d9f0c9548a365eb7fc 100644 (file)
@@ -4,13 +4,13 @@
 ViewConduct::ViewConduct(Glib::ustring _name, int orientacion):ViewItem(_name)
 {
        switch (orientacion) {
-               case 0:
+               case 0: // Caño vertical
                        image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/canio_n.png");
                break;
-               case 1:
+               case 1: // Caño horizontal
                        image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/canio_s.png");
        }
-       std::cout << "Conducto creado" << std::endl;
+       m_or = orientacion;
        image.show();
        set_size_request();
 }
@@ -19,3 +19,27 @@ ViewConduct::~ViewConduct()
 {
 }
 
+bool ViewConduct::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       Gdk::Color blanco = Gdk::Color("white");
+       colormap->alloc_color(blanco);
+       colormap->alloc_color(color);
+       gc->set_foreground(color);
+       gc->set_background(color);
+       int w,h;
+       w = image.get_width();
+       h = image.get_height();
+       switch (m_or) {
+               case 0: // Vertical
+                       image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h);
+                       gc->set_foreground(blanco);
+                       image.get_window()->draw_rectangle(gc, 0, w/2-3, 0, 6, h);
+               break;
+               case 1: // Horizontal
+                       image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, h, 4);
+                       gc->set_foreground(blanco);
+                       image.get_window()->draw_rectangle(gc, 0, 0, h/2-3, h, 6);
+       }
+}
+
index d9c1a9b763323583e80afe4f865b8bcad92562e7..39f2a880b2ca8d9f866697feb7d996899e8a8b6f 100644 (file)
@@ -10,6 +10,7 @@ ViewExclusa::ViewExclusa(Glib::ustring _name, int orientacion):ViewItem(_name)
                case 1:
                        image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/exclusa_s.png");
        }
+       m_or = orientacion;
        image.show();
        set_size_request();
 }
@@ -18,3 +19,21 @@ ViewExclusa::~ViewExclusa()
 {
 }
 
+bool ViewExclusa::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       colormap->alloc_color(color);
+       gc->set_foreground(color);
+       gc->set_background(color);
+       int w,h;
+       w = image.get_width();
+       h = image.get_height();
+       switch (m_or) {
+               case 1: // Vertical
+                       image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h);
+               break;
+               case 0: // Horizontal
+                       image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, w, 4);
+       }
+}
+
index b96c137845c7f3c2b6d0cd8ab1d5211937040858..08bad4ed80fa04d59b7e7e85b47eca2826fb9ab5 100644 (file)
@@ -17,6 +17,7 @@ ViewUnion::ViewUnion(Glib::ustring _name, int orientacion):ViewItem(_name)
                case 3:
                        image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/y_o.png");
        }
+       m_or = orientacion;
        image.show();
        set_size_request();
 }
@@ -25,3 +26,31 @@ ViewUnion::~ViewUnion()
 {
 }
 
+bool ViewUnion::on_image_expose_event(GdkEventExpose *e)
+{
+       Glib::RefPtr<Gdk::Colormap> colormap = image.get_colormap();
+       Gdk::Color blanco = Gdk::Color("white");
+       colormap->alloc_color(color);
+       colormap->alloc_color(blanco);
+       gc->set_foreground(color);
+       gc->set_background(color);
+       int w,h;
+       w = image.get_width();
+       h = image.get_height();
+       switch (m_or) {
+               case 0:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-2, h/2, 4, h/2);
+                       gc->set_foreground(blanco);
+                       image.get_window()->draw_rectangle(gc, 0, w/2-3, h/2-1, 6, h/2);
+               break;
+               case 1:
+                       image.get_window()->draw_rectangle(gc, 1, 0, h/2-2, w/2, 4);
+               break;
+               case 2:
+                       image.get_window()->draw_rectangle(gc, 1, w/2-2, 0, 4, h/2);
+               break;
+               case 3:
+                       image.get_window()->draw_rectangle(gc, 1, w/2, h/2-2, w/2, 4);
+       }
+}
+
index d5959a9476b01513ee4cee83f9ed8f70532bd27d..0ec83bb536464771c4b1b4b3f4fb42fd20d9d1b9 100644 (file)
@@ -193,6 +193,13 @@ void Principal::update_items_prop()
 
        color_preview->modify_bg(Gtk::STATE_NORMAL, last_selected->get_color());
        color_preview->queue_draw();
+
+       // Mando a redibujar a todos los items
+       std::map<const std::string, ViewItem *>::iterator i;
+       for(i=mapItems.begin(); i!=mapItems.end(); i++) {
+               i->second->queue_draw();
+       }
+
 }
 
 void Principal::on_conexion_connected()