COIN-OR::LEMON - Graph Library

Changeset 1856:3f0558065bcd in lemon-0.x for gui


Ignore:
Timestamp:
12/08/05 15:16:08 (14 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2424
Message:

Notebook tabs can be closed.

Location:
gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gui/main_win.cc

    r1849 r1856  
    7575  ag->add( Gtk::Action::create("FileNewTab", "New _Tab"),
    7676      sigc::mem_fun(*this, &MainWin::newTab));
     77  ag->add( Gtk::Action::create("FileCloseTab", "_Close Tab"),
     78      sigc::mem_fun(*this, &MainWin::closeTab));
    7779  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
    7880      sigc::mem_fun(*this, &MainWin::newFile));
     
    132134      "    <menu action='FileMenu'>"
    133135      "      <menuitem action='FileNewTab'/>"
     136      "      <menuitem action='FileCloseTab'/>"
    134137      "      <menuitem action='FileNew'/>"
    135138      "      <menuitem action='FileOpen'/>"
     
    231234}
    232235
     236void MainWin::closeTab()
     237{
     238  if(active_tab!=-1)
     239    {
     240      //tabs vector will be decreased with the deleted value
     241      int size=tabs.size();
     242      if(size>1)
     243        {
     244          for(int i=active_tab+1;i<size;i++)
     245            {
     246              tabs[i-1]=tabs[i];
     247            }
     248        }
     249
     250      //if size==1 resize will delete the only element
     251      tabs.resize(size-1);
     252
     253      int old_active_tab=active_tab;
     254      notebook.remove_page(active_tab);
     255
     256      //If the first tab was active, upon delete notebook
     257      //will first switch one tab upper and not lower like
     258      //in the case, when not the first tab was active.
     259      //But after deletion it will become the first tab,
     260      //and this should be registrated in tabs vector,
     261      //as well.
     262      if(old_active_tab==0)
     263        {
     264          onChangeTab(NULL,0);
     265        }
     266
     267      //if this was the last page in notebook, there is
     268      //no active_tab now
     269      if(size==1)
     270        {
     271          active_tab=-1;
     272        }
     273    }
     274}
     275
    233276void MainWin::onChangeTab(GtkNotebookPage* page, guint page_num)
    234277{
  • gui/main_win.h

    r1849 r1856  
    7575  ///Callback for 'FileNewTab' action.
    7676  virtual void newTab();
     77  virtual void closeTab();
    7778  virtual void onChangeTab(GtkNotebookPage*, guint);
    7879  virtual void onCloseTab();
Note: See TracChangeset for help on using the changeset viewer.