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