]> git.llucax.com Git - z.facultad/75.52/treemulator.git/blob - viewer/view_btree.h
Menu y actions para abrir un arbol.
[z.facultad/75.52/treemulator.git] / viewer / view_btree.h
1
2 #ifndef _VIEW_BTREE_H_
3 #define _VIEW_BTREE_H_
4
5 #include <libgnomecanvasmm.h>
6 #include <string>
7 #include <stack>
8
9 #include "btree.h"
10 #include "view_node.h"
11
12 using namespace Gnome;
13
14 class ViewNode;
15
16 class ViewBTree : public Canvas::Group, public BTree {
17         public:
18                 ViewBTree (Canvas::Group *parent, std::string filename, uint block_size, int tree_type, int type);
19                 ViewBTree (Canvas::Group *parent, const std::string filename);
20
21                 static ViewBTree* Open (Canvas::Group *parent, const std::string &filename);
22
23                 void Clear ();
24                 void HighliteKey (Clave &k);
25                 void GoBack ();
26
27                 static double byte_to_pixels;
28                 static double node_width;
29                 static double node_height;
30
31                 typedef SigC::Signal2<void, BTreeData *, BTreeNodeHeader&> type_signal_selected;
32                 type_signal_selected signal_selected ();
33         protected:
34                 type_signal_selected m_signal_selected;
35                 int max_level; /* Lo saco de la raiz */
36                 /* Posicion X por nivel */
37                 std::map<uint,double> pos_x;
38                 /* Control para no poner 2 veces un nodo */
39                 /* Un nodo que quiera ser puesto 2 veces es un bug :) */
40                 std::map<uint,bool> node_placed;
41                 std::stack<uint> back;
42                 uint last_visited;
43
44         public:
45                 void AddNode (uint num, uint padre = 0);
46                 void on_item_selected (BTreeData *, uint, ViewNode *);
47                 void on_item_activated (BTreeData *, uint, ViewNode *);
48
49                 ViewNode *last_selected;
50 };
51
52 #endif
53