2 #include "view_btree.h"
3 #include "view_btree_data.h"
4 #include <sigc++/slot.h>
6 double ViewBTree::byte_to_pixels = 0;
7 double ViewBTree::node_width = 0;
8 double ViewBTree::node_height = 0;
10 ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename, uint block_size, int tree_type, int type):Canvas::Group (*parent, 0, 0),
11 BTree (filename, block_size, tree_type, type)
13 /* Cada bytes lo hago de 5 units de ancho */
14 node_width = 4 * block_size;
16 byte_to_pixels = node_width/block_size;
22 void ViewBTree::GoBack ()
31 void ViewBTree::AddNode (uint num, uint padre)
33 /* Hack de ultima hora :P */
35 /* evito quedar en circulo :D */
36 back.push (last_visited);
40 uchar *node = ReadBlock (num);
42 BTreeNodeHeader node_h;
43 ReadNodoHeader (node, &node_h);
45 std::list<BTreeData *> keys = ReadKeys (node, node_h);
47 ViewNode *vnode = new ViewNode (this, num, padre, node_h, keys);
48 vnode->property_y () = 10;
49 vnode->property_x () = 10;
51 vnode->signal_selected().connect ( sigc::mem_fun (*this, &ViewBTree::on_item_selected) );
52 vnode->signal_activated().connect ( sigc::mem_fun (*this, &ViewBTree::on_item_activated) );
54 last_selected = vnode;
57 void ViewBTree::on_item_activated (BTreeData *data, uint num, ViewNode *vnode)
61 uint next = data->GetChild ();
64 std::cout << next << std::endl;
68 void ViewBTree::on_item_selected (BTreeData *data, uint num, ViewNode *vnode)
70 BTreeNodeHeader node_h;
73 node = ReadBlock (num);
74 ReadNodoHeader (node, &node_h);
78 if (vnode != last_selected)
79 last_selected->SetSelected (false);
80 last_selected = vnode;
82 m_signal_selected (data, node_h);
85 ViewBTree::type_signal_selected ViewBTree::signal_selected ()
87 return m_signal_selected;
90 void ViewBTree::Clear ()
96 void ViewBTree::HighliteKey (Clave &k)
98 last_selected->HighliteKey (k);