gui/main_win.h
author ladanyi
Thu, 23 Mar 2006 19:57:14 +0000
changeset 2012 224cd6aacfc1
parent 1884 9c061834b33b
permissions -rw-r--r--
- added gettext infrastructure to the gui
- the gui has a separate configure script now
- other minor changes
     1 // -*- C++ -*- //
     2 
     3 #ifndef MAIN_WIN_H
     4 #define MAIN_WIN_H
     5 
     6 #include "all_include.h"
     7 #include "algowin.h"
     8 #include "map_win.h"
     9 #include "new_map_win.h"
    10 #include "nbtab.h"
    11 #include <libgnomecanvasmm.h>
    12 #include <libgnomecanvasmm/polygon.h>
    13 
    14 
    15 ///This class is the main window of GUI.
    16 
    17 ///It has menus, and a notebook. Notebook has different pages,
    18 ///the so called tabs (\ref NoteBookTab). Each \ref NoteBookTab contains a canvas on which graphs can be drawn.
    19 ///To manage creation and close of tabs and tabswitching is the task of MainWin.
    20 class MainWin : public Gtk::Window
    21 {
    22   ///Container in which the menus and the notebook is.
    23   Gtk::VBox vbox;
    24 
    25   ///The notebook that has tabs (\ref NoteBookTab) with different graphs.
    26   Gtk::Notebook notebook;
    27 
    28   ///The tool selected to manipulate graph.
    29 
    30   ///It has to be stored, because in case of tabswitching
    31   ///the correct tool has to be set for the actual graph.
    32   int active_tool;
    33 
    34   ///The number of active tab in the notebook.
    35   int active_tab;
    36 
    37   ///Vector of existing tabs in the notebook.
    38   std::vector<NoteBookTab *> tabs;
    39 
    40   ///Vector of the name of tabs.
    41 
    42   ///All \ref NoteBookTab has a name that is stored here. The index of the name
    43   ///is the same as the index of the \ref NoteBookTab in \ref tabs.
    44   std::vector<std::string> tabnames;
    45 
    46   ///Counter of occurence of the same file names.
    47 
    48   ///If a file is opened more than once we have to score
    49   ///the occurences to let the titles on tabs different.
    50   ///If more than one occurence is present, from the second
    51   ///one near the filename the number of the occurence appear.
    52   std::map<std::string, int> strinst;
    53 
    54   ///Set of opened \ref AlgoWin s.
    55 
    56   ///More than one \refAlgoWin can be opened. We have to
    57   ///communicate with them in case of new \ref NoteBookTab creation,
    58   ///\ref NoteBookTab close, or map change. Therefore we have to score
    59   ///their occurences.
    60   std::set< AlgoWin* > aws;
    61 
    62 public:
    63   
    64   ///Constructor of the \ref MainWin.
    65 
    66   ///It creates the menus, the toolbar and the notebook in which
    67   ///\ref NoteBookTab s take place. \ref NoteBookTab s are the
    68   ///holder of the canvases on which the graphs are drawn.
    69   MainWin();
    70 
    71   ///Sets title of tabs.
    72 
    73   ///It alse registrates it in \ref tabnames. If more than one
    74   ///occurence is in the notebook of the same file it has to
    75   ///extend tabname with the number of occurence.
    76   void set_tabtitle(std::string);
    77 
    78   ///ActionGroup for menu
    79   Glib::RefPtr<Gtk::ActionGroup> ag;
    80 
    81   ///UIManager for menu
    82   Glib::RefPtr<Gtk::UIManager> uim;
    83 
    84   ///Creates a new \ref NoteBookTab and opens the given file.
    85 
    86   ///It is called only with command line parameters at stratup.
    87   void readFile(const std::string &);
    88 
    89   ///Tooltips
    90   Gtk::Tooltips tooltips;
    91 
    92   //Call-backs of buttons
    93 
    94   ///Callback for 'FileNew' action.
    95   virtual void newFile();
    96   ///Callback for 'FileOpen' action.
    97   virtual void openFile();
    98   ///Callback for 'FileSave' action.
    99   virtual void saveFile();
   100   ///Callback for 'FileSaveAs' action.
   101   virtual void saveFileAs();
   102   ///Callback for 'Close' action.
   103   virtual void close();
   104 
   105   //Toolbar
   106 
   107   ///Callback for 'zoomIn' action.
   108 
   109   ///It calls the appropriate function in
   110   ///\ref GraphDisplayerCanvas
   111   virtual void zoomIn();
   112   ///Callback for 'zoomOut' action.
   113 
   114   ///It calls the appropriate function in
   115   ///\ref GraphDisplayerCanvas
   116   virtual void zoomOut();
   117   ///Callback for 'zoomFit' action.
   118 
   119   ///It calls the appropriate function in
   120   ///\ref GraphDisplayerCanvas
   121   virtual void zoomFit();
   122   ///Callback for 'zoom100' action.
   123 
   124   ///It calls the appropriate function in
   125   ///\ref GraphDisplayerCanvas
   126   virtual void zoom100();
   127 
   128   ///Callback for Show Maps menupoint.
   129 
   130   ///It calls the appropriate function in
   131   ///\ref NoteBookTab
   132   virtual void createMapWin();
   133 
   134   ///Pops up an Algorithm window.
   135 
   136   ///It not only creates but registrates the newly created \ref AlgoWin.
   137   ///It is necessary, because in case of changement between tabs or maps
   138   ///we have to communicate with it. Signals are also have to be connected
   139   ///to it, because \ref AlgoWin emits signals if it needs anything (maplist, deregistration).
   140   ///\param algo type of the algorithm to run.
   141   virtual void createAlgoWin(int algo);
   142 
   143   ///Deregisters AlgoWin
   144 
   145   ///This is the function connected to the closing signal of \ref AlgoWin.
   146   ///It only deletes the sender \ref AlgoWin from \ref aws. This function
   147   ///is called only by the closing \ref AlgoWin itself.
   148   ///\param aw the \ref AlgoWin to delete.
   149   virtual void deRegisterAlgoWin(AlgoWin * aw);
   150 
   151   ///Updates list of tabs in all of the \ref AlgoWin
   152 
   153   ///When \ref NoteBookTab inserted somewhere or closed one tablist in all \ref AlgoWin
   154   ///have to be updated. That is why we score all the opened \ref AlgoWin.
   155   ///During update \ref tabnames will be passed to each \ref AlgoWin.
   156   virtual void updateAlgoWinTabs();
   157 
   158   ///Refresh list of maps in the AlgoWin that requested it.
   159 
   160   ///In an \ref AlgoWin there is a ComboBoxText, in which
   161   ///a \ref NoteBookTab can be chosen that contains the graph and the maps,
   162   ///on which we would like to run algorithms. If we change the
   163   ///tab the available maps also have to be updated, because
   164   ///in the different tabs different maps are available. Therefore
   165   ///on tab change the \ref AlgoWin emits a signal that contains itself
   166   ///so that the appropriate maps can be sent to it. For the sake of simplicity
   167   ///the program answers this call with the mapstorage of the newly selected tab.
   168   ///\param aw the caller \ref AlgoWin
   169   ///\param tabname the newly selected tab in the \ref AlgoWin
   170   virtual void updateAlgoWinMaps(AlgoWin * aw, std::string tabname);
   171 
   172   ///Registrates the new graph-editor tool in hand.
   173 
   174   ///The editor-tool in hand is global, it is the same for all tab
   175   ///at the same time. Therefore the active tool has to be scored here (\ref active_tool).
   176   ///This function is the callback function of the editor-tool buttons. It sets \ref active_tool
   177   ///to the correct value.
   178   ///\param tool the newly selected graph-editor tool (See all_include.h)
   179   virtual void changeEditorialTool(int tool);
   180 
   181   ///Pops up a \ref NewMapWin dialog after requested by a \ref MapWin
   182 
   183   ///Each tab can pop-up a \ref MapWin. In \ref MapWin new tab can be created.
   184   ///In this case \ref NoteBookTab emits a signal. This function is connected to that signal.
   185   ///It sends the caller \ref NoteBookTab and whether an edgemap or a nodemap should be created.
   186   ///Caller \ref NoteBookTab is necessary for the window to be able to place the new map in its
   187   ///correct place.
   188   ///\param nbt the caller tab
   189   ///\param itisedge true if edgemap has to be created, false if nodemap
   190   virtual void createNewMapWinAfterSignal(NoteBookTab * nbt, bool itisedge);
   191 
   192   ///Pops up a \ref NewMapWin dialog after requested by an \ref AlgoWin
   193 
   194   ///\ref AlgoWin can also can request a \ref NewMapWin to pop-up. 
   195   ///It emits a signal in this case. This function is bound to that signal.
   196   ///The signal contains the name of \ref NoteBookTab in which the new map has to be
   197   ///placed and whether the new map is an edgemap or a nodemap.
   198   ///\ref tabname the tab in which the new map has to be placed
   199   ///\ref itisedge true if the new map will be edge map, false if it will be nodemap
   200   virtual void createNewMapWinTabString(std::string tabname, bool itisedge);
   201 
   202   ///Pops up a \ref NewMapWin dialog if button on \ref MainWin has been pressed.
   203 
   204   ///In this case a general \ref NewMapWin will be popped up. This means that
   205   ///both edge and nodemap can be created by it. The new map will be placed in
   206   ///\MapStorage of the actual selected \ref NoteBookTab.
   207   virtual void createNewMapWin();
   208 
   209   //Notebook handlers
   210   ///Callback for 'FileNewTab' action.
   211   virtual void newTab();
   212 
   213   ///Callback for 'FileCloseTab' action.
   214 
   215   ///It closes the actual \ref NoteBookTab and registrates this event:
   216   ///data is shifted to the correct places in vectors.
   217   virtual void closeTab();
   218 
   219   ///Tabswitching handler
   220 
   221   ///Sets the variables that have to store the actual state, and it
   222   ///updates the title of window to the actually selected \ref NoteBookTab.
   223   virtual void onChangeTab(GtkNotebookPage*, guint);
   224 };
   225 
   226 #endif //MAIN_WIN_H