// -*- C++ -*- // #ifndef MAPSELECTOR_H #define MAPSELECTOR_H class MapSelector; #include #include #include #include ///A widget by which node and edgemaps can be selected, deselected and created. ///During the usage of \ref glemon we have to select ///maps several times. We also need some aid-function ///like new map creation and deselecting previously ///selected map. Instead of writing a the mapselection ///at all occurences we can use this widget by connecting ///its signals to the correct place. class MapSelector : public Gtk::HBox { protected: ///This signal indicates that the selection has been changed by user. sigc::signal signal_cbt; ///Signal that indicates that user wants to create a new map. sigc::signal signal_newmapwin; ///If this is true, beyond the mapnames a 'Default' selection is available as well. ///For example \ref MapWin needs 'Default' option as well. In this case no map ///will be visualized by the appropriate property. ///But \ref AlgoWin do not need 'Default' option, because if no map is selected, ///no algorithm can be run. ///Its value is got and set in contructor. bool def; ///Are the names of edgemaps or nodemaps stored here. bool itisedge; ///Shows whether 'Default' option is selected or not. bool default_state; ///It is true when the new button had been pressed but the new map has not been registrated yet. ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector ///this variable is set to true. When the new map ///is done, it will be registrated in all existing \ref MapSelector ///by \ref append_text function. That function checks ///whether this variable is true. If it is true that means ///that this \ref MapSelector has requested \ref NewMapWin. ///Therefore it set itself to the recently created map. ///After that \ref set_new_map is set again false, not to ///set maps active if \ref MapSelector piece is not the requester. bool set_new_map; ///The widget that holds the names of maps. ///It can be rolled down ///Names in it are selectable. Gtk::ComboBoxText cbt; ///New button. ///By pressing it ///\ref NewMapWin wilol pop-up Gtk::Button * newbut; ///Reset button. ///If pressed \ref cbt will ///set to 'Default' option. /// ///It is visible only if \ref def is true. Gtk::Button * defbut; ///Container in which GUI elements are packed. Gtk::HBox hbox; ///Shows purpose of \ref MapSelector piece. Gtk::Label * label; public: ///Constructor of \ref MapSelector ///Creates the layout and binds signal to the correct place. ///\param optionlist list of names to place in \ref cbt ///\param act preselected option ///\param purpose text of label indicating purpose of \ref MapStorage ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames. ///\param def do we need 'Default' option. See \ref def. MapSelector(std::vector optionlist, std::string act, std::string purpose, bool itisedge, bool def=true); ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt) sigc::signal signal_cbt_ch(); ///Returns signal emitted if the user has pressed New button (\ref newbut) (\ref signal_newmapwin) sigc::signal signal_newmapwin_needed(); ///Maintain \ref cbt. ///Fills in \ref cbt with names, taking ///into account that the previously selected option ///has to be set back after the operation. void update_list( std::vector ); ///Handles changement in \ref cbt. ///In default case it emits a signal with the selected option. ///But if 'Default' option is selected, it resets the \ref MapSelector virtual void comboChanged(); ///Requests a \ref NewMapWin ///See \ref set_new_map. ///First it sets \ref set_new_map true to be identified ///at registration of new map that ///it has sent the \ref signal_newmapwin, therefore it ///has to set \ref cbt to that option. virtual void new_but_pressed(); ///If called, 'Default' option is selected, that means unselection of any maps. ///Practically this means that if this is called, ///properties of graph will set to default state. ///The function achieves this by emitting appropriately ///parametrized signal_cbt. virtual void reset(); ///Returns the currently selected option. Glib::ustring get_active_text(); ///Sets the parameter active in \ref cbt. ///\param new_value the ///new value to be set in \ref cbt. void set_active_text(Glib::ustring new_value); ///Sets the parameter active in \ref cbt. ///\param index the ///index of row to be set in \ref cbt. void set_active(int index){cbt.set_active(index);}; ///Clear all options from \ref cbt. void clear(){cbt.clear();}; ///Appends a new option to the existing ones in \ref cbt. ///If \ref set_new_map is true, the ///\ref MapSelector has requested the opened \ref NewMapWin, ///from that the option to append is coming. In this case ///this function will set \ref cbt to the new option. ///\param new_option new option to append void append_text(Glib::ustring new_option); }; #endif //MAPSELECTOR_H