main_win.cc
changeset 154 65c1b103443d
parent 149 930e838ad5b6
child 155 74065e83844d
equal deleted inserted replaced
41:7700e43d8676 42:60e3d83779a6
     9 
     9 
    10 MainWin::MainWin()
    10 MainWin::MainWin()
    11 {
    11 {
    12   set_title ("no file");
    12   set_title ("no file");
    13   set_default_size(WIN_WIDTH,WIN_HEIGHT);
    13   set_default_size(WIN_WIDTH,WIN_HEIGHT);
    14   add(vbox);
    14   //add(vbox);
       
    15   add(table);
    15 
    16 
    16   // custom icons for the toolbar
    17   // custom icons for the toolbar
    17   Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
    18   Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
    18  
    19  
    19   Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline(
    20   Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline(
   183     std::cerr << "building menus failed: " <<  ex.what();
   184     std::cerr << "building menus failed: " <<  ex.what();
   184   }
   185   }
   185 
   186 
   186   Gtk::Widget* menubar = uim->get_widget("/MenuBar");
   187   Gtk::Widget* menubar = uim->get_widget("/MenuBar");
   187   if (menubar){
   188   if (menubar){
   188     vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
   189     //vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
       
   190     table.attach(*menubar, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
   189   }
   191   }
   190 
   192 
   191   Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
   193   Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
   192   if (toolbar)
   194   if (toolbar)
   193   {
   195   {
   194     static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
   196     static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
   195     vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
   197     //hbox.pack_start(*toolbar, Gtk::PACK_EXPAND_WIDGET);
       
   198 
       
   199     table.attach(*toolbar, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
       
   200 
   196   }
   201   }
       
   202 
       
   203   auto_scale= new Gtk::CheckButton("Autoscale");
       
   204   auto_scale->set_active(false);
       
   205   auto_scale->signal_toggled().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
       
   206 
       
   207   table2.set_row_spacings(10);
       
   208   table2.set_col_spacings(5);
       
   209 
       
   210   table2.attach(*auto_scale, 0,2,0,1);
       
   211  
       
   212   Gtk::Label * unit_label= new Gtk::Label("Unit:");
       
   213   table2.attach(*unit_label, 2,3,0,1);
       
   214   
       
   215   Gtk::Adjustment * adjustment_unit=new Gtk::Adjustment(20, 5, 200, 5, 10);
       
   216 
       
   217   radius_unit = new Gtk::SpinButton(*adjustment_unit, 5,0);
       
   218   radius_unit->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
       
   219   table2.attach(*radius_unit, 3,4,0,1);
       
   220 
       
   221   Gtk::Label * min_label= new Gtk::Label("Min:");
       
   222   table2.attach(*min_label, 0,1,1,2);
       
   223   
       
   224   Gtk::Adjustment * adjustment_min=new Gtk::Adjustment(20, 5, 200, 5, 10);
       
   225 
       
   226   radius_min = new Gtk::SpinButton(*adjustment_min, 5,0);
       
   227   radius_min->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
       
   228   table2.attach(*radius_min, 1,2,1,2);
       
   229 
       
   230   Gtk::Label * max_label= new Gtk::Label("Max:");
       
   231   table2.attach(*max_label, 2,3,1,2);
       
   232   
       
   233   Gtk::Adjustment * adjustment_max=new Gtk::Adjustment(20, 5, 200, 5, 10);
       
   234 
       
   235   radius_max = new Gtk::SpinButton(*adjustment_max, 5,0);
       
   236   radius_max->signal_value_changed().connect(sigc::mem_fun(*this, &MainWin::nodeViewChanged));
       
   237   table2.attach(*radius_max, 3,4,1,2);
       
   238 
       
   239   //vbox.pack_start(hbox, Gtk::PACK_SHRINK);
       
   240   table.attach(table2, 1, 2, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
   197 
   241 
   198   tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
   242   tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
   199   tooltips.enable();
   243   tooltips.enable();
   200 
   244 
   201   active_tab=-1;
   245   active_tab=-1;
   202   notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
   246   notebook.signal_switch_page().connect(sigc::mem_fun(*this, &MainWin::onChangeTab));
   203 
   247 
   204   active_tool = MOVE;
   248   active_tool = MOVE;
   205 
   249 
   206   vbox.pack_start(notebook);
   250   //vbox.pack_start(notebook);
       
   251   table.attach(notebook,0,2,2,3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
   207   
   252   
   208   show_all_children();
   253   show_all_children();
   209 }
   254 }
   210 
   255 
   211 void MainWin::set_tabtitle(std::string name)
   256 void MainWin::set_tabtitle(std::string name)
   314 {
   359 {
   315   page=page;
   360   page=page;
   316   active_tab=page_num;
   361   active_tab=page_num;
   317   tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
   362   tabs[active_tab]->gd_canvas->changeEditorialTool(active_tool);
   318   set_title(tabnames[active_tab]);
   363   set_title(tabnames[active_tab]);
       
   364   bool autoscale;
       
   365   double min;
       
   366   double max;
       
   367   double unit;
       
   368   tabs[active_tab]->getNodeView(autoscale, min, max, unit);
       
   369   radius_min->set_value(min);
       
   370   radius_max->set_value(max);
       
   371   radius_unit->set_value(unit);
       
   372   auto_scale->set_active(autoscale);
       
   373 
   319 }
   374 }
   320 
   375 
   321 void MainWin::newFile()
   376 void MainWin::newFile()
   322 {
   377 {
   323   if(active_tab!=-1)
   378   if(active_tab!=-1)
   475 	}
   530 	}
   476     }
   531     }
   477   NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false);
   532   NewMapWin * nmw=new NewMapWin(_("Create New Map - ")+tabnames[i], *nbt, itisedge, false);
   478   nmw->run();
   533   nmw->run();
   479 }
   534 }
       
   535 
       
   536 
       
   537 void MainWin::nodeViewChanged()
       
   538 {
       
   539   double min=radius_min->get_value();
       
   540   double max=radius_max->get_value();
       
   541   double unit=radius_unit->get_value();
       
   542   bool autoscale=auto_scale->get_active();
       
   543   tabs[active_tab]->setNodeView(autoscale, min, max, unit);
       
   544 }