home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / listz21s.exe / LZSET10S.RAR / LZS_MBOX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  2.2 KB  |  80 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. #include <opcrt.h>
  16. #include <opwindow.h>
  17. #include <opinline.h>
  18. #include <opsedit.h>
  19. #include <string.h>
  20. #include "str.h"
  21.  
  22. extern FrameArray lz_FrameType;
  23.  
  24. // display text in a messagebox. 'text' can contain '\r' characters which
  25. // will split it in separate lines
  26. void
  27. MsgBox(char *header, char *text, ColorSet &colors)
  28. {
  29.     RawWindow   dlg;
  30.     byte        left, right, top, bottom;
  31.     size_t      width, nlines;
  32.     long        options = wBordered | wClear | wUserContents;
  33.     char       *p, buf[255], center[255];
  34.     CursorType  cursor = ClassifyCursorType();
  35.  
  36.     // get the maximum width required
  37.     strcpy(buf, text);
  38.     nlines = 0;
  39.     width = strlen(header) + 2;
  40.     for( p = strtok(buf, "\r"); p; p = strtok(NULL, "\r") )
  41.     {
  42.         width = MaxWord(width, strlen(p));
  43.         nlines++;
  44.     }
  45.  
  46.     nlines += 2;  // leave 2 lines on top and bottom of message
  47.     left    = (ScreenWidth - width) / 2;
  48.     right   = left + width + 2;
  49.     top     = (ScreenHeight - nlines) / 2;
  50.     bottom  = top + nlines - 1;
  51.  
  52.     if( dlg.InitCustom(left, top, right, bottom, colors, options) )
  53.     {
  54.         dlg.wFrame.SetFrameType(lz_FrameType);
  55.         dlg.wFrame.AddHeader(header, heTR);
  56.         dlg.wFrame.AddShadow(shBR, shSeeThru);
  57.         dlg.EnableExplosions(15);
  58.         dlg.Draw();
  59.         HiddenCursor();
  60.  
  61.         strcpy(buf, text);
  62.         top = 2;
  63.         for( p = strtok(buf, "\r"); p; p = strtok(NULL, "\r") )
  64.         {
  65.             dlg.wFastCenter(p, top++, colors.TextColor);
  66.         }
  67.  
  68.         for( ;; )
  69.         {
  70.             char ch = Upcase( Lo(SimpEditCommands.cpGetKey()) );
  71.  
  72.             if( ' ' == ch || 27 == ch || 13 == ch ) break;
  73.         }
  74.  
  75.         dlg.Erase();
  76.         dlg.Done();
  77.         SetCursorType(cursor);
  78.     }
  79. }
  80.