File indexing completed on 2025-01-17 09:55:14
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_CURSESF_H_incl
0039 #define NCURSES_CURSESF_H_incl 1
0040
0041 #include <ncursesw/cursesp.h>
0042
0043 #ifndef __EXT_QNX
0044 #include <string.h>
0045 #endif
0046
0047 extern "C" {
0048 # include <ncursesw/form.h>
0049 }
0050
0051
0052
0053
0054
0055 class NCURSES_CXX_IMPEXP NCursesFormField;
0056
0057
0058
0059 class NCURSES_CXX_IMPEXP NCursesFieldType
0060 {
0061 friend class NCursesFormField;
0062
0063 protected:
0064 FIELDTYPE* fieldtype;
0065
0066 inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) {
0067 if (err!=E_OK)
0068 THROW(new NCursesFormException (err));
0069 }
0070
0071 NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
0072 }
0073
0074 virtual ~NCursesFieldType() {}
0075
0076
0077 virtual void set(NCursesFormField& f) = 0;
0078
0079 public:
0080 NCursesFieldType()
0081 : fieldtype(STATIC_CAST(FIELDTYPE*)(0))
0082 {
0083 }
0084
0085 NCursesFieldType& operator=(const NCursesFieldType& rhs)
0086 {
0087 if (this != &rhs) {
0088 *this = rhs;
0089 }
0090 return *this;
0091 }
0092
0093 NCursesFieldType(const NCursesFieldType& rhs)
0094 : fieldtype(rhs.fieldtype)
0095 {
0096 }
0097
0098 };
0099
0100
0101
0102
0103
0104
0105 class NCURSES_CXX_IMPEXP NCursesFormField
0106 {
0107 friend class NCursesForm;
0108
0109 protected:
0110 FIELD *field;
0111 NCursesFieldType* ftype;
0112
0113
0114 inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
0115 if (err != E_OK)
0116 THROW(new NCursesFormException (err));
0117 }
0118
0119 public:
0120
0121 NCursesFormField()
0122 : field(STATIC_CAST(FIELD*)(0)),
0123 ftype(STATIC_CAST(NCursesFieldType*)(0))
0124 {
0125 }
0126
0127
0128 NCursesFormField (int rows,
0129 int ncols,
0130 int first_row = 0,
0131 int first_col = 0,
0132 int offscreen_rows = 0,
0133 int additional_buffers = 0)
0134 : field(0),
0135 ftype(STATIC_CAST(NCursesFieldType*)(0))
0136 {
0137 field = ::new_field(rows, ncols, first_row, first_col,
0138 offscreen_rows, additional_buffers);
0139 if (!field)
0140 OnError(errno);
0141 }
0142
0143 NCursesFormField& operator=(const NCursesFormField& rhs)
0144 {
0145 if (this != &rhs) {
0146 *this = rhs;
0147 }
0148 return *this;
0149 }
0150
0151 NCursesFormField(const NCursesFormField& rhs)
0152 : field(rhs.field), ftype(rhs.ftype)
0153 {
0154 }
0155
0156 virtual ~NCursesFormField () THROWS(NCursesException);
0157
0158
0159 inline NCursesFormField* dup(int first_row, int first_col)
0160 {
0161 NCursesFormField* f = new NCursesFormField();
0162 if (!f)
0163 OnError(E_SYSTEM_ERROR);
0164 else {
0165 f->ftype = ftype;
0166 f->field = ::dup_field(field,first_row,first_col);
0167 if (!f->field)
0168 OnError(errno);
0169 }
0170 return f;
0171 }
0172
0173
0174 inline NCursesFormField* link(int first_row, int first_col) {
0175 NCursesFormField* f = new NCursesFormField();
0176 if (!f)
0177 OnError(E_SYSTEM_ERROR);
0178 else {
0179 f->ftype = ftype;
0180 f->field = ::link_field(field,first_row,first_col);
0181 if (!f->field)
0182 OnError(errno);
0183 }
0184 return f;
0185 }
0186
0187
0188 inline FIELD* get_field() const {
0189 return field;
0190 }
0191
0192
0193 inline void info(int& rows, int& ncols,
0194 int& first_row, int& first_col,
0195 int& offscreen_rows, int& additional_buffers) const {
0196 OnError(::field_info(field, &rows, &ncols,
0197 &first_row, &first_col,
0198 &offscreen_rows, &additional_buffers));
0199 }
0200
0201
0202 inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
0203 int& max_growth) const {
0204 OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
0205 &max_growth));
0206 }
0207
0208
0209
0210 inline void set_maximum_growth(int growth = 0) {
0211 OnError(::set_max_field(field,growth));
0212 }
0213
0214
0215 inline void move(int row, int col) {
0216 OnError(::move_field(field,row,col));
0217 }
0218
0219
0220 inline void new_page(bool pageFlag = FALSE) {
0221 OnError(::set_new_page(field,pageFlag));
0222 }
0223
0224
0225 inline bool is_new_page() const {
0226 return ::new_page(field);
0227 }
0228
0229
0230 inline void set_justification(int just) {
0231 OnError(::set_field_just(field,just));
0232 }
0233
0234
0235 inline int justification() const {
0236 return ::field_just(field);
0237 }
0238
0239 inline void set_foreground(chtype foreground) {
0240 OnError(::set_field_fore(field,foreground));
0241 }
0242
0243
0244 inline chtype fore() const {
0245 return ::field_fore(field);
0246 }
0247
0248
0249 inline void set_background(chtype background) {
0250 OnError(::set_field_back(field,background));
0251 }
0252
0253
0254 inline chtype back() const {
0255 return ::field_back(field);
0256 }
0257
0258
0259 inline void set_pad_character(int padding) {
0260 OnError(::set_field_pad(field, padding));
0261 }
0262
0263
0264 inline int pad() const {
0265 return ::field_pad(field);
0266 }
0267
0268
0269 inline void options_on (Field_Options opts) {
0270 OnError (::field_opts_on (field, opts));
0271 }
0272
0273
0274 inline void options_off (Field_Options opts) {
0275 OnError (::field_opts_off (field, opts));
0276 }
0277
0278
0279 inline Field_Options options () const {
0280 return ::field_opts (field);
0281 }
0282
0283
0284 inline void set_options (Field_Options opts) {
0285 OnError (::set_field_opts (field, opts));
0286 }
0287
0288
0289 inline void set_changed(bool changeFlag = TRUE) {
0290 OnError(::set_field_status(field,changeFlag));
0291 }
0292
0293
0294 inline bool changed() const {
0295 return ::field_status(field);
0296 }
0297
0298
0299
0300 inline int (index)() const {
0301 return ::field_index(field);
0302 }
0303
0304
0305 inline void set_value(const char *val, int buffer = 0) {
0306 OnError(::set_field_buffer(field,buffer,val));
0307 }
0308
0309
0310 inline char* value(int buffer = 0) const {
0311 return ::field_buffer(field,buffer);
0312 }
0313
0314
0315 inline void set_fieldtype(NCursesFieldType& f) {
0316 ftype = &f;
0317 f.set(*this);
0318 }
0319
0320
0321 inline NCursesFieldType* fieldtype() const {
0322 return ftype;
0323 }
0324
0325 };
0326
0327
0328
0329
0330 extern "C" {
0331 void _nc_xx_frm_init(FORM *);
0332 void _nc_xx_frm_term(FORM *);
0333 void _nc_xx_fld_init(FORM *);
0334 void _nc_xx_fld_term(FORM *);
0335 }
0336
0337
0338
0339
0340
0341
0342 class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel
0343 {
0344 protected:
0345 FORM* form;
0346
0347 private:
0348 NCursesWindow* sub;
0349 bool b_sub_owner;
0350 bool b_framed;
0351 bool b_autoDelete;
0352
0353 NCursesFormField** my_fields;
0354
0355
0356
0357 typedef struct {
0358 void* m_user;
0359 const NCursesForm* m_back;
0360 const FORM* m_owner;
0361 } UserHook;
0362
0363
0364 static inline NCursesForm* getHook(const FORM *f) {
0365 UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
0366 assert(hook != 0 && hook->m_owner==f);
0367 return const_cast<NCursesForm*>(hook->m_back);
0368 }
0369
0370 friend void _nc_xx_frm_init(FORM *);
0371 friend void _nc_xx_frm_term(FORM *);
0372 friend void _nc_xx_fld_init(FORM *);
0373 friend void _nc_xx_fld_term(FORM *);
0374
0375
0376 FIELD** mapFields(NCursesFormField* nfields[]);
0377
0378 protected:
0379
0380 inline void set_user(void *user) {
0381 UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
0382 assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
0383 uptr->m_user = user;
0384 }
0385
0386 inline void *get_user() {
0387 UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
0388 assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
0389 return uptr->m_user;
0390 }
0391
0392 void InitForm (NCursesFormField* Fields[],
0393 bool with_frame,
0394 bool autoDeleteFields);
0395
0396 inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
0397 if (err != E_OK)
0398 THROW(new NCursesFormException (err));
0399 }
0400
0401
0402 virtual int driver (int c) ;
0403
0404
0405
0406 NCursesForm( int nlines,
0407 int ncols,
0408 int begin_y = 0,
0409 int begin_x = 0)
0410 : NCursesPanel(nlines, ncols, begin_y, begin_x),
0411 form (STATIC_CAST(FORM*)(0)),
0412 sub(0),
0413 b_sub_owner(0),
0414 b_framed(0),
0415 b_autoDelete(0),
0416 my_fields(0)
0417 {
0418 }
0419
0420 public:
0421
0422 NCursesForm (NCursesFormField* Fields[],
0423 bool with_frame=FALSE,
0424 bool autoDelete_Fields=FALSE)
0425 : NCursesPanel(),
0426 form(0),
0427 sub(0),
0428 b_sub_owner(0),
0429 b_framed(0),
0430 b_autoDelete(0),
0431 my_fields(0)
0432 {
0433 InitForm(Fields, with_frame, autoDelete_Fields);
0434 }
0435
0436
0437 NCursesForm (NCursesFormField* Fields[],
0438 int nlines,
0439 int ncols,
0440 int begin_y,
0441 int begin_x,
0442 bool with_frame=FALSE,
0443 bool autoDelete_Fields=FALSE)
0444 : NCursesPanel(nlines, ncols, begin_y, begin_x),
0445 form(0),
0446 sub(0),
0447 b_sub_owner(0),
0448 b_framed(0),
0449 b_autoDelete(0),
0450 my_fields(0)
0451 {
0452 InitForm(Fields, with_frame, autoDelete_Fields);
0453 }
0454
0455 NCursesForm& operator=(const NCursesForm& rhs)
0456 {
0457 if (this != &rhs) {
0458 *this = rhs;
0459 NCursesPanel::operator=(rhs);
0460 }
0461 return *this;
0462 }
0463
0464 NCursesForm(const NCursesForm& rhs)
0465 : NCursesPanel(rhs),
0466 form(rhs.form),
0467 sub(rhs.sub),
0468 b_sub_owner(rhs.b_sub_owner),
0469 b_framed(rhs.b_framed),
0470 b_autoDelete(rhs.b_autoDelete),
0471 my_fields(rhs.my_fields)
0472 {
0473 }
0474
0475 virtual ~NCursesForm() THROWS(NCursesException);
0476
0477
0478 virtual void setDefaultAttributes();
0479
0480
0481 inline NCursesFormField* current_field() const {
0482 return my_fields[::field_index(::current_field(form))];
0483 }
0484
0485
0486 void setSubWindow(NCursesWindow& sub);
0487
0488
0489 inline void setFields(NCursesFormField* Fields[]) {
0490 OnError(::set_form_fields(form,mapFields(Fields)));
0491 }
0492
0493
0494 inline void unpost (void) {
0495 OnError (::unpost_form (form));
0496 }
0497
0498
0499 inline void post(bool flag = TRUE) {
0500 OnError (flag ? ::post_form(form) : ::unpost_form (form));
0501 }
0502
0503
0504 inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
0505 if (b_framed)
0506 NCursesPanel::frame(title,btitle);
0507 else
0508 OnError(E_SYSTEM_ERROR);
0509 }
0510
0511 inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
0512 if (b_framed)
0513 NCursesPanel::boldframe(title,btitle);
0514 else
0515 OnError(E_SYSTEM_ERROR);
0516 }
0517
0518 inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
0519 if (b_framed)
0520 NCursesPanel::label(topLabel,bottomLabel);
0521 else
0522 OnError(E_SYSTEM_ERROR);
0523 }
0524
0525
0526
0527
0528
0529
0530
0531 virtual void On_Form_Init();
0532
0533
0534
0535 virtual void On_Form_Termination();
0536
0537
0538 virtual void On_Field_Init(NCursesFormField& field);
0539
0540
0541 virtual void On_Field_Termination(NCursesFormField& field);
0542
0543
0544 void scale(int& rows, int& ncols) const {
0545 OnError(::scale_form(form,&rows,&ncols));
0546 }
0547
0548
0549 int count() const {
0550 return ::field_count(form);
0551 }
0552
0553
0554 void set_page(int pageNum) {
0555 OnError(::set_form_page(form, pageNum));
0556 }
0557
0558
0559 int page() const {
0560 return ::form_page(form);
0561 }
0562
0563
0564 inline void options_on (Form_Options opts) {
0565 OnError (::form_opts_on (form, opts));
0566 }
0567
0568
0569 inline void options_off (Form_Options opts) {
0570 OnError (::form_opts_off (form, opts));
0571 }
0572
0573
0574 inline Form_Options options () const {
0575 return ::form_opts (form);
0576 }
0577
0578
0579 inline void set_options (Form_Options opts) {
0580 OnError (::set_form_opts (form, opts));
0581 }
0582
0583
0584 inline bool data_ahead() const {
0585 return ::data_ahead(form);
0586 }
0587
0588
0589 inline bool data_behind() const {
0590 return ::data_behind(form);
0591 }
0592
0593
0594 inline void position_cursor () {
0595 OnError (::pos_form_cursor (form));
0596 }
0597
0598 inline void set_current(NCursesFormField& F) {
0599 OnError (::set_current_field(form, F.field));
0600 }
0601
0602
0603
0604
0605
0606 virtual int virtualize(int c);
0607
0608
0609 inline NCursesFormField* operator[](int i) const {
0610 if ( (i < 0) || (i >= ::field_count (form)) )
0611 OnError (E_BAD_ARGUMENT);
0612 return my_fields[i];
0613 }
0614
0615
0616
0617 virtual NCursesFormField* operator()(void);
0618
0619
0620 virtual void On_Request_Denied(int c) const;
0621 virtual void On_Invalid_Field(int c) const;
0622 virtual void On_Unknown_Command(int c) const;
0623
0624 };
0625
0626
0627
0628
0629
0630
0631
0632
0633 template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField
0634 {
0635 public:
0636 NCursesUserField (int rows,
0637 int ncols,
0638 int first_row = 0,
0639 int first_col = 0,
0640 const T* p_UserData = STATIC_CAST(T*)(0),
0641 int offscreen_rows = 0,
0642 int additional_buffers = 0)
0643 : NCursesFormField (rows, ncols,
0644 first_row, first_col,
0645 offscreen_rows, additional_buffers) {
0646 if (field)
0647 OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
0648 }
0649
0650 virtual ~NCursesUserField() THROWS(NCursesException) {};
0651
0652 inline const T* UserData (void) const {
0653 return reinterpret_cast<const T*>(::field_userptr (field));
0654 }
0655
0656 inline virtual void setUserData(const T* p_UserData) {
0657 if (field)
0658 OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)));
0659 }
0660 };
0661
0662
0663
0664
0665
0666 template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm
0667 {
0668 protected:
0669
0670
0671 NCursesUserForm( int nlines,
0672 int ncols,
0673 int begin_y = 0,
0674 int begin_x = 0,
0675 const T* p_UserData = STATIC_CAST(T*)(0))
0676 : NCursesForm(nlines,ncols,begin_y,begin_x) {
0677 if (form)
0678 set_user (const_cast<void *>(reinterpret_cast<const void*>
0679 (p_UserData)));
0680 }
0681
0682 public:
0683 NCursesUserForm (NCursesFormField* Fields[],
0684 const T* p_UserData = STATIC_CAST(T*)(0),
0685 bool with_frame=FALSE,
0686 bool autoDelete_Fields=FALSE)
0687 : NCursesForm (Fields, with_frame, autoDelete_Fields) {
0688 if (form)
0689 set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
0690 };
0691
0692 NCursesUserForm (NCursesFormField* Fields[],
0693 int nlines,
0694 int ncols,
0695 int begin_y = 0,
0696 int begin_x = 0,
0697 const T* p_UserData = STATIC_CAST(T*)(0),
0698 bool with_frame=FALSE,
0699 bool autoDelete_Fields=FALSE)
0700 : NCursesForm (Fields, nlines, ncols, begin_y, begin_x,
0701 with_frame, autoDelete_Fields) {
0702 if (form)
0703 set_user (const_cast<void *>(reinterpret_cast<const void*>
0704 (p_UserData)));
0705 };
0706
0707 virtual ~NCursesUserForm() THROWS(NCursesException) {
0708 };
0709
0710 inline T* UserData (void) {
0711 return reinterpret_cast<T*>(get_user ());
0712 };
0713
0714 inline virtual void setUserData (const T* p_UserData) {
0715 if (form)
0716 set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
0717 }
0718
0719 };
0720
0721
0722
0723
0724
0725 class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType
0726 {
0727 private:
0728 int min_field_width;
0729
0730 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0731 OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
0732 }
0733
0734 public:
0735 explicit Alpha_Field(int width)
0736 : NCursesFieldType(TYPE_ALPHA),
0737 min_field_width(width) {
0738 }
0739 };
0740
0741 class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType
0742 {
0743 private:
0744 int min_field_width;
0745
0746 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0747 OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
0748 }
0749
0750 public:
0751 explicit Alphanumeric_Field(int width)
0752 : NCursesFieldType(TYPE_ALNUM),
0753 min_field_width(width) {
0754 }
0755 };
0756
0757 class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType
0758 {
0759 private:
0760 int precision;
0761 long lower_limit, upper_limit;
0762
0763 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0764 OnError(::set_field_type(f.get_field(),fieldtype,
0765 precision,lower_limit,upper_limit));
0766 }
0767
0768 public:
0769 Integer_Field(int prec, long low=0L, long high=0L)
0770 : NCursesFieldType(TYPE_INTEGER),
0771 precision(prec), lower_limit(low), upper_limit(high) {
0772 }
0773 };
0774
0775 class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType
0776 {
0777 private:
0778 int precision;
0779 double lower_limit, upper_limit;
0780
0781 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0782 OnError(::set_field_type(f.get_field(),fieldtype,
0783 precision,lower_limit,upper_limit));
0784 }
0785
0786 public:
0787 Numeric_Field(int prec, double low=0.0, double high=0.0)
0788 : NCursesFieldType(TYPE_NUMERIC),
0789 precision(prec), lower_limit(low), upper_limit(high) {
0790 }
0791 };
0792
0793 class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType
0794 {
0795 private:
0796 char* regex;
0797
0798 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0799 OnError(::set_field_type(f.get_field(),fieldtype,regex));
0800 }
0801
0802 void copy_regex(const char *source)
0803 {
0804 regex = new char[1 + ::strlen(source)];
0805 (::strcpy)(regex, source);
0806 }
0807
0808 public:
0809 explicit Regular_Expression_Field(const char *expr)
0810 : NCursesFieldType(TYPE_REGEXP),
0811 regex(NULL)
0812 {
0813 copy_regex(expr);
0814 }
0815
0816 Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
0817 {
0818 if (this != &rhs) {
0819 *this = rhs;
0820 copy_regex(rhs.regex);
0821 NCursesFieldType::operator=(rhs);
0822 }
0823 return *this;
0824 }
0825
0826 Regular_Expression_Field(const Regular_Expression_Field& rhs)
0827 : NCursesFieldType(rhs),
0828 regex(NULL)
0829 {
0830 copy_regex(rhs.regex);
0831 }
0832
0833 ~Regular_Expression_Field() {
0834 delete[] regex;
0835 }
0836 };
0837
0838 class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType
0839 {
0840 private:
0841 const char** list;
0842 int case_sensitive;
0843 int non_unique_matches;
0844
0845 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0846 OnError(::set_field_type(f.get_field(),fieldtype,
0847 list,case_sensitive,non_unique_matches));
0848 }
0849 public:
0850 Enumeration_Field(const char* enums[],
0851 bool case_sens=FALSE,
0852 bool non_unique=FALSE)
0853 : NCursesFieldType(TYPE_ENUM),
0854 list(enums),
0855 case_sensitive(case_sens ? -1 : 0),
0856 non_unique_matches(non_unique ? -1 : 0) {
0857 }
0858
0859 Enumeration_Field& operator=(const Enumeration_Field& rhs)
0860 {
0861 if (this != &rhs) {
0862 *this = rhs;
0863 NCursesFieldType::operator=(rhs);
0864 }
0865 return *this;
0866 }
0867
0868 Enumeration_Field(const Enumeration_Field& rhs)
0869 : NCursesFieldType(rhs),
0870 list(rhs.list),
0871 case_sensitive(rhs.case_sensitive),
0872 non_unique_matches(rhs.non_unique_matches)
0873 {
0874 }
0875 };
0876
0877 class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType
0878 {
0879 private:
0880 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0881 OnError(::set_field_type(f.get_field(),fieldtype));
0882 }
0883
0884 public:
0885 IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
0886 }
0887 };
0888
0889 extern "C" {
0890 bool _nc_xx_fld_fcheck(FIELD *, const void*);
0891 bool _nc_xx_fld_ccheck(int c, const void *);
0892 void* _nc_xx_fld_makearg(va_list*);
0893 }
0894
0895
0896
0897
0898
0899
0900 class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType
0901 {
0902 friend class UDF_Init;
0903 private:
0904
0905
0906 static FIELDTYPE* generic_fieldtype;
0907
0908 protected:
0909
0910
0911 friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
0912 friend bool _nc_xx_fld_ccheck(int c, const void *);
0913 friend void* _nc_xx_fld_makearg(va_list*);
0914
0915 void set(NCursesFormField& f) NCURSES_OVERRIDE {
0916 OnError(::set_field_type(f.get_field(),fieldtype,&f));
0917 }
0918
0919 protected:
0920
0921
0922 virtual bool field_check(NCursesFormField& f) = 0;
0923
0924
0925
0926 virtual bool char_check (int c) = 0;
0927
0928 public:
0929 UserDefinedFieldType();
0930 };
0931
0932 extern "C" {
0933 bool _nc_xx_next_choice(FIELD*, const void *);
0934 bool _nc_xx_prev_choice(FIELD*, const void *);
0935 }
0936
0937
0938
0939
0940
0941
0942 class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
0943 {
0944 friend class UDF_Init;
0945 private:
0946
0947
0948 static FIELDTYPE* generic_fieldtype_with_choice;
0949
0950
0951
0952 friend bool _nc_xx_next_choice(FIELD*, const void *);
0953 friend bool _nc_xx_prev_choice(FIELD*, const void *);
0954
0955 protected:
0956
0957
0958 virtual bool next (NCursesFormField& f) = 0;
0959
0960
0961
0962 virtual bool previous(NCursesFormField& f) = 0;
0963
0964 public:
0965 UserDefinedFieldType_With_Choice();
0966 };
0967
0968 #endif