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