5 #include <libgnomecanvasmm.h>
8 #include "view_btree.h"
9 #include "view_properties.h"
10 #include "new_tree_dialog.h"
11 #include "view_debug.h"
13 using namespace Gnome::Canvas;
15 Glib::ustring ui_info =
17 " <menubar name='MenuBar'>"
18 " <menu action='MenuFile'>"
19 " <menuitem action='Nuevo'/>"
21 " <menuitem action='Salir'/>"
23 " <menu action='MenuZoom'>"
24 " <menuitem action='Alejar'/>"
25 " <menuitem action='Acercar'/>"
27 " <menuitem action='100 %'/>"
37 Glib::RefPtr<ViewBTree> tree;
39 Gnome::Canvas::Canvas *real_canvas;
40 ViewProperties *real_frame;
42 int main(int argc, char *argv[])
44 Gtk::Main kit(argc, argv);
46 Gnome::Canvas::init ();
52 Gtk::ScrolledWindow area;
53 Gnome::Canvas::Canvas canvas;
57 real_canvas = &canvas;
61 canvas.set_scroll_region (0, 0, 100, 100);
64 hbox.pack_start (frame, false, false, 10);
65 hbox.pack_start (area);
66 hbox.pack_end (debug, false, true, 10);
68 Glib::RefPtr<Gtk::ActionGroup> actiongroup = Gtk::ActionGroup::create();
70 actiongroup->add( Gtk::Action::create("MenuFile", "_Arbol") );
71 actiongroup->add( Gtk::Action::create("Nuevo", Gtk::Stock::NEW), &nuevo_arbol);
72 actiongroup->add( Gtk::Action::create("Salir", Gtk::Stock::QUIT), &Gtk::Main::quit);
73 actiongroup->add( Gtk::Action::create("MenuZoom", "_Zoom"));
74 actiongroup->add( Gtk::Action::create("Alejar", Gtk::Stock::ZOOM_OUT), Gtk::AccelKey ("<control>z"), &zoom_out );
75 actiongroup->add( Gtk::Action::create("Acercar", Gtk::Stock::ZOOM_IN), Gtk::AccelKey ("<control>x"), &zoom_in);
76 actiongroup->add( Gtk::Action::create("100 %", Gtk::Stock::ZOOM_100), Gtk::AccelKey ("<control>1"), &zoom_normal);
78 Glib::RefPtr<Gtk::UIManager> m_refUIManager = Gtk::UIManager::create();
79 m_refUIManager->insert_action_group (actiongroup);
81 m_refUIManager->add_ui_from_string(ui_info);
82 Gtk::Widget* menubar = m_refUIManager->get_widget("/MenuBar");
85 vbox.pack_start (*menubar, false, true, 0);
86 vbox.pack_end (hbox, true, true, 5);
88 window.add_accel_group (m_refUIManager->get_accel_group ());
90 window.set_size_request (640, 480);
93 /* Conecto el Canvas con el Frame */
94 Gtk::Main::run(window);
101 real_canvas->set_scroll_region (0, 0, 5000, 5000);
104 if (d.run () == Gtk::RESPONSE_OK) {
105 uint tot = d.getAmount ();
106 int type = d.getKeyType ();
107 tree = Glib::RefPtr<ViewBTree>(new ViewBTree (real_canvas->root(), "test.idx", d.getBlockSize (), type));
108 tree->signal_selected ().connect ( sigc::mem_fun (*real_frame, &ViewProperties::ShowItem) );
109 vdebug->SetTree (tree);
110 if (type == BTree::KEY_FIXED) {
112 std::list<int>::iterator it;
114 Random::Ints (lst, tot);
117 while (it != lst.end ()) {
125 std::list<std::string> lst;
126 std::list<std::string>::iterator it;
128 Random::Strings (lst, tot);
131 while (it != lst.end ()) {
132 ClaveVariable c(*it);
140 double x1, x2, y1, y2;
141 tree->get_bounds (x1, y1, x2, y2);
147 double r = real_canvas->get_pixels_per_unit ();
151 real_canvas->set_pixels_per_unit (r);
156 double r = real_canvas->get_pixels_per_unit ();
160 real_canvas->set_pixels_per_unit (r);
165 real_canvas->set_pixels_per_unit (1.0f);