Coding of Algorithms has begun, but code is really-really ugly yet.
authorhegyi
Tue, 03 Jan 2006 17:30:22 +0000
changeset 18713905d347112c
parent 1870 b9c9b52f839e
child 1872 3b7694cf0a08
Coding of Algorithms has begun, but code is really-really ugly yet.
gui/algobox.h
gui/algowin.h
gui/main_win.cc
gui/main_win.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gui/algobox.h	Tue Jan 03 17:30:22 2006 +0000
     1.3 @@ -0,0 +1,62 @@
     1.4 +// -*- C++ -*- //
     1.5 +
     1.6 +#ifndef ALGOBOX_H
     1.7 +#define ALGOBOX_H
     1.8 +
     1.9 +class AlgoBox;
    1.10 +
    1.11 +#include <all_include.h>
    1.12 +#include <libgnomecanvasmm.h>
    1.13 +#include <libgnomecanvasmm/polygon.h>
    1.14 +
    1.15 +class AlgoBox : public Gtk::VBox
    1.16 +{
    1.17 +  
    1.18 +  Gtk::Label * label;
    1.19 +  Gtk::ComboBoxText cbt;
    1.20 +  
    1.21 + public:
    1.22 +  AlgoBox(std::vector<std::string> tabnames)
    1.23 +    {
    1.24 +      update_tablist(tabnames);
    1.25 +
    1.26 +      label=new Gtk::Label("Haliho");
    1.27 +      
    1.28 +      pack_start(*label);
    1.29 +      pack_start(cbt);
    1.30 +
    1.31 +      show_all_children();
    1.32 +    };
    1.33 +
    1.34 +  void update_tablist( std::vector< std::string > tl )
    1.35 +    {
    1.36 +      std::string actname=cbt.get_active_text();
    1.37 +      int prev_act=-1;
    1.38 +
    1.39 +      cbt.clear();
    1.40 +      int actptr=0;
    1.41 +
    1.42 +      std::vector< std::string >::iterator emsi=tl.begin();
    1.43 +      for(;emsi!=tl.end();emsi++)
    1.44 +	{
    1.45 +	  if(actname==*emsi)
    1.46 +	    {
    1.47 +	      prev_act=actptr;
    1.48 +	    }
    1.49 +
    1.50 +	  cbt.append_text(*emsi);
    1.51 +	  actptr++;
    1.52 +	}
    1.53 +
    1.54 +      if(prev_act!=-1)
    1.55 +	{
    1.56 +	  cbt.set_active(prev_act);
    1.57 +	}
    1.58 +      else if(actptr>0) //so there is item in the list
    1.59 +	{
    1.60 +	  cbt.set_active(0);
    1.61 +	}
    1.62 +    }
    1.63 +
    1.64 +};
    1.65 +#endif //ALGOBOX_H
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/gui/algowin.h	Tue Jan 03 17:30:22 2006 +0000
     2.3 @@ -0,0 +1,53 @@
     2.4 +// -*- C++ -*- //
     2.5 +
     2.6 +#ifndef ALGOWIN_H
     2.7 +#define ALGOWIN_H
     2.8 +
     2.9 +class AlgoWin;
    2.10 +
    2.11 +#include <all_include.h>
    2.12 +#include <algobox.h>
    2.13 +#include <libgnomecanvasmm.h>
    2.14 +#include <libgnomecanvasmm/polygon.h>
    2.15 +
    2.16 +enum {GENERAL, ALGO_NUM}; // algorithm IDs;
    2.17 +
    2.18 +class AlgoWin : public Gtk::Dialog
    2.19 +{
    2.20 +private:
    2.21 +  AlgoBox * ab;
    2.22 +
    2.23 +protected:
    2.24 +  sigc::signal<void, AlgoWin *> signal_closed;  
    2.25 +
    2.26 +public:
    2.27 +  sigc::signal<void, AlgoWin *> signal_closing()
    2.28 +  {
    2.29 +    return signal_closed;
    2.30 +  }
    2.31 +
    2.32 +  AlgoWin(int algoid, std::vector<std::string> tabnames)
    2.33 +    {
    2.34 +      Gtk::VBox * vbox=get_vbox();
    2.35 +      
    2.36 +      ab=new AlgoBox(tabnames);
    2.37 +      
    2.38 +      vbox->pack_start(*ab);
    2.39 +      
    2.40 +      add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    2.41 +      
    2.42 +      show_all_children();
    2.43 +    };
    2.44 +
    2.45 +  void update_tablist(std::vector<std::string> tabnames)
    2.46 +  {
    2.47 +    ab->update_tablist(tabnames);
    2.48 +  }
    2.49 +
    2.50 +  void on_hide()
    2.51 +  {
    2.52 +    signal_closed.emit(this);
    2.53 +    Gtk::Dialog::on_hide();
    2.54 +  }
    2.55 +};
    2.56 +#endif //ALGOWIN_H
     3.1 --- a/gui/main_win.cc	Tue Jan 03 16:05:27 2006 +0000
     3.2 +++ b/gui/main_win.cc	Tue Jan 03 17:30:22 2006 +0000
     3.3 @@ -101,6 +101,10 @@
     3.4    ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
     3.5  	   sigc::mem_fun(*this, &MainWin::createMapWin));
     3.6  
     3.7 +  ag->add( Gtk::Action::create("AlgoMenu", "_Algorithms") );
     3.8 +  ag->add( Gtk::Action::create("AlgoGeneral", "_General"),
     3.9 +	   sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) );
    3.10 +
    3.11    Gtk::RadioAction::Group tool_group;
    3.12    ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
    3.13        sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) );
    3.14 @@ -147,6 +151,9 @@
    3.15        "    <menu action='ShowMenu'>"
    3.16        "      <menuitem action='ShowMaps'/>"
    3.17        "    </menu>"
    3.18 +      "    <menu action='AlgoMenu'>"
    3.19 +      "      <menuitem action='AlgoGeneral'/>"
    3.20 +      "    </menu>"
    3.21        "  </menubar>"
    3.22        "  <toolbar name='ToolBar'>"
    3.23        "    <toolitem action='FileNew' />"
    3.24 @@ -206,6 +213,7 @@
    3.25    tabnames[active_tab]=name;
    3.26    set_title(tabnames[active_tab] + " - " + prog_name);
    3.27    notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]);
    3.28 +  updateAlgoWins();
    3.29  }
    3.30  
    3.31  void MainWin::readFile(const std::string & filename)
    3.32 @@ -228,6 +236,7 @@
    3.33    notebook.append_page((Gtk::Widget&)(*(tabs[active_tab])));
    3.34    notebook.set_current_page(size);
    3.35    set_tabtitle(tabnames[active_tab]);
    3.36 +  updateAlgoWins();
    3.37  }
    3.38  
    3.39  void MainWin::closeTab()
    3.40 @@ -258,12 +267,13 @@
    3.41  	{
    3.42  	  for(int i=active_tab+1;i<size;i++)
    3.43  	    {
    3.44 +	      tabnames[i-1]=tabnames[i];
    3.45  	      tabs[i-1]=tabs[i];
    3.46  	    }
    3.47  	}
    3.48 -
    3.49        //if size==1 resize will delete the only element
    3.50        tabs.resize(size-1);
    3.51 +      tabnames.resize(size-1);
    3.52  
    3.53        int old_active_tab=active_tab;
    3.54        notebook.remove_page(active_tab);
    3.55 @@ -274,17 +284,21 @@
    3.56        //But after deletion it will become the first tab,
    3.57        //and this should be registrated in tabs vector,
    3.58        //as well.
    3.59 -      if(old_active_tab==0)
    3.60 +      if((old_active_tab==0)&&(size!=1))
    3.61  	{
    3.62  	  onChangeTab(NULL,0);
    3.63  	}
    3.64  
    3.65 +      std::cout << "NAAAA" << std::endl;
    3.66 +
    3.67        //if this was the last page in notebook, there is
    3.68        //no active_tab now
    3.69        if(size==1)
    3.70  	{
    3.71  	  active_tab=-1;
    3.72  	}
    3.73 +
    3.74 +      updateAlgoWins();
    3.75      }
    3.76  }
    3.77  
    3.78 @@ -380,6 +394,28 @@
    3.79      }
    3.80  }
    3.81  
    3.82 +void MainWin::createAlgoWin(int algoid)
    3.83 +{
    3.84 +  AlgoWin * aw=new AlgoWin(algoid, tabnames);
    3.85 +  aw->signal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin));
    3.86 +  aws.insert(aw);
    3.87 +  aw->show();
    3.88 +}
    3.89 +
    3.90 +void MainWin::deRegisterAlgoWin(AlgoWin * awp)
    3.91 +{
    3.92 +  aws.erase(awp);
    3.93 +}
    3.94 +
    3.95 +void MainWin::updateAlgoWins()
    3.96 +{
    3.97 +  std::set< AlgoWin* >::iterator awsi=aws.begin();
    3.98 +  for(;awsi!=aws.end();awsi++)
    3.99 +    {
   3.100 +      (*awsi)->update_tablist(tabnames);
   3.101 +    }
   3.102 +}
   3.103 +
   3.104  void MainWin::changeEditorialTool(int tool)
   3.105  {
   3.106    active_tool=tool;
     4.1 --- a/gui/main_win.h	Tue Jan 03 16:05:27 2006 +0000
     4.2 +++ b/gui/main_win.h	Tue Jan 03 17:30:22 2006 +0000
     4.3 @@ -4,6 +4,7 @@
     4.4  #define MAIN_WIN_H
     4.5  
     4.6  #include "all_include.h"
     4.7 +#include "algowin.h"
     4.8  #include "map_win.h"
     4.9  #include "new_map_win.h"
    4.10  #include "nbtab.h"
    4.11 @@ -26,6 +27,8 @@
    4.12    std::vector<NoteBookTab *> tabs;
    4.13    std::vector<std::string> tabnames;
    4.14  
    4.15 +  std::set< AlgoWin* > aws;
    4.16 +
    4.17  public:
    4.18    
    4.19    ///Constructor of the \ref NoteBookTab. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn.
    4.20 @@ -66,6 +69,10 @@
    4.21  
    4.22    virtual void createMapWin();
    4.23  
    4.24 +  virtual void createAlgoWin(int);
    4.25 +  virtual void deRegisterAlgoWin(AlgoWin *);
    4.26 +  virtual void updateAlgoWins();
    4.27 +
    4.28    virtual void changeEditorialTool(int);
    4.29  
    4.30    virtual void createNewMapWinAfterSignal(NoteBookTab *, bool);