1 /* $NetBSD: post.c,v 1.11 2003/03/09 01:08:48 lukem Exp $ */
4 * Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __RCSID("$NetBSD: post.c,v 1.11 2003/03/09 01:08:48 lukem Exp $");
34 #include "internals.h"
37 * Post the menu to the screen. Call any defined init routines and then
38 * draw the menu on the screen.
46 return E_BAD_ARGUMENT
;
47 if (menu
->posted
== 1)
49 if (menu
->in_init
== 1)
51 if (menu
->items
== NULL
)
52 return E_NOT_CONNECTED
;
53 if (*menu
->items
== NULL
)
54 return E_NOT_CONNECTED
;
58 if (menu
->menu_init
!= NULL
)
59 menu
->menu_init(menu
);
60 if (menu
->item_init
!= NULL
)
61 menu
->item_init(menu
);
65 getmaxyx(menu
->scrwin
, maxy
, maxx
);
66 if ((maxx
== ERR
) || (maxy
== ERR
)) return E_SYSTEM_ERROR
;
68 if ((menu
->cols
* menu
->max_item_width
+ menu
->cols
- 1) > maxx
)
71 if ((menu
->opts
& O_RADIO
) != O_RADIO
) {
72 for (i
= 0; i
< menu
->item_count
; i
++) {
73 menu
->items
[i
]->selected
= 0;
78 return _menui_draw_menu(menu
);
83 * Unpost the menu. Call any defined termination routines and remove the
84 * menu from the screen.
87 unpost_menu(MENU
*menu
)
90 return E_BAD_ARGUMENT
;
91 if (menu
->posted
!= 1)
93 if (menu
->in_init
== 1)
95 if (menu
->item_term
!= NULL
)
96 menu
->item_term(menu
);
98 if (menu
->menu_term
!= NULL
)
99 menu
->menu_term(menu
);
102 werase(menu
->scrwin
);
103 wrefresh(menu
->scrwin
);