2 #include "pumpptywnd.h"
6 imageE = Gdk::Pixbuf::create_from_file("bomba_e.png");
7 imageO = Gdk::Pixbuf::create_from_file("bomba_o.png");
8 null = Gdk::Pixbuf::create_from_file("bomba_null.png");
11 set_size_request(image->get_width(), image->get_height());
13 Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create("constructor.glade", "pump_pty_wnd");
14 ref->get_widget_derived("pump_pty_wnd",pump_pty_wnd);
15 pump_pty_wnd->pump = this;
23 bool Pump::on_button_press_event(GdkEventButton *event)
25 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
26 combo_entry->set_text(name);
28 if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
30 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
40 set_size_request(image->get_width(),image->get_height());
41 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
44 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
45 menu_popup.popup(event->button, event->time);
46 return true; //It has been handled.
49 if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
50 pump_pty_wnd->spin_fluid->set_value( entrega );
51 pump_pty_wnd->txt_pump_name->set_text( name );
57 void Pump::on_menu_popup_rotar()
60 event.type = GDK_BUTTON_PRESS;
62 Pump::on_button_press_event(&event);
65 void Pump::on_menu_popup_propiedades()
68 event.type = GDK_2BUTTON_PRESS;
70 Pump::on_button_press_event(&event);
73 void Pump::set_entrega(double _ent)
78 void Pump::set_liquid_color(Gdk::Color _color)
80 liquid_color = _color;
83 double Pump::get_entrega()
88 Gdk::Color Pump::get_liquid_color()
93 void Pump::save(FILE *archivo)
95 char c_id[50], c_entrega[50], c_x[50], c_y[50], c_img[50], c_red[50], c_green[50], c_blue[50];
96 sprintf(c_red,"\t\t\t<rojo>%d</rojo>\n",liquid_color.get_red());
97 sprintf(c_green,"\t\t\t<verde>%d</verde>\n",liquid_color.get_green());
98 sprintf(c_blue,"\t\t\t<azul>%d</azul>\n",liquid_color.get_blue());
99 sprintf(c_x,"\t\t<x>%d</x>\n",x);
100 sprintf(c_y,"\t\t<y>%d</y>\n",y);
101 sprintf(c_id,"%d",ID);
102 sprintf(c_entrega,"\t\t<entrega>%.2f</entrega>\n", entrega);
103 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
105 dato = "\t<bomba nombre=\""+name+"\" id=\"";
109 dato += "\t<color>\n";
113 dato += "\t</color>\n";
117 dato += "\t</bomba>\n";
118 fprintf(archivo,dato.c_str());
121 bool Pump::check_connection()
123 switch (get_img_actual()) {
125 if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5 , get_position_y() +16) )
129 if ( is_other_connection_area( get_position_x() -5, get_position_y() +16) )
135 bool Pump::is_connection_area(int _a, int _b)
138 case 0: if ( (_a <= x+image->get_width()-1)&&(_a>=x+image->get_width()-10)&&(_b<=y+22)&&(_b > y) )
140 case 1: if ( (_a <= x+10)&&(_a > x)&&(_b<=y+22)&&(_b > y) )