1 2 /*************************************************************************** 3 * COPYRIGHT NOTICE * 4 **************************************************************************** 5 * ncurses is copyright (C) 1992-1995 * 6 * Zeyd M. Ben-Halim * 7 * zmbenhal@netcom.com * 8 * Eric S. Raymond * 9 * esr@snark.thyrsus.com * 10 * * 11 * Permission is hereby granted to reproduce and distribute ncurses * 12 * by any means and for any fee, whether alone or as part of a * 13 * larger distribution, in source or in binary form, PROVIDED * 14 * this notice is included with any such distribution, and is not * 15 * removed from any of its header files. Mention of ncurses in any * 16 * applications linked with it is highly appreciated. * 17 * * 18 * ncurses comes AS IS with no warranty, implied or expressed. * 19 * * 20 ***************************************************************************/ 21 22 /*************************************************************************** 23 * Module menu_hook * 24 * Assign application specific routines for automatic invocation by menus * 25 ***************************************************************************/ 26 27 #include "menu.priv.h" 28 29 /* "Template" macro to generate function to set application specific hook */ 30 #define GEN_HOOK_SET_FUNCTION( typ, name ) \ 31 int set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ 32 {\ 33 (Normalize_Menu(menu) -> typ ## name = func );\ 34 RETURN(E_OK);\ 35 } 36 37 /* "Template" macro to generate function to get application specific hook */ 38 #define GEN_HOOK_GET_FUNCTION( typ, name ) \ 39 Menu_Hook typ ## _ ## name ( const MENU *menu )\ 40 {\ 41 return (Normalize_Menu(menu) -> typ ## name);\ 42 } 43 44 /*--------------------------------------------------------------------------- 45 | Facility : libnmenu 46 | Function : int set_menu_init(MENU *menu, void (*f)(MENU *)) 47 | 48 | Description : Set user-exit which is called when menu is posted 49 | or just after the top row changes. 50 | 51 | Return Values : E_OK - success 52 +--------------------------------------------------------------------------*/ 53 GEN_HOOK_SET_FUNCTION( menu, init ) 54 55 /*--------------------------------------------------------------------------- 56 | Facility : libnmenu 57 | Function : void (*)(MENU *) menu_init(const MENU *menu) 58 | 59 | Description : Return address of user-exit function which is called 60 | when a menu is posted or just after the top row 61 | changes. 62 | 63 | Return Values : Menu init function address or NULL 64 +--------------------------------------------------------------------------*/ 65 GEN_HOOK_GET_FUNCTION( menu, init ) 66 67 /*--------------------------------------------------------------------------- 68 | Facility : libnmenu 69 | Function : int set_menu_term (MENU *menu, void (*f)(MENU *)) 70 | 71 | Description : Set user-exit which is called when menu is unposted 72 | or just before the top row changes. 73 | 74 | Return Values : E_OK - success 75 +--------------------------------------------------------------------------*/ 76 GEN_HOOK_SET_FUNCTION( menu, term ) 77 78 /*--------------------------------------------------------------------------- 79 | Facility : libnmenu 80 | Function : void (*)(MENU *) menu_term(const MENU *menu) 81 | 82 | Description : Return address of user-exit function which is called 83 | when a menu is unposted or just before the top row 84 | changes. 85 | 86 | Return Values : Menu finalization function address or NULL 87 +--------------------------------------------------------------------------*/ 88 GEN_HOOK_GET_FUNCTION( menu, term ) 89 90 /*--------------------------------------------------------------------------- 91 | Facility : libnmenu 92 | Function : int set_item_init (MENU *menu, void (*f)(MENU *)) 93 | 94 | Description : Set user-exit which is called when menu is posted 95 | or just after the current item changes. 96 | 97 | Return Values : E_OK - success 98 +--------------------------------------------------------------------------*/ 99 GEN_HOOK_SET_FUNCTION( item, init ) 100 101 /*--------------------------------------------------------------------------- 102 | Facility : libnmenu 103 | Function : void (*)(MENU *) item_init (const MENU *menu) 104 | 105 | Description : Return address of user-exit function which is called 106 | when a menu is posted or just after the current item 107 | changes. 108 | 109 | Return Values : Item init function address or NULL 110 +--------------------------------------------------------------------------*/ 111 GEN_HOOK_GET_FUNCTION( item, init ) 112 113 /*--------------------------------------------------------------------------- 114 | Facility : libnmenu 115 | Function : int set_item_term (MENU *menu, void (*f)(MENU *)) 116 | 117 | Description : Set user-exit which is called when menu is unposted 118 | or just before the current item changes. 119 | 120 | Return Values : E_OK - success 121 +--------------------------------------------------------------------------*/ 122 GEN_HOOK_SET_FUNCTION( item, term ) 123 124 /*--------------------------------------------------------------------------- 125 | Facility : libnmenu 126 | Function : void (*)(MENU *) item_init (const MENU *menu) 127 | 128 | Description : Return address of user-exit function which is called 129 | when a menu is unposted or just before the current item 130 | changes. 131 | 132 | Return Values : Item finalization function address or NULL 133 +--------------------------------------------------------------------------*/ 134 GEN_HOOK_GET_FUNCTION( item, term ) 135 136 /* m_hook.c ends here */ 137