summaryrefslogtreecommitdiff
path: root/src/form_field.h
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-06-18 15:45:45 +0200
committerOlivier Gayot <duskcoder@gmail.com>2014-06-18 15:49:38 +0200
commit0e03940802cebefdf6b0597a154bd9395e1af4d2 (patch)
tree409a58499128227dd57943515d003074190551f5 /src/form_field.h
Add the vanilla version of the project
This version can still be found here: http://www.roland-riegel.de/nload/index.html
Diffstat (limited to 'src/form_field.h')
-rw-r--r--src/form_field.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/form_field.h b/src/form_field.h
new file mode 100644
index 0000000..7ce2734
--- /dev/null
+++ b/src/form_field.h
@@ -0,0 +1,110 @@
+/***************************************************************************
+ form_field.h
+ -------------------
+ begin : Sat Jul 27 2002
+ copyright : (C) 2002 - 2012 by Roland Riegel
+ email : feedback@roland-riegel.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef FORM_FIELD_H
+#define FORM_FIELD_H
+
+#include <curses.h>
+#include <form.h>
+#undef clear
+#undef erase
+#undef refresh
+
+#include <string>
+#include <vector>
+
+class Window;
+class SubWindow;
+class Form;
+
+class Field
+{
+ public:
+ Field(int x, int y, int width, int height);
+ ~Field();
+
+ void setText(const std::string& text);
+ std::string getText();
+
+ void move(int x, int y);
+
+ void setVisible(bool new_visible);
+ bool isVisible();
+
+ void setEnabled(bool new_enabled);
+ bool isEnabled();
+
+ void setIntegerField(int min, int max);
+ void setEnumField(const std::vector<std::string>& elements);
+
+ void setFixed(bool new_fixed);
+ bool isFixed();
+
+ void setFirstOnPage(bool new_newpage);
+ bool isFirstOnPage();
+
+ friend bool operator==(const Field& field1, const Field& field2);
+ friend bool operator==(const Field& field1, const FIELD* field2);
+
+ private:
+ friend class Form;
+
+ FIELD* m_field;
+ std::vector<std::string> m_enumElements;
+ const char** m_enumElementsArray;
+};
+
+class Form
+{
+ public:
+ class Slots
+ {
+ public:
+ Slots() {}
+ virtual ~Slots() {}
+ virtual void slot_fieldChanged(Field* field) {}
+ };
+
+ Form(Slots* slots = 0);
+ ~Form();
+
+ std::vector<Field *>& fields();
+
+ void show(Window* main_window, SubWindow* sub_window);
+ void hide();
+
+ void processKey(int key);
+
+ bool isVisible();
+
+ int getPage();
+ int getPageCount();
+
+ private:
+ Slots* m_slots;
+
+ FORM* m_form;
+ FIELD** m_curses_fields;
+ std::vector<Field *> m_fields;
+
+ bool m_visible;
+
+ static void fieldChanged(FORM* form);
+};
+
+#endif
+