+//
+// -------------------------------------------------------------------------
+//
+class Label : public NCursesFormField
+{
+public:
+ Label(const char* title,
+ int row, int col)
+ : NCursesFormField(1, static_cast<int>(::strlen(title)), row, col) {
+ set_value(title);
+ options_off(O_EDIT|O_ACTIVE);
+ }
+};
+//
+// -------------------------------------------------------------------------
+//
+class MyFieldType : public UserDefinedFieldType
+{
+private:
+ int chk;
+protected:
+ bool field_check(NCursesFormField& f) {
+ (void) f;
+ return TRUE;
+ }
+ bool char_check(int c) {
+ return (c==chk?TRUE:FALSE);
+ }
+public:
+ MyFieldType(int x) : chk(x) {
+ }
+};
+//
+// -------------------------------------------------------------------------
+//
+class TestForm : public NCursesForm
+{
+private:
+ NCursesFormField** F;
+ MyFieldType* mft;
+ Integer_Field *ift;
+ Enumeration_Field *eft;
+
+ 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)
+ {
+ }