1 /****************************************************************************
2 * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
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: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
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. *
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 *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Juergen Pfeifer, 1995,1997 *
31 * Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en *
32 ****************************************************************************/
34 /***************************************************************************
36 * Assign application specific routines for automatic invocation by menus *
37 ***************************************************************************/
39 #include "menu.priv.h"
41 MODULE_ID("$Id: m_hook.c,v 1.10 2002/07/06 15:22:16 juergen Exp $")
43 /* "Template" macro to generate function to set application specific hook */
44 #define GEN_HOOK_SET_FUNCTION( typ, name ) \
45 NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
47 (Normalize_Menu(menu) -> typ ## name = func );\
51 /* "Template" macro to generate function to get application specific hook */
52 #define GEN_HOOK_GET_FUNCTION( typ, name ) \
53 NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
55 return (Normalize_Menu(menu) -> typ ## name);\
58 /*---------------------------------------------------------------------------
60 | Function : int set_menu_init(MENU *menu, void (*f)(MENU *))
62 | Description : Set user-exit which is called when menu is posted
63 | or just after the top row changes.
65 | Return Values : E_OK - success
66 +--------------------------------------------------------------------------*/
67 GEN_HOOK_SET_FUNCTION( menu, init )
69 /*---------------------------------------------------------------------------
71 | Function : void (*)(MENU *) menu_init(const MENU *menu)
73 | Description : Return address of user-exit function which is called
74 | when a menu is posted or just after the top row
77 | Return Values : Menu init function address or NULL
78 +--------------------------------------------------------------------------*/
79 GEN_HOOK_GET_FUNCTION( menu, init )
81 /*---------------------------------------------------------------------------
83 | Function : int set_menu_term (MENU *menu, void (*f)(MENU *))
85 | Description : Set user-exit which is called when menu is unposted
86 | or just before the top row changes.
88 | Return Values : E_OK - success
89 +--------------------------------------------------------------------------*/
90 GEN_HOOK_SET_FUNCTION( menu, term )
92 /*---------------------------------------------------------------------------
94 | Function : void (*)(MENU *) menu_term(const MENU *menu)
96 | Description : Return address of user-exit function which is called
97 | when a menu is unposted or just before the top row
100 | Return Values : Menu finalization function address or NULL
101 +--------------------------------------------------------------------------*/
102 GEN_HOOK_GET_FUNCTION( menu, term )
104 /*---------------------------------------------------------------------------
105 | Facility : libnmenu
106 | Function : int set_item_init (MENU *menu, void (*f)(MENU *))
108 | Description : Set user-exit which is called when menu is posted
109 | or just after the current item changes.
111 | Return Values : E_OK - success
112 +--------------------------------------------------------------------------*/
113 GEN_HOOK_SET_FUNCTION( item, init )
115 /*---------------------------------------------------------------------------
116 | Facility : libnmenu
117 | Function : void (*)(MENU *) item_init (const MENU *menu)
119 | Description : Return address of user-exit function which is called
120 | when a menu is posted or just after the current item
123 | Return Values : Item init function address or NULL
124 +--------------------------------------------------------------------------*/
125 GEN_HOOK_GET_FUNCTION( item, init )
127 /*---------------------------------------------------------------------------
128 | Facility : libnmenu
129 | Function : int set_item_term (MENU *menu, void (*f)(MENU *))
131 | Description : Set user-exit which is called when menu is unposted
132 | or just before the current item changes.
134 | Return Values : E_OK - success
135 +--------------------------------------------------------------------------*/
136 GEN_HOOK_SET_FUNCTION( item, term )
138 /*---------------------------------------------------------------------------
139 | Facility : libnmenu
140 | Function : void (*)(MENU *) item_init (const MENU *menu)
142 | Description : Return address of user-exit function which is called
143 | when a menu is unposted or just before the current item
146 | Return Values : Item finalization function address or NULL
147 +--------------------------------------------------------------------------*/
148 GEN_HOOK_GET_FUNCTION( item, term )
150 /* m_hook.c ends here */