From: Nicolás Dimov Date: Mon, 24 Nov 2003 03:55:12 +0000 (+0000) Subject: -Se carga la lista de items al ir haciendo click sobre ellos X-Git-Tag: svn_import~184 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/ea7708f0d91b00a54cc5f136a67e9f9bd272329d?ds=sidebyside -Se carga la lista de items al ir haciendo click sobre ellos -Se corrige una huevada cuando se dibujan los conectores logicos -No se por que cuando un item rota se borran los conectores -No se que mas cambie --- diff --git a/Constructor/dialogs/constructor.glade b/Constructor/dialogs/constructor.glade index e64fc7e..1dd2fd1 100644 --- a/Constructor/dialogs/constructor.glade +++ b/Constructor/dialogs/constructor.glade @@ -221,7 +221,7 @@ - + True False True @@ -230,7 +230,7 @@ False - + True True True diff --git a/Constructor/include/constructor.h b/Constructor/include/constructor.h index 9e4fac2..a9c1cbf 100644 --- a/Constructor/include/constructor.h +++ b/Constructor/include/constructor.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "workplace.h" #include "item.h" #include "splitter.h" @@ -42,13 +42,14 @@ class Constructor : public Gtk::Window { Gtk::ImageMenuItem *main_menu_quit,*main_menu_new, *edit_menu_del, *edit_menu_delete_all, *main_menu_save, *main_menu_open; Gtk::CheckButton *chk_btn_logica; Gtk::FileSelection *file_selection, *file_open_selection; - Gtk::Entry *combo_entry; + Gtk::Combo *combo_entry; Gtk::Dialog *dlg_connect; Gtk::Label *dlg_label; Glib::RefPtr ico_canio, ico_y, ico_codo, ico_tanque, ico_bomba, ico_exclusa, ico_drain, ico_and, ico_or, ico_not; Glib::RefPtr ico_last; std::list listTargets; std::list listaItems, lista_logic_Items; + std::list list_pointed; WorkPlace *workplace; bool logica; bool can_drop(CItem *, int , int); diff --git a/Constructor/include/item.h b/Constructor/include/item.h index 83aa0b2..d0ed613 100644 --- a/Constructor/include/item.h +++ b/Constructor/include/item.h @@ -127,7 +127,7 @@ public: WorkPlace *workplace; ///Puntero al cuadro de texto de la ventana principal - Gtk::Entry *combo_entry; + Gtk::Combo *combo_entry; ///Puntero a la lista de items std::list *listaItems; @@ -163,6 +163,9 @@ public: std::vector connect_vec; void set_img_actual(int i) { imgActual = i; } + + ///Puntero al cuadro de texo de la ventana principal. + std::list *list_pointed; protected: ///Indica el numero que le corresponde a la imagen actual del item. int imgActual; @@ -172,6 +175,8 @@ protected: Glib::RefPtr gc; + Gdk::Color blue, red; + ///Nombre del item Glib::ustring name; @@ -193,8 +198,6 @@ protected: ///Puntero a la ventana de propiedades del item ItemPtyWnd *property_wnd; - Gdk::Color blue, red; - ///Posicion del item en el area de trabajo int x, y; diff --git a/Constructor/src/and.cpp b/Constructor/src/and.cpp index 4e0534e..2862eaa 100644 --- a/Constructor/src/and.cpp +++ b/Constructor/src/and.cpp @@ -29,8 +29,10 @@ bool And::on_button_press_event(GdkEventButton *event) CItem::gate_id = ID; WorkPlace::pointed = ID; } - combo_entry->set_text(name); - + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); } if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){ diff --git a/Constructor/src/cistern.cpp b/Constructor/src/cistern.cpp index 147cc5b..f58df18 100644 --- a/Constructor/src/cistern.cpp +++ b/Constructor/src/cistern.cpp @@ -44,7 +44,9 @@ bool Cistern::on_button_press_event(GdkEventButton *event) GdkEventExpose e; t_line tmp_line; if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); WorkPlace::pointed = ID; if (CItem::logic_connect && CItem::gate_id != -1) { if ( detect_click_position((int)event->x, (int)event->y) == IN ){ @@ -258,13 +260,13 @@ void Cistern::update_logic_position() { switch (imgActual) { case 1: - in_x = x + image->get_width(); + in_x = x + image->get_width()-5; in_y = y + 16; out_x = x+16; out_y = y + image->get_height(); break; case 0: - in_x = x; + in_x = x+5; in_y = y+16; out_x = x + image->get_width() -16; out_y = y + image->get_height(); diff --git a/Constructor/src/conduct.cpp b/Constructor/src/conduct.cpp index b4c911c..c6dd074 100644 --- a/Constructor/src/conduct.cpp +++ b/Constructor/src/conduct.cpp @@ -32,8 +32,11 @@ Conduct::~Conduct() bool Conduct::on_button_press_event(GdkEventButton *event) { if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); WorkPlace::pointed = ID; + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); } if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){ diff --git a/Constructor/src/constructor.cpp b/Constructor/src/constructor.cpp index 6cc741b..21bdbca 100644 --- a/Constructor/src/constructor.cpp +++ b/Constructor/src/constructor.cpp @@ -278,6 +278,8 @@ void Constructor::on_load_from_xml() current->workplace= workplace; //Apunto a la lista. current->combo_entry = combo_entry; + //Apunto a la lista de apuntados + current->list_pointed = &list_pointed; //Apunto a la listaItems. current->listaItems = &listaItems; //Apunto a la lista de items logicos @@ -363,13 +365,21 @@ void Constructor::on_btn_find_clicked() CItem * temp = NULL; std::list::iterator i = listaItems.begin(); while ( i !=listaItems.end() ) { - if ( (*i)->get_name() == combo_entry->get_text() ) { + if ( (*i)->get_name() == combo_entry->get_entry()->get_text() ) { temp = *i; break; } i++; } + i = lista_logic_Items.begin(); + while ( i !=lista_logic_Items.end() ) { + if ( (*i)->get_name() == combo_entry->get_entry()->get_text() ) { + temp = *i; + break; + } + i++; + } if ( temp != NULL ) workplace->get_window()->draw_rectangle(workplace->get_style()->get_black_gc(), false , temp->get_position_x()-5, temp->get_position_y()-5, temp->get_image()->get_width()+10, temp->get_image()->get_height()+10); @@ -519,9 +529,11 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtrput(*a, i*32, j*32); //Apunto al workplace - a->workplace= workplace; + a->workplace = workplace; //Apunto a la lista. a->combo_entry = combo_entry; + //Apunto a la lista de apuntados + a->list_pointed = &list_pointed; //Apunto a la listaItems. a->listaItems = &listaItems; //Apunto a la lista de items logicos diff --git a/Constructor/src/drain.cpp b/Constructor/src/drain.cpp index 202c6f3..3154ded 100644 --- a/Constructor/src/drain.cpp +++ b/Constructor/src/drain.cpp @@ -42,7 +42,10 @@ Drain::~Drain() bool Drain::on_button_press_event(GdkEventButton *event) { if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); WorkPlace::pointed = ID; } diff --git a/Constructor/src/exclusa.cpp b/Constructor/src/exclusa.cpp index 7c70848..b0210f2 100644 --- a/Constructor/src/exclusa.cpp +++ b/Constructor/src/exclusa.cpp @@ -41,7 +41,9 @@ bool Exclusa::on_button_press_event(GdkEventButton *event) { t_line tmp_line; if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); WorkPlace::pointed = ID; if (CItem::logic_connect && CItem::gate_id != -1) { if ( detect_click_position((int)event->x, (int)event->y) == IN) { @@ -253,10 +255,10 @@ void Exclusa::update_logic_position() { switch (imgActual) { case 1: - in_x = x + image->get_width(); - in_y = y + image->get_height()/2; - out_x = x; - out_y = in_y; + in_x = x + image->get_width()-5; + in_y = y + image->get_height()/2-5; + out_x = x+5; + out_y = in_y+10; break; case 0: in_x = x + image->get_width()/2; diff --git a/Constructor/src/not.cpp b/Constructor/src/not.cpp index 463a91a..0a7c8c7 100644 --- a/Constructor/src/not.cpp +++ b/Constructor/src/not.cpp @@ -30,7 +30,10 @@ bool Not::on_button_press_event(GdkEventButton *event) CItem::gate_id = ID; WorkPlace::pointed = ID; } - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); } if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){ diff --git a/Constructor/src/or.cpp b/Constructor/src/or.cpp index fbd2152..d7e8a78 100644 --- a/Constructor/src/or.cpp +++ b/Constructor/src/or.cpp @@ -28,8 +28,11 @@ bool Or::on_button_press_event(GdkEventButton *event) if ( CItem::logic_connect ) { CItem::gate_id = ID; WorkPlace::pointed = ID; + workplace->queue_draw(); } - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); } if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){ diff --git a/Constructor/src/pump.cpp b/Constructor/src/pump.cpp index 26a2841..48435cc 100644 --- a/Constructor/src/pump.cpp +++ b/Constructor/src/pump.cpp @@ -41,7 +41,9 @@ bool Pump::on_button_press_event(GdkEventButton *event) { t_line tmp_line; if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); WorkPlace::pointed = ID; if (CItem::logic_connect && CItem::gate_id != -1) { if ( detect_click_position((int)event->x, (int)event->y) == IN) { diff --git a/Constructor/src/splitter.cpp b/Constructor/src/splitter.cpp index d0dc063..6cd6b3c 100644 --- a/Constructor/src/splitter.cpp +++ b/Constructor/src/splitter.cpp @@ -40,7 +40,10 @@ Splitter::~Splitter() bool Splitter::on_button_press_event(GdkEventButton *event) { if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); WorkPlace::pointed = ID; } diff --git a/Constructor/src/union.cpp b/Constructor/src/union.cpp index 61e5838..3e98e6d 100644 --- a/Constructor/src/union.cpp +++ b/Constructor/src/union.cpp @@ -45,7 +45,10 @@ Union::~Union() bool Union::on_button_press_event(GdkEventButton *event) { if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 1)) { - combo_entry->set_text(name); + list_pointed->push_back(name); + combo_entry->set_popdown_strings(*list_pointed); + combo_entry->get_entry()->set_text (name); + workplace->queue_draw(); WorkPlace::pointed = ID; } diff --git a/Constructor/src/workplace.cpp b/Constructor/src/workplace.cpp index fd9b898..94e3934 100644 --- a/Constructor/src/workplace.cpp +++ b/Constructor/src/workplace.cpp @@ -26,6 +26,7 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) if ( *logica ) { std::list::iterator j = listaItems->begin(); while ( j != listaItems->end() ) { + (*j)->update_logic_position(); (*j)->draw_connectors(); j++; } @@ -167,4 +168,3 @@ void WorkPlace::draw_line(int x1, int y1, int x2, int y2) get_window()->draw_line (get_style()->get_black_gc(), x1, y1, x1, y2); get_window()->draw_line (get_style()->get_black_gc(), x1, y2, x2, y2); } -