home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / df3os2.zip / NOTICE.CPP < prev    next >
C/C++ Source or Header  |  1993-09-23  |  2KB  |  77 lines

  1. // ------------- notice.cpp
  2.  
  3. #include <ctype.h>
  4. #include "notice.h"
  5.  
  6. static Color col = {
  7.     BLACK,            // fg
  8.     GREEN,            // bg
  9.     BLACK,            // selected fg
  10.     GREEN,            // selected bg
  11.     BLACK,            // frame fg
  12.     GREEN,            // frame bg
  13.     BLACK,            // highlighted fg
  14.     GREEN            // highlighted bg
  15. };
  16.  
  17. NoticeBox::NoticeBox(const char *text, const char *ttl) :
  18.         Dialog(ttl, 7, 20),
  19.         notice(text, 1, 2, (DFWindow *)this),
  20.         ok(0, 4, (DFWindow *)this)
  21. {
  22.     int wd = max(10,max(strlen(text)+2,strlen(ttl)+2));
  23.     Size(Left()+wd-1, Bottom());
  24.     ok.Move(Left()+((wd-8)/2), ok.Top());
  25.     colors = col;
  26. }
  27.  
  28. static Color ecol = {
  29.     YELLOW, RED,
  30.     YELLOW, RED,
  31.     YELLOW, RED,
  32.     YELLOW, RED
  33. };
  34.  
  35. ErrorMessageBox::ErrorMessageBox(const char *text, const char *ttl) :
  36.         NoticeBox(text, ttl)
  37. {
  38.     desktop.speaker().Beep();
  39.     colors = ecol;
  40. }
  41.  
  42. static Color yncol = {
  43.     BLACK,GREEN,
  44.     BLACK,GREEN,
  45.     BLACK,GREEN,
  46.     BLACK,GREEN
  47. };
  48.  
  49. YesNoBox::YesNoBox(const char *text, const char *ttl) :
  50.         Dialog(ttl, 7, 20),
  51.         notice(text, 1, 2, (DFWindow *)this),
  52.         yes(0, 4, (DFWindow *)this),
  53.         no(0, 4, (DFWindow *)this)
  54. {
  55.     int wd = max(21,max(strlen(text)+2,strlen(ttl)+2));
  56.     Size(Left()+wd-1, Bottom());
  57.     yes.Move(Left()+((wd-17)/2), yes.Top());
  58.     no.Move(Left()+((wd-17)/2)+9, no.Top());
  59.     colors = yncol;
  60. }
  61.  
  62. void YesNoBox::Keyboard(int key)
  63. {
  64.     switch (tolower(key))    {
  65.         case 'n':
  66.             CancelFunction();
  67.             break;
  68.         case 'y':
  69.             OKFunction();
  70.             break;
  71.         default:
  72.             Dialog::Keyboard(key);
  73.             break;
  74.     }
  75. }
  76.  
  77.