--- /dev/null
+TARGET=viewer
+CXXFLAGS=-Wall -g `pkg-config gtkmm-2.4 libgnomecanvasmm-2.6 --cflags` -I../src
+OBJECTS=main.o view_btree.o view_btree_data.o
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS)
+ g++ -o $(TARGET) $(OBJECTS) ../src/libbtree.a `pkg-config gtkmm-2.4 libgnomecanvasmm-2.6 --libs`
+
+clean:
+ rm -rf *.o $(TARGET)
+
+
--- /dev/null
+
+#include <iostream>
+
+#include <gtkmm.h>
+#include <libgnomecanvasmm.h>
+
+#include "view_btree.h"
+
+using namespace Gnome::Canvas;
+
+int main(int argc, char *argv[])
+{
+ Gtk::Main kit(argc, argv);
+
+ Gnome::Canvas::init ();
+
+ Gtk::Window window;
+ Gnome::Canvas::Canvas canvas;
+
+ ViewBTree canvas_grp (canvas.root (), "test.idx");
+
+ window.add (canvas);
+ window.set_size_request (800, 100);
+ window.show_all ();
+
+ Gtk::Main::run(window);
+
+ return 0;
+}
--- /dev/null
+
+#include "view_btree.h"
+#include "view_btree_data.h"
+
+ViewBTree::ViewBTree (Canvas::Group *parent, std::string filename):Canvas::Group (*parent, 0, 0),
+ BTree (filename, 64)
+{
+ /* TODO : hace que el arbol se abra de un archivo ya creado o que se
+ * cree afuera
+ */
+ for (int i=0; i<=64; i++) {
+ ClaveFija c(i);
+
+ AddKey (c);
+ }
+
+ /* Muestro la raiz */
+ uchar *node = ReadBlock (0);
+ BTreeNodeHeader node_h;
+ ReadNodoHeader (node, &node_h);
+ std::list<BTreeData *> keys = ReadKeys (node, node_h);
+
+ Canvas::Rect *rect = new Canvas::Rect (*this, 0, 0, NODE_WIDTH, NODE_HEIGHT);
+ rect->property_fill_color() = "gray";
+
+ int byte_to_pixels = NODE_WIDTH/64; // TODO : 64 == BlockSize
+
+ /* Ahora pongo el lugar que opcupa el header */
+ double header_w = byte_to_pixels * sizeof (BTreeNodeHeader);
+ double x = 0;
+
+ Canvas::Rect *view_header = new Canvas::Rect (*this, x, 0, x+header_w, NODE_HEIGHT);
+ x += header_w;
+
+ std::list<BTreeData *>::iterator it = keys.begin ();
+ while (it != keys.end ()) {
+ BTreeData *data = (*it);
+ double w = byte_to_pixels * data->Size ();
+
+ ViewBTreeData::Create (data, this, x, 0, w+x, NODE_HEIGHT);
+
+ x += w;
+ it++;
+ }
+
+}
+
--- /dev/null
+
+#ifndef _VIEW_BTREE_H_
+#define _VIEW_BTREE_H_
+
+#include <libgnomecanvasmm.h>
+#include <string>
+
+#include "btree.h"
+
+#define NODE_WIDTH 500
+#define NODE_HEIGHT 50
+
+using namespace Gnome;
+
+class ViewBTree : public Canvas::Group, public BTree {
+ public:
+ ViewBTree (Canvas::Group *parent, std::string filename);
+
+};
+
+#endif
+
--- /dev/null
+
+#include "view_btree_data.h"
+
+ViewBTreeData::ViewBTreeData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2):
+ Canvas::Rect (*parent, x1, y1, x2, y2)
+{
+ this->data = data;
+ property_fill_color () = "red";
+ property_outline_color () = "black";
+}
+
+
+ViewBTreeData*
+ViewBTreeData::Create (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2)
+{
+ if (dynamic_cast<BTreeChildData *>(data))
+ return new ViewBTreeChildData (data, parent, x1, y1, x2, y2);
+
+ return new ViewBTreeData (data, parent, x1, y1, x2, y2);
+}
+
+ViewBTreeChildData::ViewBTreeChildData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2):
+ ViewBTreeData (data, parent, x1, y1, x2, y2)
+{
+ property_fill_color () = "yellow";
+ property_outline_color () = "black";
+
+ double w = x2 - x1;
+ double h = y2 - y1;
+
+ std::string s = *data;
+ Canvas::Text *text = new Canvas::Text (*parent, x1 + w/2, y1 + h/2, s);
+}
+
--- /dev/null
+
+#ifndef _VIEW_BTREE_DATA_H_
+#define _VIEW_BTREE_DATA_H_
+
+#include <libgnomecanvasmm.h>
+#include <string>
+
+#include "btree.h"
+#include "btree_data.h"
+
+using namespace Gnome;
+
+class ViewBTreeData :public Canvas::Rect {
+ public:
+ ViewBTreeData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2);
+
+ static ViewBTreeData *Create (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2);
+
+ protected:
+ BTreeData *data;
+};
+
+class ViewBTreeChildData :public ViewBTreeData {
+ public:
+ ViewBTreeChildData (BTreeData *data, Canvas::Group *parent, double x1, double y1, double x2, double y2);
+
+ protected:
+ BTreeData *data;
+};
+#endif
+