home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LZSET10S.RAR / LZS_ASK.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  2.6 KB  |  108 lines

  1. /*
  2.  * This file is part of LZSETUP (Configuration program for Listerz)
  3.  *
  4.  * Copyright (c) 1997 Branislav L. Slantchev (gargoyle)
  5.  * A fine product of Silicon Creations, Inc.
  6.  *
  7.  * This file is released under the terms and conditions of the GNU
  8.  * General Public License Version 2. The full text of the license is
  9.  * supplied in the Copying.Doc file included with this archive. This
  10.  * free software comes with absolutely no warranty, as outlined in the
  11.  * licensing text. You are not allowed to remove this copyright notice.
  12.  *
  13.  * Contact: Branislav L. Slantchev at 73023.262@compuserve.com
  14. */
  15. #ifndef INCLUDED_OPWINDOW_H
  16. #define INCLUDED_OPWINDOW_H
  17. #include <opwindow.h>
  18. #endif
  19.  
  20. #ifndef INCLUDED_OPINLINE_H
  21. #define INCLUDED_OPINLINE_H
  22. #include <opinline.h>
  23. #endif
  24.  
  25. #ifndef INCLUDED_OPCRT_H
  26. #define INCLUDED_OPCRT_H
  27. #include <opcrt.h>
  28. #endif
  29.  
  30. #ifndef INCLUDED_OPSEDIT_H
  31. #define INCLUDED_OPSEDIT_H
  32. #include <opsedit.h>
  33. #endif
  34.  
  35. #ifndef INCLUDED_STRING_H
  36. #define INCLUDED_STRING_H
  37. #include <string.h>
  38. #endif
  39.  
  40. #ifndef INCLUDED_STDIO_H
  41. #define INCLUDED_STDIO_H
  42. #include <stdio.h>
  43. #endif
  44.  
  45. extern FrameArray lz_FrameType;
  46.  
  47. boolean
  48. MsgAsk( char *aHeader, char *aText, boolean *escaped,
  49.         ColorSet &colors, boolean Default = TRUE )
  50. {
  51.     byte        right, left, row;
  52.     boolean     retval  = FALSE;
  53.     size_t      width   = MaxWord(strlen(aHeader), strlen(aText)) + 8;
  54.     long        options = wBordered+wClear+wUserContents+wCoversOnDemand;
  55.     CursorType  cursor;
  56.     char        text[255], header[255], response[4];
  57.     StackWindow Popup;
  58.  
  59.     *escaped = TRUE;
  60.  
  61.     strcpy(response, "y/n");
  62.     if( Default ) response[0] = 'Y';
  63.     else response[2] = 'N';
  64.  
  65.     sprintf(header, " %s ", aHeader);
  66.     sprintf(text, " %s (%s) ", aText, response);
  67.  
  68.     left  = (ScreenWidth - width) / 2 + 1;
  69.     right = left + width - 1;
  70.     row   = ScreenHeight / 2 - 1;
  71.  
  72.     if( Popup.InitCustom(left, row, right, row + 2, colors, options) )
  73.     {
  74.         boolean done = FALSE;
  75.  
  76.         cursor = ClassifyCursorType();
  77.         Popup.wFrame.SetFrameType(lz_FrameType);
  78.         Popup.wFrame.AddHeader(header, heTR);
  79.         Popup.wFrame.AddShadow(shBR, shSeeThru);
  80.         Popup.EnableExplosions(15);
  81.         Popup.Draw();
  82.         HiddenCursor();
  83.         Popup.wFastWrite(text, 2, 1, colors.TextColor);
  84.         *escaped = FALSE;
  85.  
  86.         for( ; !done; )
  87.         {
  88.             done = TRUE;
  89.  
  90.             switch( Upcase(Lo(SimpEditCommands.cpGetKey())) )
  91.             {
  92.                 case 13 : retval = Default; break;
  93.                 case 27 : *escaped = TRUE; break;
  94.                 case 'Y': retval = TRUE; break;
  95.                 case 'N': retval = FALSE; break;
  96.                 default : done = FALSE;
  97.             }
  98.         }
  99.  
  100.         SetCursorType(cursor);
  101.         Popup.Erase();
  102.         Popup.Done();
  103.     }
  104.  
  105. FunctionExit:
  106.     return retval;
  107. }
  108.