gui/nbtab.h
author deba
Fri, 31 Mar 2006 12:12:06 +0000
changeset 2027 119db4e6ab2c
parent 1849 a4d1362397fe
permissions -rw-r--r--
MinGW compatibility fix
hegyi@1849
     1
// -*- C++ -*- //
hegyi@1849
     2
hegyi@1849
     3
#ifndef NBTAB_H
hegyi@1849
     4
#define NBTAB_H
hegyi@1849
     5
hegyi@1849
     6
class NoteBookTab;
hegyi@1849
     7
hegyi@1849
     8
#include "mapstorage.h"
hegyi@1849
     9
#include "map_win.h"
hegyi@1849
    10
#include "graph_displayer_canvas.h"
hegyi@1849
    11
#include <libgnomecanvasmm.h>
hegyi@1849
    12
#include <libgnomecanvasmm/polygon.h>
hegyi@1849
    13
hegyi@1891
    14
///One tab in the Notebook that is placed in the main window (\ref MainWin).
hegyi@1891
    15
hegyi@1891
    16
///One graph and all of its accessories like maps are assigned to one tab in the notebook.
hegyi@1891
    17
///\ref NoteBookTab is responsible for the user defined display of the graph: view can be
hegyi@1891
    18
///set by visualized maps, therefore \ref NoteBookTab must provide an interface to set the
hegyi@1891
    19
///view of graph. This is \ref Mapwin window.
hegyi@1891
    20
///
hegyi@1891
    21
///\ref NoteBookTab is also
hegyi@1891
    22
///responsible for modify the graph if it is
hegyi@1891
    23
///requested. Therefore it is responsible for translating user events to modifications to
hegyi@1891
    24
///do on graph, like node/edge addition/deletion, map modification, addition and so on.
hegyi@1891
    25
///
hegyi@1891
    26
///To be able to solve these tasks the help of \ref MainWin is also needed, for example to
hegyi@1891
    27
///know which editor-tool is active at the moment. Therefore \ref MainWin knows \ref NoteBookTab.
hegyi@1891
    28
///
hegyi@1891
    29
///Some information in the other direction is needed as well: for example when new map creation is requested for this tab
hegyi@1891
    30
///\ref NoteBookTab must ask \ref MainWin to pop-up a \ref NewMapWin. Communication in this direction is realized by signals
hegyi@1891
    31
///therefore \ref NoteBookTab does not know \ref MainWin at all, but in this way it is not necessary.
hegyi@1849
    32
