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