]> git.llucax.com Git - z.facultad/75.52/treemulator.git/blob - viewer/view_btree_data.cpp
Agrega ABB (Altas, Bajas y Búsqueda ;) de claves al viewer.
[z.facultad/75.52/treemulator.git] / viewer / view_btree_data.cpp
1
2 #include "view_btree_data.h"
3 #define NODE_PTR_WIDTH 5
4
5 ViewBTreeData::ViewBTreeData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2):
6         Canvas::Rect (*parent, x1, y1, x2, y2)
7 {
8         this->data = data;
9         property_fill_color () = "red";
10         property_outline_color () = "black";
11 }
12
13 void ViewBTreeData::init (Canvas::Group *parent)
14 {
15         double w = property_x2() - property_x1();
16         double h = property_y2() - property_y1();
17
18         Canvas::Rect *ptr = new Canvas::Rect (*parent, property_x1()+w-NODE_PTR_WIDTH, h-NODE_PTR_WIDTH, property_x1()+w-1, h-1);
19         ptr->property_fill_color () = "green";
20         ptr->property_outline_color () = "black";
21 }
22                 
23 bool ViewBTreeData::on_event (GdkEvent *p1)
24 {
25         switch (p1->type) {
26                 case GDK_BUTTON_PRESS:
27                         m_signal_clicked(data, this);
28                 break;
29                 case GDK_2BUTTON_PRESS:
30                         m_signal_double_clicked (data, this);
31         }
32
33         return Canvas::Rect::on_event (p1);
34 }
35
36
37 ViewBTreeData::type_signal_clicked ViewBTreeData::signal_clicked ()
38 {
39         return m_signal_clicked;
40 }
41
42 ViewBTreeData::type_signal_double_clicked ViewBTreeData::signal_double_clicked ()
43 {
44         return m_signal_double_clicked;
45 }
46
47
48 ViewBTreeData*
49 ViewBTreeData::Create (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2)
50 {
51         ViewBTreeData *ret;
52         if (dynamic_cast<BTreeChildData *>(data))
53                 ret = new ViewBTreeChildData (data, parent, x1, y1, x2, y2);
54         else
55                 ret     = new ViewBTreeData (data, parent, x1, y1, x2, y2);
56         ret->init (parent);
57         return ret;
58 }
59
60 ViewBTreeChildData::ViewBTreeChildData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2):
61         ViewBTreeData (data, parent, x1, y1, x2, y2)
62 {
63 }
64
65 void ViewBTreeChildData::init (Canvas::Group *parent)
66 {
67         property_outline_color () = "black";
68 }
69
70 void ViewBTreeData::SetSelected (bool b)
71 {
72         if (b) {
73                 property_fill_color () = "yellow";
74         } else {
75                 property_fill_color () = "red";
76         }
77 }
78