#include "workplace.h"
+#include "item.h"
WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
{
}
-bool WorkPlace::on_expose_event(GdkEventExpose *e)
+WorkPlace::~WorkPlace()
+{
+}
+
+bool WorkPlace::on_expose_event(GdkEventExpose *event)
{
int x, y;
for(x=0; x<get_width(); x+=32)
get_window()->draw_point (get_style()->get_black_gc(), x+1,y);
get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
}
- //TODO recorer la lista_lineas y dibujar todas
- get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
- return true;
-}
-
-
-bool WorkPlace::on_button_press_event(GdkEventButton *event)
-{
- std::cout<< temp.x<<" "<<temp.y<< std::endl;
- if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
- get_pointer(temp.x,temp.y);
- std::cout<< temp.x<<" "<<temp.y<< std::endl;
- }
- return true;
-}
-
-bool WorkPlace::on_button_release_event(GdkEventButton *event)
-{
- if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
- get_pointer(temp.w,temp.z);
- lista_lineas.push_back(temp);
- get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
+
+
+ Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
+ Gdk::Color color;
+ color.set_rgb(255,0,0);
+ gc->set_rgb_bg_color(color);
+ get_style()->set_black(color);
+ 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.logic->get_position_x(),temp.logic->get_position_y(), temp.store->get_position_x(),temp.store->get_position_y());
+ i++;
}
return true;
}
while ( i != listaItems->end() ){
CItem *temp = *i;
if ( temp->get_id() == _id ){
+ delete_line(_id);
+ listaItems->erase(i);
+ delete temp;
+ break;
+ }
+ i++;
+ }
+ i = lista_logic_Items->begin();
+ while ( i != lista_logic_Items->end() ){
+ CItem *temp = *i;
+ if ( temp->get_id() == _id ){
+ delete_line(_id);
listaItems->erase(i);
delete temp;
break;
}
i++;
}
+
+}
+
+CItem* WorkPlace::get_logic_item(int _id)
+{
+ std::list<CItem *>::iterator i = lista_logic_Items->begin();
+ while ( i != lista_logic_Items->end() ){
+ CItem *temp = *i;
+ if ( temp->get_id() == _id )
+ return temp;
+ i++;
+ }
+ return NULL;
+}
+
+void WorkPlace::delete_line(int _id)
+{
+ std::list<t_line>::iterator i = lista_lineas.begin();
+ while ( i != lista_lineas.end() ){
+ if ( (*i).logic->get_id() == _id || (*i).store->get_id == _id)
+ lista_lineas.erase(i);
+ i++;
+ }
}