4 ViewNode::ViewNode (Canvas::Group *parent, uint num, uint padre, BTreeNodeHeader &header, std::list<BTreeData *> &keys)
5 : Canvas::Group (*parent)
8 double header_w = ViewBTree::byte_to_pixels * sizeof (BTreeNodeHeader);
13 int w1 = (int)(ViewBTree::node_width / 512.0f);
19 Canvas::Rect *h = new Canvas::Rect (*this, 0, 0, header_w, ViewBTree::node_height);
20 h->property_fill_color() = "blue";
21 h->property_outline_color() = "black";
28 new Canvas::Text (*this, header_w/2, ViewBTree::node_height/2, node_num);
33 std::list<BTreeData *>::iterator it = keys.begin ();
34 while (it != keys.end ()) {
35 BTreeData *data = (*it);
36 double w = ViewBTree::byte_to_pixels * data->Size ();
38 ViewBTreeData *v = ViewBTreeData::Create (data, this, x, y, w+x, y+ViewBTree::node_height);
39 v->signal_clicked ().connect ( sigc::mem_fun (this , &ViewNode::on_item_clicked ));
40 v->signal_double_clicked ().connect ( sigc::mem_fun (this , &ViewNode::on_item_activated ));
45 y += ViewBTree::node_height + 5;
51 if (!dynamic_cast<BTreeLeafData *>(data)) {
52 /* Si no es un dato de una hoja, tiene hijos */
53 hijos.push_back (data->GetChild ());
56 w1 = ViewBTree::node_width - used_width;
58 fondo = new Canvas::Rect (*this, x, y, x+w1, ViewBTree::node_height+y);
59 fondo->property_fill_color() = "gray";
60 fondo->property_outline_color() = "black";
64 void ViewNode::on_item_clicked (BTreeData *data, ViewBTreeData *s)
67 if (s != last_selected)
68 last_selected->SetSelected (false);
70 m_signal_selected (data, num, this);
73 void ViewNode::on_item_activated (BTreeData *data, ViewBTreeData *s)
75 /* Solo activo los que tienen hijos */
76 if (dynamic_cast<BTreeLeafData *> (data) == NULL)
77 m_signal_activated (data, num, this);
80 ViewNode::type_signal_selected ViewNode::signal_selected ()
82 return m_signal_selected;
85 ViewNode::type_signal_activated ViewNode::signal_activated ()
87 return m_signal_activated;
90 void ViewNode::SetSelected (bool b)
93 last_selected->SetSelected (b);
97 void ViewNode::HighliteKey (Clave &k)
99 std::list<ViewBTreeData *>::iterator it;
102 while (it != datas.end ()) {
105 last_selected->SetSelected (false);
107 last_selected->SetSelected (true);