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 type):Canvas::Group (*parent, 0, 0),
11 BTree (filename, block_size, type)
13 /* Cada bytes lo hago de 5 units de ancho */
14 node_width = 5 * block_size;
15 node_height = node_width/10;
16 byte_to_pixels = node_width/block_size;
21 void ViewBTree::AddNode (uint num, uint padre)
23 uchar *node = ReadBlock (num);
25 BTreeNodeHeader node_h;
26 ReadNodoHeader (node, &node_h);
28 std::list<BTreeData *> keys = ReadKeys (node, node_h);
30 ViewNode *vnode = new ViewNode (this, num, padre, node_h, keys);
31 vnode->property_y () = 10;
32 vnode->property_x () = 10;
34 vnode->signal_selected().connect ( sigc::mem_fun (*this, &ViewBTree::on_item_selected) );
35 vnode->signal_activated().connect ( sigc::mem_fun (*this, &ViewBTree::on_item_activated) );
37 last_selected = vnode;
40 void ViewBTree::on_item_activated (BTreeData *data, uint num, ViewNode *vnode)
44 uint next = data->GetChild ();
47 std::cout << next << std::endl;
51 void ViewBTree::on_item_selected (BTreeData *data, uint num, ViewNode *vnode)
53 BTreeNodeHeader node_h;
56 node = ReadBlock (num);
57 ReadNodoHeader (node, &node_h);
61 if (vnode != last_selected)
62 last_selected->SetSelected (false);
63 last_selected = vnode;
64 vnode->SetSelected (true);
66 m_signal_selected (data, node_h);
69 ViewBTree::type_signal_selected ViewBTree::signal_selected ()
71 return m_signal_selected;