#include "activezone.h"
+#include "workplace.h"
ActiveZone::ActiveZone(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Viewport(cobject)
{
+ cant_click=1;
}
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;
}
#include <gtkmm.h>
#include <gtkmm/viewport.h>
#include <iostream>
-#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<Gnome::Glade::Xml> &refGlade);
virtual ~ActiveZone();
virtual bool on_button_press_event(GdkEventButton *e);
- virtual bool on_button_release_event(GdkEventButton *e);
t_line temp;
- std::list<t_line> lista_lineas;
+ int cant_click;
WorkPlace *workplace;
};
#endif
}
void Constructor::on_edit_menu_del()
-{
- // hay que meter algo aca.
+{ // OJO que borra al primero que encuentra con el mismo nombre!!!
+ std::list<CItem *>::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()
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
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);
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<CItem *> *listaItems;
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<t_line>::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;
}
WorkPlace(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &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<CItem *> *listaItems;
+ std::list<t_line> lista_lineas;
ActiveZone *viewport;
};