Documentation of MapSelector. If no default value is present in MapSelector, Reset button does not appear. gui
authorhegyi
Thu, 12 Jan 2006 14:36:08 +0000
branchgui
changeset 12296bfa82264c3
parent 121 637c12cbd64c
child 123 a3781bff1032
Documentation of MapSelector. If no default value is present in MapSelector, Reset button does not appear.
mapselector.cc
mapselector.h
     1.1 --- a/mapselector.cc	Thu Jan 12 13:28:54 2006 +0000
     1.2 +++ b/mapselector.cc	Thu Jan 12 14:36:08 2006 +0000
     1.3 @@ -26,13 +26,17 @@
     1.4  
     1.5    label->set_width_chars(longest_property_string_length);
     1.6  
     1.7 -  defbut=new Gtk::Button();
     1.8 -  defbut->set_label("Reset");
     1.9 -
    1.10 -  defbut->signal_pressed().connect
    1.11 -    (
    1.12 -     sigc::mem_fun(*this, &MapSelector::reset)
    1.13 -     );
    1.14 +  defbut=NULL;
    1.15 +  if(def)
    1.16 +    {
    1.17 +      defbut=new Gtk::Button();
    1.18 +      defbut->set_label("Reset");
    1.19 +      
    1.20 +      defbut->signal_pressed().connect
    1.21 +	(
    1.22 +	 sigc::mem_fun(*this, &MapSelector::reset)
    1.23 +	 );
    1.24 +    }
    1.25  
    1.26    newbut=new Gtk::Button(Gtk::Stock::NEW);
    1.27  
    1.28 @@ -45,7 +49,11 @@
    1.29  
    1.30    add(cbt);
    1.31  
    1.32 -  add(*defbut);
    1.33 +  if(def)
    1.34 +    {
    1.35 +      add(*defbut);
    1.36 +    }
    1.37 +
    1.38    add(*newbut);
    1.39  }
    1.40  
    1.41 @@ -76,7 +84,7 @@
    1.42  
    1.43  void MapSelector::comboChanged()
    1.44  {
    1.45 -  if(cbt.get_active_row_number()!=0)
    1.46 +  if(cbt.get_active_row_number()!=0 || !def)
    1.47      {
    1.48        default_state=false;
    1.49        Glib::ustring mapname = cbt.get_active_text();
     2.1 --- a/mapselector.h	Thu Jan 12 13:28:54 2006 +0000
     2.2 +++ b/mapselector.h	Thu Jan 12 14:36:08 2006 +0000
     2.3 @@ -10,51 +10,149 @@
     2.4  #include <libgnomecanvasmm.h>
     2.5  #include <libgnomecanvasmm/polygon.h>
     2.6  
     2.7 +///A widget by which node and edgemaps can be selected, deselected and created.
     2.8 +
     2.9 +///During the usage of \ref glemon we have to select
    2.10 +///maps several times. We also need some aid-function
    2.11 +///like new map creation and deselecting previously
    2.12 +///selected map. Instead of writing a the mapselection
    2.13 +///at all occurences we can use this widget by connecting
    2.14 +///its signals to the correct place.
    2.15  class MapSelector : public Gtk::HBox
    2.16  {
    2.17   protected:
    2.18 +  ///This signal indicates that the selection has been changed by user.
    2.19    sigc::signal<void, std::string> signal_cbt;
    2.20 +
    2.21 +  ///Signal that indicates that user wants to create a new map.
    2.22    sigc::signal<void, bool> signal_newmapwin;
    2.23  
    2.24 +  ///If this is true, beyond the mapnames a 'Default' selection is available as well.
    2.25 +
    2.26 +  ///For example \ref MapWin needs 'Default' option as well. In this case no map
    2.27 +  ///will be visualized by the appropriate property.
    2.28 +  ///But \ref AlgoWin do not need 'Default' option, because if no map is selected,
    2.29 +  ///no algorithm can be run.
    2.30 +  ///Its value is got and set in contructor.
    2.31    bool def;
    2.32  
    2.33 +  ///Are the names of edgemaps or nodemaps stored here.
    2.34    bool itisedge;
    2.35  
    2.36 +  ///Shows whether 'Default' option is selected or not.
    2.37    bool default_state;
    2.38  
    2.39 +  ///It is true when the new button had been pressed but the new map has not been registrated yet.
    2.40 +
    2.41 +  ///Before signal of \ref NewMapWin request is emitted by the \ref MapSelector
    2.42 +  ///this variable is set to true. When the new map
    2.43 +  ///is done, it will be registrated in all existing \ref MapSelector 
    2.44 +  ///by \ref append_text function. That function checks
    2.45 +  ///whether this variable is true. If it is true that means
    2.46 +  ///that this \ref MapSelector has requested \ref NewMapWin.
    2.47 +  ///Therefore it set itself to the recently created map.
    2.48 +  ///After that \ref set_new_map is set again false, not to
    2.49 +  ///set maps active if \ref MapSelector piece is not the requester.
    2.50    bool set_new_map;
    2.51  
    2.52 +  ///The widget that holds the names of maps.
    2.53 +
    2.54 +  ///It can be rolled down
    2.55 +  ///Names in it are selectable.
    2.56    Gtk::ComboBoxText cbt;
    2.57  
    2.58 -  Gtk::Button * newbut, * defbut;
    2.59 +  ///New button.
    2.60  
    2.61 +  ///By pressing it
    2.62 +  ///\ref NewMapWin wilol pop-up
    2.63 +  Gtk::Button * newbut;
    2.64 +
    2.65 +  ///Reset button.
    2.66 +
    2.67 +  ///If pressed \ref cbt will
    2.68 +  ///set to 'Default' option.
    2.69 +  ///
    2.70 +  ///It is visible only if \ref def is true.
    2.71 +  Gtk::Button * defbut;
    2.72 +
    2.73 +  ///Container in which GUI elements are packed.
    2.74    Gtk::HBox hbox;
    2.75  
    2.76 +  ///Shows purpose of \ref MapSelector piece.
    2.77    Gtk::Label * label;
    2.78  
    2.79   public:
    2.80  
    2.81 -  MapSelector(std::vector<std::string>, std::string, std::string, bool, bool def=true);
    2.82 +  ///Constructor of \ref MapSelector
    2.83  
    2.84 +  ///Creates the layout and binds signal to the correct place.
    2.85 +  ///\param optionlist list of names to place in \ref cbt
    2.86 +  ///\param act preselected option
    2.87 +  ///\param purpose text of label indicating purpose of \ref MapStorage
    2.88 +  ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
    2.89 +  ///\param def do we need 'Default' option. See \ref def.
    2.90 +  MapSelector(std::vector<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true);
    2.91 +
    2.92 +  ///Signal emitted if the user has changed the selection.
    2.93    sigc::signal<void, std::string> signal_cbt_ch();
    2.94 +
    2.95 +  ///Signal emitted if the user has pressed New button (\ref newbut)
    2.96    sigc::signal<void, bool> signal_newmapwin_needed();
    2.97  
    2.98 +  ///Maintain \ref cbt.
    2.99 +
   2.100 +  ///Fills in \ref cbt with names, taking
   2.101 +  ///into account that the previously selected option
   2.102 +  ///has to be set back after the operation.
   2.103    void update_list( std::vector<std::string> );
   2.104  
   2.105 -  ///If a radiobutton is clicked, this function determines
   2.106 -  ///which button was that and after that calls the
   2.107 -  ///appropriate function of the \ref GraphDisplayerCanvas
   2.108 -  ///to change the visible values of that attribute.
   2.109 +  ///Handles changement in \ref cbt.
   2.110 +
   2.111 +  ///In default case it emits a signal with the selected option.
   2.112 +  ///But if 'Default' option is selected, it resets the \ref MapSelector
   2.113    virtual void comboChanged();
   2.114  
   2.115 +  ///Requests a \ref NewMapWin
   2.116 +
   2.117 +  ///See \ref set_new_map.
   2.118 +  ///First it sets \ref set_new_map true to be identified
   2.119 +  ///at registration of new map that
   2.120 +  ///it has sent the \ref signal_newmapwin, therefore it
   2.121 +  ///has to set \ref cbt to that option.
   2.122    virtual void new_but_pressed();
   2.123  
   2.124 +  ///If called, 'Default' option is selected, that means unselection of any maps.
   2.125 +
   2.126 +  ///Practically this means that if this is called,
   2.127 +  ///properties of graph will set to default state.
   2.128 +  ///The function achieves this by emitting appropriately
   2.129 +  ///parametrized signal_cbt.
   2.130    virtual void reset();
   2.131  
   2.132 +  ///Returns the currently selected option.
   2.133    Glib::ustring get_active_text();
   2.134 -  void set_active_text(Glib::ustring);
   2.135 +
   2.136 +  ///Sets the parameter active in \ref cbt.
   2.137 +
   2.138 +  ///\param new_value the
   2.139 +  ///new value to be set in \ref cbt.
   2.140 +  void set_active_text(Glib::ustring new_value);
   2.141 +
   2.142 +  ///Sets the parameter active in \ref cbt.
   2.143 +  ///\param index the
   2.144 +  ///index of row to be set in \ref cbt.
   2.145    void set_active(int index){cbt.set_active(index);};
   2.146 +
   2.147 +  ///Clear all options from \ref cbt.
   2.148    void clear(){cbt.clear();};
   2.149 -  void append_text(Glib::ustring);
   2.150 +
   2.151 +  ///Appends a new option to the existing ones in \ref cbt.
   2.152 +
   2.153 +  ///If \ref set_new_map is true, the
   2.154 +  ///\ref MapSelector has requested the opened \ref NewMapWin,
   2.155 +  ///from that the option to append is coming. In this case
   2.156 +  ///this function  will set \ref cbt to the new option.
   2.157 +  ///\param new_option new option to append
   2.158 +  void append_text(Glib::ustring new_option);
   2.159  };
   2.160  #endif //MAPSELECTOR_H