+
+#include <curses.h>
+#include "w_btree.h"
+
+wBTree::wBTree ():Window ("TreeMulator", 0, 0)
+{
+ last_length = 0;
+}
+
+wBTree::~wBTree ()
+{
+}
+
+void wBTree::SetTree (BTree *b)
+{
+ tree = b;
+}
+
+void wBTree::ShowNode (uint node_num)
+{
+ uchar *node;
+ std::list<BTreeData*> node_keys;
+
+ node = tree->ReadBlock (node_num);
+ tree->ReadNodoHeader (node, &node_header);
+ node_keys = tree->ReadKeys (node, node_header);
+
+ int y, x;
+ y = 5;
+ x = 5;
+ /* Dibujo el bloque de color rojo */
+ /*wattron (win, COLOR_PAIR (1));
+ for (uint i=0; i < tree->header.block_size + 2; i++)
+ mvwaddstr (win, y+1, i+x-1, ".");
+ for (uint i=0; i < tree->header.block_size + 2; i++)
+ mvwaddstr (win, y-1, i+x-1, ".");
+ mvwaddstr (win, y, x-1, ".");
+ mvwaddstr (win, y, tree->header.block_size + x, ".");
+ wattroff (win, COLOR_PAIR (1));*/
+
+ for (uint o=0; o<last_length; o++)
+ mvwaddstr (win, y, x+o, " ");
+
+ std::list<BTreeData*>::iterator it = node_keys.begin ();
+ int n = 0;
+ while (it != node_keys.end ()) {
+ std::string s = *(*it);
+
+ if (n%2)
+ wattron (win, COLOR_PAIR (2));
+ else
+ wattron (win, COLOR_PAIR (3));
+ mvwaddnstr (win, y, x, (const char *)(s.c_str ()), s.length ());
+ if (n%2)
+ wattroff (win, COLOR_PAIR (2));
+ else
+ wattroff (win, COLOR_PAIR (3));
+ x += s.length ();
+ n++;
+ it++;
+ }
+ last_length = x;
+ mvwaddstr (win, 20, 5, "Ir al nodo (-1 para salir) : ");
+}
+