]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/src/workplace.cpp
* Se modifica la estructura de directorios : src include dialogs y pixmaps
[z.facultad/75.42/plaqui.git] / Constructor / src / workplace.cpp
1 #include "workplace.h"
2 #include "item.h"
3
4 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
5 {
6 }
7
8 WorkPlace::~WorkPlace()
9 {
10 }
11
12 bool WorkPlace::on_expose_event(GdkEventExpose *event)
13 {
14         int x, y;
15         for(x=0; x<get_width(); x+=32) 
16                 for (y=0; y<get_height();y+=32){
17                         get_window()->draw_point (get_style()->get_black_gc(), x,y);
18                         get_window()->draw_point (get_style()->get_black_gc(), x,y+1);
19                         get_window()->draw_point (get_style()->get_black_gc(), x,y-1);
20                         get_window()->draw_point (get_style()->get_black_gc(), x+1,y);
21                         get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
22                 }
23                 
24         
25         Glib::RefPtr<Gdk::GC> gc = get_style()->get_black_gc();
26         Gdk::Color color;
27         color.set_rgb(255,0,0);
28         gc->set_rgb_bg_color(color);
29         get_style()->set_black(color);
30         std::list<t_line>::iterator i = lista_lineas.begin();
31         while ( i != lista_lineas.end() ) {
32                 t_line temp = *i;
33                 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());
34                 i++;
35         }
36         return true;
37 }
38
39 void WorkPlace::delete_item(int _id)
40 {
41         std::list<CItem*>::iterator i = listaItems->begin();
42         while ( i != listaItems->end() ){
43         CItem *temp = *i;
44                 if ( temp->get_id() == _id ){
45                         delete_line(_id);
46                         listaItems->erase(i);
47                         delete temp;
48                         break;
49                 }
50                 i++;
51         }
52         i = lista_logic_Items->begin();
53         while ( i != lista_logic_Items->end() ){
54         CItem *temp = *i;
55                 if ( temp->get_id() == _id ){
56                         delete_line(_id);
57                         listaItems->erase(i);
58                         delete temp;
59                         break;
60                 }
61                 i++;
62         }
63         
64 }
65
66 CItem* WorkPlace::get_logic_item(int _id)
67 {
68         std::list<CItem *>::iterator i = lista_logic_Items->begin();
69         while ( i != lista_logic_Items->end() ){
70                 CItem *temp = *i;
71                 if ( temp->get_id() == _id ) 
72                         return temp;
73                 i++;
74         }
75         return NULL;
76 }
77
78 void WorkPlace::delete_line(int _id)
79 {
80         std::list<t_line>::iterator i = lista_lineas.begin();
81         while ( i != lista_lineas.end() ){
82                 if ( ((*i).logic->get_id() == _id) || ((*i).store->get_id() == _id) )
83                         lista_lineas.erase(i);
84                 i++;
85         }
86 }