File indexing completed on 2025-01-18 10:02:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifndef NCURSES_CURSSLK_H_incl
0039 #define NCURSES_CURSSLK_H_incl
0040
0041 #include <ncursesw/cursesw.h>
0042
0043 class NCURSES_CXX_IMPEXP Soft_Label_Key_Set {
0044 public:
0045
0046 class NCURSES_CXX_IMPEXP Soft_Label_Key {
0047 friend class Soft_Label_Key_Set;
0048 public:
0049 typedef enum { Left=0, Center=1, Right=2 } Justification;
0050
0051 private:
0052 char *label;
0053 Justification format;
0054 int num;
0055
0056 Soft_Label_Key() : label(NULL), format(Left), num(-1) {
0057 }
0058
0059 virtual ~Soft_Label_Key() {
0060 delete[] label;
0061 };
0062
0063 public:
0064
0065 Soft_Label_Key& operator=(char *text);
0066
0067
0068 Soft_Label_Key& operator=(Justification just) {
0069 format = just;
0070 return *this;
0071 }
0072
0073
0074 inline char* operator()(void) const {
0075 return label;
0076 }
0077
0078 Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
0079 {
0080 if (this != &rhs) {
0081 *this = rhs;
0082 }
0083 return *this;
0084 }
0085
0086 Soft_Label_Key(const Soft_Label_Key& rhs)
0087 : label(NULL),
0088 format(rhs.format),
0089 num(rhs.num)
0090 {
0091 *this = rhs.label;
0092 }
0093 };
0094
0095 public:
0096 typedef enum {
0097 None = -1,
0098 Three_Two_Three = 0,
0099 Four_Four = 1,
0100 PC_Style = 2,
0101 PC_Style_With_Index = 3
0102 } Label_Layout;
0103
0104 private:
0105 static long count;
0106 static Label_Layout format;
0107 static int num_labels;
0108 bool b_attrInit;
0109
0110 Soft_Label_Key *slk_array;
0111
0112
0113 void init();
0114
0115
0116 void activate_label(int i, bool bf=TRUE);
0117
0118
0119 void activate_labels(bool bf);
0120
0121 protected:
0122 inline void Error (const char* msg) const THROWS(NCursesException) {
0123 THROW(new NCursesException (msg));
0124 }
0125
0126
0127 void clear() {
0128 if (ERR==::slk_clear())
0129 Error("slk_clear");
0130 }
0131
0132
0133 void restore() {
0134 if (ERR==::slk_restore())
0135 Error("slk_restore");
0136 }
0137
0138 public:
0139
0140
0141
0142
0143
0144 explicit Soft_Label_Key_Set(Label_Layout fmt);
0145
0146
0147
0148 Soft_Label_Key_Set();
0149
0150 Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
0151 {
0152 if (this != &rhs) {
0153 *this = rhs;
0154 init();
0155 }
0156 return *this;
0157 }
0158
0159 Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
0160 : b_attrInit(rhs.b_attrInit),
0161 slk_array(NULL)
0162 {
0163 init();
0164 }
0165
0166 virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
0167
0168
0169 Soft_Label_Key& operator[](int i);
0170
0171
0172 int labels() const;
0173
0174
0175 inline void refresh() {
0176 if (ERR==::slk_refresh())
0177 Error("slk_refresh");
0178 }
0179
0180
0181
0182 inline void noutrefresh() {
0183 if (ERR==::slk_noutrefresh())
0184 Error("slk_noutrefresh");
0185 }
0186
0187
0188 inline void touch() {
0189 if (ERR==::slk_touch())
0190 Error("slk_touch");
0191 }
0192
0193
0194 inline void show(int i) {
0195 activate_label(i,FALSE);
0196 activate_label(i,TRUE);
0197 }
0198
0199
0200 inline void hide(int i) {
0201 activate_label(i,FALSE);
0202 }
0203
0204
0205 inline void show() {
0206 activate_labels(FALSE);
0207 activate_labels(TRUE);
0208 }
0209
0210
0211 inline void hide() {
0212 activate_labels(FALSE);
0213 }
0214
0215 inline void attron(attr_t attrs) {
0216 if (ERR==::slk_attron(attrs))
0217 Error("slk_attron");
0218 }
0219
0220 inline void attroff(attr_t attrs) {
0221 if (ERR==::slk_attroff(attrs))
0222 Error("slk_attroff");
0223 }
0224
0225 inline void attrset(attr_t attrs) {
0226 if (ERR==::slk_attrset(attrs))
0227 Error("slk_attrset");
0228 }
0229
0230 inline void color(short color_pair_number) {
0231 if (ERR==::slk_color(color_pair_number))
0232 Error("slk_color");
0233 }
0234
0235 inline attr_t attr() const {
0236 return ::slk_attr();
0237 }
0238 };
0239
0240 #endif