COIN-OR::LEMON - Graph Library

source: glemon/eps_win.cc

Last change on this file was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 16 years ago

SVN revision 3500 made compilable with Lemon 1.0.

File size: 2.7 KB
Line 
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
19#include <eps_win.h>
20
21#include <mapselector.h>
22
23#include <set>
24
25bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e)
26{
27  if(e->keyval==GDK_Escape)
28  {
29    hide();
30  }
31  return true;
32}
33
34EpsWin::EpsWin(const std::string& title, std::vector<std::string> n_nml, std::vector<std::string> s_nml):Gtk::Dialog(title, true, true)
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 arcmaps";
49  labels[ARROWS]="Show arrows in directed digraphs";
50  labels[PAR]="Indicate parallel arcs";
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
60  mapselector=new MapSelector(n_nml, s_nml, "", "Nodeshapes", false, true, NUM);
61  mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
62
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);
69  vbox->pack_start(*mapselector);
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
80bool EpsWin::on_delete_event(GdkEventAny * event)
81{
82  event=event;
83  signal_eps_close.emit();
84  return true;
85}
86
87void 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        }
97      signal_eps_details.emit(values, name.get_text(), mapselector->get_active_text());
98    }
99  on_delete_event(NULL);
100}
101
102void EpsWin::newMapWinNeeded(bool isitarc)
103{
104  signal_new_map.emit(false);
105}
106
107void EpsWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
108{
109    mapselector->append_text((Glib::ustring)newmapname, type);
110}
Note: See TracBrowser for help on using the repository browser.