]> ncurses.scripts.mit.edu Git - ncurses.git/blob - menu/m_hook.c
ncurses 5.3
[ncurses.git] / menu / m_hook.c
1 /****************************************************************************
2  * Copyright (c) 1998,2000 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, 1995,1997                                    *
31  *   Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en             *
32  ****************************************************************************/
33
34 /***************************************************************************
35 * Module m_hook                                                            *
36 * Assign application specific routines for automatic invocation by menus   *
37 ***************************************************************************/
38
39 #include "menu.priv.h"
40
41 MODULE_ID("$Id: m_hook.c,v 1.10 2002/07/06 15:22:16 juergen Exp $")
42
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 )\
46 {\
47    (Normalize_Menu(menu) -> typ ## name = func );\
48    RETURN(E_OK);\
49 }
50
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 )\
54 {\
55    return (Normalize_Menu(menu) -> typ ## name);\
56 }
57
58 /*---------------------------------------------------------------------------
59 |   Facility      :  libnmenu  
60 |   Function      :  int set_menu_init(MENU *menu, void (*f)(MENU *))
61 |   
62 |   Description   :  Set user-exit which is called when menu is posted
63 |                    or just after the top row changes.
64 |
65 |   Return Values :  E_OK               - success
66 +--------------------------------------------------------------------------*/
67 GEN_HOOK_SET_FUNCTION( menu, init )               
68
69 /*---------------------------------------------------------------------------
70 |   Facility      :  libnmenu  
71 |   Function      :  void (*)(MENU *) menu_init(const MENU *menu)
72 |   
73 |   Description   :  Return address of user-exit function which is called
74 |                    when a menu is posted or just after the top row 
75 |                    changes.
76 |
77 |   Return Values :  Menu init function address or NULL
78 +--------------------------------------------------------------------------*/
79 GEN_HOOK_GET_FUNCTION( menu, init )
80
81 /*---------------------------------------------------------------------------
82 |   Facility      :  libnmenu  
83 |   Function      :  int set_menu_term (MENU *menu, void (*f)(MENU *))
84 |   
85 |   Description   :  Set user-exit which is called when menu is unposted
86 |                    or just before the top row changes.
87 |
88 |   Return Values :  E_OK               - success
89 +--------------------------------------------------------------------------*/
90 GEN_HOOK_SET_FUNCTION( menu, term )               
91
92 /*---------------------------------------------------------------------------
93 |   Facility      :  libnmenu  
94 |   Function      :  void (*)(MENU *) menu_term(const MENU *menu)
95 |   
96 |   Description   :  Return address of user-exit function which is called
97 |                    when a menu is unposted or just before the top row 
98 |                    changes.
99 |
100 |   Return Values :  Menu finalization function address or NULL
101 +--------------------------------------------------------------------------*/
102 GEN_HOOK_GET_FUNCTION( menu, term )
103
104 /*---------------------------------------------------------------------------
105 |   Facility      :  libnmenu  
106 |   Function      :  int set_item_init (MENU *menu, void (*f)(MENU *))
107 |   
108 |   Description   :  Set user-exit which is called when menu is posted
109 |                    or just after the current item changes.
110 |
111 |   Return Values :  E_OK               - success
112 +--------------------------------------------------------------------------*/
113 GEN_HOOK_SET_FUNCTION( item, init )               
114
115 /*---------------------------------------------------------------------------
116 |   Facility      :  libnmenu  
117 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
118 |   
119 |   Description   :  Return address of user-exit function which is called
120 |                    when a menu is posted or just after the current item 
121 |                    changes.
122 |
123 |   Return Values :  Item init function address or NULL
124 +--------------------------------------------------------------------------*/
125 GEN_HOOK_GET_FUNCTION( item, init )
126
127 /*---------------------------------------------------------------------------
128 |   Facility      :  libnmenu  
129 |   Function      :  int set_item_term (MENU *menu, void (*f)(MENU *))
130 |   
131 |   Description   :  Set user-exit which is called when menu is unposted
132 |                    or just before the current item changes.
133 |
134 |   Return Values :  E_OK               - success
135 +--------------------------------------------------------------------------*/
136 GEN_HOOK_SET_FUNCTION( item, term )               
137
138 /*---------------------------------------------------------------------------
139 |   Facility      :  libnmenu  
140 |   Function      :  void (*)(MENU *) item_init (const MENU *menu)
141 |   
142 |   Description   :  Return address of user-exit function which is called
143 |                    when a menu is unposted or just before the current item 
144 |                    changes.
145 |
146 |   Return Values :  Item finalization function address or NULL
147 +--------------------------------------------------------------------------*/
148 GEN_HOOK_GET_FUNCTION( item, term )
149
150 /* m_hook.c ends here */