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