2 #include "exclusaptywnd.h"
6 imageN = Gdk::Pixbuf::create_from_file("exclusa_h.png");
7 imageS = Gdk::Pixbuf::create_from_file("exclusa_s.png");
8 null = Gdk::Pixbuf::create_from_file("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", "exclusa_pty_wnd");
14 ref->get_widget_derived("exclusa_pty_wnd",exclusa_pty_wnd);
15 exclusa_pty_wnd->exclusa = this;
21 connect_vec.push_back(temp);
22 connect_vec.push_back(temp);
29 bool Exclusa::on_button_press_event(GdkEventButton *event)
32 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
33 combo_entry->set_text(name);
35 if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
37 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);
47 get_size_request(w, h);
48 set_size_request(h, w);
49 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);
51 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
52 menu_popup.popup(event->button, event->time);
53 return true; //It has been handled.
56 if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
57 exclusa_pty_wnd->txt_exclusa_name->set_text( name);
58 if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
59 exclusa_pty_wnd->show();
64 void Exclusa::set_estado(bool _state)
69 bool Exclusa::get_estado()
74 void Exclusa::on_menu_popup_rotar()
77 event.type = GDK_BUTTON_PRESS;
79 Exclusa::on_button_press_event(&event);
82 void Exclusa::on_menu_popup_propiedades()
85 event.type = GDK_2BUTTON_PRESS;
87 Exclusa::on_button_press_event(&event);
90 void Exclusa::save(FILE *archivo)
92 char c_id[50], c_est[50], c_x[50], c_y[50], c_img[50];
94 sprintf(c_x,"\t\t<x>%d</x>\n",x);
95 sprintf(c_y,"\t\t<y>%d</y>\n",y);
96 sprintf(c_id,"%d",ID);
99 sprintf(c_est,"\t\t<estado>%d</estado>\n", est);
100 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
102 dato = "\t<exclusa nombre=\""+name+"\" id=\"";
109 dato += "\t</exclusa>\n";
110 fprintf(archivo,dato.c_str());
113 bool Exclusa::check_connection()
115 switch (get_img_actual()) {
117 connect_vec[0].type = is_other_connection_area( get_position_x()+16, get_position_y()-5);
118 connect_vec[1].type = is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height() +5);
121 connect_vec[0].type = is_other_connection_area( get_position_x()-5, get_position_y()+16);
122 connect_vec[1].type = is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16);
124 if ( connect_vec[0].type != UNDEF && connect_vec[1].type != UNDEF )
125 return ( is_connected = (connect_vec[0].type != connect_vec[1].type) );
129 ConnectorType Exclusa::get_connector_type(int _a, int _b)
131 if ( ! is_connected ) {
134 if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
135 return is_other_connection_area(get_position_x()+16, get_position_y()+get_image()->get_height() +5); //pregunto que hay abajo
136 if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 ))//abajo
137 return is_other_connection_area( get_position_x()+16, get_position_y()-5);//pregunto que hay arriba.
140 if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
141 return is_other_connection_area(get_position_x()+get_image()->get_width()+5, get_position_y()+16);//pregunto por la derecha
142 if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
143 return is_other_connection_area(get_position_x()-5, get_position_y()+16); //pregunto por la izquierda.
148 if ( (_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 ) ) //arriba
149 return connect_vec[0].type;
150 if ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) //abajo
151 return connect_vec[1].type;
154 if ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) //izquierda
155 return connect_vec[0].type;
156 if ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) //derecha
157 return connect_vec[1].type;
163 void Exclusa::set_default_connector()
165 connect_vec[0].type = UNDEF;
166 connect_vec[1].type = UNDEF;