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