1.1 --- a/gui/mapselector.cc Mon Nov 21 09:08:16 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,225 +0,0 @@
1.4 -#include "mapselector.h"
1.5 -
1.6 -MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID)
1.7 -{
1.8 - update_list();
1.9 -
1.10 - cbt.set_active(0);
1.11 -
1.12 - //binding signal to the actual entry
1.13 - cbt.signal_changed().connect
1.14 - (
1.15 - sigc::mem_fun((*this), &MapSelector::comboChanged),
1.16 - false
1.17 - );
1.18 -
1.19 - if(itisedge)
1.20 - {
1.21 - label=new Gtk::Label(edge_property_strings[id]);
1.22 - }
1.23 - else
1.24 - {
1.25 - label=new Gtk::Label(node_property_strings[id]);
1.26 - }
1.27 -
1.28 - label->set_width_chars(longest_property_string_length);
1.29 -
1.30 - defbut=new Gtk::Button();
1.31 - defbut->set_label("Reset");
1.32 -
1.33 - defbut->signal_pressed().connect
1.34 - (
1.35 - sigc::mem_fun(*this, &MapSelector::reset)
1.36 - );
1.37 -
1.38 - newbut=new Gtk::Button(Gtk::Stock::NEW);
1.39 -
1.40 - newbut->signal_pressed().connect
1.41 - (
1.42 - sigc::mem_fun(*this, &MapSelector::new_but_pressed)
1.43 - );
1.44 -
1.45 - add(*label);
1.46 -
1.47 - add(cbt);
1.48 -
1.49 - add(*defbut);
1.50 - add(*newbut);
1.51 -}
1.52 -
1.53 -void MapSelector::new_but_pressed()
1.54 -{
1.55 - set_new_map=true;
1.56 - nmw.showByPreChoose(itisedge);
1.57 -}
1.58 -
1.59 -void MapSelector::update_list()
1.60 -{
1.61 - cbt.clear();
1.62 - if(itisedge)
1.63 - {
1.64 - std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
1.65 - for(;emsi!=ms.endOfEdgeMaps();emsi++)
1.66 - {
1.67 - cbt.append_text(emsi->first);
1.68 - }
1.69 - }
1.70 - else
1.71 - {
1.72 - std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
1.73 - for(;emsi!=ms.endOfNodeMaps();emsi++)
1.74 - {
1.75 - cbt.append_text(emsi->first);
1.76 - }
1.77 - }
1.78 - cbt.prepend_text("Default values");
1.79 -}
1.80 -
1.81 -void MapSelector::comboChanged()
1.82 -{
1.83 - if(cbt.get_active_row_number()!=0)
1.84 - {
1.85 - default_state=false;
1.86 - Glib::ustring mapname = cbt.get_active_text();
1.87 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.88 - {
1.89 - if(itisedge)
1.90 - {
1.91 - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
1.92 - {
1.93 - Edge edge=edge_to_update;
1.94 - switch(id)
1.95 - {
1.96 - case E_WIDTH:
1.97 - gdc.changeEdgeWidth(mapname, edge);
1.98 - break;
1.99 - case E_COLOR:
1.100 - gdc.changeEdgeColor(mapname, edge);
1.101 - break;
1.102 - case E_TEXT:
1.103 - gdc.changeEdgeText(mapname, edge);
1.104 - break;
1.105 - default:
1.106 - std::cerr<<"Error\n";
1.107 - }
1.108 - }
1.109 - }
1.110 - else
1.111 - {
1.112 - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
1.113 - {
1.114 - Node node=node_to_update;
1.115 - switch(id)
1.116 - {
1.117 - case N_RADIUS:
1.118 - gdc.changeNodeRadius(mapname, node);
1.119 - break;
1.120 - case N_COLOR:
1.121 - gdc.changeNodeColor(mapname, node);
1.122 - break;
1.123 - case N_TEXT:
1.124 - gdc.changeNodeText(mapname, node);
1.125 - break;
1.126 - default:
1.127 - std::cerr<<"Error\n";
1.128 - }
1.129 - }
1.130 - }
1.131 - }
1.132 - }
1.133 - else if((!default_state)&&(cbt.get_active_row_number()==0))
1.134 - {
1.135 - reset();
1.136 - }
1.137 -}
1.138 -
1.139 -void MapSelector::reset()
1.140 -{
1.141 - default_state=true;
1.142 - cbt.set_active(0);
1.143 -
1.144 - if(itisedge)
1.145 - {
1.146 - Edge edge=edge_to_update;
1.147 - switch(id)
1.148 - {
1.149 - case E_WIDTH:
1.150 - gdc.resetEdgeWidth(edge);
1.151 - break;
1.152 - case E_COLOR:
1.153 - gdc.resetEdgeColor(edge);
1.154 - break;
1.155 - case E_TEXT:
1.156 - gdc.resetEdgeText(edge);
1.157 - break;
1.158 - default:
1.159 - std::cerr<<"Error\n";
1.160 - }
1.161 - }
1.162 - else
1.163 - {
1.164 - Node node=node_to_update;
1.165 - switch(id)
1.166 - {
1.167 - case N_RADIUS:
1.168 - gdc.resetNodeRadius(node);
1.169 - break;
1.170 - case N_COLOR:
1.171 - gdc.resetNodeColor(node);
1.172 - break;
1.173 - case N_TEXT:
1.174 - gdc.resetNodeText(node);
1.175 - break;
1.176 - default:
1.177 - std::cerr<<"Error\n";
1.178 - }
1.179 - }
1.180 -}
1.181 -
1.182 -void MapSelector::update(Node node)
1.183 -{
1.184 - node_to_update=node;
1.185 - if(default_state)
1.186 - {
1.187 - reset();
1.188 - }
1.189 - else
1.190 - {
1.191 - comboChanged();
1.192 - }
1.193 - node_to_update=INVALID;
1.194 -}
1.195 -
1.196 -void MapSelector::update(Edge edge)
1.197 -{
1.198 - edge_to_update=edge;
1.199 - if(default_state)
1.200 - {
1.201 - reset();
1.202 - }
1.203 - else
1.204 - {
1.205 - comboChanged();
1.206 - }
1.207 - edge_to_update=INVALID;
1.208 -}
1.209 -
1.210 -Glib::ustring MapSelector::get_active_text()
1.211 -{
1.212 - return cbt.get_active_text();
1.213 -}
1.214 -
1.215 -void MapSelector::set_active_text(Glib::ustring text)
1.216 -{
1.217 - cbt.set_active_text(text);
1.218 -}
1.219 -
1.220 -void MapSelector::append_text(Glib::ustring text)
1.221 -{
1.222 - cbt.append_text(text);
1.223 - if(set_new_map)
1.224 - {
1.225 - set_active_text(text);
1.226 - set_new_map=false;
1.227 - }
1.228 -}