* written by Anatoly Ivasyuk (anatoly@nick.csh.rit.edu)
*
* Demo code for NCursesMenu and NCursesForm written by
- * Juergen Pfeifer <juergen.pfeifer@gmx.net>
+ * Juergen Pfeifer
+ * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en
*
- * $Id: demo.cc,v 1.18 1999/09/11 18:57:54 tom Exp $
+ * $Id: demo.cc,v 1.22 2002/07/06 15:47:52 juergen Exp $
*/
#include "cursesapp.h"
extern "C" unsigned int sleep(unsigned int);
-#undef index // needed for NeXT
+#undef index // needed for NeXT
//
// -------------------------------------------------------------------------
{
public:
MyAction (const char* p_name,
- const T* p_UserData)
+ const T* p_UserData)
: NCursesUserItem<T>(p_name, (const char*)0, p_UserData)
{};
{
public:
Label(const char* title,
- int row, int col)
+ int row, int col)
: NCursesFormField(1,(int)::strlen(title),row,col) {
set_value(title);
options_off(O_EDIT|O_ACTIVE);
for (int i=0; i < PADSIZE; i++) {
for (int j=0; j < PADSIZE; j++) {
- if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) {
- if (i==0 || j==0)
- FP.addch('+');
- else
- FP.addch((chtype)('A' + (gridcount++ % 26)));
- }
- else if (i % GRIDSIZE == 0)
- FP.addch('-');
- else if (j % GRIDSIZE == 0)
- FP.addch('|');
- else
- FP.addch(' ');
+ if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) {
+ if (i==0 || j==0)
+ FP.addch('+');
+ else
+ FP.addch((chtype)('A' + (gridcount++ % 26)));
+ }
+ else if (i % GRIDSIZE == 0)
+ FP.addch('-');
+ else if (j % GRIDSIZE == 0)
+ FP.addch('|');
+ else
+ FP.addch(' ');
}
}
options_off(O_SELECTABLE);
}
};
+
+//
+// -------------------------------------------------------------------------
+//
+class ScanAction : public NCursesMenuItem
+{
+public:
+ ScanAction(const char* s) : NCursesMenuItem(s) {
+ }
+
+ bool action() {
+ NCursesPanel *std = new NCursesPanel();
+
+ NCursesPanel *w = new NCursesPanel(std->lines() - 2, std->cols() - 2, 1, 1);
+ w->box();
+ w->refresh();
+
+ NCursesPanel *s = new NCursesPanel(w->lines() - 6, w->cols() - 6, 3, 3);
+ s->scrollok(TRUE);
+ ::echo();
+
+ s->printw("Enter decimal integers. The running total will be shown\n");
+ int value = -1;
+ int result = 0;
+ while (value != 0) {
+ value = 0;
+ s->scanw("%d", &value);
+ if (value != 0) {
+ s->printw("%d: ", result += value);
+ }
+ s->refresh();
+ }
+ s->printw("\nPress any key to continue...");
+ s->getch();
+
+ delete s;
+ delete w;
+ delete std;
+ ::noecho();
+ return FALSE;
+ }
+};
+
//
// -------------------------------------------------------------------------
//
I[2] = new MyAction<UserData> ("Silly", u);
I[3] = new FormAction("Form");
I[4] = new PadAction("Pad");
- I[5] = new PassiveItem("Six");
+ I[5] = new ScanAction("Scan");
I[6] = new QuitItem();
I[7] = new NCursesMenuItem(); // Terminating empty item