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;
23 bool Exclusa::on_button_press_event(GdkEventButton *event)
26 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1))
27 combo_entry->set_text(name);
29 if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
31 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);
41 get_size_request(w, h);
42 set_size_request(h, w);
43 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);
45 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
46 menu_popup.popup(event->button, event->time);
47 return true; //It has been handled.
50 if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
51 exclusa_pty_wnd->txt_exclusa_name->set_text( name);
52 if (estado) exclusa_pty_wnd->rd_btn_open->set_active(true);
53 exclusa_pty_wnd->show();
58 void Exclusa::set_estado(bool _state)
63 bool Exclusa::get_estado()
68 void Exclusa::on_menu_popup_rotar()
71 event.type = GDK_BUTTON_PRESS;
73 Exclusa::on_button_press_event(&event);
76 void Exclusa::on_menu_popup_propiedades()
79 event.type = GDK_2BUTTON_PRESS;
81 Exclusa::on_button_press_event(&event);
84 void Exclusa::save(FILE *archivo)
86 char c_id[50], c_est[50], c_x[50], c_y[50], c_img[50];
88 sprintf(c_x,"\t\t<x>%d</x>\n",x);
89 sprintf(c_y,"\t\t<y>%d</y>\n",y);
90 sprintf(c_id,"%d",ID);
93 sprintf(c_est,"\t\t<estado>%d</estado>\n", est);
94 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
96 dato = "\t<exclusa nombre=\""+name+"\" id=\"";
103 dato += "\t</exclusa>\n";
104 fprintf(archivo,dato.c_str());
107 bool Exclusa::check_connection()
109 switch (get_img_actual()) {
111 if ( is_other_connection_area( get_position_x()+get_image()->get_width()+5, get_position_y()+16) &&
112 is_other_connection_area( get_position_x()-5, get_position_y() + 16) )
116 if ( is_other_connection_area( get_position_x()+16, get_position_y()-5 ) &&
117 is_other_connection_area( get_position_x()+16, get_position_y()+get_image()->get_height()+5) )
123 bool Exclusa::is_connection_area(int _a, int _b)
127 if ( ((_a <= x+10 )&&(_a > 0) && (_b <= y+image->get_height()-10) &&(_b >= y+10 )) ||
128 ((_a <= x+image->get_width()-1)&&(_a >= x+image->get_width()-10) && (_b <= y+image->get_height()-10) &&(_b >= y +10 )) )
131 if ( ((_a <= x+image->get_width()-10 )&&(_a >= x + 10) && (_b <= y+10) &&(_b > 0 )) ||
132 ((_a <= x+22 )&&(_a >= x + 10) && (_b <= y+image->get_height()-1) &&(_b >= y+image->get_height()-10 )) )