]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/workplace.cpp
* Se agrega una exclusa al ejemplo a la salida de la bomba.
[z.facultad/75.42/plaqui.git] / Constructor / workplace.cpp
1 #include "workplace.h"
2
3 WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
4 {
5         refGlade->get_widget_derived("viewport",viewport);
6         this->signal_button_press_event().connect(SigC::slot(*this,&WorkPlace::on_button_press_event));
7 }
8
9 WorkPlace::~WorkPlace()
10 {
11 }
12
13 bool WorkPlace::on_expose_event(GdkEventExpose *event)
14 {
15         int x, y;
16         for(x=0; x<get_width(); x+=32) 
17                 for (y=0; y<get_height();y+=32){
18                         get_window()->draw_point (get_style()->get_black_gc(), x,y);
19                         get_window()->draw_point (get_style()->get_black_gc(), x,y+1);
20                         get_window()->draw_point (get_style()->get_black_gc(), x,y-1);
21                         get_window()->draw_point (get_style()->get_black_gc(), x+1,y);
22                         get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
23                 }
24         //TODO recorer la lista_lineas y dibujar todas          
25         get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
26         return true;
27 }
28
29
30 bool WorkPlace::on_button_press_event(GdkEventButton *event)
31 {
32         std::cout<< temp.x<<"    "<<temp.y<< std::endl;
33         if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
34                 get_pointer(temp.x,temp.y);
35                 std::cout<< temp.x<<"    "<<temp.y<< std::endl;
36         }
37         return true;
38 }
39
40 bool WorkPlace::on_button_release_event(GdkEventButton *event)
41 {
42         if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
43                 get_pointer(temp.w,temp.z);     
44                 lista_lineas.push_back(temp);
45                 get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
46         }
47         return true;
48 }
49
50 void WorkPlace::delete_item(int _id)
51 {
52         std::list<CItem*>::iterator i = listaItems->begin();
53         while ( i != listaItems->end() ){
54         CItem *temp = *i;
55                 if ( temp->get_id() == _id ){
56                         listaItems->erase(i);
57                         delete temp;
58                         break;
59                 }
60                 i++;
61         }
62 }