]> ncurses.scripts.mit.edu Git - ncurses.git/blob - form/form.priv.h
ncurses 5.4
[ncurses.git] / form / form.priv.h
1 /****************************************************************************
2  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /****************************************************************************
30  *   Author:  Juergen Pfeifer, 1995,1997                                    *
31  ****************************************************************************/
32
33 /* $Id: form.priv.h,v 0.11 2003/11/08 20:38:51 tom Exp $ */
34
35 #include "mf_common.h"
36 #include "form.h"
37
38 /* form  status values */
39 #define _OVLMODE         (0x04) /* Form is in overlay mode                */
40 #define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
41 #define _FCHECK_REQUIRED (0x20) /* Current field needs validation         */
42
43 /* field status values */
44 #define _CHANGED         (0x01) /* Field has been changed                 */
45 #define _NEWTOP          (0x02) /* Vertical scrolling occurred            */
46 #define _NEWPAGE         (0x04) /* field begins new page of form          */
47 #define _MAY_GROW        (0x08) /* dynamic field may still grow           */
48
49 /* fieldtype status values */
50 #define _LINKED_TYPE     (0x01) /* Type is a linked type                  */
51 #define _HAS_ARGS        (0x02) /* Type has arguments                     */
52 #define _HAS_CHOICE      (0x04) /* Type has choice methods                */
53 #define _RESIDENT        (0x08) /* Type is built-in                       */
54
55 /* This are the field options required to be a selectable field in field
56    navigation requests */
57 #define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
58
59 /* If form is NULL replace form argument by default-form */
60 #define Normalize_Form(form)  ((form)=(form)?(form):_nc_Default_Form)
61
62 /* If field is NULL replace field argument by default-field */
63 #define Normalize_Field(field)  ((field)=(field)?(field):_nc_Default_Field)
64
65 /* Retrieve forms window */
66 #define Get_Form_Window(form) \
67   ((form)->sub?(form)->sub:((form)->win?(form)->win:stdscr))
68
69 /* Calculate the size for a single buffer for this field */
70 #define Buffer_Length(field) ((field)->drows * (field)->dcols)
71
72 /* Calculate the total size of all buffers for this field */
73 #define Total_Buffer_Size(field) \
74    ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
75
76 /* Logic to determine whether or not a field is single lined */
77 #define Single_Line_Field(field) \
78    (((field)->rows + (field)->nrow) == 1)
79
80 /* Logic to determine whether or not a field is selectable */
81 #define Field_Is_Selectable(f)     (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
82 #define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE)
83
84 typedef struct typearg {
85   struct typearg *left;
86   struct typearg *right;
87 } TypeArgument;
88
89 /* This is a dummy request code (normally invalid) to be used internally
90    with the form_driver() routine to position to the first active field
91    on the form
92 */
93 #define FIRST_ACTIVE_MAGIC (-291056)
94
95 #define ALL_FORM_OPTS  (                \
96                         O_NL_OVERLOAD  |\
97                         O_BS_OVERLOAD   )
98
99 #define ALL_FIELD_OPTS (           \
100                         O_VISIBLE |\
101                         O_ACTIVE  |\
102                         O_PUBLIC  |\
103                         O_EDIT    |\
104                         O_WRAP    |\
105                         O_BLANK   |\
106                         O_AUTOSKIP|\
107                         O_NULLOK  |\
108                         O_PASSOK  |\
109                         O_STATIC   )
110
111
112 #define C_BLANK ' '
113 #define is_blank(c) ((c)==C_BLANK)
114
115 extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
116
117 extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*,va_list*,int*);
118 extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*,const TypeArgument*, int*);
119 extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*,TypeArgument*);
120 extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
121 extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
122
123 extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
124 extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*,Field_Options);
125 extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*,int,FIELD*);
126 extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
127 extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
128 extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
129 extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*,FIELD*);
130 extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);