+ 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;
+ }
+};
+
+//
+// -------------------------------------------------------------------------
+//