1 /* $OpenBSD: m_spacing.c,v 1.2 1997/12/03 05:31:26 millert Exp $ */ 2 3 /*-----------------------------------------------------------------------------+ 4 | The ncurses menu library is Copyright (C) 1995-1997 | 5 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | 6 | All Rights Reserved. | 7 | | 8 | Permission to use, copy, modify, and distribute this software and its | 9 | documentation for any purpose and without fee is hereby granted, provided | 10 | that the above copyright notice appear in all copies and that both that | 11 | copyright notice and this permission notice appear in supporting | 12 | documentation, and that the name of the above listed copyright holder(s) not | 13 | be used in advertising or publicity pertaining to distribution of the | 14 | software without specific, written prior permission. | 15 | | 16 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO | 17 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | 18 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR | 19 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- | 20 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | 21 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | 22 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | 23 +-----------------------------------------------------------------------------*/ 24 25 /*************************************************************************** 26 * Module m_spacing * 27 * Routines to handle spacing between entries * 28 ***************************************************************************/ 29 30 #include "menu.priv.h" 31 32 MODULE_ID("Id: m_spacing.c,v 1.8 1997/10/21 08:40:51 juergen Exp $") 33 34 #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8) 35 #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8) 36 #define MAX_SPC_ROWS (3) 37 38 /*--------------------------------------------------------------------------- 39 | Facility : libnmenu 40 | Function : int set_menu_spacing(MENU *menu,int desc, int r, int c); 41 | 42 | Description : Set the spacing between entried 43 | 44 | Return Values : E_OK - on success 45 +--------------------------------------------------------------------------*/ 46 int set_menu_spacing(MENU *menu, int s_desc, int s_row, int s_col ) 47 { 48 MENU *m; /* split for ATAC workaround */ 49 m = Normalize_Menu(menu); 50 51 assert(m); 52 if (m->status & _POSTED) 53 RETURN(E_POSTED); 54 55 if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) || 56 ((s_row < 0) || (s_row > MAX_SPC_ROWS)) || 57 ((s_col < 0) || (s_col > MAX_SPC_COLS))) 58 RETURN(E_BAD_ARGUMENT); 59 60 m->spc_desc = s_desc ? s_desc : 1; 61 m->spc_rows = s_row ? s_row : 1; 62 m->spc_cols = s_col ? s_col : 1; 63 _nc_Calculate_Item_Length_and_Width(m); 64 65 RETURN(E_OK); 66 } 67 68 69 /*--------------------------------------------------------------------------- 70 | Facility : libnmenu 71 | Function : int menu_spacing (const MENU *,int *,int *,int *); 72 | 73 | Description : Retrieve info about spacing between the entries 74 | 75 | Return Values : E_OK - on success 76 +--------------------------------------------------------------------------*/ 77 int menu_spacing( const MENU *menu, int* s_desc, int* s_row, int* s_col) 78 { 79 const MENU *m; /* split for ATAC workaround */ 80 m = Normalize_Menu(menu); 81 82 assert(m); 83 if (s_desc) *s_desc = m->spc_desc; 84 if (s_row) *s_row = m->spc_rows; 85 if (s_col) *s_col = m->spc_cols; 86 87 RETURN(E_OK); 88 } 89 90 /* m_spacing.c ends here */ 91