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 fondo = new Canvas::Rect (*this, 0, 0, ViewBTree::node_width, ViewBTree::node_height);
14 fondo->property_fill_color() = "gray";
15 fondo->property_outline_color() = "black";
18 Canvas::Rect *h = new Canvas::Rect (*this, 0, 0, header_w, ViewBTree::node_height);
19 h->property_fill_color() = "blue";
20 h->property_outline_color() = "black";
27 new Canvas::Text (*this, header_w/2, ViewBTree::node_height/2, node_num);
31 std::list<BTreeData *>::iterator it = keys.begin ();
32 while (it != keys.end ()) {
33 BTreeData *data = (*it);
34 double w = ViewBTree::byte_to_pixels * data->Size ();
36 ViewBTreeData *v = ViewBTreeData::Create (data, this, x, 0, w+x, ViewBTree::node_height);
37 v->signal_clicked ().connect ( sigc::mem_fun (this , &ViewNode::on_item_clicked ));
38 v->signal_double_clicked ().connect ( sigc::mem_fun (this , &ViewNode::on_item_activated ));
44 if (!dynamic_cast<BTreeLeafData *>(data)) {
45 /* Si no es un dato de una hoja, tiene hijos */
46 hijos.push_back (data->GetChild ());
51 void ViewNode::on_item_clicked (BTreeData *data, ViewBTreeData *s)
54 if (s != last_selected)
55 last_selected->SetSelected (false);
57 m_signal_selected (data, num, this);
60 void ViewNode::on_item_activated (BTreeData *data, ViewBTreeData *s)
62 /* Solo activo los que tienen hijos */
63 if (dynamic_cast<BTreeLeafData *> (data) == NULL)
64 m_signal_activated (data, num, this);
67 ViewNode::type_signal_selected ViewNode::signal_selected ()
69 return m_signal_selected;
72 ViewNode::type_signal_activated ViewNode::signal_activated ()
74 return m_signal_activated;
77 void ViewNode::SetSelected (bool b)
80 last_selected->SetSelected (b);
84 void ViewNode::HighliteKey (Clave &k)
86 std::list<ViewBTreeData *>::iterator it;
89 while (it != datas.end ()) {
92 last_selected->SetSelected (false);
94 last_selected->SetSelected (true);