class NoteBookTab : public Gtk::VBox
hegyi@1849
    33
{
hegyi@1849
    34
public:
hegyi@1891
    35
  
hegyi@1891
    36
  ///Constructor of \ref NoteBookTab
hegyi@1891
    37
hegyi@1891
    38
  ///It initiates the \re GraphDisplayerCanvas, on which the graph will be drawn
hegyi@1891
    39
  ///Signals of \ref MapStorage will be bound to the appropriate callback functions here.
hegyi@1849
    40
  NoteBookTab();
hegyi@1849
    41
  
hegyi@1891
    42
  ///Maps assigned to the graph displayed in this \ref NoteBookTab of notebook.
hegyi@1849
    43
  MapStorage mapstorage;
hegyi@1849
    44
    
hegyi@1891
    45
  ///Title changement indicator.
hegyi@1891
    46
hegyi@1891
    47
  ///If graph is loaded from disk or saved to disk or changed its name somehow
hegyi@1891
    48
  ///this signal will be emit to let
hegyi@1891
    49
  ///\ref MainWin know that it has to modify the title of the main window.
hegyi@1891
    50
  ///It contains the new title.
hegyi@1849
    51
  sigc::signal<void, std::string> signal_title;
hegyi@1849
    52
hegyi@1891
    53
  ///Returns \ref signal_title to be the caller able to connect it to a callback function.
hegyi@1849
    54
  sigc::signal<void, std::string> signal_title_ch();
hegyi@1849
    55
hegyi@1891
    56
  ///Indicates that new map window should be popped up.
hegyi@1891
    57
hegyi@1891
    58
  ///\ref NoteBookTab can ask \ref MainWin to pop up a \ref NweMapWin ny emitting this signal.
hegyi@1891
    59
  ///The signal contains whether an edgemap or a nodemap should be popped up. \ref NewMapWin
hegyi@1891
    60
  ///is not popped up by \ref NoteBookTab, because not only \ref NoteBookTab needs \ref NewMapWin,
hegyi@1891
    61
  ///but for example \ref MainWin and \ref AlgoWin s as well.
hegyi@1849
    62
  sigc::signal<void, NoteBookTab *, bool> signal_newmap;
hegyi@1849
    63
hegyi@1891
    64
  ///Returns \ref signal_newmap to be the caller able to connect it to a callback function.
hegyi@1849
    65
  sigc::signal<void, NoteBookTab *, bool> signal_newmap_needed();
hegyi@1849
    66
hegyi@1891
    67
  ///Loads the given file.
hegyi@1891
    68
hegyi@1891
    69
  ///The given file will be load in the \ref MapStorage and afeter that
hegyi@1891
    70
  ///\ref GraphDisplayerCanvas will be requested to display the graph.
hegyi@1891
    71
  ///\ref GraphDisplayer will get datas from the recently set \ref MapStorage.
hegyi@1849
    72
  void readFile(const std::string &);
hegyi@1849
    73
    
hegyi@1849
    74
  ///The graph will be drawn on this \ref GraphDisplayerCanvas
hegyi@1849
    75
  GraphDisplayerCanvas * gd_canvas;
hegyi@1849
    76
hegyi@1891
    77
  ///Indicates whether the \ref MapWin is opened or not. See \ref mapwin.
hegyi@1849
    78
  bool mapwinexists;
hegyi@1849
    79
hegyi@1891
    80
  ///Address of the only \ref MapWin that the \ref NoteBookTab can open.
hegyi@1891
    81
hegyi@1891
    82
  ///Only one of this window can be opened at the same time (\ref mapwinexists), 
hegyi@1891
    83
  ///because there is no need for more, one per tab is enough.
hegyi@1891
    84
  ///There won1t be benefit of more than one, but it would be
hegyi@1891
    85
  ///more complicated to synchronize them.
hegyi@1849
    86
  MapWin * mapwin;
hegyi@1849
    87
    
hegyi@1849
    88
public:
hegyi@1849
    89
  ///Callback for 'FileNew' action.
hegyi@1849
    90
  virtual void newFile();
hegyi@1849
    91
  ///Callback for 'FileOpen' action.
hegyi@1849
    92
  virtual void openFile();
hegyi@1849
    93
  ///Callback for 'FileSave' action.
hegyi@1849
    94
  virtual void saveFile();
hegyi@1849
    95
  ///Callback for 'FileSaveAs' action.
hegyi@1849
    96
  virtual void saveFileAs();
hegyi@1849
    97
  ///Callback for 'Close' action.
hegyi@1849
    98
  virtual void close();
hegyi@1849
    99
hegyi@1891
   100
  ///Handles changement of view of graph.
hegyi@1849
   101
hegyi@1891
   102
  ///If the user changes the map to show by a property to a nother in \ref MapWin,
hegyi@1891
   103
  ///\ref MapWin will call this function. This function will registrate in \ref MapStorage
hegyi@1891
   104
  ///the new map to display by the changed property. After that \ref MapStorage will
hegyi@1891
   105
  ///emits a signal that will be forwarded to \ref GraphDisplayerCanvas to update the
hegyi@1891
   106
  ///appropriate parts of graph.
hegyi@1891
   107
  ///\param itiesedge whether the changed property is edge property or node property
hegyi@1891
   108
  ///\param prop id of property, see all_include.h
hegyi@1891
   109
  ///\param mapname name of the recently selected map
hegyi@1891
   110
  void propertyChange(bool itisedge, int prop, std::string mapname);
hegyi@1849
   111
hegyi@1891
   112
  ///Emits a signal that request \ref MainWin to pop up \ref NewMapWin
hegyi@1849
   113
hegyi@1891
   114
  ///This function is called by \ref MapWin.
hegyi@1891
   115
  ///\param itisedge whether the new map should be an edgemap or a nodemap.
hegyi@1891
   116
  void popupNewMapWin(bool itisedge);
hegyi@1891
   117
hegyi@1891
   118
  ///Returns the actually selected edgemap to visualize by the given property.
hegyi@1891
   119
hegyi@1891
   120
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@1891
   121
  ///\param prop property to inquire.
hegyi@1891
   122
  std::string getActiveEdgeMap(int prop);
hegyi@1891
   123
hegyi@1891
   124
  ///Returns the actually selected nodemap to visualize by the given property.
hegyi@1891
   125
hegyi@1891
   126
  ///\ref MapWin calls this function, beacuse it does not know \ref MapStorage.
hegyi@1891
   127
  ///\param prop property to inquire.
hegyi@1891
   128
  std::string getActiveNodeMap(int prop);
hegyi@1891
   129
hegyi@1891
   130
  ///Registers recently created edgemap in \ref MapWin.
hegyi@1891
   131
hegyi@1891
   132
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@1891
   133
  ///This signal is bound to this callback function, that will call
hegyi@1891
   134
  ///a function with the same name and same parameterin \ref MapWin.
hegyi@1891
   135
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@1891
   136
  ///\param mapname name of new map
hegyi@1891
   137
  void registerNewEdgeMap(std::string mapname);
hegyi@1891
   138
hegyi@1891
   139
  ///Registers recently created nodemap in \ref MapWin.
hegyi@1891
   140
hegyi@1891
   141
  ///After creation of new map \ref MapStorage emits a signal.
hegyi@1891
   142
  ///This signal is bound to this callback function, that will call
hegyi@1891
   143
  ///a function with the same name and same parameter in \ref MapWin.
hegyi@1891
   144
  ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
hegyi@1891
   145
  ///\param mapname name of new map
hegyi@1891
   146
  void registerNewNodeMap(std::string mapname);
hegyi@1891
   147
hegyi@1891
   148
  ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
hegyi@1891
   149
  
hegyi@1891
   150
  ///See also
hegyi@1891
   151
  ///\ref mapwin.
hegyi@1849
   152
  void createMapWin(std::string);
hegyi@1891
   153
hegyi@1891
   154
  ///Closes and deregistrates the \ref MapWin of \ref NoteBookTab.
hegyi@1891
   155
  
hegyi@1891
   156
  ///See also
hegyi@1891
   157
  ///\ref mapwin.
hegyi@1849
   158
  void closeMapWin();
hegyi@1849
   159
};
hegyi@1849
   160
hegyi@1849
   161
#endif //NBTAB_H