gui/edit_win.cc
author hegyi
Mon, 13 Jun 2005 19:49:33 +0000
changeset 1478 bc7ae573d77d
parent 1469 104aab6e5d86
child 1485 3a1c6678fa23
permissions -rwxr-xr-x
Known bugs are eliminated from gui, and new ones are created by changing tool selectors to special radiobuttons, and by adding edgecreation-canceller function (right-click on any group element).
hegyi@1469
     1
#include <edit_win.h>
hegyi@1469
     2
#include <set>
hegyi@1469
     3
hegyi@1469
     4
bool EditWin::close_if_escape_is_pressed(GdkEventKey* e)
hegyi@1469
     5
{
hegyi@1469
     6
  if(e->keyval==GDK_Escape)
hegyi@1469
     7
  {
hegyi@1469
     8
    hide();
hegyi@1469
     9
  }
hegyi@1469
    10
  return true;
hegyi@1469
    11
}
hegyi@1469
    12
hegyi@1469
    13
EditWin::EditWin(const std::string& title, GraphDisplayerCanvas & grdispc):gdc(grdispc),table(2, 2, true)
hegyi@1469
    14
{
hegyi@1469
    15
  set_title(title);
hegyi@1469
    16
  set_default_size(200, 50);
hegyi@1478
    17
  set_keep_above(true);
hegyi@1469
    18
  signal_key_press_event().connect(sigc::mem_fun(*this, &EditWin::close_if_escape_is_pressed));
hegyi@1469
    19
  
hegyi@1478
    20
  //buttons array
hegyi@1478
    21
  buttons=new (Gtk::RadioButton *) [TOOL_NUM];
hegyi@1478
    22
  for(int i=0;i<TOOL_NUM;i++)
hegyi@1478
    23
    {
hegyi@1478
    24
      buttons[i]=NULL;
hegyi@1478
    25
    }
hegyi@1478
    26
hegyi@1478
    27
  Gtk::RadioButton::Group group;//=buttons[MOVE]->get_group();
hegyi@1478
    28
hegyi@1469
    29
  //New node button
hegyi@1478
    30
  buttons[CREATE_NODE]=new Gtk::RadioButton("New Node");
hegyi@1478
    31
  buttons[CREATE_NODE]->set_mode(false);
hegyi@1478
    32
  buttons[CREATE_NODE]->set_group(group);
hegyi@1478
    33
  buttons[CREATE_NODE]->signal_clicked().connect
hegyi@1469
    34
    (
hegyi@1469
    35
     sigc::bind
hegyi@1469
    36
     (
hegyi@1469
    37
      sigc::mem_fun(*this, &EditWin::makeEditorialToolChanged),
hegyi@1469
    38
      1
hegyi@1469
    39
      )
hegyi@1469
    40
     );
hegyi@1478
    41
  table.attach(*buttons[CREATE_NODE],0,1,0,1);
hegyi@1469
    42
hegyi@1469
    43
  //New edge button
hegyi@1478
    44
  buttons[CREATE_EDGE]=new Gtk::RadioButton("New Edge");
hegyi@1478
    45
  buttons[CREATE_EDGE]->set_mode(false);
hegyi@1478
    46
  buttons[CREATE_EDGE]->set_group(group);
hegyi@1478
    47
  buttons[CREATE_EDGE]->signal_clicked().connect
hegyi@1469
    48
    (
hegyi@1469
    49
     sigc::bind
hegyi@1469
    50
     (
hegyi@1469
    51
      sigc::mem_fun(*this, &EditWin::makeEditorialToolChanged),
hegyi@1469
    52
      2
hegyi@1469
    53
      )
hegyi@1469
    54
     );
hegyi@1478
    55
  table.attach(*buttons[CREATE_EDGE],1,2,0,1);
hegyi@1469
    56
    
hegyi@1469
    57
  //Move button
hegyi@1478
    58
  buttons[MOVE]=new Gtk::RadioButton("Move");
hegyi@1478
    59
  buttons[MOVE]->set_mode(false);
hegyi@1478
    60
  buttons[MOVE]->set_group(group);
hegyi@1478
    61
  buttons[MOVE]->signal_clicked().connect
hegyi@1469
    62
    (
hegyi@1469
    63
     sigc::bind
hegyi@1469
    64
     (
hegyi@1469
    65
      sigc::mem_fun(*this, &EditWin::makeEditorialToolChanged),
hegyi@1469
    66
      0
hegyi@1469
    67
      )
hegyi@1469
    68
     );
hegyi@1478
    69
  table.attach(*buttons[MOVE],0,1,1,2);
hegyi@1478
    70
      
hegyi@1469
    71
  add(table);
hegyi@1469
    72
hegyi@1469
    73
  show_all_children();
hegyi@1469
    74
hegyi@1469
    75
}
hegyi@1469
    76
hegyi@1469
    77
void EditWin::makeEditorialToolChanged(int newtool)
hegyi@1469
    78
{
hegyi@1469
    79
  gdc.changeEditorialTool(newtool);
hegyi@1469
    80
}