# HG changeset patch # User hegyi # Date 1136309422 0 # Node ID 3a263e57e1d939f36ac25e649d04035d7586f8a9 # Parent 25a4698cbe0c15b7026c28e31f0642c90a9f006d Coding of Algorithms has begun, but code is really-really ugly yet. diff -r 25a4698cbe0c -r 3a263e57e1d9 algobox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/algobox.h Tue Jan 03 17:30:22 2006 +0000 @@ -0,0 +1,62 @@ +// -*- C++ -*- // + +#ifndef ALGOBOX_H +#define ALGOBOX_H + +class AlgoBox; + +#include +#include +#include + +class AlgoBox : public Gtk::VBox +{ + + Gtk::Label * label; + Gtk::ComboBoxText cbt; + + public: + AlgoBox(std::vector tabnames) + { + update_tablist(tabnames); + + label=new Gtk::Label("Haliho"); + + pack_start(*label); + pack_start(cbt); + + show_all_children(); + }; + + void update_tablist( std::vector< std::string > tl ) + { + std::string actname=cbt.get_active_text(); + int prev_act=-1; + + cbt.clear(); + int actptr=0; + + std::vector< std::string >::iterator emsi=tl.begin(); + for(;emsi!=tl.end();emsi++) + { + if(actname==*emsi) + { + prev_act=actptr; + } + + cbt.append_text(*emsi); + actptr++; + } + + if(prev_act!=-1) + { + cbt.set_active(prev_act); + } + else if(actptr>0) //so there is item in the list + { + cbt.set_active(0); + } + } + +}; +#endif //ALGOBOX_H diff -r 25a4698cbe0c -r 3a263e57e1d9 algowin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/algowin.h Tue Jan 03 17:30:22 2006 +0000 @@ -0,0 +1,53 @@ +// -*- C++ -*- // + +#ifndef ALGOWIN_H +#define ALGOWIN_H + +class AlgoWin; + +#include +#include +#include +#include + +enum {GENERAL, ALGO_NUM}; // algorithm IDs; + +class AlgoWin : public Gtk::Dialog +{ +private: + AlgoBox * ab; + +protected: + sigc::signal signal_closed; + +public: + sigc::signal signal_closing() + { + return signal_closed; + } + + AlgoWin(int algoid, std::vector tabnames) + { + Gtk::VBox * vbox=get_vbox(); + + ab=new AlgoBox(tabnames); + + vbox->pack_start(*ab); + + add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); + + show_all_children(); + }; + + void update_tablist(std::vector tabnames) + { + ab->update_tablist(tabnames); + } + + void on_hide() + { + signal_closed.emit(this); + Gtk::Dialog::on_hide(); + } +}; +#endif //ALGOWIN_H diff -r 25a4698cbe0c -r 3a263e57e1d9 main_win.cc --- a/main_win.cc Tue Jan 03 14:56:45 2006 +0000 +++ b/main_win.cc Tue Jan 03 17:30:22 2006 +0000 @@ -101,6 +101,10 @@ ag->add( Gtk::Action::create("ShowMaps", "_Maps"), sigc::mem_fun(*this, &MainWin::createMapWin)); + ag->add( Gtk::Action::create("AlgoMenu", "_Algorithms") ); + ag->add( Gtk::Action::create("AlgoGeneral", "_General"), + sigc::bind( sigc::mem_fun ( *this, &MainWin::createAlgoWin ), 0) ); + Gtk::RadioAction::Group tool_group; ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 0) ); @@ -147,6 +151,9 @@ " " " " " " + " " + " " + " " " " " " " " @@ -206,6 +213,7 @@ tabnames[active_tab]=name; set_title(tabnames[active_tab] + " - " + prog_name); notebook.set_tab_label_text((Widget&)*(tabs[active_tab]), tabnames[active_tab]); + updateAlgoWins(); } void MainWin::readFile(const std::string & filename) @@ -228,6 +236,7 @@ notebook.append_page((Gtk::Widget&)(*(tabs[active_tab]))); notebook.set_current_page(size); set_tabtitle(tabnames[active_tab]); + updateAlgoWins(); } void MainWin::closeTab() @@ -258,12 +267,13 @@ { for(int i=active_tab+1;isignal_closing().connect(sigc::mem_fun(*this, &MainWin::deRegisterAlgoWin)); + aws.insert(aw); + aw->show(); +} + +void MainWin::deRegisterAlgoWin(AlgoWin * awp) +{ + aws.erase(awp); +} + +void MainWin::updateAlgoWins() +{ + std::set< AlgoWin* >::iterator awsi=aws.begin(); + for(;awsi!=aws.end();awsi++) + { + (*awsi)->update_tablist(tabnames); + } +} + void MainWin::changeEditorialTool(int tool) { active_tool=tool; diff -r 25a4698cbe0c -r 3a263e57e1d9 main_win.h --- a/main_win.h Tue Jan 03 14:56:45 2006 +0000 +++ b/main_win.h Tue Jan 03 17:30:22 2006 +0000 @@ -4,6 +4,7 @@ #define MAIN_WIN_H #include "all_include.h" +#include "algowin.h" #include "map_win.h" #include "new_map_win.h" #include "nbtab.h" @@ -26,6 +27,8 @@ std::vector tabs; std::vector tabnames; + std::set< AlgoWin* > aws; + public: ///Constructor of the \ref NoteBookTab. It creates the menu and the \ref GraphDisplayerCanvas on which the graph will be drawn. @@ -66,6 +69,10 @@ virtual void createMapWin(); + virtual void createAlgoWin(int); + virtual void deRegisterAlgoWin(AlgoWin *); + virtual void updateAlgoWins(); + virtual void changeEditorialTool(int); virtual void createNewMapWinAfterSignal(NoteBookTab *, bool);