base/config/kconfig/lxdialog/msgbox.c

Go to the documentation of this file.
00001 /* 00002 * msgbox.c -- implements the message box and info box 00003 * 00004 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 00005 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #include "dialog.h" 00023 00024 /* 00025 * Display a message box. Program will pause and display an "OK" button 00026 * if the parameter 'pause' is non-zero. 00027 */ 00028 int 00029 dialog_msgbox (const char *title, const char *prompt, int height, int width, 00030 int pause) 00031 { 00032 int i, x, y, key = 0; 00033 WINDOW *dialog; 00034 00035 /* center dialog box on screen */ 00036 x = (COLS - width) / 2; 00037 y = (LINES - height) / 2; 00038 00039 draw_shadow (stdscr, y, x, height, width); 00040 00041 dialog = newwin (height, width, y, x); 00042 keypad (dialog, TRUE); 00043 00044 draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); 00045 00046 if (title != NULL && strlen(title) >= width-2 ) { 00047 /* truncate long title -- mec */ 00048 char * title2 = malloc(width-2+1); 00049 memcpy( title2, title, width-2 ); 00050 title2[width-2] = '\0'; 00051 title = title2; 00052 } 00053 00054 if (title != NULL) { 00055 wattrset (dialog, title_attr); 00056 mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); 00057 waddstr (dialog, (char *)title); 00058 waddch (dialog, ' '); 00059 } 00060 wattrset (dialog, dialog_attr); 00061 print_autowrap (dialog, prompt, width - 2, 1, 2); 00062 00063 if (pause) { 00064 wattrset (dialog, border_attr); 00065 mvwaddch (dialog, height - 3, 0, ACS_LTEE); 00066 for (i = 0; i < width - 2; i++) 00067 waddch (dialog, ACS_HLINE); 00068 wattrset (dialog, dialog_attr); 00069 waddch (dialog, ACS_RTEE); 00070 00071 print_button (dialog, " Ok ", 00072 height - 2, width / 2 - 4, TRUE); 00073 00074 wrefresh (dialog); 00075 while (key != ESC && key != '\n' && key != ' ' && 00076 key != 'O' && key != 'o' && key != 'X' && key != 'x') 00077 key = wgetch (dialog); 00078 } else { 00079 key = '\n'; 00080 wrefresh (dialog); 00081 } 00082 00083 delwin (dialog); 00084 return key == ESC ? -1 : 0; 00085 }

Generated on Thu Nov 20 11:49:48 2008 for RTAI API by doxygen 1.3.8