From 34fb46485db0fb44f8dcc532866d988f8e54caa2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicol=C3=A1s=20Dimov?= Date: Thu, 13 Nov 2003 20:56:13 +0000 Subject: [PATCH] Luca, si podes lleva esto, no creo que termine nada mas hoy --- Constructor/activezone.cpp | 21 +++++++++++++++------ Constructor/activezone.h | 8 +++----- Constructor/constructor.cpp | 13 +++++++++++-- Constructor/constructor.glade | 1 + Constructor/item.h | 2 +- Constructor/workplace.cpp | 16 +++++++--------- Constructor/workplace.h | 2 +- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Constructor/activezone.cpp b/Constructor/activezone.cpp index ee426b0..f23eefc 100644 --- a/Constructor/activezone.cpp +++ b/Constructor/activezone.cpp @@ -1,7 +1,9 @@ #include "activezone.h" +#include "workplace.h" ActiveZone::ActiveZone(BaseObjectType* cobject, const Glib::RefPtr &refGlade):Gtk::Viewport(cobject) { + cant_click=1; } ActiveZone::~ActiveZone() @@ -11,12 +13,19 @@ ActiveZone::~ActiveZone() bool ActiveZone::on_button_press_event(GdkEventButton *event) { if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) { - get_pointer(temp.x,temp.y); + if (cant_click ==2) { + get_pointer(temp.w, temp.z); + cant_click--; + workplace->lista_lineas.push_back(temp); + workplace->get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z); + } + } + + if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) { + if (cant_click == 1) { + get_pointer(temp.x,temp.y); + cant_click++; + } } - return true; -} - -bool ActiveZone::on_button_release_event(GdkEventButton *event) -{ return true; } diff --git a/Constructor/activezone.h b/Constructor/activezone.h index b2a2413..d4f468f 100644 --- a/Constructor/activezone.h +++ b/Constructor/activezone.h @@ -4,22 +4,20 @@ #include #include #include -#include "workplace.h" + +class WorkPlace; typedef struct { int x,y,w,z; }t_line; -class WorkPlace; - class ActiveZone:public Gtk::Viewport { public: ActiveZone(BaseObjectType* cobject, const Glib::RefPtr &refGlade); virtual ~ActiveZone(); virtual bool on_button_press_event(GdkEventButton *e); - virtual bool on_button_release_event(GdkEventButton *e); t_line temp; - std::list lista_lineas; + int cant_click; WorkPlace *workplace; }; #endif diff --git a/Constructor/constructor.cpp b/Constructor/constructor.cpp index 0278ec0..deb918d 100644 --- a/Constructor/constructor.cpp +++ b/Constructor/constructor.cpp @@ -162,8 +162,17 @@ void Constructor::on_main_menu_save() } void Constructor::on_edit_menu_del() -{ - // hay que meter algo aca. +{ // OJO que borra al primero que encuentra con el mismo nombre!!! + std::list::iterator i = listaItems.begin(); + Glib::ustring pointed = combo_entry->get_text(); + while ( i != listaItems.end() ){ + CItem *temp = *i; + if ( temp->get_name() == pointed ){ + workplace->delete_item(temp->get_id()); + break; + } + i++; + } } void Constructor::on_chk_btn_clicked() diff --git a/Constructor/constructor.glade b/Constructor/constructor.glade index 81fb82d..cf1bea9 100644 --- a/Constructor/constructor.glade +++ b/Constructor/constructor.glade @@ -542,6 +542,7 @@ 0 False False + GTK_PACK_END diff --git a/Constructor/item.h b/Constructor/item.h index cf9b714..7c1e771 100644 --- a/Constructor/item.h +++ b/Constructor/item.h @@ -30,6 +30,7 @@ public: int get_conector_in(); int get_conector_out(); int get_img_actual(); + Glib::ustring get_name(); double get_caudal(); void set_position(int _x, int _y); void set_id(int _id); @@ -42,7 +43,6 @@ public: virtual void save(FILE *archivo) = 0; virtual bool check_connection()=0; virtual bool is_connection_area(int _a, int _b)=0; - Glib::ustring get_name(); WorkPlace *workplace; Gtk::Entry *combo_entry; std::list *listaItems; diff --git a/Constructor/workplace.cpp b/Constructor/workplace.cpp index 418f6b7..1e7ceab 100644 --- a/Constructor/workplace.cpp +++ b/Constructor/workplace.cpp @@ -21,15 +21,13 @@ bool WorkPlace::on_expose_event(GdkEventExpose *event) get_window()->draw_point (get_style()->get_black_gc(), x+1,y); get_window()->draw_point (get_style()->get_black_gc(), x-1,y); } - return true; -} - -bool WorkPlace::on_button_press_event(GdkEventButton *event) -{ - if ((event->type==GDK_BUTTON_RELEASE) && (event->button ==1)) { - get_pointer(viewport->temp.w, viewport->temp.z); - get_window()->draw_line (get_style()->get_black_gc(), viewport->temp.x,viewport->temp.y,viewport->temp.w,viewport->temp.z); - } + +/* std::list::iterator i = lista_lineas.begin(); + while ( i != lista_lineas.end() ) { + t_line temp = *i; + get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z); + i++; + }*/ return true; } diff --git a/Constructor/workplace.h b/Constructor/workplace.h index 0677da3..c3e2901 100644 --- a/Constructor/workplace.h +++ b/Constructor/workplace.h @@ -16,9 +16,9 @@ class WorkPlace:public Gtk::Fixed { WorkPlace(BaseObjectType* cobject, const Glib::RefPtr &refGlade); virtual ~WorkPlace(); virtual bool on_expose_event(GdkEventExpose *event); - virtual bool on_button_press_event (GdkEventButton *event); void delete_item(int _id); std::list *listaItems; + std::list lista_lineas; ActiveZone *viewport; }; -- 2.43.0