From c73dbf7ef079fe2212ebb9df5cb9f4ef26eb7416 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 17 Oct 2005 05:09:22 +0000 Subject: [PATCH] Agrego ventana de input. --- nviewer/Makefile | 2 +- nviewer/w_ask.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ nviewer/w_ask.h | 15 +++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 nviewer/w_ask.cpp create mode 100644 nviewer/w_ask.h diff --git a/nviewer/Makefile b/nviewer/Makefile index 8bd21a5..15e718e 100644 --- a/nviewer/Makefile +++ b/nviewer/Makefile @@ -1,6 +1,6 @@ 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) diff --git a/nviewer/w_ask.cpp b/nviewer/w_ask.cpp new file mode 100644 index 0000000..aa3cb96 --- /dev/null +++ b/nviewer/w_ask.cpp @@ -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 index 0000000..54a2687 --- /dev/null +++ b/nviewer/w_ask.h @@ -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 + -- 2.43.0