]> ncurses.scripts.mit.edu Git - ncurses.git/blob - form/form.priv.h
ncurses 4.1
[ncurses.git] / form / form.priv.h
1 /*-----------------------------------------------------------------------------+
2 |           The ncurses form library is  Copyright (C) 1995-1997               |
3 |             by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de>                 |
4 |                          All Rights Reserved.                                |
5 |                                                                              |
6 | Permission to use, copy, modify, and distribute this software and its        |
7 | documentation for any purpose and without fee is hereby granted, provided    |
8 | that the above copyright notice appear in all copies and that both that      |
9 | copyright notice and this permission notice appear in supporting             |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the        |
12 | software without specific, written prior permission.                         | 
13 |                                                                              |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO  |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-  |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR   |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH    |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE.                                     |
21 +-----------------------------------------------------------------------------*/
22
23 #include "mf_common.h"
24 #include "form.h"
25
26 /* form  status values */
27 #define _OVLMODE         (0x04) /* Form is in overlay mode                */
28 #define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
29 #define _FCHECK_REQUIRED (0x20) /* Current field needs validation         */
30
31 /* field status values */
32 #define _CHANGED         (0x01) /* Field has been changed                 */
33 #define _NEWTOP          (0x02) /* Vertical scrolling occured             */
34 #define _NEWPAGE         (0x04) /* field begins new page of form          */
35 #define _MAY_GROW        (0x08) /* dynamic field may still grow           */
36
37 /* fieldtype status values */
38 #define _LINKED_TYPE     (0x01) /* Type is a linked type                  */
39 #define _HAS_ARGS        (0x02) /* Type has arguments                     */
40 #define _HAS_CHOICE      (0x04) /* Type has choice methods                */
41 #define _RESIDENT        (0x08) /* Type is builtin                        */
42
43 /* If form is NULL replace form argument by default-form */
44 #define Normalize_Form(form)  ((form)=(form)?(form):_nc_Default_Form)
45
46 /* If field is NULL replace field argument by default-field */
47 #define Normalize_Field(field)  ((field)=(field)?(field):_nc_Default_Field)
48
49 /* Retrieve forms window */
50 #define Get_Form_Window(form) \
51   ((form)->sub?(form)->sub:((form)->win?(form)->win:stdscr))
52
53 /* Calculate the size for a single buffer for this field */
54 #define Buffer_Length(field) ((field)->drows * (field)->dcols)
55
56 /* Calculate the total size of all buffers for this field */
57 #define Total_Buffer_Size(field) \
58    ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
59
60 /* Logic to determine whether or not a field is single lined */
61 #define Single_Line_Field(field) \
62    (((field)->rows + (field)->nrow) == 1)
63
64
65 typedef struct typearg {
66   struct typearg *left;
67   struct typearg *right;
68 } TypeArgument;
69
70 /* This is a dummy request code (normally invalid) to be used internally
71    with the form_driver() routine to position to the first active field
72    on the form
73 */
74 #define FIRST_ACTIVE_MAGIC (-291056)
75
76 #define ALL_FORM_OPTS  (                \
77                         O_NL_OVERLOAD  |\
78                         O_BS_OVERLOAD   )
79
80 #define ALL_FIELD_OPTS (           \
81                         O_VISIBLE |\
82                         O_ACTIVE  |\
83                         O_PUBLIC  |\
84                         O_EDIT    |\
85                         O_WRAP    |\
86                         O_BLANK   |\
87                         O_AUTOSKIP|\
88                         O_NULLOK  |\
89                         O_PASSOK  |\
90                         O_STATIC   )
91
92
93 #define C_BLANK ' '
94 #define is_blank(c) ((c)==C_BLANK)