150276Speter/**************************************************************************** 2262685Sdelphij * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 30166124Srafan * Author: Juergen Pfeifer, 1995,1997 * 3150276Speter ****************************************************************************/ 3250276Speter 3350276Speter/*************************************************************************** 3450276Speter* Module m_hook * 3550276Speter* Assign application specific routines for automatic invocation by menus * 3650276Speter***************************************************************************/ 3750276Speter 3850276Speter#include "menu.priv.h" 3950276Speter 40262685SdelphijMODULE_ID("$Id: m_hook.c,v 1.16 2012/03/10 23:43:41 tom Exp $") 4150276Speter 4250276Speter/* "Template" macro to generate function to set application specific hook */ 4350276Speter#define GEN_HOOK_SET_FUNCTION( typ, name ) \ 4476726SpeterNCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ 4550276Speter{\ 46262685Sdelphij T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), (void *) menu, func));\ 4750276Speter (Normalize_Menu(menu) -> typ ## name = func );\ 4850276Speter RETURN(E_OK);\ 4950276Speter} 5050276Speter 5150276Speter/* "Template" macro to generate function to get application specific hook */ 5250276Speter#define GEN_HOOK_GET_FUNCTION( typ, name ) \ 5376726SpeterNCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\ 5450276Speter{\ 55262629Sdelphij T((T_CALLED(#typ "_" #name "(%p)"), (const void *) menu));\ 56166124Srafan returnMenuHook(Normalize_Menu(menu) -> typ ## name);\ 5750276Speter} 5850276Speter 5950276Speter/*--------------------------------------------------------------------------- 6050276Speter| Facility : libnmenu 6150276Speter| Function : int set_menu_init(MENU *menu, void (*f)(MENU *)) 6250276Speter| 6350276Speter| Description : Set user-exit which is called when menu is posted 6450276Speter| or just after the top row changes. 6550276Speter| 6650276Speter| Return Values : E_OK - success 6750276Speter+--------------------------------------------------------------------------*/ 68166124SrafanGEN_HOOK_SET_FUNCTION(menu, init) 6950276Speter 7050276Speter/*--------------------------------------------------------------------------- 7150276Speter| Facility : libnmenu 7250276Speter| Function : void (*)(MENU *) menu_init(const MENU *menu) 7350276Speter| 7450276Speter| Description : Return address of user-exit function which is called 7550276Speter| when a menu is posted or just after the top row 7650276Speter| changes. 7750276Speter| 7850276Speter| Return Values : Menu init function address or NULL 7950276Speter+--------------------------------------------------------------------------*/ 80166124SrafanGEN_HOOK_GET_FUNCTION(menu, init) 8150276Speter 8250276Speter/*--------------------------------------------------------------------------- 8350276Speter| Facility : libnmenu 8450276Speter| Function : int set_menu_term (MENU *menu, void (*f)(MENU *)) 8550276Speter| 8650276Speter| Description : Set user-exit which is called when menu is unposted 8750276Speter| or just before the top row changes. 8850276Speter| 8950276Speter| Return Values : E_OK - success 9050276Speter+--------------------------------------------------------------------------*/ 91166124SrafanGEN_HOOK_SET_FUNCTION(menu, term) 9250276Speter 9350276Speter/*--------------------------------------------------------------------------- 9450276Speter| Facility : libnmenu 9550276Speter| Function : void (*)(MENU *) menu_term(const MENU *menu) 9650276Speter| 9750276Speter| Description : Return address of user-exit function which is called 9850276Speter| when a menu is unposted or just before the top row 9950276Speter| changes. 10050276Speter| 10150276Speter| Return Values : Menu finalization function address or NULL 10250276Speter+--------------------------------------------------------------------------*/ 103166124SrafanGEN_HOOK_GET_FUNCTION(menu, term) 10450276Speter 10550276Speter/*--------------------------------------------------------------------------- 10650276Speter| Facility : libnmenu 10750276Speter| Function : int set_item_init (MENU *menu, void (*f)(MENU *)) 10850276Speter| 10950276Speter| Description : Set user-exit which is called when menu is posted 11050276Speter| or just after the current item changes. 11150276Speter| 11250276Speter| Return Values : E_OK - success 11350276Speter+--------------------------------------------------------------------------*/ 114166124SrafanGEN_HOOK_SET_FUNCTION(item, init) 11550276Speter 11650276Speter/*--------------------------------------------------------------------------- 11750276Speter| Facility : libnmenu 11850276Speter| Function : void (*)(MENU *) item_init (const MENU *menu) 11950276Speter| 12050276Speter| Description : Return address of user-exit function which is called 12150276Speter| when a menu is posted or just after the current item 12250276Speter| changes. 12350276Speter| 12450276Speter| Return Values : Item init function address or NULL 12550276Speter+--------------------------------------------------------------------------*/ 126166124SrafanGEN_HOOK_GET_FUNCTION(item, init) 12750276Speter 12850276Speter/*--------------------------------------------------------------------------- 12950276Speter| Facility : libnmenu 13050276Speter| Function : int set_item_term (MENU *menu, void (*f)(MENU *)) 13150276Speter| 13250276Speter| Description : Set user-exit which is called when menu is unposted 13350276Speter| or just before the current item changes. 13450276Speter| 13550276Speter| Return Values : E_OK - success 13650276Speter+--------------------------------------------------------------------------*/ 137166124SrafanGEN_HOOK_SET_FUNCTION(item, term) 13850276Speter 13950276Speter/*--------------------------------------------------------------------------- 14050276Speter| Facility : libnmenu 14150276Speter| Function : void (*)(MENU *) item_init (const MENU *menu) 14250276Speter| 14350276Speter| Description : Return address of user-exit function which is called 14450276Speter| when a menu is unposted or just before the current item 14550276Speter| changes. 14650276Speter| 14750276Speter| Return Values : Item finalization function address or NULL 14850276Speter+--------------------------------------------------------------------------*/ 149166124SrafanGEN_HOOK_GET_FUNCTION(item, term) 15050276Speter 15150276Speter/* m_hook.c ends here */ 152