3 Or::Or(int orientacion)
7 imageN = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/or_n.png");
8 imageS = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/or_s.png");
9 imageE = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/or_e.png");
10 imageO = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/or_o.png");
11 null = Gdk::Pixbuf::create_from_file(PACKAGE_DATA_DIR"/plaqui-constructor/pixmaps/null.png");
12 imgActual = orientacion;
43 set_size_request(image->get_width(), image->get_height());
45 menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Conectar", menu_image_linea,SigC::slot(*this, &CItem::on_menu_popup_conectar) ) ) ;
52 bool Or::on_button_press_event(GdkEventButton *event)
54 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) {
55 if ( CItem::logic_connect ) {
56 if ( detect_click_position((int)event->x, (int)event->y ) == OUT && !out_connected) {
58 WorkPlace::pointed = ID;
60 if ( detect_click_position((int)event->x, (int)event->y ) == IN ) {
62 WorkPlace::pointed = ID;
65 list_pointed->push_back(name);
66 combo_entry->set_popdown_strings(*list_pointed);
67 combo_entry->get_entry()->set_text (name);
70 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
72 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);
104 set_size_request(image->get_width(),image->get_height());
105 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);
107 if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
108 menu_popup.popup(event->button, event->time);
109 return true; //It has been handled.
111 workplace->queue_draw();
115 void Or::on_menu_popup_rotar()
117 GdkEventButton event;
118 event.type = GDK_BUTTON_PRESS;
120 Or::on_button_press_event(&event);
123 void Or::save(FILE *archivo)
125 vec_connector.clear();
128 char c_img[50], c_x[50], c_y[50], c_id[50];
129 sprintf(c_id,"%d",ID);
130 sprintf(c_img,"\t\t<orientacion>%d</orientacion>\n",imgActual);
131 sprintf(c_x,"\t\t<x>%d</x>\n",x);
132 sprintf(c_y,"\t\t<y>%d</y>\n",y);
133 dato = "\t<or nombre=\""+name+"\" id=\"";
139 for ( int i=0; i<=vec_connector.size()-1&&!vec_connector.empty(); i++) {
140 if ( vec_connector[i].type == IN ) {
141 dato += "\t\t<entrada>";
142 dato += vec_connector[i].name_dest + "</entrada>\n";
144 dato += "\t\t<salida>";
145 dato += vec_connector[i].name_dest + "</salida>\n";
149 fprintf(archivo, dato.c_str() );
152 bool Or::check_connection()
154 int cant_in = 0, cant_out =0;
155 t_logic_connector temp;
156 std::list<t_line>::iterator i = workplace->lista_lineas_in.begin();
157 while ( i != workplace->lista_lineas_in.end() ) {
158 if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
160 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
161 vec_connector.push_back(temp);
167 i = workplace->lista_lineas_out.begin();
168 while ( i != workplace->lista_lineas_out.end() ) {
169 if ( workplace->get_logic_item((*i).logic_id)->get_id() == ID ) {
171 temp.name_dest = workplace->get_item((*i).store_id)->get_name();
172 vec_connector.push_back(temp);
179 return true;// out_connected;
182 ConnectorType Or::detect_click_position(int _a, int _b)
186 if ( (_a<=32 )&&(_a>=22)&&(_b<=20)&&(_b>=10) )
188 if ( (_a<=10)&&(_a>=0)&&(_b<=20)&&(_b>=10) )
192 if ( (_a<=20 )&&(_a>=10)&&(_b<=32)&&(_b>=22) )
194 if ( (_a<=20)&&(_a>=10)&&(_b<=10)&&(_b>=0) )
198 if ( (_a<=10 )&&(_a>=0)&&(_b<=20)&&(_b>=10) )
200 if ( (_a<=32)&&(_a>=22)&&(_b<=20)&&(_b>=10) )
204 if ( (_a<=20 )&&(_a>=10)&&(_b<=10)&&(_b>=0) )
206 if ( (_a<=20)&&(_a>=10)&&(_b<=32)&&(_b>=22) )
212 void Or::update_logic_position()
241 void Or::get_in_logic_connect_position(int& _a, int& _b)
247 void Or::get_out_logic_connect_position(int& _a, int& _b)
253 void Or::set_out_connected(bool _o)