From 0e03940802cebefdf6b0597a154bd9395e1af4d2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 18 Jun 2014 15:45:45 +0200 Subject: Add the vanilla version of the project This version can still be found here: http://www.roland-riegel.de/nload/index.html --- src/form_field.h | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/form_field.h (limited to 'src/form_field.h') 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 +#include +#undef clear +#undef erase +#undef refresh + +#include +#include + +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& 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 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& 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 m_fields; + + bool m_visible; + + static void fieldChanged(FORM* form); +}; + +#endif + -- cgit v1.2.3