+ static const char *weekdays[];
+
+public:
+ TestForm()
+ : NCursesForm(13, 51, (lines() - 15)/2, (cols() - 53)/2),
+ F(0),
+ mft(0),
+ ift(0),
+ eft(0)
+ {
+
+ F = new NCursesFormField*[10];
+ mft = new MyFieldType('X');
+ ift = new Integer_Field(0, 1, 10);
+ eft = new Enumeration_Field(weekdays);
+
+ F[0] = new Label("Demo Entry Form", 0, 16);
+ F[1] = new Label("Weekday Enum", 2, 1);
+ F[2] = new Label("Number(1-10)", 2, 21);
+ F[3] = new Label("Only 'X'", 2, 35);
+ F[4] = new Label("Multiline Field (Dynamic and Scrollable)", 5, 1);
+ F[5] = new NCursesFormField(1, 18, 3, 1);
+ F[6] = new NCursesFormField(1, 12, 3, 21);
+ F[7] = new NCursesFormField(1, 12, 3, 35);
+ F[8] = new NCursesFormField(4, 46, 6, 1, 2);
+ F[9] = new NCursesFormField();
+
+ InitForm(F, TRUE, TRUE);
+ boldframe();
+
+ F[5]->set_fieldtype(*eft);
+ F[6]->set_fieldtype(*ift);
+
+ F[7]->set_fieldtype(*mft);
+ F[7]->set_maximum_growth(20); // max. 20 characters
+ F[7]->options_off(O_STATIC); // make field dynamic
+
+ F[8]->set_maximum_growth(10); // max. 10 lines
+ F[8]->options_off(O_STATIC); // make field dynamic
+ }
+
+ TestForm& operator=(const TestForm& rhs)
+ {
+ if (this != &rhs) {
+ *this = rhs;
+ }
+ return *this;
+ }
+
+ TestForm(const TestForm& rhs)
+ : NCursesForm(rhs), F(0), mft(0), ift(0), eft(0)
+ {
+ }
+
+ ~TestForm() THROWS(NCursesException) {
+ delete mft;
+ delete ift;
+ delete eft;
+ }
+};
+
+const char* TestForm::weekdays[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday", NULL };
+//
+// -------------------------------------------------------------------------
+//
+class FormAction : public NCursesMenuItem
+{
+public:
+ FormAction(const char *s) : NCursesMenuItem(s) {
+ }
+
+ bool action() {
+ TestForm F;
+ Soft_Label_Key_Set* S = new Soft_Label_Key_Set;
+ for(int i=1; i <= S->labels(); i++) {
+ char buf[8];
+ assert(i < 100);
+ ::_nc_SPRINTF(buf, _nc_SLIMIT(sizeof(buf)) "Frm%02d", i % 100);
+ (*S)[i] = buf; // Text
+ (*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
+ }
+ NCursesApplication::getApplication()->push(*S);
+ F();
+ NCursesApplication::getApplication()->pop();
+ delete S;
+ return FALSE;
+ }
+};
+//
+// -------------------------------------------------------------------------
+//
+class PadAction : public NCursesMenuItem
+{
+public:
+ PadAction(const char* s) : NCursesMenuItem(s) {
+ }
+
+ bool action() {
+ const int GRIDSIZE = 3;
+ const int PADSIZE = 200;
+ unsigned gridcount = 0;
+
+ NCursesPanel mystd;
+ NCursesPanel P(mystd.lines()-2, mystd.cols()-2, 1, 1);
+ NCursesFramedPad FP(P, PADSIZE, PADSIZE);
+
+ 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(static_cast<chtype>('A' + (gridcount++ % 26)));
+ }
+ else if (i % GRIDSIZE == 0)
+ FP.addch('-');
+ else if (j % GRIDSIZE == 0)
+ FP.addch('|');
+ else
+ FP.addch(' ');
+ }
+ }
+
+ P.label("Pad Demo", NULL);
+ FP();
+ P.clear();
+ return FALSE;
+ }
+};
+
+//
+// -------------------------------------------------------------------------
+//
+class PassiveItem : public NCursesMenuItem
+{
+public:
+ PassiveItem(const char* text) : NCursesMenuItem(text) {
+ options_off(O_SELECTABLE);
+ }
+};
+
+//
+// -------------------------------------------------------------------------
+//
+class ScanAction : public NCursesMenuItem
+{
+public:
+ ScanAction(const char* s) : NCursesMenuItem(s) {
+ }
+
+ bool action() {
+ NCursesPanel *mystd = new NCursesPanel();
+
+ NCursesPanel *w = new NCursesPanel(mystd->lines() - 2, mystd->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 nvalue = -1;
+ int result = 0;
+ while (nvalue != 0) {
+ nvalue = 0;
+ s->scanw("%d", &nvalue);
+ if (nvalue != 0) {
+ s->printw("%d: ", result += nvalue);
+ }
+ s->refresh();
+ }
+ s->printw("\nPress any key to continue...");
+ s->getch();
+
+ delete s;
+ delete w;
+ delete mystd;
+ ::noecho();
+ return FALSE;
+ }
+};
+
+//
+// -------------------------------------------------------------------------
+//