]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/workplace.cpp
11a98d1a3b54f5e15679871a0d4b33c3a2873f33
[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 }
6
7 bool WorkPlace::on_expose_event(GdkEventExpose *e)
8 {
9         int x, y;
10         for(x=0; x<get_width(); x+=32) 
11                 for (y=0; y<get_height();y+=32){
12                         get_window()->draw_point (get_style()->get_black_gc(), x,y);
13                         get_window()->draw_point (get_style()->get_black_gc(), x,y+1);
14                         get_window()->draw_point (get_style()->get_black_gc(), x,y-1);
15                         get_window()->draw_point (get_style()->get_black_gc(), x+1,y);
16                         get_window()->draw_point (get_style()->get_black_gc(), x-1,y);
17                 }
18         //TODO recorer la lista_lineas y dibujar todas          
19         get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);     
20         return true;
21 }
22
23
24 bool WorkPlace::on_button_press_event(GdkEventButton *event)
25 {
26         std::cout<< temp.x<<"    "<<temp.y<< std::endl;
27         if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
28                 get_pointer(temp.x,temp.y);
29                 std::cout<< temp.x<<"    "<<temp.y<< std::endl;
30         }
31         return true;
32 }
33
34 bool WorkPlace::on_button_release_event(GdkEventButton *event)
35 {
36         if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) {
37                 get_pointer(temp.w,temp.z);     
38                 lista_lineas.push_back(temp);
39                 get_window()->draw_line (get_style()->get_black_gc(), temp.x,temp.y,temp.w,temp.z);
40         }
41         return true;
42 }
43
44 void WorkPlace::delete_item(int _id)
45 {
46         std::list<CItem*>::iterator i = listaItems->begin();
47         while ( i != listaItems->end() ){
48         CItem *temp = *i;
49                 if ( temp->get_id() == _id ){
50                         listaItems->erase(i);
51                         delete temp;
52                         break;
53                 }
54                 i++;
55         }
56 }