blob: 7ce2734062fdffc002bd7948c51e7f3f8ae4f1e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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
|