home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 18 / CD_ASCQ_18_111294_W.iso / dos / prg / c / x_lib10 / xw_msg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-20  |  973 b   |  59 lines

  1. #include    "xw.h"
  2.  
  3. /*-----
  4. */
  5.  
  6. #include    "xk.h"
  7. #include    "xo.h"
  8. #include    "xx.h"
  9.  
  10. /*-----
  11.     XWinMgr::msg
  12.     affiche une boite de message
  13. */
  14.  
  15. class    MsgWin : public XWin
  16.         {
  17.     public :
  18.         MsgWin (int wdt, int hgh, const char *hdr, const char *msg);
  19.         };
  20.  
  21. MsgWin::MsgWin (int wdt, int hgh, const char *hdr, const char *msg)
  22.  
  23.         : XWin(wdt + 8, hgh + 6)
  24.  
  25.         {
  26.         XText *    obj;
  27.  
  28.         if (hdr == 0)
  29.             defw(xw_STDWIN & ~xw_HEADER);
  30.         else
  31.             head(hdr);
  32.  
  33.         link(new XBox(1, 1, 1, wdt + 4, hgh + 2, 0, 1));
  34.         obj = (XText *)link(new XText(2, 2, 3, wdt, hgh, 0, 0));
  35.         obj->defs(0, msg);
  36.         }
  37.  
  38. XWin *    XWinMgr::msg (const char *hdr, const char *msg)
  39.         {
  40.         int            wdt, hgh;
  41.         MsgWin *    win;
  42.  
  43.         if ((wdt = _smax(msg, '\n') + 2) > 70)
  44.             wdt = 70;
  45.         else if (wdt < 26)
  46.             wdt = 26;
  47.  
  48.         if ((hgh = _scnt(msg, '\n') + 2) > 20)
  49.             hgh = 20;
  50.         else if (hgh < 3)
  51.             hgh = 3;
  52.  
  53.         win = new MsgWin(wdt, hgh, hdr, msg);
  54.         win->topw();
  55.  
  56.         return (win);
  57.         }
  58.  
  59.