]> ncurses.scripts.mit.edu Git - ncurses.git/blob - menu/m_spacing.c
7f690b279120e8e8ecd485620de6e8adfc288bef
[ncurses.git] / menu / m_spacing.c
1 /*-----------------------------------------------------------------------------+
2 |           The ncurses menu 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 /***************************************************************************
24 * Module menu_spacing                                                      *
25 * Routines to handle spacing between entries                               *
26 ***************************************************************************/
27
28 #include "menu.priv.h"
29
30 MODULE_ID("$Id: m_spacing.c,v 1.7 1997/05/01 16:47:26 juergen Exp $")
31
32 #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
33 #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
34 #define MAX_SPC_ROWS (3)
35
36 /*---------------------------------------------------------------------------
37 |   Facility      :  libnmenu
38 |   Function      :  int set_menu_spacing(MENU *menu,int desc, int r, int c);
39 |
40 |   Description   :  Set the spacing between entried
41 |
42 |   Return Values :  E_OK                 - on success
43 +--------------------------------------------------------------------------*/
44 int set_menu_spacing(MENU *menu, int s_desc, int s_row, int s_col )
45 {
46   MENU *m; /* split for ATAC workaround */
47   m = Normalize_Menu(menu);
48
49   assert(m);
50   if (m->status & _POSTED)
51     RETURN(E_POSTED);
52
53   if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
54       ((s_row  < 0) || (s_row  > MAX_SPC_ROWS)) ||
55       ((s_col  < 0) || (s_col  > MAX_SPC_COLS)))
56     RETURN(E_BAD_ARGUMENT);
57
58   m->spc_desc = s_desc ? s_desc : 1;
59   m->spc_rows = s_row  ? s_row  : 1;
60   m->spc_cols = s_col  ? s_col  : 1;
61   _nc_Calculate_Item_Length_and_Width(m);
62
63   RETURN(E_OK);
64 }
65
66
67 /*---------------------------------------------------------------------------
68 |   Facility      :  libnmenu
69 |   Function      :  int menu_spacing (const MENU *,int *,int *,int *);
70 |
71 |   Description   :  Retrieve info about spacing between the entries
72 |
73 |   Return Values :  E_OK             - on success
74 +--------------------------------------------------------------------------*/
75 int menu_spacing( const MENU *menu, int* s_desc, int* s_row, int* s_col)
76 {
77   const MENU *m; /* split for ATAC workaround */
78   m = Normalize_Menu(menu);
79
80   assert(m);
81   if (s_desc) *s_desc = m->spc_desc;
82   if (s_row)  *s_row  = m->spc_rows;
83   if (s_col)  *s_col  = m->spc_cols;
84
85   RETURN(E_OK);
86 }
87
88 /* m_spacing.c ends here */