xref: /freebsd/contrib/ncurses/menu/m_hook.c (revision a1a4f1a0d87b594d3f17a97dc0127eec1417e6f6)
1 /****************************************************************************
2  * Copyright (c) 1998 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28 
29 /****************************************************************************
30  *   Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
31  ****************************************************************************/
32 
33 /***************************************************************************
34 * Module m_hook                                                            *
35 * Assign application specific routines for automatic invocation by menus   *
36 ***************************************************************************/
37 
38 #include "menu.priv.h"
39 
40 MODULE_ID("$Id: m_hook.c,v 1.8 1999/05/16 17:25:24 juergen Exp $")
41 
42 /* "Template" macro to generate function to set application specific hook */
43 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
44 int set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
45 {\
46    (Normalize_Menu(menu) -> typ ## name = func );\
47    RETURN(E_OK);\
48 }
49 
50 /* "Template" macro to generate function to get application specific hook */
51 #define GEN_HOOK_GET_FUNCTION( typ, name ) \
52 Menu_Hook typ ## _ ## name ( const MENU *menu )\
53 {\
54    return (Normalize_Menu(menu) -> typ ## name);\
55 }
56 
57 /*---------------------------------------------------------------------------
58 |   Facility      :  libnmenu
59 |   Function      :  int set_menu_init(MENU *menu, void (*f)(MENU *))
60 |
61 |   Description   :  Set user-exit which is called when menu is posted
62 |                    or just after the top row changes.
63 |
64 |   Return Values :  E_OK               - success
65 +--------------------------------------------------------------------------*/
66 GEN_HOOK_SET_FUNCTION( menu, init )
67 
68 /*---------------------------------------------------------------------------
69 |   Facility      :  libnmenu
70 |   Function      :  void (*)(MENU *) menu_init(const MENU *menu)
71 |
72 |   Description   :  Return address of user-exit function which is called
73 |                    when a menu is posted or just after the top row
74 |                    changes.
75 |
76 |   Return Values :  Menu init function address or NULL
77 +--------------------------------------------------------------------------*/
78 GEN_HOOK_GET_FUNCTION( menu, init )
79 
80 /*---------------------------------------------------------------------------
81 |   Facility      :  libnmenu
82 |   Function      :  int set_menu_term (MENU *menu, void (*f)(MENU *))
83 |
84 |   Description   :  Set user-exit which is called when menu is unposted
85 |                    or just before the top row changes.
86 |
87 |   Return Values :  E_OK               - success
88 +--------------------------------------------------------------------------*/
89 GEN_HOOK_SET_FUNCTION( menu, term )
90 
91 /*---------------------------------------------------------------------------
92 |   Facility      :  libnmenu
93 |   Function      :  void (*)(MENU *) menu_term(const MENU *menu)
94 |
95 |   Description   :  Return address of user-exit function which is called
96 |                    when a menu is unposted or just before the top row
97 |                    changes.
98 |
99 |   Return Values :  Menu finalization function address or NULL
100 +--------------------------------------------------------------------------*/
101 GEN_HOOK_GET_FUNCTION( menu, term )
102 
103 /*---------------------------------------------------------------------------
104 |   Facility      :  libnmenu
105 |   Function      :  int set_item_init (MENU *menu, void (*f)(MENU *))
106 |
107 |   Description   :  Set user-exit which is called when menu is posted
108 |                    or just after the current item changes.
109 |
110 |   Return Values :  E_OK               - success
111 +--------------------------------------------------------------------------*/
112 GEN_HOOK_SET_FUNCTION( item, init )
113 
114 /*---------------------------------------------------------------------------
115 |   Facility      :  libnmenu
116 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
117 |
118 |   Description   :  Return address of user-exit function which is called
119 |                    when a menu is posted or just after the current item
120 |                    changes.
121 |
122 |   Return Values :  Item init function address or NULL
123 +--------------------------------------------------------------------------*/
124 GEN_HOOK_GET_FUNCTION( item, init )
125 
126 /*---------------------------------------------------------------------------
127 |   Facility      :  libnmenu
128 |   Function      :  int set_item_term (MENU *menu, void (*f)(MENU *))
129 |
130 |   Description   :  Set user-exit which is called when menu is unposted
131 |                    or just before the current item changes.
132 |
133 |   Return Values :  E_OK               - success
134 +--------------------------------------------------------------------------*/
135 GEN_HOOK_SET_FUNCTION( item, term )
136 
137 /*---------------------------------------------------------------------------
138 |   Facility      :  libnmenu
139 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
140 |
141 |   Description   :  Return address of user-exit function which is called
142 |                    when a menu is unposted or just before the current item
143 |                    changes.
144 |
145 |   Return Values :  Item finalization function address or NULL
146 +--------------------------------------------------------------------------*/
147 GEN_HOOK_GET_FUNCTION( item, term )
148 
149 /* m_hook.c ends here */
150