From: Ricardo Markiewicz Date: Mon, 24 Nov 2003 03:35:27 +0000 (+0000) Subject: Se agrega una mejora visual para poder ver los colores de todos X-Git-Tag: svn_import~185 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/a2567db67c5d678c5e71bfadc555f8319ee835a8?ds=inline Se agrega una mejora visual para poder ver los colores de todos los componentes al mismo tiempo. Esto ira mejorando en cada item con el correr de la semana. --- diff --git a/Client/include/item.h b/Client/include/item.h index 5a374dd..02e62b9 100644 --- a/Client/include/item.h +++ b/Client/include/item.h @@ -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 gc; + int x, y, m_or; float actual_flow, extra; bool open; }; diff --git a/Client/include/item_codo.h b/Client/include/item_codo.h index ccd47af..87dc16a 100644 --- a/Client/include/item_codo.h +++ b/Client/include/item_codo.h @@ -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 diff --git a/Client/include/item_conduct.h b/Client/include/item_conduct.h index 4c0ddfc..5157d98 100644 --- a/Client/include/item_conduct.h +++ b/Client/include/item_conduct.h @@ -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 diff --git a/Client/include/item_exclusa.h b/Client/include/item_exclusa.h index 0ca9256..522a7ad 100644 --- a/Client/include/item_exclusa.h +++ b/Client/include/item_exclusa.h @@ -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 diff --git a/Client/include/item_union.h b/Client/include/item_union.h index e99d4af..5ec9845 100644 --- a/Client/include/item_union.h +++ b/Client/include/item_union.h @@ -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 diff --git a/Client/src/item.cpp b/Client/src/item.cpp index 8fab941..6bbaf1d 100644 --- a/Client/src/item.cpp +++ b/Client/src/item.cpp @@ -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 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 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); +} + diff --git a/Client/src/item_codo.cpp b/Client/src/item_codo.cpp index 639e635..6212627 100644 --- a/Client/src/item_codo.cpp +++ b/Client/src/item_codo.cpp @@ -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 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); + }*/ +} + diff --git a/Client/src/item_conduct.cpp b/Client/src/item_conduct.cpp index 9f46810..e203b2f 100644 --- a/Client/src/item_conduct.cpp +++ b/Client/src/item_conduct.cpp @@ -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 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); + } +} + diff --git a/Client/src/item_exclusa.cpp b/Client/src/item_exclusa.cpp index d9c1a9b..39f2a88 100644 --- a/Client/src/item_exclusa.cpp +++ b/Client/src/item_exclusa.cpp @@ -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 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); + } +} + diff --git a/Client/src/item_union.cpp b/Client/src/item_union.cpp index b96c137..08bad4e 100644 --- a/Client/src/item_union.cpp +++ b/Client/src/item_union.cpp @@ -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 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); + } +} + diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index d5959a9..0ec83bb 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -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::iterator i; + for(i=mapItems.begin(); i!=mapItems.end(); i++) { + i->second->queue_draw(); + } + } void Principal::on_conexion_connected()