10 imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/and_n.png");
11 imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/and_s.png");
12 imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/and_e.png");
13 imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/and_o.png");
14 null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
17 set_size_request(image->get_width(), image->get_height());
19 menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Conectar", menu_image_linea,SigC::slot(*this, &CItem::on_menu_popup_conectar) ) ) ;
26 bool And::on_button_press_event(GdkEventButton *event)
28 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
29 if ( CItem::logic_connect ) {
30 if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected) {
32 WorkPlace::pointed = ID;
34 if ( detect_click_position((int)event->x, (int)event->y ) == IN ) {
36 WorkPlace::pointed = ID;
39 list_pointed->push_back(name);
40 combo_entry->set_popdown_strings(*list_pointed);
41 combo_entry->get_entry()->set_text (name);
42 workplace->queue_draw();
45 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
47 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);
79 set_size_request(image->get_width(),image->get_height());
80 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);
82 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
83 menu_popup.popup(event->button, event->time);
84 return true; //It has been handled.
86 workplace->queue_draw();
89 void And::on_menu_popup_rotar()
92 event.type = GDK_BUTTON_PRESS;
94 And::on_button_press_event(&event);
97 void And::save(FILE *archivo)
99 vec_connector.clear();
102 char c_img[50], c_x[50], c_y[50], c_id[50];
103 sprintf(c_id,"%d",ID);
104 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
105 sprintf(c_x,"\t\t<x>%d</x>\n",x);
106 sprintf(c_y,"\t\t<y>%d</y>\n",y);
107 dato = "\t<and nombre=\""+name+"\" id=\"";
113 for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
114 if ( vec_connector[i].type == IN ) {
115 dato += "\t\t<entrada>";
116 dato += vec_connector[i].name_dest + "</entrada>\n";
118 dato += "\t\t<salida>";
119 dato += vec_connector[i].name_dest + "</salida>\n";
122 dato += "\t</and>\n";
123 fprintf(archivo, dato.c_str() );
126 bool And::check_connection()
128 int cant_in = 0, cant_out =0;
129 t_logic_connector temp;
130 std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
131 while ( i != workplace->lista_lineas_in.end() ) {
132 if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
134 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
135 vec_connector.push_back(temp);
141 i = workplace->lista_lineas_out.begin();
142 while ( i != workplace->lista_lineas_out.end() ) {
143 if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
145 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
146 vec_connector.push_back(temp);
151 return true; //out_connected;
154 ConnectorType And::detect_click_position(int _a, int _b)
158 if ( (_a<=32 )&&(_a>=22)&&(_b<=20)&&(_b>=10) )
160 if ( (_a<=10)&&(_a>=0)&&(_b<=20)&&(_b>=10) )
164 if ( (_a<=20 )&&(_a>=10)&&(_b<=32)&&(_b>=22) )
166 if ( (_a<=20)&&(_a>=10)&&(_b<=10)&&(_b>=0) )
170 if ( (_a<=10 )&&(_a>=0)&&(_b<=20)&&(_b>=10) )
172 if ( (_a<=32)&&(_a>=22)&&(_b<=20)&&(_b>=10) )
176 if ( (_a<=20 )&&(_a>=10)&&(_b<=10)&&(_b>=0) )
178 if ( (_a<=20)&&(_a>=10)&&(_b<=32)&&(_b>=22) )
184 void And::update_logic_position()
213 void And::get_in_logic_connect_position(int& _a, int& _b)
219 void And::get_out_logic_connect_position(int& _a, int& _b)
225 void And::set_out_connected(bool _o)