form_wrap.h (2174B) - raw
1 /*
2 * This is a curses forms wrapper as part of ncurses-ruby
3 * Contributed by Simon Kaczor <skaczor@cox.net>
4 * Prognosoft Inc. <http://www.prognosoft.biz>
5 * Copyright 2004
6 *
7 * This module is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This module is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this module; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * Changes
22 * (C) 2011 Tobias Herzke
23 * (C) 2013 Gaute Hope <eg@gaute.vetsj.com>
24 */
25
26 #if !defined(FORM_HH) && (defined(HAVE_FORM_H) || defined(HAVE_NCURSESW_FORM_H))
27 #define FORM_HH
28
29 # define _XOPEN_SOURCE_EXTENDED
30
31 #ifdef HAVE_FORM_H
32 #include <form.h>
33 #else
34 #include <ncursesw/form.h>
35 #endif
36
37 #include <ruby.h>
38
39 extern VALUE mForm;
40 extern VALUE cFIELD;
41 extern VALUE cFIELDTYPE;
42 extern VALUE cFORM;
43 /*extern VALUE cPAGE;*/
44
45 typedef struct {
46 bool (* field_check)(FIELD *,const void *);
47 FIELDTYPE* fieldtype;
48 } FLDCHKFUNC;
49
50
51
52 #define FORM_DEF_CONST(name) \
53 rb_define_const(mForm, #name, INT2NUM(name));
54
55 #define FORM_SNG_FUNC(name, nargs) \
56 rb_define_singleton_method(mForm, \
57 #name, \
58 &rbncurs_m_ ## name, \
59 nargs)
60 #define RB_CLASS_METH(class, alt_name, name, nargs) \
61 rb_define_method(class, #name, (&rbncurs_c_ ## name), nargs); \
62 if (alt_name != NULL) \
63 rb_define_method(class, alt_name, (&rbncurs_c_ ## name), nargs); \
64
65 void init_req_constants();
66 void init_just_constants();
67 void init_opts_constants();
68
69 void init_form(void);
70
71 #endif