2 #include "cisternptywnd.h"
6 imageE = Gdk::Pixbuf::create_from_file("tanque_e.png");
7 imageO = Gdk::Pixbuf::create_from_file("tanque_o.png");
8 null = Gdk::Pixbuf::create_from_file("tanque_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", "cistern_pty_wnd");
14 ref->get_widget_derived("cistern_pty_wnd",cistern_pty_wnd);
15 cistern_pty_wnd->cistern = this;
16 cistern_pty_wnd->set_title("Propiedades del Tanque");
23 bool Cistern::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 cistern_pty_wnd->spin_capacidad->set_value( capacidad );
51 cistern_pty_wnd->spin_inicial->set_value( contenido_inicial );
52 cistern_pty_wnd->txt_cistern_name->set_text( name );
53 cistern_pty_wnd->show();
58 void Cistern::on_menu_popup_rotar()
61 event.type = GDK_BUTTON_PRESS;
63 Cistern::on_button_press_event(&event);
66 void Cistern::on_menu_popup_propiedades()
69 event.type = GDK_2BUTTON_PRESS;
71 Cistern::on_button_press_event(&event);
74 void Cistern::set_capacidad(double _cap)
79 double Cistern::get_capacidad()
84 void Cistern::set_contenido_inicial(double _ini)
86 contenido_inicial = _ini;
89 double Cistern::get_contenido_inicial()
91 return contenido_inicial;
94 void Cistern::save(FILE *archivo)
96 char c_id[50], c_cap[50], c_x[50], c_y[50], c_img[50], c_ini[50];
97 sprintf(c_x,"\t\t<x>%d</x>\n",x);
98 sprintf(c_y,"\t\t<y>%d</y>\n",y);
99 sprintf(c_id,"%d",ID);
100 sprintf(c_cap,"\t\t<capacidad>%.2f</capacidad>\n", capacidad);
101 sprintf(c_ini,"\t\t<inicial>%.2f</inicial>\n", contenido_inicial);
102 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
104 dato = "\t<tanque nombre=\""+name+"\" id=\"";
112 dato += "\t</tanque>\n";
113 fprintf(archivo,dato.c_str());
116 bool Cistern::check_connection()
118 switch (get_img_actual()) {
120 if ( is_other_occupied_area( get_position_x()+get_image()->get_width()+10 , get_position_y()+get_image()->get_height() -10) )
124 if ( is_other_occupied_area( get_position_x() -10, get_position_y()+get_image()->get_height()-10) )