mapselector.h
branchgui
changeset 122 96bfa82264c3
parent 115 9e5196647a5a
child 123 a3781bff1032
     1.1 --- a/mapselector.h	Thu Jan 12 13:28:54 2006 +0000
     1.2 +++ b/mapselector.h	Thu Jan 12 14:36:08 2006 +0000
     1.3 @@ -10,51 +10,149 @@
     1.4  #include <libgnomecanvasmm.h>
     1.5  #include <libgnomecanvasmm/polygon.h>
     1.6  
     1.7 +///A widget by which node and edgemaps can be selected, deselected and created.
     1.8 +
     1.9 +///During the usage of \ref glemon we have to select
    1.10 +///maps several times. We also need some aid-function
    1.11 +///like new map creation and deselecting previously
    1.12 +///selected map. Instead of writing a the mapselection
    1.13 +///at all occurences we can use this widget by connecting
    1.14 +///its signals to the correct place.
    1.15  class MapSelector : public Gtk::HBox
    1.16  {
    1.17   protected:
    1.18 +  ///This signal indicates that the selection has been changed by user.
    1.19    sigc::signal<void, std::string> signal_cbt;
    1.20 +
    1.21 +  ///Signal that indicates that user wants to create a new map.
    1.22    sigc::signal<void, bool> signal_newmapwin;
    1.23  
    1.24 +  ///If this is true, beyond the mapnames a 'Default' selection is available as well.
    1.25 +
    1.26 +  ///For example \ref MapWin needs 'Default' option as well. In this case no map
    1.27 +  ///will be visualized by the appropriate property.
    1.28 +  ///But \ref AlgoWin do not need 'Default' option, because if no map is selected,
    1.29 +  ///no algorithm can be run.
    1.30 +  ///Its value is got and set in contructor.
    1.31    bool def;
    1.32  
    1.33 +  ///Are the names of edgemaps or nodemaps stored here.
    1.34    bool itisedge;
    1.35  
    1.36 +  ///Shows whether 'Default' option is selected or not.
    1.37    bool default_state;
    1.38  
    1.39 +  ///It is true when the new button had been pressed but the new map has not been registrated yet.
    1.40 +
    1.41 +  ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector
    1.42 +  ///this variable is set to true. When the new map
    1.43 +  ///is done, it will be registrated in all existing \ref MapSelector 
    1.44 +  ///by \ref append_text function. That function checks
    1.45 +  ///whether this variable is true. If it is true that means
    1.46 +  ///that this \ref MapSelector has requested \ref NewMapWin.
    1.47 +  ///Therefore it set itself to the recently created map.
    1.48 +  ///After that \ref set_new_map is set again false, not to
    1.49 +  ///set maps active if \ref MapSelector piece is not the requester.
    1.50    bool set_new_map;
    1.51  
    1.52 +  ///The widget that holds the names of maps.
    1.53 +
    1.54 +  ///It can be rolled down
    1.55 +  ///Names in it are selectable.
    1.56    Gtk::ComboBoxText cbt;
    1.57  
    1.58 -  Gtk::Button * newbut, * defbut;
    1.59 +  ///New button.
    1.60  
    1.61 +  ///By pressing it
    1.62 +  ///\ref NewMapWin wilol pop-up
    1.63 +  Gtk::Button * newbut;
    1.64 +
    1.65 +  ///Reset button.
    1.66 +
    1.67 +  ///If pressed \ref cbt will
    1.68 +  ///set to 'Default' option.
    1.69 +  ///
    1.70 +  ///It is visible only if \ref def is true.
    1.71 +  Gtk::Button * defbut;
    1.72 +
    1.73 +  ///Container in which GUI elements are packed.
    1.74    Gtk::HBox hbox;
    1.75  
    1.76 +  ///Shows purpose of \ref MapSelector piece.
    1.77    Gtk::Label * label;
    1.78  
    1.79   public:
    1.80  
    1.81 -  MapSelector(std::vector<std::string>, std::string, std::string, bool, bool def=true);
    1.82 +  ///Constructor of \ref MapSelector
    1.83  
    1.84 +  ///Creates the layout and binds signal to the correct place.
    1.85 +  ///\param optionlist list of names to place in \ref cbt
    1.86 +  ///\param act preselected option
    1.87 +  ///\param purpose text of label indicating purpose of \ref MapStorage
    1.88 +  ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
    1.89 +  ///\param def do we need 'Default' option. See \ref def.
    1.90 +  MapSelector(std::vector<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true);
    1.91 +
    1.92 +  ///Signal emitted if the user has changed the selection.
    1.93    sigc::signal<void, std::string> signal_cbt_ch();
    1.94 +
    1.95 +  ///Signal emitted if the user has pressed New button (\ref newbut)
    1.96    sigc::signal<void, bool> signal_newmapwin_needed();
    1.97  
    1.98 +  ///Maintain \ref cbt.
    1.99 +
   1.100 +  ///Fills in \ref cbt with names, taking
   1.101 +  ///into account that the previously selected option
   1.102 +  ///has to be set back after the operation.
   1.103    void update_list( std::vector<std::string> );
   1.104  
   1.105 -  ///If a radiobutton is clicked, this function determines
   1.106 -  ///which button was that and after that calls the
   1.107 -  ///appropriate function of the \ref GraphDisplayerCanvas
   1.108 -  ///to change the visible values of that attribute.
   1.109 +  ///Handles changement in \ref cbt.
   1.110 +
   1.111 +  ///In default case it emits a signal with the selected option.
   1.112 +  ///But if 'Default' option is selected, it resets the \ref MapSelector
   1.113    virtual void comboChanged();
   1.114  
   1.115 +  ///Requests a \ref NewMapWin
   1.116 +
   1.117 +  ///See \ref set_new_map.
   1.118 +  ///First it sets \ref set_new_map true to be identified
   1.119 +  ///at registration of new map that
   1.120 +  ///it has sent the \ref signal_newmapwin, therefore it
   1.121 +  ///has to set \ref cbt to that option.
   1.122    virtual void new_but_pressed();
   1.123  
   1.124 +  ///If called, 'Default' option is selected, that means unselection of any maps.
   1.125 +
   1.126 +  ///Practically this means that if this is called,
   1.127 +  ///properties of graph will set to default state.
   1.128 +  ///The function achieves this by emitting appropriately
   1.129 +  ///parametrized signal_cbt.
   1.130    virtual void reset();
   1.131  
   1.132 +  ///Returns the currently selected option.
   1.133    Glib::ustring get_active_text();
   1.134 -  void set_active_text(Glib::ustring);
   1.135 +
   1.136 +  ///Sets the parameter active in \ref cbt.
   1.137 +
   1.138 +  ///\param new_value the
   1.139 +  ///new value to be set in \ref cbt.
   1.140 +  void set_active_text(Glib::ustring new_value);
   1.141 +
   1.142 +  ///Sets the parameter active in \ref cbt.
   1.143 +  ///\param index the
   1.144 +  ///index of row to be set in \ref cbt.
   1.145    void set_active(int index){cbt.set_active(index);};
   1.146 +
   1.147 +  ///Clear all options from \ref cbt.
   1.148    void clear(){cbt.clear();};
   1.149 -  void append_text(Glib::ustring);
   1.150 +
   1.151 +  ///Appends a new option to the existing ones in \ref cbt.
   1.152 +
   1.153 +  ///If \ref set_new_map is true, the
   1.154 +  ///\ref MapSelector has requested the opened \ref NewMapWin,
   1.155 +  ///from that the option to append is coming. In this case
   1.156 +  ///this function  will set \ref cbt to the new option.
   1.157 +  ///\param new_option new option to append
   1.158 +  void append_text(Glib::ustring new_option);
   1.159  };
   1.160  #endif //MAPSELECTOR_H