3 NoteBookTab::NoteBookTab():mapwinexists(false)
5 gd_canvas=new GraphDisplayerCanvas(*this);
8 //connecting signals - controller character
9 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
14 void NoteBookTab::readFile(const std::string &file)
16 mapstorage.readFromFile(file);
17 mapstorage.file_name = file;
18 mapstorage.modified = false;
19 gd_canvas->drawGraph();
22 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
24 signal_title.emit(Glib::filename_display_basename(file));
27 void NoteBookTab::newFile()
29 if (mapstorage.modified)
31 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
32 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
33 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
34 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
35 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
36 switch (mdialog.run())
38 case Gtk::RESPONSE_CANCEL:
40 case Gtk::RESPONSE_REJECT:
42 case Gtk::RESPONSE_ACCEPT:
51 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
53 signal_title.emit("unsaved file");
56 void NoteBookTab::openFile()
58 if (mapstorage.modified)
60 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
61 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
62 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
63 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
64 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
65 switch (mdialog.run())
67 case Gtk::RESPONSE_CANCEL:
69 case Gtk::RESPONSE_REJECT:
71 case Gtk::RESPONSE_ACCEPT:
76 Gtk::FileChooserDialog fcdialog("Open File");
77 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
78 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
79 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
83 Glib::ustring filename = fcdialog.get_filename();
84 if (!mapstorage.readFromFile(filename))
86 mapstorage.file_name = filename;
87 mapstorage.modified = false;
88 gd_canvas->drawGraph();
91 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
93 signal_title.emit(Glib::filename_display_basename(filename));
98 void NoteBookTab::saveFile()
100 if (mapstorage.file_name == "") {
105 mapstorage.writeToFile(mapstorage.file_name);
106 mapstorage.modified = false;
107 signal_title.emit(Glib::filename_display_basename(mapstorage.file_name));
111 void NoteBookTab::saveFileAs()
113 Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
114 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
115 fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
116 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
118 Glib::ustring filename = fcdialog.get_filename();
119 mapstorage.file_name = filename;
120 mapstorage.writeToFile(filename);
121 mapstorage.modified = false;
122 signal_title.emit(Glib::filename_display_basename(filename));
126 void NoteBookTab::close()
128 if (mapstorage.modified)
130 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
131 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
132 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
133 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
134 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
135 switch (mdialog.run())
137 case Gtk::RESPONSE_CANCEL:
139 case Gtk::RESPONSE_REJECT:
141 case Gtk::RESPONSE_ACCEPT:
150 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
152 signal_title.emit("unsaved file");
155 void NoteBookTab::propertyChange(bool itisedge, int prop, std::string mapname)
157 mapstorage.changeActiveMap(itisedge, prop, mapname);
160 sigc::signal<void, NoteBookTab *, bool> NoteBookTab::signal_newmap_needed()
162 return signal_newmap;
165 void NoteBookTab::popupNewMapWin(bool itisedge, int prop)
168 signal_newmap.emit(this, itisedge);
171 std::string NoteBookTab::getActiveEdgeMap(int prop)
173 return mapstorage.getActiveEdgeMap(prop);
176 std::string NoteBookTab::getActiveNodeMap(int prop)
178 return mapstorage.getActiveNodeMap(prop);
181 void NoteBookTab::registerNewEdgeMap(std::string mapname)
185 mapwin->registerNewEdgeMap(mapname);
189 void NoteBookTab::registerNewNodeMap(std::string mapname)
193 mapwin->registerNewNodeMap(mapname);
197 void NoteBookTab::createMapWin(std::string name)
201 mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
207 void NoteBookTab::closeMapWin()
213 sigc::signal<void, std::string> NoteBookTab::signal_title_ch()