2 #include "view_properties.h"
4 ViewProperties::ViewProperties ():Frame ()
6 lnode_num.set_use_markup (true);
7 lnode_level.set_use_markup (true);
8 lnode_items.set_use_markup (true);
9 lnode_freespace.set_use_markup (true);
10 ldata_type.set_use_markup (true);
11 ldata_key.set_use_markup (true);
12 ldata_child.set_use_markup (true);
14 lnode_num.set_label ("<b>Nodo</b> :");
15 lnode_level.set_label ("<b>Nivel</b> : ");
16 lnode_items.set_label ("<b>Items</b> :");
17 lnode_freespace.set_label ("<b>Libre</b> :");
18 ldata_type.set_label ("<b>Tipo</b> :");
19 ldata_key.set_label ("<b>Clave</b> : ");
20 ldata_child.set_label ("<b>Hijo</b> : ");
22 lnode_num.set_alignment(Gtk::JUSTIFY_LEFT);
23 lnode_level.set_alignment(Gtk::JUSTIFY_LEFT);
24 lnode_items.set_alignment(Gtk::JUSTIFY_LEFT);
25 lnode_freespace.set_alignment(Gtk::JUSTIFY_LEFT);
26 ldata_type.set_alignment(Gtk::JUSTIFY_LEFT);
27 ldata_key.set_alignment(Gtk::JUSTIFY_LEFT);
28 ldata_child.set_alignment(Gtk::JUSTIFY_LEFT);
30 table.attach (lnode_num, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
31 table.attach (lnode_level, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
32 table.attach (lnode_items, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
33 table.attach (lnode_freespace, 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
34 table.attach (ldata_type, 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
35 table.attach (ldata_key, 0, 1, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
36 table.attach (ldata_child, 0, 1, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
38 table.attach (node_num, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
39 table.attach (node_level, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
40 table.attach (node_items, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
41 table.attach (node_freespace, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
42 table.attach (data_type, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
43 table.attach (data_key, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
44 table.attach (data_child, 1, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
46 table.property_column_spacing () = 8;
47 table.property_row_spacing () = 8;
49 hbox.pack_start (table, false, true, 8);
50 hbox.pack_start (raw_view, true, true, 8);
52 table.set_size_request (250, 0);
56 property_label_xalign () = 0;
57 set_label ("Propiedades");
58 set_shadow_type(Gtk::SHADOW_NONE);
59 set_size_request (200, 0);
62 void ViewProperties::ShowItem (BTreeData *data, BTreeNodeHeader &header)
64 std::string s1, s2, s3;
65 std::stringstream ss1, ss2, ss3;
67 node_num.set_label ("TODO");
71 node_level.set_label (s1);
73 ss2 << header.item_count;
75 node_items.set_label (s2);
77 ss3 << header.free_space;
79 node_freespace.set_label (s3);
81 raw_view.get_buffer ()->assign (ToRaw (data));
83 if (dynamic_cast<BTreeChildData *>(data)) {
84 data_type.set_label ("BTreeChildData");
85 data_key.set_label ("N/C");
88 std::stringstream ss4;
89 ss4 << data->GetChild ();
91 data_child.set_label (s4);
92 } else if (dynamic_cast<BTreeLeafData *>(data)) {
93 data_type.set_label ("BTreeLeafData");
94 data_child.set_label ("N/C");
96 std::string s4 = *(data->GetKey ());
97 std::cout << "----> " << s4 << std::endl;
98 data_key.set_label (s4);
100 data_type.set_label ("BTreeData");
103 std::stringstream ss4;
104 ss4 << data->GetChild ();
106 data_child.set_label (s4);
108 std::string s5 = *(data->GetKey ());
109 data_key.set_label (s5);
113 std::string ViewProperties::ToRaw (BTreeData *p)
115 std::stringstream ss;
119 arr = p->GetKey ()->ToRaw (size);
122 for (i=0; i < size; i++) {
123 if (isalnum (arr[i]))
129 if (p->GetChild () != 0) {
131 ss << p->GetChild ();