00001 /**************************************************************************** 00002 * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. * 00003 * * 00004 * Permission is hereby granted, free of charge, to any person obtaining a * 00005 * copy of this software and associated documentation files (the * 00006 * "Software"), to deal in the Software without restriction, including * 00007 * without limitation the rights to use, copy, modify, merge, publish, * 00008 * distribute, distribute with modifications, sublicense, and/or sell * 00009 * copies of the Software, and to permit persons to whom the Software is * 00010 * furnished to do so, subject to the following conditions: * 00011 * * 00012 * The above copyright notice and this permission notice shall be included * 00013 * in all copies or substantial portions of the Software. * 00014 * * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 00016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 00018 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 00019 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 00020 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 00021 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 00022 * * 00023 * Except as contained in this notice, the name(s) of the above copyright * 00024 * holders shall not be used in advertising or otherwise to promote the * 00025 * sale, use or other dealings in this Software without prior written * 00026 * authorization. * 00027 ****************************************************************************/ 00028 00029 /**************************************************************************** 00030 * Author: Juergen Pfeifer, 1995,1997 * 00031 ****************************************************************************/ 00032 00033 #include "form.priv.h" 00034 00035 MODULE_ID("$Id: frm_post.c,v 1.9 2004/12/11 22:19:06 tom Exp $") 00036 00037 /*--------------------------------------------------------------------------- 00038 | Facility : libnform 00039 | Function : int post_form(FORM * form) 00040 | 00041 | Description : Writes the form into its associated subwindow. 00042 | 00043 | Return Values : E_OK - success 00044 | E_BAD_ARGUMENT - invalid form pointer 00045 | E_POSTED - form already posted 00046 | E_NOT_CONNECTED - no fields connected to form 00047 | E_NO_ROOM - form doesn't fit into subwindow 00048 | E_SYSTEM_ERROR - system error 00049 +--------------------------------------------------------------------------*/ 00050 NCURSES_EXPORT(int) 00051 post_form(FORM *form) 00052 { 00053 WINDOW *formwin; 00054 int err; 00055 int page; 00056 00057 T((T_CALLED("post_form(%p)"), form)); 00058 00059 if (!form) 00060 RETURN(E_BAD_ARGUMENT); 00061 00062 if (form->status & _POSTED) 00063 RETURN(E_POSTED); 00064 00065 if (!(form->field)) 00066 RETURN(E_NOT_CONNECTED); 00067 00068 formwin = Get_Form_Window(form); 00069 if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin))) 00070 RETURN(E_NO_ROOM); 00071 00072 /* reset form->curpage to an invald value. This forces Set_Form_Page 00073 to do the page initialization which is required by post_form. 00074 */ 00075 page = form->curpage; 00076 form->curpage = -1; 00077 if ((err = _nc_Set_Form_Page(form, page, form->current)) != E_OK) 00078 RETURN(err); 00079 00080 form->status |= _POSTED; 00081 00082 Call_Hook(form, forminit); 00083 Call_Hook(form, fieldinit); 00084 00085 _nc_Refresh_Current_Field(form); 00086 RETURN(E_OK); 00087 } 00088 00089 /*--------------------------------------------------------------------------- 00090 | Facility : libnform 00091 | Function : int unpost_form(FORM * form) 00092 | 00093 | Description : Erase form from its associated subwindow. 00094 | 00095 | Return Values : E_OK - success 00096 | E_BAD_ARGUMENT - invalid form pointer 00097 | E_NOT_POSTED - form isn't posted 00098 | E_BAD_STATE - called from a hook routine 00099 +--------------------------------------------------------------------------*/ 00100 NCURSES_EXPORT(int) 00101 unpost_form(FORM *form) 00102 { 00103 T((T_CALLED("unpost_form(%p)"), form)); 00104 00105 if (!form) 00106 RETURN(E_BAD_ARGUMENT); 00107 00108 if (!(form->status & _POSTED)) 00109 RETURN(E_NOT_POSTED); 00110 00111 if (form->status & _IN_DRIVER) 00112 RETURN(E_BAD_STATE); 00113 00114 Call_Hook(form, fieldterm); 00115 Call_Hook(form, formterm); 00116 00117 werase(Get_Form_Window(form)); 00118 delwin(form->w); 00119 form->w = (WINDOW *)0; 00120 form->status &= ~_POSTED; 00121 RETURN(E_OK); 00122 } 00123 00124 /* frm_post.c ends here */