[Lemon-commits] [lemon_svn] hegyi: r2467 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:52:53 CET 2006
Author: hegyi
Date: Thu Jan 12 15:36:08 2006
New Revision: 2467
Modified:
hugo/trunk/gui/mapselector.cc
hugo/trunk/gui/mapselector.h
Log:
Documentation of MapSelector. If no default value is present in MapSelector, Reset button does not appear.
Modified: hugo/trunk/gui/mapselector.cc
==============================================================================
--- hugo/trunk/gui/mapselector.cc (original)
+++ hugo/trunk/gui/mapselector.cc Thu Jan 12 15:36:08 2006
@@ -26,13 +26,17 @@
label->set_width_chars(longest_property_string_length);
- defbut=new Gtk::Button();
- defbut->set_label("Reset");
-
- defbut->signal_pressed().connect
- (
- sigc::mem_fun(*this, &MapSelector::reset)
- );
+ defbut=NULL;
+ if(def)
+ {
+ defbut=new Gtk::Button();
+ defbut->set_label("Reset");
+
+ defbut->signal_pressed().connect
+ (
+ sigc::mem_fun(*this, &MapSelector::reset)
+ );
+ }
newbut=new Gtk::Button(Gtk::Stock::NEW);
@@ -45,7 +49,11 @@
add(cbt);
- add(*defbut);
+ if(def)
+ {
+ add(*defbut);
+ }
+
add(*newbut);
}
@@ -76,7 +84,7 @@
void MapSelector::comboChanged()
{
- if(cbt.get_active_row_number()!=0)
+ if(cbt.get_active_row_number()!=0 || !def)
{
default_state=false;
Glib::ustring mapname = cbt.get_active_text();
Modified: hugo/trunk/gui/mapselector.h
==============================================================================
--- hugo/trunk/gui/mapselector.h (original)
+++ hugo/trunk/gui/mapselector.h Thu Jan 12 15:36:08 2006
@@ -10,51 +10,149 @@
#include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/polygon.h>
+///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<void, std::string> signal_cbt;
+
+ ///Signal that indicates that user wants to create a new map.
sigc::signal<void, bool> 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;
- Gtk::Button * newbut, * defbut;
+ ///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:
- MapSelector(std::vector<std::string>, std::string, std::string, bool, bool def=true);
+ ///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<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true);
+
+ ///Signal emitted if the user has changed the selection.
sigc::signal<void, std::string> signal_cbt_ch();
+
+ ///Signal emitted if the user has pressed New button (\ref newbut)
sigc::signal<void, bool> 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<std::string> );
- ///If a radiobutton is clicked, this function determines
- ///which button was that and after that calls the
- ///appropriate function of the \ref GraphDisplayerCanvas
- ///to change the visible values of that attribute.
+ ///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();
- void set_active_text(Glib::ustring);
+
+ ///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();};
- void append_text(Glib::ustring);
+
+ ///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
More information about the Lemon-commits
mailing list