[192] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
| 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2003-2006 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
| 8 | * |
---|
| 9 | * Permission to use, modify and distribute this software is granted |
---|
| 10 | * provided that this copyright notice appears in all copies. For |
---|
| 11 | * precise terms see the accompanying LICENSE file. |
---|
| 12 | * |
---|
| 13 | * This software is provided "AS IS" with no warranty of any kind, |
---|
| 14 | * express or implied, and with no claim as to its suitability for any |
---|
| 15 | * purpose. |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | |
---|
[194] | 19 | #include <eps_win.h> |
---|
[198] | 20 | |
---|
| 21 | #include <mapselector.h> |
---|
| 22 | |
---|
[192] | 23 | #include <set> |
---|
| 24 | |
---|
| 25 | bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e) |
---|
| 26 | { |
---|
| 27 | if(e->keyval==GDK_Escape) |
---|
| 28 | { |
---|
| 29 | hide(); |
---|
| 30 | } |
---|
| 31 | return true; |
---|
| 32 | } |
---|
| 33 | |
---|
[198] | 34 | EpsWin::EpsWin(const std::string& title, std::vector<std::string> nml):Gtk::Dialog(title, true, true) |
---|
[192] | 35 | { |
---|
| 36 | set_default_size(200, 50); |
---|
| 37 | |
---|
| 38 | set_resizable(false); |
---|
| 39 | |
---|
| 40 | signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed)); |
---|
| 41 | |
---|
| 42 | table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false); |
---|
| 43 | |
---|
| 44 | std::vector<std::string> labels; |
---|
| 45 | labels.resize(EPS_PROPERTY_NUM); |
---|
| 46 | |
---|
| 47 | labels[N_MAPS]="Dump visualized nodemaps"; |
---|
| 48 | labels[E_MAPS]="Dump visualizes edgemaps"; |
---|
| 49 | labels[ARROWS]="Show arrows in directed graphs"; |
---|
| 50 | labels[PAR]="Indicate parallel edges"; |
---|
| 51 | |
---|
| 52 | options.resize(EPS_PROPERTY_NUM); |
---|
| 53 | |
---|
| 54 | for(int i=0;i<EPS_PROPERTY_NUM;i++) |
---|
| 55 | { |
---|
| 56 | options[i]=new Gtk::CheckButton(labels[i]); |
---|
| 57 | (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3); |
---|
| 58 | } |
---|
| 59 | |
---|
[198] | 60 | mapselector=new MapSelector(nml, "", "Nodeshapes", false); |
---|
| 61 | mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded)); |
---|
| 62 | |
---|
[192] | 63 | hbox.pack_start(*(new Gtk::Label("Filename"))); |
---|
| 64 | hbox.pack_start(name); |
---|
| 65 | |
---|
| 66 | Gtk::VBox * vbox=get_vbox(); |
---|
| 67 | |
---|
| 68 | vbox->pack_start(*table); |
---|
[198] | 69 | vbox->pack_start(*mapselector); |
---|
[192] | 70 | vbox->pack_start(hbox); |
---|
| 71 | |
---|
| 72 | //OK button |
---|
| 73 | add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
---|
| 74 | add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); |
---|
| 75 | |
---|
| 76 | show_all_children(); |
---|
| 77 | |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | bool EpsWin::on_delete_event(GdkEventAny * event) |
---|
| 81 | { |
---|
| 82 | event=event; |
---|
[196] | 83 | signal_eps_close.emit(); |
---|
[192] | 84 | return true; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | void EpsWin::on_response(int response_id) |
---|
| 88 | { |
---|
| 89 | if(response_id==Gtk::RESPONSE_OK) |
---|
| 90 | { |
---|
| 91 | std::vector <bool> values; |
---|
| 92 | values.resize(EPS_PROPERTY_NUM); |
---|
| 93 | for(int i=0;i<EPS_PROPERTY_NUM;i++) |
---|
| 94 | { |
---|
| 95 | values[i]=options[i]->get_active(); |
---|
| 96 | } |
---|
[198] | 97 | signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text()); |
---|
[192] | 98 | } |
---|
| 99 | on_delete_event(NULL); |
---|
| 100 | } |
---|
[198] | 101 | |
---|
| 102 | void EpsWin::newMapWinNeeded(bool isitedge) |
---|
| 103 | { |
---|
| 104 | signal_new_map.emit(false); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | void EpsWin::registerNewNodeMap(std::string newmapname) |
---|
| 108 | { |
---|
| 109 | mapselector->append_text((Glib::ustring)newmapname); |
---|
| 110 | } |
---|