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