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 ));
42 if (!dynamic_cast<BTreeLeafData *>(data)) {
43 /* Si no es un dato de una hoja, tiene hijos */
44 hijos.push_back (data->GetChild ());
49 void ViewNode::on_item_clicked (BTreeData *data, ViewBTreeData *s)
52 if (s != last_selected)
53 last_selected->SetSelected (false);
55 m_signal_selected (data, num, this);
58 void ViewNode::on_item_activated (BTreeData *data, ViewBTreeData *s)
60 /* Solo activo los que tienen hijos */
61 if (dynamic_cast<BTreeLeafData *> (data) == NULL)
62 m_signal_activated (data, num, this);
65 ViewNode::type_signal_selected ViewNode::signal_selected ()
67 return m_signal_selected;
70 ViewNode::type_signal_activated ViewNode::signal_activated ()
72 return m_signal_activated;
75 void ViewNode::SetSelected (bool b)
78 last_selected->SetSelected (b);