]> git.llucax.com Git - z.facultad/75.52/treemulator.git/commitdiff
Agrego ventana de input.
authorRicardo Markiewicz <rmarkie@fi.uba.ar>
Mon, 17 Oct 2005 05:09:22 +0000 (05:09 +0000)
committerRicardo Markiewicz <rmarkie@fi.uba.ar>
Mon, 17 Oct 2005 05:09:22 +0000 (05:09 +0000)
nviewer/Makefile
nviewer/w_ask.cpp [new file with mode: 0644]
nviewer/w_ask.h [new file with mode: 0644]

index 8bd21a558fd06c19c6c675b54225ec3b8616cb48..15e718e73bf92f7a0fe244689a5da35cfe429482 100644 (file)
@@ -1,6 +1,6 @@
 TARGET=nviewer
 CXXFLAGS=-Wall -g -I../src
 TARGET=nviewer
 CXXFLAGS=-Wall -g -I../src
-OBJECTS=main.o window.o w_node_header.o w_btree.o
+OBJECTS=main.o window.o w_node_header.o w_btree.o w_ask.o
 
 all: $(TARGET)
 
 
 all: $(TARGET)
 
diff --git a/nviewer/w_ask.cpp b/nviewer/w_ask.cpp
new file mode 100644 (file)
index 0000000..aa3cb96
--- /dev/null
@@ -0,0 +1,47 @@
+
+#include "w_ask.h"
+
+wAsk::wAsk (Window *p, const std::string &s) : Window (p, s, p->Width ()-2, 3, 1, p->Height()-4)
+{
+}
+
+#define MAX_ 50
+
+uint wAsk::Node ()
+{
+       uint pos = 0;
+       char arr[MAX_];
+       int c;
+
+       c = GetChar ();
+       while (c != 13) {
+               switch (c) {
+                       case '0':
+                       case '1':
+                       case '2':
+                       case '3':
+                       case '4':
+                       case '5':
+                       case '6':
+                       case '7':
+                       case '8':
+                       case '9':
+                       case '-':
+                               arr[pos++] = c;
+                               break;
+                       case 9:
+                       case 8:
+                               pos--;
+                               if (pos > 0) pos = 0;
+               }
+               SetText (1, 1, "                                                 ");
+
+               mvwaddnstr (win, 1, 1, arr, pos);
+               Show ();
+               c = GetChar ();
+       }
+
+       arr[pos] = '\0';
+       return atoi (arr);
+}
+
diff --git a/nviewer/w_ask.h b/nviewer/w_ask.h
new file mode 100644 (file)
index 0000000..54a2687
--- /dev/null
@@ -0,0 +1,15 @@
+
+#ifndef _W_ASK_H_
+#define _W_ASK_H_
+
+#include "window.h"
+
+class wAsk : public Window {
+       public:
+               wAsk (Window *p, const std::string &s);
+
+               uint Node ();
+};
+
+#endif
+