1 /****************************************************************************
2 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 1998-2010,2012 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1995,1997 *
32 ****************************************************************************/
34 #include "form.priv.h"
36 MODULE_ID("$Id: frm_post.c,v 1.14 2020/05/24 01:40:20 anonymous.maarten Exp $")
38 /*---------------------------------------------------------------------------
40 | Function : int post_form(FORM * form)
42 | Description : Writes the form into its associated subwindow.
44 | Return Values : E_OK - success
45 | E_BAD_ARGUMENT - invalid form pointer
46 | E_POSTED - form already posted
47 | E_NOT_CONNECTED - no fields connected to form
48 | E_NO_ROOM - form doesn't fit into subwindow
49 | E_SYSTEM_ERROR - system error
50 +--------------------------------------------------------------------------*/
58 T((T_CALLED("post_form(%p)"), (void *)form));
61 RETURN(E_BAD_ARGUMENT);
63 if (form->status & _POSTED)
67 RETURN(E_NOT_CONNECTED);
69 formwin = Get_Form_Window(form);
70 if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
73 /* reset form->curpage to an invalid value. This forces Set_Form_Page
74 to do the page initialization which is required by post_form.
78 if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK)
81 SetStatus(form, _POSTED);
83 Call_Hook(form, forminit);
84 Call_Hook(form, fieldinit);
86 _nc_Refresh_Current_Field(form);
90 /*---------------------------------------------------------------------------
92 | Function : int unpost_form(FORM * form)
94 | Description : Erase form from its associated subwindow.
96 | Return Values : E_OK - success
97 | E_BAD_ARGUMENT - invalid form pointer
98 | E_NOT_POSTED - form isn't posted
99 | E_BAD_STATE - called from a hook routine
100 +--------------------------------------------------------------------------*/
102 unpost_form(FORM *form)
104 T((T_CALLED("unpost_form(%p)"), (void *)form));
107 RETURN(E_BAD_ARGUMENT);
109 if (!(form->status & _POSTED))
110 RETURN(E_NOT_POSTED);
112 if (form->status & _IN_DRIVER)
115 Call_Hook(form, fieldterm);
116 Call_Hook(form, formterm);
118 werase(Get_Form_Window(form));
120 form->w = (WINDOW *)0;
121 ClrStatus(form, _POSTED);
125 /* frm_post.c ends here */