[Lemon-commits] [lemon_svn] hegyi: r2097 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:50:07 CET 2006


Author: hegyi
Date: Tue Jul 26 23:20:01 2005
New Revision: 2097

Added:
   hugo/trunk/gui/new_map_win.cc
   hugo/trunk/gui/new_map_win.h

Log:
EdgeMap and NodeMap creation is done, at last. Bach 4ever.

Added: hugo/trunk/gui/new_map_win.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/gui/new_map_win.cc	Tue Jul 26 23:20:01 2005
@@ -0,0 +1,105 @@
+#include <new_map_win.h>
+
+bool NewMapWin::closeIfEscapeIsPressed(GdkEventKey* e)
+{
+  if(e->keyval==GDK_Escape)
+  {
+    hide();
+  }
+  return true;
+}
+
+NewMapWin::NewMapWin(const std::string& title, GraphDisplayerCanvas & grdispc):gdc(grdispc),node("Create NodeMap"),edge("Create EdgeMap")
+{
+  set_title(title);
+  set_default_size(200, 50);
+
+  signal_key_press_event().connect(sigc::mem_fun(*this, &NewMapWin::closeIfEscapeIsPressed));
+
+
+  //entries
+  table=new Gtk::Table(3, 2, false);
+
+  label=new Gtk::Label;
+  label->set_text("Name of new map:");
+  name.set_text("");
+
+  (*table).attach(*label,0,1,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+  (*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+  label=new Gtk::Label;
+  label->set_text("Default value in the map:");
+  default_value.set_text("0");
+
+  (*table).attach(*label,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
+  (*table).attach(default_value,1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+  //node vs. edge map selector
+  Gtk::RadioButton::Group group = node.get_group();
+  edge.set_group(group);
+
+  (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
+  (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+  vbox.pack_start(*table);
+
+  //OK button
+  button=new Gtk::Button("OK");
+
+  button->signal_clicked().connect
+    (
+     sigc::mem_fun(*this, &NewMapWin::buttonPressed)
+    );
+
+
+  vbox.pack_start(*button);
+
+  add(vbox);
+
+  show_all_children();
+
+}
+
+void NewMapWin::buttonPressed()
+{
+  bool valid_double=true;
+  int point_num=0;
+
+  std::string def_val_str=default_value.get_text();
+  char * def_val_ch=new char [def_val_str.length()];
+  for(int i=0;i<(int)(def_val_str.length());i++)
+    {
+      if(((def_val_str[i]<'0')||(def_val_str[i]>'9'))&&(def_val_str[i]!='.'))
+	{
+	  valid_double=false;
+	}
+      else
+	{
+	  if(def_val_str[i]=='.')
+	    {
+	      point_num++;
+	    }
+	}
+      def_val_ch[i]=def_val_str[i];
+    }
+  
+  double def_val=atof(def_val_ch);
+
+  std::string mapname=name.get_text();
+
+  if((point_num<=1)&&(valid_double)&&(!mapname.empty()))
+    {
+      if(edge.get_active())
+	{
+	  gdc.addNewEdgeMap(def_val,mapname);
+	}
+      else
+	{
+	  gdc.addNewNodeMap(def_val,mapname);
+	}
+      name.set_text("");
+      default_value.set_text("0");
+      hide();
+    }
+}
+

Added: hugo/trunk/gui/new_map_win.h
==============================================================================
--- (empty file)
+++ hugo/trunk/gui/new_map_win.h	Tue Jul 26 23:20:01 2005
@@ -0,0 +1,49 @@
+// -*- C++ -*- //
+
+#ifndef NEWMAPWIN_H
+#define NEWMAPWIN_H
+
+class NewMapWin;
+
+#include <all_include.h>
+#include <graph_displayer_canvas.h>
+#include <libgnomecanvasmm.h>
+#include <libgnomecanvasmm/polygon.h>
+
+///This class is responsible for creating a window,
+///on which the parameters of a new map can be set.
+
+class NewMapWin : public Gtk::Window
+{
+  ///The \ref GraphDisplayerCanvas on which the graph will be drawn.
+  ///It has to be known for this class, because
+  ///when a map is created
+  ///a function of the \ref GraphDisplayerCanvas will be called.
+  GraphDisplayerCanvas & gdc;
+
+ public:
+  ///Constructor of NewMapWin creates the widgets shown in NewMapWin.
+  NewMapWin(const std::string& title, GraphDisplayerCanvas &);
+
+
+  ///Signal on button is connected to this function,
+  ///Therefore this function determines whether to
+  ///call the map/creatort function, and if yes, it
+  //tells it the attributes.(name, default value)
+  virtual void buttonPressed();
+
+  virtual bool closeIfEscapeIsPressed(GdkEventKey*);
+
+  Gtk::Entry name, default_value;
+
+  Gtk::VBox vbox;
+
+  Gtk::Button * button;
+
+  Gtk::Table * table;
+  Gtk::Label * label;
+
+  Gtk::RadioButton node, edge;
+};
+
+#endif //NEWMAPWIN_H



More information about the Lemon-commits mailing list