COIN-OR::LEMON - Graph Library

source: glemon/mapselector.h @ 4:244d8c60b997

Last change on this file since 4:244d8c60b997 was 1:67188bd752db, checked in by Peter Hegyi <hegyi@…>, 16 years ago

SVN revision 3500 made compilable with Lemon 1.0.

File size: 6.0 KB
Line 
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#ifndef MAPSELECTOR_H
20#define MAPSELECTOR_H
21
22#include <all_include.h>
23#include <libgnomecanvasmm.h>
24#include <libgnomecanvasmm/polygon.h>
25#include "map_value.h"
26
27///A widget by which node and arcmaps can be selected, deselected and created.
28
29///During the usage of \ref glemon we have to select
30///maps several times. We also need some aid-function
31///like new map creation and deselecting previously
32///selected map. Instead of writing a the mapselection
33///at all occurences we can use this widget by connecting
34///its signals to the correct place.
35class MapSelector : public Gtk::HBox
36{
37 protected:
38  ///This signal indicates that the selection has been changed by user.
39  sigc::signal<void, std::string> signal_cbt;
40
41  ///Signal that indicates that user wants to create a new map.
42  sigc::signal<void, bool> signal_newmapwin;
43
44  ///If this is true, beyond the mapnames a 'Default' selection is available as well.
45
46  ///For example \ref MapWin needs 'Default' option as well. In this case no map
47  ///will be visualized by the appropriate property.
48  ///But \ref AlgoWin do not need 'Default' option, because if no map is selected,
49  ///no algorithm can be run.
50  ///Its value is got and set in contructor.
51  bool def;
52
53  ///Are the names of arcmaps or nodemaps stored here.
54  bool itisarc;
55
56  ///Shows whether 'Default' option is selected or not.
57  bool default_state;
58
59  ///It is true when the new button had been pressed but the new map has not been registrated yet.
60
61  ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector
62  ///this variable is set to true. When the new map
63  ///is done, it will be registrated in all existing \ref MapSelector
64  ///by \ref append_text function. That function checks
65  ///whether this variable is true. If it is true that means
66  ///that this \ref MapSelector has requested \ref NewMapWin.
67  ///Therefore it set itself to the recently created map.
68  ///After that \ref set_new_map is set again false, not to
69  ///set maps active if \ref MapSelector piece is not the requester.
70  bool set_new_map;
71
72  ///The widget that holds the names of maps.
73
74  ///It can be rolled down
75  ///Names in it are selectable.
76  Gtk::ComboBoxText cbt;
77
78  std::vector<std::string> cbt_content;
79
80  ///New button.
81
82  ///By pressing it
83  ///\ref NewMapWin wilol pop-up
84  Gtk::Button newbut;
85
86  ///Reset button.
87
88  ///If pressed \ref cbt will
89  ///set to 'Default' option.
90  ///
91  ///It is visible only if \ref def is true.
92  Gtk::Button defbut;
93
94  ///Shows purpose of \ref MapSelector piece.
95  Gtk::Label label;
96
97  /// Which types of maps (integer, string, ...) to display.
98  MapType map_type;
99
100 public:
101
102  ///Constructor of \ref MapSelector
103
104  ///Creates the layout and binds signal to the correct place.
105  ///\param mapstorage Pointer to the \ref MapStorage to get the map list from.
106  ///\param act preselected option
107  ///\param purpose text of label indicating purpose of \ref MapStorage
108  ///\param itisarc do \ref MapSelector contains arcmap names or nodemapnames.
109  ///\param def do we need 'Default' option. See \ref def.
110  ///\param type Specifies which types of maps to display.
111  MapSelector(std::vector<std::string> n_ml,
112      std::vector<std::string> s_ml, std::string act, std::string labeltext,
113      bool arc, bool d = true, MapType type = ALL);
114
115  ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
116  sigc::signal<void, std::string> signal_cbt_ch();
117
118  ///Returns signal emitted if the user has pressed New button (\ref newbut) (\ref signal_newmapwin)
119  sigc::signal<void, bool> signal_newmapwin_needed();
120
121  ///Maintain \ref cbt.
122
123  ///Fills in \ref cbt with names, taking
124  ///into account that the previously selected option
125  ///has to be set back after the operation.
126  void update_list(std::vector<std::string> n_ml,
127      std::vector<std::string> s_ml);
128
129  ///Handles changement in \ref cbt.
130
131  ///In default case it emits a signal with the selected option.
132  ///But if 'Default' option is selected, it resets the \ref MapSelector
133  virtual void comboChanged();
134
135  ///Requests a \ref NewMapWin
136
137  ///See \ref set_new_map.
138  ///First it sets \ref set_new_map true to be identified
139  ///at registration of new map that
140  ///it has sent the \ref signal_newmapwin, therefore it
141  ///has to set \ref cbt to that option.
142  virtual void new_but_pressed();
143
144  ///If called, 'Default' option is selected, that means unselection of any maps.
145
146  ///Practically this means that if this is called,
147  ///properties of digraph will set to default state.
148  ///The function achieves this by emitting appropriately
149  ///parametrized signal_cbt.
150  virtual void reset();
151
152  ///Returns the currently selected option.
153  Glib::ustring get_active_text();
154
155  ///Sets the parameter active in \ref cbt.
156
157  ///\param new_value the
158  ///new value to be set in \ref cbt.
159  void set_active_text(Glib::ustring new_value);
160
161  ///Sets the parameter active in \ref cbt.
162  ///\param index the
163  ///index of row to be set in \ref cbt.
164  void set_active(int index){cbt.set_active(index);};
165
166  ///Clear all options from \ref cbt.
167  void clear(){cbt.clear();};
168
169  ///Appends a new option to the existing ones in \ref cbt.
170
171  ///If \ref set_new_map is true, the
172  ///\ref MapSelector has requested the opened \ref NewMapWin,
173  ///from that the option to append is coming. In this case
174  ///this function  will set \ref cbt to the new option.
175  ///\param new_option new option to append
176  void append_text(Glib::ustring new_option, MapValue::Type);
177};
178#endif //MAPSELECTOR_H
Note: See TracBrowser for help on using the repository browser.