Debian Codegraph @

c++/cursesm.h

raw symbols SCIP
1 // * This makes emacs happy -*-Mode: C++;-*-cxx . . $ `<file>/c++/cursesm.h`/
2 /****************************************************************************
3 * Copyright 2019-2024,2025 Thomas E. Dickey *
4 * Copyright 1998-2012,2014 Free Software Foundation, Inc. *
5 * *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
13 * *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
16 * *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
28 * authorization. *
29 ****************************************************************************/
30
31 /****************************************************************************
32 * Author: Juergen Pfeifer, 1997 *
33 ****************************************************************************/
34
35 // $Id: cursesm.h,v 1.37 2025/01/25 21:20:17 tom Exp $
36
37 #ifndef NCURSES_CURSESM_H_incl
38 #define NCURSES_CURSESM_H_inclcxx . . $ `c++/cursesm.h:38:9`! 1
39
40 #include <cursesp.h>cxx . . $ `<file>/c++/cursesp.h`/
41
42 extern "C" {
43 # include <menu.h>cxx . . $ `<file>/include/menu.h`/
44 }
45 //
46 // -------------------------------------------------------------------------
47 // This wraps the ITEM type of <menu.h>
48 // -------------------------------------------------------------------------
49 //
50 class NCURSES_CXX_IMPEXPcxx . . $ `c++/etip.h:176:9`! NCursesMenuItemcxx . . $ NCursesMenuItem#
51 {
52 friend class NCursesMenucxx . . $ NCursesMenu#;
53
54 protected:
55 ITEM *itemcxx . . $ NCursesMenuItem#item.;
56
57 inline void OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (int err) const THROW2cxx . . $ `c++/etip.h:421:9`!(NCursesException const, NCursesMenuException) {
58 if (err != E_OKcxx . . $ `include/eti.h:39:9`!)
59 THROWcxx . . $ THROW(c282b3683bf58f81).(new NCursesMenuExceptioncxx . . $ NCursesMenuException# (err));
60 }
61
62 public:
63 NCursesMenuItemcxx . . $ NCursesMenuItem#NCursesMenuItem(2fa786934fe80e24). (const char* p_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!,
64 const char* p_descript = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
65 : itemcxx . . $ NCursesMenuItem#item.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
66 {
67 itemcxx . . $ NCursesMenuItem#item. = p_name ? ::new_item (p_name, p_descript) : STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(ITEM*)(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
68 if (p_name && !itemcxx . . $ NCursesMenuItem#item.)
69 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (E_SYSTEM_ERRORcxx . . $ `include/eti.h:40:9`!);
70 }
71 // Create an item. If you pass both parameters as NULL, a delimiting
72 // item is constructed which can be used to terminate a list of
73 // NCursesMenu objects.
74
75 NCursesMenuItemcxx . . $ NCursesMenuItem#& operatorcxx . . $ NCursesMenuItem#`operator=`(1b003b821905af81).=(const NCursesMenuItemcxx . . $ NCursesMenuItem#& rhs)
76 {
77 if (this != &rhs) {
78 *this =cxx . . $ NCursesMenuItem#`operator=`(1b003b821905af81). rhs;
79 }
80 return *this;
81 }
82
83 NCursesMenuItemcxx . . $ NCursesMenuItem#NCursesMenuItem(104064fb3e11391a).(const NCursesMenuItemcxx . . $ NCursesMenuItem#& rhs)
84 : itemcxx . . $ NCursesMenuItem#item.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
85 {
86 (void) rhs;
87 }
88
89 virtual ~cxx . . $ NCursesMenuItem#`~NCursesMenuItem`(ced63f7c635d850d).NCursesMenuItemcxx . . $ NCursesMenuItem# () THROWScxx . . $ `c++/etip.h:420:9`!(NCursesException);
90 // Release the items memory
91
92 inline const char* namecxx . . $ NCursesMenuItem#name(a9f41ea0e82d88cf). () const {
93 return ::item_name (itemcxx . . $ NCursesMenuItem#item.);
94 }
95 // Name of the item
96
97 inline const char* descriptioncxx . . $ NCursesMenuItem#description(a9f41ea0e82d88cf). () const {
98 return ::item_description (itemcxx . . $ NCursesMenuItem#item.);
99 }
100 // Description of the item
101
102 inline int (indexcxx . . $ NCursesMenuItem#index(455f465bc33b4cdf).) (void) const {
103 return ::item_index (itemcxx . . $ NCursesMenuItem#item.);
104 }
105 // Index of the item in an item array (or -1)
106
107 inline void options_oncxx . . $ NCursesMenuItem#options_on(d4f767463ce0a6b3). (Item_Options opts) {
108 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::item_opts_on (itemcxx . . $ NCursesMenuItem#item., opts));
109 }
110 // Switch on the items options
111
112 inline void options_offcxx . . $ NCursesMenuItem#options_off(d4f767463ce0a6b3). (Item_Options opts) {
113 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::item_opts_off (itemcxx . . $ NCursesMenuItem#item., opts));
114 }
115 // Switch off the item's option
116
117 inline Item_Options optionscxx . . $ NCursesMenuItem#options(455f465bc33b4cdf). () const {
118 return ::item_opts (itemcxx . . $ NCursesMenuItem#item.);
119 }
120 // Retrieve the items options
121
122 inline void set_optionscxx . . $ NCursesMenuItem#set_options(d4f767463ce0a6b3). (Item_Options opts) {
123 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::set_item_opts (itemcxx . . $ NCursesMenuItem#item., opts));
124 }
125 // Set the items options
126
127 inline void set_valuecxx . . $ NCursesMenuItem#set_value(b45ddcbc8423892c). (bool f) {
128 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::set_item_value (itemcxx . . $ NCursesMenuItem#item.,f));
129 }
130 // Set/Reset the items selection state
131
132 inline bool valuecxx . . $ NCursesMenuItem#value(50ce9a9e25b4a850). () const {
133 return ::item_value (itemcxx . . $ NCursesMenuItem#item.);
134 }
135 // Retrieve the items selection state
136
137 inline bool visiblecxx . . $ NCursesMenuItem#visible(50ce9a9e25b4a850). () const {
138 return ::item_visible (itemcxx . . $ NCursesMenuItem#item.);
139 }
140 // Retrieve visibility of the item
141
142 virtual bool actioncxx . . $ NCursesMenuItem#action(c9857a73d68e59ba).();
143 // Perform an action associated with this item; you may use this in an
144 // user supplied driver for a menu; you may derive from this class and
145 // overload action() to supply items with different actions.
146 // If an action returns true, the menu will be exited. The default action
147 // is to do nothing.
148 };
149
150 // Prototype for an items callback function.
151 typedef bool ITEMCALLBACKcxx . . $ ITEMCALLBACK#(NCursesMenuItemcxx . . $ NCursesMenuItem#&);
152
153 // If you don't like to create a child class for individual items to
154 // overload action(), you may use this class and provide a callback
155 // function pointer for items.
156 class NCURSES_CXX_IMPEXPcxx . . $ `c++/etip.h:176:9`! NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem# : public NCursesMenuItemcxx . . $ NCursesMenuItem#
157 {
158 private:
159 ITEMCALLBACKcxx . . $ ITEMCALLBACK#* p_fctcxx . . $ NCursesMenuCallbackItem#p_fct.;
160
161 public:
162 NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#NCursesMenuCallbackItem(d28cbbeca8c6c989).(ITEMCALLBACKcxx . . $ ITEMCALLBACK#* fct = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!,
163 const char* p_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!,
164 const char* p_descript = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`! )
165 : NCursesMenuItemcxx . . $ NCursesMenuItem#NCursesMenuItem(2fa786934fe80e24). (p_name, p_descript),
166 p_fctcxx . . $ NCursesMenuCallbackItem#p_fct. (fct) {
167 }
168
169 NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#& operatorcxx . . $ NCursesMenuCallbackItem#`operator=`(b649a794b2fe20a3).=(const NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#& rhs)
170 {
171 if (this != &rhs) {
172 *this =cxx . . $ NCursesMenuCallbackItem#`operator=`(b649a794b2fe20a3). rhs;
173 }
174 return *this;
175 }
176
177 NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#NCursesMenuCallbackItem(42b30918cc7a63ca).(const NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#& rhs)
178 : NCursesMenuItemcxx . . $ NCursesMenuItem#NCursesMenuItem(104064fb3e11391a).(rhs),
179 p_fctcxx . . $ NCursesMenuCallbackItem#p_fct.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
180 {
181 }
182
183 virtual ~cxx . . $ NCursesMenuCallbackItem#`~NCursesMenuCallbackItem`(ced63f7c635d850d).NCursesMenuCallbackItemcxx . . $ NCursesMenuCallbackItem#() THROWScxx . . $ `c++/etip.h:420:9`!(NCursesException);
184
185 bool actioncxx . . $ NCursesMenuCallbackItem#action(c9857a73d68e59ba).() NCURSES_OVERRIDEcxx . . $ `c++/etip.h:158:9`!;
186 };
187
188 // This are the built-in hook functions in this C++ binding. In C++ we use
189 // virtual member functions (see below On_..._Init and On_..._Termination)
190 // to provide this functionality in an object oriented manner.
191 extern "C" {
192 void _nc_xx_mnu_init(MENU *);
193 void _nc_xx_mnu_term(MENU *);
194 void _nc_xx_itm_init(MENU *);
195 void _nc_xx_itm_term(MENU *);
196 }
197
198 //
199 // -------------------------------------------------------------------------
200 // This wraps the MENU type of <menu.h>
201 // -------------------------------------------------------------------------
202 //
203 class NCURSES_CXX_IMPEXPcxx . . $ `c++/etip.h:176:9`! NCursesMenucxx . . $ NCursesMenu# : public NCursesPanelcxx . . $ NCursesPanel#
204 {
205 protected:
206 MENU *menucxx . . $ NCursesMenu#menu.;
207
208 private:
209 NCursesWindowcxx . . $ NCursesWindow#* subcxx . . $ NCursesMenu#sub.; // the subwindow object
210 bool b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.; // is this our own subwindow?
211 bool b_framedcxx . . $ NCursesMenu#b_framed.; // has the menu a border?
212 bool b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.; // Delete items when deleting menu?
213
214 NCursesMenuItemcxx . . $ NCursesMenuItem#** my_itemscxx . . $ NCursesMenu#my_items.; // The array of items for this menu
215
216 // This structure is used for the menu's user data field to link the
217 // MENU* to the C++ object and to provide extra space for a user pointer.
218 typedef structcxx . . $ NCursesMenu#$anonymous_type_0# {
219 void* m_usercxx . . $ NCursesMenu#$anonymous_type_0#m_user.; // the pointer for the user's data
220 const NCursesMenucxx . . $ NCursesMenu#* m_backcxx . . $ NCursesMenu#$anonymous_type_0#m_back.; // backward pointer to C++ object
221 const MENU* m_ownercxx . . $ NCursesMenu#$anonymous_type_0#m_owner.;
222 } UserHookcxx . . $ NCursesMenu#UserHook#;
223
224 // Get the backward pointer to the C++ object from a MENU
225 static inline NCursesMenucxx . . $ NCursesMenu#* getHookcxx . . $ NCursesMenu#getHook(1f94bb2806469d6c).(const MENU *m) {
226 UserHookcxx . . $ NCursesMenu#UserHook#* hook = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(UserHook*)(::menu_userptr(m));
227 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(hook != NULL && hook->m_owner==m);
228 return const_cast<NCursesMenucxx . . $ NCursesMenu#*>(hook->m_backcxx . . $ NCursesMenu#$anonymous_type_0#m_back.);
229 }
230
231 friend void _nc_xx_mnu_initcxx . . $ _nc_xx_mnu_init(4577cec95feb4376).(MENU *);
232 friend void _nc_xx_mnu_termcxx . . $ _nc_xx_mnu_term(4577cec95feb4376).(MENU *);
233 friend void _nc_xx_itm_initcxx . . $ _nc_xx_itm_init(4577cec95feb4376).(MENU *);
234 friend void _nc_xx_itm_termcxx . . $ _nc_xx_itm_term(4577cec95feb4376).(MENU *);
235
236 // Calculate ITEM* array for the menu
237 ITEM** mapItemscxx . . $ NCursesMenu#mapItems(a41f81167a030dc1).(NCursesMenuItemcxx . . $ NCursesMenuItem#* nitems[]);
238
239 protected:
240 // internal routines
241 inline void set_usercxx . . $ NCursesMenu#set_user(5d22bdacc48458e8).(void *user) {
242 UserHookcxx . . $ NCursesMenu#UserHook#* uptr = STATIC_CASTcxx . . $ NCursesMenu#UserHook#(UserHook*)(::menu_userptr (menucxx . . $ NCursesMenu#menu.));
243 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`! (uptr != NULL && uptr->m_back==this && uptr->m_owner==menu);
244 uptr->m_usercxx . . $ NCursesMenu#$anonymous_type_0#m_user. = user;
245 }
246
247 inline void *get_usercxx . . $ NCursesMenu#get_user(50c7df7de5344ebb).() {
248 const UserHookcxx . . $ NCursesMenu#UserHook#* uptr = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(UserHook*)(::menu_userptr (menucxx . . $ NCursesMenu#menu.));
249 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`! (uptr != NULL && uptr->m_back==this && uptr->m_owner==menu);
250 return uptr->m_usercxx . . $ NCursesMenu#$anonymous_type_0#m_user.;
251 }
252
253 void InitMenucxx . . $ NCursesMenu#InitMenu(e68b08efe43e2fdf). (NCursesMenuItemcxx . . $ NCursesMenuItem#* menu[],
254 bool with_frame,
255 bool autoDeleteItems);
256
257 inline void OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (int err) const THROW2cxx . . $ `c++/etip.h:421:9`!(NCursesException const, NCursesMenuException) {
258 if (err != E_OKcxx . . $ `include/eti.h:39:9`!)
259 THROWcxx . . $ THROW(c282b3683bf58f81).(new NCursesMenuExceptioncxx . . $ NCursesMenuException# (this, err));
260 }
261
262 // this wraps the menu_driver call.
263 virtual int drivercxx . . $ NCursesMenu#driver(7864480464b09eea). (int c) ;
264
265 // 'Internal' constructor to create a menu without association to
266 // an array of items.
267 NCursesMenucxx . . $ NCursesMenu#NCursesMenu(748afa4755bc9595).( int nlines,
268 int ncols,
269 int begin_y = 0,
270 int begin_x = 0)
271 : NCursesPanelcxx . . $ NCursesPanel#NCursesPanel(748afa4755bc9595).(nlines,ncols,begin_y,begin_x),
272 menucxx . . $ NCursesMenu#menu. (STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(MENU*)(0)),
273 subcxx . . $ NCursesMenu#sub.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
274 b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.(0),
275 b_framedcxx . . $ NCursesMenu#b_framed.(0),
276 b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.(0),
277 my_itemscxx . . $ NCursesMenu#my_items.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
278 {
279 }
280
281 public:
282 // Make a full window size menu
283 NCursesMenucxx . . $ NCursesMenu#NCursesMenu(e68b08efe43e2fdf). (NCursesMenuItemcxx . . $ NCursesMenuItem#* Items[],
284 bool with_frame=FALSEcxx . . $ `include/curses.h:288:9`!, // Reserve space for a frame?
285 bool autoDelete_Items=FALSEcxx . . $ `include/curses.h:288:9`!) // Autocleanup of Items?
286 : NCursesPanelcxx . . $ NCursesPanel#NCursesPanel(49f6e7a06ebc5aa8).(),
287 menucxx . . $ NCursesMenu#menu.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
288 subcxx . . $ NCursesMenu#sub.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
289 b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.(0),
290 b_framedcxx . . $ NCursesMenu#b_framed.(0),
291 b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.(0),
292 my_itemscxx . . $ NCursesMenu#my_items.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
293 {
294 InitMenucxx . . $ NCursesMenu#InitMenu(e68b08efe43e2fdf).(Items, with_frame, autoDelete_Items);
295 }
296
297 // Make a menu with a window of this size.
298 NCursesMenucxx . . $ NCursesMenu#NCursesMenu(2be1e865d1cd23e6). (NCursesMenuItemcxx . . $ NCursesMenuItem#* Items[],
299 int nlines,
300 int ncols,
301 int begin_y = 0,
302 int begin_x = 0,
303 bool with_frame=FALSEcxx . . $ `include/curses.h:288:9`!, // Reserve space for a frame?
304 bool autoDelete_Items=FALSEcxx . . $ `include/curses.h:288:9`!) // Autocleanup of Items?
305 : NCursesPanelcxx . . $ NCursesPanel#NCursesPanel(748afa4755bc9595).(nlines, ncols, begin_y, begin_x),
306 menucxx . . $ NCursesMenu#menu.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
307 subcxx . . $ NCursesMenu#sub.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
308 b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.(0),
309 b_framedcxx . . $ NCursesMenu#b_framed.(0),
310 b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.(0),
311 my_itemscxx . . $ NCursesMenu#my_items.(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
312 {
313 InitMenucxx . . $ NCursesMenu#InitMenu(e68b08efe43e2fdf).(Items, with_frame, autoDelete_Items);
314 }
315
316 NCursesMenucxx . . $ NCursesMenu#& operatorcxx . . $ NCursesMenu#`operator=`(65e23785da97c58d).=(const NCursesMenucxx . . $ NCursesMenu#& rhs)
317 {
318 if (this != &rhs) {
319 *this =cxx . . $ NCursesMenu#`operator=`(65e23785da97c58d). rhs;
320 NCursesPanelcxx . . $ NCursesPanel#::operator=(rhs);
321 }
322 return *this;
323 }
324
325 NCursesMenucxx . . $ NCursesMenu#NCursesMenu(ced45d1f9688542d).(const NCursesMenucxx . . $ NCursesMenu#& rhs)
326 : NCursesPanelcxx . . $ NCursesPanel#NCursesPanel(cbf3c2c176d808fd).(rhs),
327 menucxx . . $ NCursesMenu#menu.(rhs.menucxx . . $ NCursesMenu#menu.),
328 subcxx . . $ NCursesMenu#sub.(rhs.subcxx . . $ NCursesMenu#sub.),
329 b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.(rhs.b_sub_ownercxx . . $ NCursesMenu#b_sub_owner.),
330 b_framedcxx . . $ NCursesMenu#b_framed.(rhs.b_framedcxx . . $ NCursesMenu#b_framed.),
331 b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.(rhs.b_autoDeletecxx . . $ NCursesMenu#b_autoDelete.),
332 my_itemscxx . . $ NCursesMenu#my_items.(rhs.my_itemscxx . . $ NCursesMenu#my_items.)
333 {
334 }
335
336 virtual ~cxx . . $ NCursesMenu#`~NCursesMenu`(ced63f7c635d850d).NCursesMenucxx . . $ NCursesMenu# () THROWScxx . . $ `c++/etip.h:420:9`!(NCursesException);
337
338 // Retrieve the menus subwindow
339 inline NCursesWindowcxx . . $ NCursesWindow#& subWindowcxx . . $ NCursesMenu#subWindow(e9cd293dc051429b).() const {
340 assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(sub!=NULL);
341 return *subcxx . . $ NCursesMenu#sub.;
342 }
343
344 // Set the menus subwindow
345 void setSubWindowcxx . . $ NCursesMenu#setSubWindow(a83e5d064dac11d1).(NCursesWindowcxx . . $ NCursesWindow#& sub);
346
347 // Set these items for the menu
348 inline void setItemscxx . . $ NCursesMenu#setItems(8c01ea40d0d45f70).(NCursesMenuItemcxx . . $ NCursesMenuItem#* Items[]) {
349 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(::set_menu_items(menucxx . . $ NCursesMenu#menu.,mapItemscxx . . $ NCursesMenu#mapItems(a41f81167a030dc1).(Items)));
350 }
351
352 // Remove the menu from the screen
353 inline void unpostcxx . . $ NCursesMenu#unpost(49f6e7a06ebc5aa8). (void) {
354 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::unpost_menu (menucxx . . $ NCursesMenu#menu.));
355 }
356
357 // Post the menu to the screen if flag is true, unpost it otherwise
358 inline void postcxx . . $ NCursesMenu#post(b45ddcbc8423892c).(bool flag = TRUEcxx . . $ `include/curses.h:285:9`!) {
359 flag ? OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::post_menu(menucxx . . $ NCursesMenu#menu.)) : OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::unpost_menu (menucxx . . $ NCursesMenu#menu.));
360 }
361
362 // Get the number of rows and columns for this menu
363 inline void scalecxx . . $ NCursesMenu#scale(4bd75fe21bbdda99). (int& mrows, int& mcols) const {
364 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::scale_menu (menucxx . . $ NCursesMenu#menu., &mrows, &mcols));
365 }
366
367 // Set the format of this menu
368 inline void set_formatcxx . . $ NCursesMenu#set_format(3e454b8ccf442868).(int mrows, int mcols) {
369 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_menu_format(menucxx . . $ NCursesMenu#menu., mrows, mcols));
370 }
371
372 // Get the format of this menu
373 inline void menu_formatcxx . . $ NCursesMenu#menu_format(44820809252bebc4).(int& rows,int& ncols) {
374 ::menu_format(menucxx . . $ NCursesMenu#menu.,&rows,&ncols);
375 }
376
377 // Items of the menu
378 inline NCursesMenuItemcxx . . $ NCursesMenuItem#* itemscxx . . $ NCursesMenu#items(37d55ba5f7ebd8a9).() const {
379 return *my_itemscxx . . $ NCursesMenu#my_items.;
380 }
381
382 // Get the number of items in this menu
383 inline int countcxx . . $ NCursesMenu#count(455f465bc33b4cdf).() const {
384 return ::item_count(menucxx . . $ NCursesMenu#menu.);
385 }
386
387 // Get the current item (i.e. the one the cursor is located)
388 inline NCursesMenuItemcxx . . $ NCursesMenuItem#* current_itemcxx . . $ NCursesMenu#current_item(37d55ba5f7ebd8a9).() const {
389 return my_itemscxx . . $ NCursesMenu#my_items.[::item_index(::current_item(menucxx . . $ NCursesMenu#menu.))];
390 }
391
392 // Get the marker string
393 inline const char* markcxx . . $ NCursesMenu#mark(a9f41ea0e82d88cf).() const {
394 return ::menu_mark(menucxx . . $ NCursesMenu#menu.);
395 }
396
397 // Set the marker string
398 inline void set_markcxx . . $ NCursesMenu#set_mark(85c52e162fed56f9).(const char *marker) {
399 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_menu_mark (menucxx . . $ NCursesMenu#menu., marker));
400 }
401
402 // Get the name of the request code c
403 inline static const char* request_namecxx . . $ NCursesMenu#request_name(f7ae7e56280f18ae).(int c) {
404 return ::menu_request_name(c);
405 }
406
407 // Get the current pattern
408 inline char* patterncxx . . $ NCursesMenu#pattern(e7e5aa338b9d5147).() const {
409 return ::menu_pattern(menucxx . . $ NCursesMenu#menu.);
410 }
411
412 // true if there is a pattern match, false otherwise.
413 bool set_patterncxx . . $ NCursesMenu#set_pattern(c5f7da30cbc0f4e9). (const char *pat);
414
415 // set the default attributes for the menu
416 // i.e. set fore, back and grey attribute
417 virtual void setDefaultAttributescxx . . $ NCursesMenu#setDefaultAttributes(49f6e7a06ebc5aa8).();
418
419 // Get the menus background attributes
420 inline chtypecxx . . $ chtype# backcxx . . $ NCursesMenu#back(ddd8539a2fcdd4ce).() const {
421 return ::menu_back(menucxx . . $ NCursesMenu#menu.);
422 }
423
424 // Get the menus foreground attributes
425 inline chtypecxx . . $ chtype# forecxx . . $ NCursesMenu#fore(ddd8539a2fcdd4ce).() const {
426 return ::menu_fore(menucxx . . $ NCursesMenu#menu.);
427 }
428
429 // Get the menus grey attributes (used for unselectable items)
430 inline chtypecxx . . $ chtype# greycxx . . $ NCursesMenu#grey(ddd8539a2fcdd4ce).() const {
431 return ::menu_grey(menucxx . . $ NCursesMenu#menu.);
432 }
433
434 // Set the menus background attributes
435 inline chtypecxx . . $ chtype# set_backgroundcxx . . $ NCursesMenu#set_background(2141b656ce2cc063).(chtypecxx . . $ chtype# a) {
436 return ::set_menu_back(menucxx . . $ NCursesMenu#menu.,a);
437 }
438
439 // Set the menus foreground attributes
440 inline chtypecxx . . $ chtype# set_foregroundcxx . . $ NCursesMenu#set_foreground(2141b656ce2cc063).(chtypecxx . . $ chtype# a) {
441 return ::set_menu_fore(menucxx . . $ NCursesMenu#menu.,a);
442 }
443
444 // Set the menus grey attributes (used for unselectable items)
445 inline chtypecxx . . $ chtype# set_greycxx . . $ NCursesMenu#set_grey(2141b656ce2cc063).(chtypecxx . . $ chtype# a) {
446 return ::set_menu_grey(menucxx . . $ NCursesMenu#menu.,a);
447 }
448
449 inline void options_oncxx . . $ NCursesMenu#options_on(d4f767463ce0a6b3). (Menu_Options opts) {
450 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::menu_opts_on (menucxx . . $ NCursesMenu#menu.,opts));
451 }
452
453 inline void options_offcxx . . $ NCursesMenu#options_off(d4f767463ce0a6b3).(Menu_Options opts) {
454 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::menu_opts_off(menucxx . . $ NCursesMenu#menu.,opts));
455 }
456
457 inline Menu_Options optionscxx . . $ NCursesMenu#options(455f465bc33b4cdf).() const {
458 return ::menu_opts(menucxx . . $ NCursesMenu#menu.);
459 }
460
461 inline void set_optionscxx . . $ NCursesMenu#set_options(d4f767463ce0a6b3). (Menu_Options opts) {
462 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_menu_opts (menucxx . . $ NCursesMenu#menu.,opts));
463 }
464
465 inline int padcxx . . $ NCursesMenu#pad(455f465bc33b4cdf).() const {
466 return ::menu_pad(menucxx . . $ NCursesMenu#menu.);
467 }
468
469 inline void set_padcxx . . $ NCursesMenu#set_pad(d4f767463ce0a6b3). (int padch) {
470 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_menu_pad (menucxx . . $ NCursesMenu#menu., padch));
471 }
472
473 // Position the cursor to the current item
474 inline void position_cursorcxx . . $ NCursesMenu#position_cursor(83f5f38750778ac8). () const {
475 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::pos_menu_cursor (menucxx . . $ NCursesMenu#menu.));
476 }
477
478 // Set the current item
479 inline void set_currentcxx . . $ NCursesMenu#set_current(7fbba887765d6cf7).(NCursesMenuItemcxx . . $ NCursesMenuItem#& I) {
480 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_current_item(menucxx . . $ NCursesMenu#menu., I.itemcxx . . $ NCursesMenuItem#item.));
481 }
482
483 // Get the current top row of the menu
484 inline int top_rowcxx . . $ NCursesMenu#top_row(455f465bc33b4cdf). (void) const {
485 return ::top_row (menucxx . . $ NCursesMenu#menu.);
486 }
487
488 // Set the current top row of the menu
489 inline void set_top_rowcxx . . $ NCursesMenu#set_top_row(d4f767463ce0a6b3). (int row) {
490 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (::set_top_row (menucxx . . $ NCursesMenu#menu., row));
491 }
492
493 // spacing control
494 // Set the spacing for the menu
495 inline void setSpacingcxx . . $ NCursesMenu#setSpacing(b1146eedae1e1d0b).(int spc_description,
496 int spc_rows,
497 int spc_columns) {
498 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(::set_menu_spacing(menucxx . . $ NCursesMenu#menu.,
499 spc_description,
500 spc_rows,
501 spc_columns));
502 }
503
504 // Get the spacing info for the menu
505 inline void Spacingcxx . . $ NCursesMenu#Spacing(72edc360d45e293a).(int& spc_description,
506 int& spc_rows,
507 int& spc_columns) const {
508 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(::menu_spacing(menucxx . . $ NCursesMenu#menu.,
509 &spc_description,
510 &spc_rows,
511 &spc_columns));
512 }
513
514 // Decorations
515 inline void framecxx . . $ NCursesMenu#frame(2fa786934fe80e24).(const char *title=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, const char* btitle=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) NCURSES_OVERRIDEcxx . . $ `c++/etip.h:158:9`! {
516 if (b_framedcxx . . $ NCursesMenu#b_framed.)
517 NCursesPanelcxx . . $ NCursesPanel#::framecxx . . $ NCursesPanel#frame(2fa786934fe80e24).(title,btitle);
518 else
519 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(E_SYSTEM_ERRORcxx . . $ `include/eti.h:40:9`!);
520 }
521
522 inline void boldframecxx . . $ NCursesMenu#boldframe(2fa786934fe80e24).(const char *title=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, const char* btitle=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) NCURSES_OVERRIDEcxx . . $ `c++/etip.h:158:9`! {
523 if (b_framedcxx . . $ NCursesMenu#b_framed.)
524 NCursesPanelcxx . . $ NCursesPanel#::boldframecxx . . $ NCursesPanel#boldframe(2fa786934fe80e24).(title,btitle);
525 else
526 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(E_SYSTEM_ERRORcxx . . $ `include/eti.h:40:9`!);
527 }
528
529 inline void labelcxx . . $ NCursesMenu#label(2fa786934fe80e24).(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDEcxx . . $ `c++/etip.h:158:9`! {
530 if (b_framedcxx . . $ NCursesMenu#b_framed.)
531 NCursesPanelcxx . . $ NCursesPanel#::labelcxx . . $ NCursesPanel#label(2fa786934fe80e24).(topLabel,bottomLabel);
532 else
533 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1).(E_SYSTEM_ERRORcxx . . $ `include/eti.h:40:9`!);
534 }
535
536 // -----
537 // Hooks
538 // -----
539
540 // Called after the menu gets repositioned in its window.
541 // This is especially true if the menu is posted.
542 virtual void On_Menu_Initcxx . . $ NCursesMenu#On_Menu_Init(49f6e7a06ebc5aa8).();
543
544 // Called before the menu gets repositioned in its window.
545 // This is especially true if the menu is unposted.
546 virtual void On_Menu_Terminationcxx . . $ NCursesMenu#On_Menu_Termination(49f6e7a06ebc5aa8).();
547
548 // Called after the item became the current item
549 virtual void On_Item_Initcxx . . $ NCursesMenu#On_Item_Init(7fbba887765d6cf7).(NCursesMenuItemcxx . . $ NCursesMenuItem#& item);
550
551 // Called before this item is left as current item.
552 virtual void On_Item_Terminationcxx . . $ NCursesMenu#On_Item_Termination(7fbba887765d6cf7).(NCursesMenuItemcxx . . $ NCursesMenuItem#& item);
553
554 // Provide a default key virtualization. Translate the keyboard
555 // code c into a menu request code.
556 // The default implementation provides a hopefully straightforward
557 // mapping for the most common keystrokes and menu requests.
558 virtual int virtualizecxx . . $ NCursesMenu#virtualize(7864480464b09eea).(int c);
559
560
561 // Operators
562 inline NCursesMenuItemcxx . . $ NCursesMenuItem#* operatorcxx . . $ NCursesMenu#`operator[]`(8ac0610bad9787).[](int i) const {
563 if ( (i < 0) || (i >= ::item_count (menucxx . . $ NCursesMenu#menu.)) )
564 OnErrorcxx . . $ NCursesMenu#OnError(d76a70202c25db1). (E_BAD_ARGUMENTcxx . . $ `include/eti.h:41:9`!);
565 return (my_itemscxx . . $ NCursesMenu#my_items.[i]);
566 }
567
568 // Perform the menu's operation
569 // Return the item where you left the selection mark for a single
570 // selection menu, or NULL for a multivalued menu.
571 virtual NCursesMenuItemcxx . . $ NCursesMenuItem#* operatorcxx . . $ NCursesMenu#`operator()`(111fa535e0bd1492).()(void);
572
573 // --------------------
574 // Exception handlers
575 // Called by operator()
576 // --------------------
577
578 // Called if the request is denied
579 virtual void On_Request_Deniedcxx . . $ NCursesMenu#On_Request_Denied(d76a70202c25db1).(int c) const;
580
581 // Called if the item is not selectable
582 virtual void On_Not_Selectablecxx . . $ NCursesMenu#On_Not_Selectable(d76a70202c25db1).(int c) const;
583
584 // Called if pattern doesn't match
585 virtual void On_No_Matchcxx . . $ NCursesMenu#On_No_Match(d76a70202c25db1).(int c) const;
586
587 // Called if the command is unknown
588 virtual void On_Unknown_Commandcxx . . $ NCursesMenu#On_Unknown_Command(d76a70202c25db1).(int c) const;
589
590 };
591 //
592 // -------------------------------------------------------------------------
593 // This is the typical C++ typesafe way to allow to attach
594 // user data to an item of a menu. Its assumed that the user
595 // data belongs to some class T. Use T as template argument
596 // to create a UserItem.
597 // -------------------------------------------------------------------------
598 //
599 template<class T> class NCURSES_CXX_IMPEXPcxx . . $ `c++/etip.h:176:9`! NCursesUserItemcxx . . $ NCursesUserItem# : public NCursesMenuItemcxx . . $ NCursesMenuItem#
600 {
601 public:
602 NCursesUserItemcxx . . $ NCursesUserItem#`NCursesUserItem<T>`(2e4dc17a971acc36). (const char* p_name,
603 const char* p_descript = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!,
604 const T* p_UserData = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(T*)(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!))
605 : NCursesMenuItemcxx . . $ NCursesMenuItem# (p_name, p_descript) {
606 if (itemcxx . . $ NCursesMenuItem#item.)
607 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::set_item_userptr (itemcxx . . $ NCursesMenuItem#item., const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
608 }
609
610 virtual ~cxx . . $ NCursesUserItem#`~NCursesUserItem<T>`(49f6e7a06ebc5aa8).NCursesUserItem() THROWScxx . . $ `c++/etip.h:420:9`!(NCursesException) {}
611
612 inline const T* UserDatacxx . . $ NCursesUserItem#UserData(1016ee5406d91ab9). (void) const {
613 return reinterpret_cast<const T*>(::item_userptr (itemcxx . . $ NCursesMenuItem#item.));
614 };
615
616 inline virtual void setUserDatacxx . . $ NCursesUserItem#setUserData(88376428bb603c08).(const T* p_UserData) {
617 if (itemcxx . . $ NCursesMenuItem#item.)
618 OnErrorcxx . . $ NCursesMenuItem#OnError(d76a70202c25db1). (::set_item_userptr (itemcxx . . $ NCursesMenuItem#item., const_cast<void *>(reinterpret_cast<const void *>(p_UserData))));
619 }
620 };
621 //
622 // -------------------------------------------------------------------------
623 // The same mechanism is used to attach user data to a menu
624 // -------------------------------------------------------------------------
625 //
626 template<class T> class NCURSES_CXX_IMPEXPcxx . . $ `c++/etip.h:176:9`! NCursesUserMenucxx . . $ NCursesUserMenu# : public NCursesMenucxx . . $ NCursesMenu#
627 {
628 protected:
629 NCursesUserMenucxx . . $ NCursesUserMenu#`NCursesUserMenu<T>`(f71916de269ca4ba).( int nlines,
630 int ncols,
631 int begin_y = 0,
632 int begin_x = 0,
633 const T* p_UserData = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(T*)(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!))
634 : NCursesMenucxx . . $ NCursesMenu#(nlines,ncols,begin_y,begin_x) {
635 if (menucxx . . $ NCursesMenu#menu.)
636 set_usercxx . . $ NCursesMenu#set_user(5d22bdacc48458e8). (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
637 }
638
639 public:
640 NCursesUserMenucxx . . $ NCursesUserMenu#`NCursesUserMenu<T>`(43f567912d6dcea2). (NCursesMenuItemcxx . . $ NCursesMenuItem#* Items[],
641 const T* p_UserData = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(T*)(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
642 bool with_frame=FALSEcxx . . $ `include/curses.h:288:9`!,
643 bool autoDelete_Items=FALSEcxx . . $ `include/curses.h:288:9`!)
644 : NCursesMenucxx . . $ NCursesMenu# (Items, with_frame, autoDelete_Items) {
645 if (menucxx . . $ NCursesMenu#menu.)
646 set_usercxx . . $ NCursesMenu#set_user(5d22bdacc48458e8). (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
647 };
648
649 NCursesUserMenucxx . . $ NCursesUserMenu#`NCursesUserMenu<T>`(f4f1f8161813089a). (NCursesMenuItemcxx . . $ NCursesMenuItem#* Items[],
650 int nlines,
651 int ncols,
652 int begin_y = 0,
653 int begin_x = 0,
654 const T* p_UserData = STATIC_CASTcxx . . $ `c++/etip.h:170:9`!(T*)(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!),
655 bool with_frame=FALSEcxx . . $ `include/curses.h:288:9`!)
656 : NCursesMenucxx . . $ NCursesMenu# (Items, nlines, ncols, begin_y, begin_x, with_frame) {
657 if (menucxx . . $ NCursesMenu#menu.)
658 set_usercxx . . $ NCursesMenu#set_user(5d22bdacc48458e8). (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
659 };
660
661 virtual ~cxx . . $ NCursesUserMenu#`~NCursesUserMenu<T>`(49f6e7a06ebc5aa8).NCursesUserMenu() THROWScxx . . $ `c++/etip.h:420:9`!(NCursesException) {
662 };
663
664 inline T* UserDatacxx . . $ NCursesUserMenu#UserData(155dc7f103cdb9db). (void) {
665 return reinterpret_cast<T*>(get_usercxx . . $ NCursesMenu#get_user(50c7df7de5344ebb). ());
666 };
667
668 inline virtual void setUserDatacxx . . $ NCursesUserMenu#setUserData(88376428bb603c08). (const T* p_UserData) {
669 if (menucxx . . $ NCursesMenu#menu.)
670 set_usercxx . . $ NCursesMenu#set_user(5d22bdacc48458e8). (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
671 }
672 };
673
674 #endif /* NCURSES_CURSESM_H_incl */