gui/main_win.cc
changeset 1871 3905d347112c
parent 1869 52f5a7f9fb48
child 1872 3b7694cf0a08
     1.1 --- a/gui/main_win.cc	Tue Jan 03 16:05:27 2006 +0000
     1.2 +++ b/gui/main_win.cc	Tue Jan 03 17:30:22 2006 +0000
     1.3 @@ -101,6 +101,10 @@
     1.4    ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
     1.5  	   sigc::mem_fun(*this, &MainWin::createMapWin));
     1.6  
     1.7 +  ag->add( Gtk::Action::create("AlgoMenu", "_Algorithms") );
     1.8 +  ag->add( Gtk::Action::create("AlgoGeneral", "_General"),
     1.9 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) );
    1.10 +
    1.11    Gtk::RadioAction::Group tool_group;
    1.12    ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
    1.13        sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) );
    1.14 @@ -147,6 +151,9 @@
    1.15        "    <menu action='ShowMenu'>"
    1.16        "      <menuitem action='ShowMaps'/>"
    1.17        "    </menu>"
    1.18 +      "    <menu action='AlgoMenu'>"
    1.19 +      "      <menuitem action='AlgoGeneral'/>"
    1.20 +      "    </menu>"
    1.21        "  </menubar>"
    1.22        "  <toolbar name='ToolBar'>"
    1.23        "    <toolitem action='FileNew' />"
    1.24 @@ -206,6 +213,7 @@
    1.25    tabnames[active_tab]=name;
    1.26    set_title(tabnames[active_tab] + " - " + prog_name);
    1.27    notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
    1.28 +  updateAlgoWins();
    1.29  }
    1.30  
    1.31  void MainWin::readFile(const std::string & filename)
    1.32 @@ -228,6 +236,7 @@
    1.33    notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
    1.34    notebook.set_current_page(size);
    1.35    set_tabtitle(tabnames[active_tab]);
    1.36 +  updateAlgoWins();
    1.37  }
    1.38  
    1.39  void MainWin::closeTab()
    1.40 @@ -258,12 +267,13 @@
    1.41  	{
    1.42  	  for(int i=active_tab+1;i<size;i++)
    1.43  	    {
    1.44 +	      tabnames[i-1]=tabnames[i];
    1.45  	      tabs[i-1]=tabs[i];
    1.46  	    }
    1.47  	}
    1.48 -
    1.49        //if size==1 resize will delete the only element
    1.50        tabs.resize(size-1);
    1.51 +      tabnames.resize(size-1);
    1.52  
    1.53        int old_active_tab=active_tab;
    1.54        notebook.remove_page(active_tab);
    1.55 @@ -274,17 +284,21 @@
    1.56        //But after deletion it will become the first tab,
    1.57        //and this should be registrated in tabs vector,
    1.58        //as well.
    1.59 -      if(old_active_tab==0)
    1.60 +      if((old_active_tab==0)&&(size!=1))
    1.61  	{
    1.62  	  onChangeTab(NULL,0);
    1.63  	}
    1.64  
    1.65 +      std::cout << "NAAAA" << std::endl;
    1.66 +
    1.67        //if this was the last page in notebook, there is
    1.68        //no active_tab now
    1.69        if(size==1)
    1.70  	{
    1.71  	  active_tab=-1;
    1.72  	}
    1.73 +
    1.74 +      updateAlgoWins();
    1.75      }
    1.76  }
    1.77  
    1.78 @@ -380,6 +394,28 @@
    1.79      }
    1.80  }
    1.81  
    1.82 +void MainWin::createAlgoWin(int algoid)
    1.83 +{
    1.84 +  AlgoWin * aw=new AlgoWin(algoid, tabnames);
    1.85 +  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
    1.86 +  aws.insert(aw);
    1.87 +  aw->show();
    1.88 +}
    1.89 +
    1.90 +void MainWin::deRegisterAlgoWin(AlgoWin * awp)
    1.91 +{
    1.92 +  aws.erase(awp);
    1.93 +}
    1.94 +
    1.95 +void MainWin::updateAlgoWins()
    1.96 +{
    1.97 +  std::set< AlgoWin* >::iterator awsi=aws.begin();
    1.98 +  for(;awsi!=aws.end();awsi++)
    1.99 +    {
   1.100 +      (*awsi)->update_tablist(tabnames);
   1.101 +    }
   1.102 +}
   1.103 +
   1.104  void MainWin::changeEditorialTool(int tool)
   1.105  {
   1.106    active_tool=tool;