3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
22 #include <all_include.h>
23 #include <libgnomecanvasmm.h>
24 #include <libgnomecanvasmm/polygon.h>
26 ///A widget by which node and edgemaps can be selected, deselected and created.
28 ///During the usage of \ref glemon we have to select
29 ///maps several times. We also need some aid-function
30 ///like new map creation and deselecting previously
31 ///selected map. Instead of writing a the mapselection
32 ///at all occurences we can use this widget by connecting
33 ///its signals to the correct place.
34 class MapSelector : public Gtk::HBox
37 ///This signal indicates that the selection has been changed by user.
38 sigc::signal<void, std::string> signal_cbt;
40 ///Signal that indicates that user wants to create a new map.
41 sigc::signal<void, bool> signal_newmapwin;
43 ///If this is true, beyond the mapnames a 'Default' selection is available as well.
45 ///For example \ref MapWin needs 'Default' option as well. In this case no map
46 ///will be visualized by the appropriate property.
47 ///But \ref AlgoWin do not need 'Default' option, because if no map is selected,
48 ///no algorithm can be run.
49 ///Its value is got and set in contructor.
52 ///Are the names of edgemaps or nodemaps stored here.
55 ///Shows whether 'Default' option is selected or not.
58 ///It is true when the new button had been pressed but the new map has not been registrated yet.
60 ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector
61 ///this variable is set to true. When the new map
62 ///is done, it will be registrated in all existing \ref MapSelector
63 ///by \ref append_text function. That function checks
64 ///whether this variable is true. If it is true that means
65 ///that this \ref MapSelector has requested \ref NewMapWin.
66 ///Therefore it set itself to the recently created map.
67 ///After that \ref set_new_map is set again false, not to
68 ///set maps active if \ref MapSelector piece is not the requester.
71 ///The widget that holds the names of maps.
73 ///It can be rolled down
74 ///Names in it are selectable.
75 Gtk::ComboBoxText cbt;
77 std::vector<std::string> cbt_content;
82 ///\ref NewMapWin wilol pop-up
87 ///If pressed \ref cbt will
88 ///set to 'Default' option.
90 ///It is visible only if \ref def is true.
93 ///Container in which GUI elements are packed.
96 ///Shows purpose of \ref MapSelector piece.
101 ///Constructor of \ref MapSelector
103 ///Creates the layout and binds signal to the correct place.
104 ///\param optionlist list of names to place in \ref cbt
105 ///\param act preselected option
106 ///\param purpose text of label indicating purpose of \ref MapStorage
107 ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
108 ///\param def do we need 'Default' option. See \ref def.
109 MapSelector(std::vector<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true);
111 ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
112 sigc::signal<void, std::string> signal_cbt_ch();
114 ///Returns signal emitted if the user has pressed New button (\ref newbut) (\ref signal_newmapwin)
115 sigc::signal<void, bool> signal_newmapwin_needed();
117 ///Maintain \ref cbt.
119 ///Fills in \ref cbt with names, taking
120 ///into account that the previously selected option
121 ///has to be set back after the operation.
122 void update_list( std::vector<std::string> );
124 ///Handles changement in \ref cbt.
126 ///In default case it emits a signal with the selected option.
127 ///But if 'Default' option is selected, it resets the \ref MapSelector
128 virtual void comboChanged();
130 ///Requests a \ref NewMapWin
132 ///See \ref set_new_map.
133 ///First it sets \ref set_new_map true to be identified
134 ///at registration of new map that
135 ///it has sent the \ref signal_newmapwin, therefore it
136 ///has to set \ref cbt to that option.
137 virtual void new_but_pressed();
139 ///If called, 'Default' option is selected, that means unselection of any maps.
141 ///Practically this means that if this is called,
142 ///properties of graph will set to default state.
143 ///The function achieves this by emitting appropriately
144 ///parametrized signal_cbt.
145 virtual void reset();
147 ///Returns the currently selected option.
148 Glib::ustring get_active_text();
150 ///Sets the parameter active in \ref cbt.
152 ///\param new_value the
153 ///new value to be set in \ref cbt.
154 void set_active_text(Glib::ustring new_value);
156 ///Sets the parameter active in \ref cbt.
158 ///index of row to be set in \ref cbt.
159 void set_active(int index){cbt.set_active(index);};
161 ///Clear all options from \ref cbt.
162 void clear(){cbt.clear();};
164 ///Appends a new option to the existing ones in \ref cbt.
166 ///If \ref set_new_map is true, the
167 ///\ref MapSelector has requested the opened \ref NewMapWin,
168 ///from that the option to append is coming. In this case
169 ///this function will set \ref cbt to the new option.
170 ///\param new_option new option to append
171 void append_text(Glib::ustring new_option);
173 #endif //MAPSELECTOR_H