|
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 #include <set> |
|
21 |
|
22 bool EpsWin::closeIfEscapeIsPressed(GdkEventKey* e) |
|
23 { |
|
24 if(e->keyval==GDK_Escape) |
|
25 { |
|
26 hide(); |
|
27 } |
|
28 return true; |
|
29 } |
|
30 |
|
31 EpsWin::EpsWin(const std::string& title, NoteBookTab & mw):Gtk::Dialog(title, true, true),mytab(mw) |
|
32 { |
|
33 set_default_size(200, 50); |
|
34 |
|
35 set_resizable(false); |
|
36 |
|
37 signal_key_press_event().connect(sigc::mem_fun(*this, &EpsWin::closeIfEscapeIsPressed)); |
|
38 |
|
39 mytab.signal_title_ch().connect(sigc::mem_fun(*this, &EpsWin::set_title)); |
|
40 |
|
41 table=new Gtk::Table(EPS_PROPERTY_NUM, 1, false); |
|
42 |
|
43 std::vector<std::string> labels; |
|
44 labels.resize(EPS_PROPERTY_NUM); |
|
45 |
|
46 labels[N_MAPS]="Dump visualized nodemaps"; |
|
47 labels[E_MAPS]="Dump visualizes edgemaps"; |
|
48 labels[ARROWS]="Show arrows in directed graphs"; |
|
49 labels[PAR]="Indicate parallel edges"; |
|
50 |
|
51 options.resize(EPS_PROPERTY_NUM); |
|
52 |
|
53 for(int i=0;i<EPS_PROPERTY_NUM;i++) |
|
54 { |
|
55 options[i]=new Gtk::CheckButton(labels[i]); |
|
56 (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3); |
|
57 } |
|
58 |
|
59 hbox.pack_start(*(new Gtk::Label("Filename"))); |
|
60 hbox.pack_start(name); |
|
61 |
|
62 Gtk::VBox * vbox=get_vbox(); |
|
63 |
|
64 vbox->pack_start(*table); |
|
65 vbox->pack_start(hbox); |
|
66 |
|
67 //OK button |
|
68 add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
|
69 add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); |
|
70 |
|
71 show_all_children(); |
|
72 |
|
73 } |
|
74 |
|
75 bool EpsWin::on_delete_event(GdkEventAny * event) |
|
76 { |
|
77 event=event; |
|
78 mytab.closeEpsWin(); |
|
79 return true; |
|
80 } |
|
81 |
|
82 void EpsWin::on_response(int response_id) |
|
83 { |
|
84 if(response_id==Gtk::RESPONSE_OK) |
|
85 { |
|
86 std::vector <bool> values; |
|
87 values.resize(EPS_PROPERTY_NUM); |
|
88 for(int i=0;i<EPS_PROPERTY_NUM;i++) |
|
89 { |
|
90 values[i]=options[i]->get_active(); |
|
91 } |
|
92 mytab.exportGraphToEPS(values, name.get_text()); |
|
93 } |
|
94 on_delete_event(NULL); |
|
95 } |