2 * --- T2-COPYRIGHT-NOTE-BEGIN ---
3 * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 * T2 SDE: misc/confdialog/msgbox.c
6 * Copyright (C) 2004 - 2005 The T2 SDE Project
7 * Copyright (C) 1998 - 2003 ROCK Linux Project
9 * More information can be found in the files COPYING and README.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; version 2 of the License. A copy of the
14 * GNU General Public License can be found in the file COPYING.
15 * --- T2-COPYRIGHT-NOTE-END ---
18 * msgbox.c -- implements the message box and info box
20 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
21 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com)
22 * MODIFIED FOR ROCK LINUX CONFIG BY: Clifford Wolf (clifford@clifford.at)
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * as published by the Free Software Foundation; either version 2
27 * of the License, or (at your option) any later version.
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
42 * Display a message box. Program will pause and display an "OK" button
43 * if the parameter 'pause' is non-zero.
46 dialog_msgbox (const char *title
, const char *prompt
, int height
, int width
,
52 /* center dialog box on screen */
53 x
= (COLS
- width
) / 2;
54 y
= (LINES
- height
) / 2;
56 draw_shadow (stdscr
, y
, x
, height
, width
);
58 dialog
= newwin (height
, width
, y
, x
);
59 keypad (dialog
, TRUE
);
61 draw_box (dialog
, 0, 0, height
, width
, dialog_attr
, border_attr
);
63 if (title
!= NULL
&& strlen(title
) >= width
-2 ) {
64 /* truncate long title -- mec */
65 char * title2
= malloc(width
-2+1);
66 memcpy( title2
, title
, width
-2 );
67 title2
[width
-2] = '\0';
72 wattrset (dialog
, title_attr
);
73 mvwaddch (dialog
, 0, (width
- strlen(title
))/2 - 1, ' ');
74 waddstr (dialog
, (char *)title
);
77 wattrset (dialog
, dialog_attr
);
78 print_autowrap (dialog
, prompt
, width
- 2, 1, 2);
81 wattrset (dialog
, border_attr
);
82 mvwaddch (dialog
, height
- 3, 0, ACS_LTEE
);
83 for (i
= 0; i
< width
- 2; i
++)
84 waddch (dialog
, ACS_HLINE
);
85 wattrset (dialog
, dialog_attr
);
86 waddch (dialog
, ACS_RTEE
);
88 print_button (dialog
, " Ok ",
89 height
- 2, width
/ 2 - 4, TRUE
);
92 while (key
!= ESC
&& key
!= '\n' && key
!= ' ' &&
93 key
!= 'O' && key
!= 'o' && key
!= 'X' && key
!= 'x')
94 key
= wgetch (dialog
);
101 return key
== ESC
? -1 : 0;