home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / a / hdsetup / dialog-0.4-1 / dialog-0 / dialog-0.4-slackware / src / msgbox.c-3d < prev    next >
Encoding:
Text File  |  1994-06-09  |  2.3 KB  |  82 lines

  1. /*
  2.  *  msgbox.c -- implements the message box and info box
  3.  *
  4.  *  AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
  5.  *
  6.  *  This program is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU General Public License
  8.  *  as published by the Free Software Foundation; either version 2
  9.  *  of the License, or (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21.  
  22. #include "dialog.h"
  23.  
  24.  
  25. /*
  26.  * Display a message box. Program will pause and display an "OK" button
  27.  * if the parameter 'pause' is non-zero.
  28.  */
  29. int dialog_msgbox(unsigned char *title, unsigned char *prompt, int height, int width, int pause)
  30. {
  31.   int i, x, y, key = 0;
  32.   WINDOW *dialog;
  33.  
  34.   /* center dialog box on screen */
  35.   x = (COLS - width)/2;
  36.   y = (LINES - height)/2;
  37.  
  38. #ifdef HAVE_NCURSES
  39.   if (use_shadow)
  40.     draw_shadow(stdscr, y, x, height, width);
  41. #endif
  42.   dialog = newwin(height, width, y, x);
  43.   keypad(dialog, TRUE);
  44.  
  45.   draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
  46.  
  47.   if (title != NULL) {
  48.     wattrset(dialog, title_attr);
  49.     wmove(dialog, 0, (width - strlen(title))/2 - 1);
  50.     waddch(dialog, ' ');
  51.     waddstr(dialog, title);
  52.     waddch(dialog, ' ');
  53.   }
  54.   wattrset(dialog, dialog_attr);
  55.   print_autowrap(dialog, prompt, width-2, 1, 2);
  56.  
  57.   if (pause) {
  58.     wattrset(dialog, border_attr);
  59.     wmove(dialog, height-3, 0);
  60.     waddch(dialog, ACS_LTEE);
  61.     for (i = 0; i < width-2; i++)
  62.       waddch(dialog, ACS_HLINE);
  63.     wattrset(dialog, dialog_attr);
  64.     waddch(dialog, ACS_RTEE);
  65.     wmove(dialog, height-2, 1);
  66.     for (i = 0; i < width-2; i++)
  67.     waddch(dialog, ' ');
  68.     print_button(dialog, "  OK  ", height-2, width/2-4, TRUE);
  69.     wrefresh(dialog);
  70.     while (key != ESC && key != '\n' && key != ' ')
  71.       key = wgetch(dialog);
  72.   }
  73.   else {
  74.     key = '\n';
  75.     wrefresh(dialog);
  76.   }
  77.  
  78.   delwin(dialog);
  79.   return (key == ESC ? -1 : 0);
  80. }
  81. /* End of dialog_msgbox() */
  82.