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