1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/eps_win.cc Mon Jul 07 08:10:39 2008 -0500
1.3 @@ -0,0 +1,110 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2006
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#include <eps_win.h>
1.23 +
1.24 +#include <mapselector.h>
1.25 +
1.26 +#include <set>
1.27 +
1.28 +bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e)
1.29 +{
1.30 + if(e->keyval==GDK_Escape)
1.31 + {
1.32 + hide();
1.33 + }
1.34 + return true;
1.35 +}
1.36 +
1.37 +EpsWin::EpsWin(const std::string& title, std::vector<std::string> n_nml, std::vector<std::string> s_nml):Gtk::Dialog(title, true, true)
1.38 +{
1.39 + set_default_size(200, 50);
1.40 +
1.41 + set_resizable(false);
1.42 +
1.43 + signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed));
1.44 +
1.45 + table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false);
1.46 +
1.47 + std::vector<std::string> labels;
1.48 + labels.resize(EPS_PROPERTY_NUM);
1.49 +
1.50 + labels[N_MAPS]="Dump visualized nodemaps";
1.51 + labels[E_MAPS]="Dump visualizes arcmaps";
1.52 + labels[ARROWS]="Show arrows in directed digraphs";
1.53 + labels[PAR]="Indicate parallel arcs";
1.54 +
1.55 + options.resize(EPS_PROPERTY_NUM);
1.56 +
1.57 + for(int i=0;i<EPS_PROPERTY_NUM;i++)
1.58 + {
1.59 + options[i]=new Gtk::CheckButton(labels[i]);
1.60 + (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3);
1.61 + }
1.62 +
1.63 + mapselector=new MapSelector(n_nml, s_nml, "", "Nodeshapes", false, true, NUM);
1.64 + mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
1.65 +
1.66 + hbox.pack_start(*(new Gtk::Label("Filename")));
1.67 + hbox.pack_start(name);
1.68 +
1.69 + Gtk::VBox * vbox=get_vbox();
1.70 +
1.71 + vbox->pack_start(*table);
1.72 + vbox->pack_start(*mapselector);
1.73 + vbox->pack_start(hbox);
1.74 +
1.75 + //OK button
1.76 + add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1.77 + add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
1.78 +
1.79 + show_all_children();
1.80 +
1.81 +}
1.82 +
1.83 +bool EpsWin::on_delete_event(GdkEventAny * event)
1.84 +{
1.85 + event=event;
1.86 + signal_eps_close.emit();
1.87 + return true;
1.88 +}
1.89 +
1.90 +void EpsWin::on_response(int response_id)
1.91 +{
1.92 + if(response_id==Gtk::RESPONSE_OK)
1.93 + {
1.94 + std::vector <bool> values;
1.95 + values.resize(EPS_PROPERTY_NUM);
1.96 + for(int i=0;i<EPS_PROPERTY_NUM;i++)
1.97 + {
1.98 + values[i]=options[i]->get_active();
1.99 + }
1.100 + signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text());
1.101 + }
1.102 + on_delete_event(NULL);
1.103 +}
1.104 +
1.105 +void EpsWin::newMapWinNeeded(bool isitarc)
1.106 +{
1.107 + signal_new_map.emit(false);
1.108 +}
1.109 +
1.110 +void EpsWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
1.111 +{
1.112 + mapselector->append_text((Glib::ustring)newmapname, type);
1.113 +}