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);
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;
};
public:
ViewCodo(Glib::ustring _name, int orientacion);
virtual ~ViewCodo();
+ virtual bool on_image_expose_event(GdkEventExpose *e);
};
#endif
public:
ViewConduct(Glib::ustring _name, int orientacion);
virtual ~ViewConduct();
+ virtual bool on_image_expose_event(GdkEventExpose *e);
};
#endif
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
public:
ViewUnion(Glib::ustring _name, int orientacion);
virtual ~ViewUnion();
+ virtual bool on_image_expose_event(GdkEventExpose *e);
};
#endif
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()
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);
+}
+
case 3:
image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/codo_s.png");
}
+ m_or = orientacion;
image.show();
set_size_request();
}
{
}
+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);
+ }*/
+}
+
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();
}
{
}
+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);
+ }
+}
+
case 1:
image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/exclusa_s.png");
}
+ m_or = orientacion;
image.show();
set_size_request();
}
{
}
+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);
+ }
+}
+
case 3:
image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/y_o.png");
}
+ m_or = orientacion;
image.show();
set_size_request();
}
{
}
+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);
+ }
+}
+
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()