home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / heading.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  2.9 KB  |  125 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.02
  4. // Copyright (C) 1990, 1991
  5. // Software Dimensions
  6. //
  7. // Dialog Development System
  8. //
  9.  
  10. #include "elements.h"
  11. #include "mask.h"
  12.  
  13. const layoutContinue=30000;
  14. const layoutCancel=30001;
  15.  
  16. //-------------------------------------------------------------------------
  17. //
  18. // Event handler for class that gets a heading
  19. //
  20. //-------------------------------------------------------------------------
  21.  
  22. int GroupDialog::EventHandler(int Event)
  23. {
  24.     if (Event==kbEsc ||
  25.             Event==kbCr ||
  26.             Event==CloseEvent ||
  27.             Event==OutsideEvent ||
  28.             Event==layoutContinue ||
  29.             Event==layoutCancel)
  30.         return StopEvent;
  31.     return CompleteEvent;
  32. }
  33.  
  34. //-------------------------------------------------------------------------
  35. //
  36. // Define/constructor group heading dialog
  37. //
  38. //-------------------------------------------------------------------------
  39.  
  40. GroupDialog::GroupDialog(int Gp) : DialogClass(57,9,"Group Heading Specifications")
  41. {
  42.   GroupText[0]=0;
  43.   HotKeyDefine[0]=0;
  44.  
  45.   GroupingCode=Gp;
  46.  
  47.     Element(new DiaChar(15,1,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",GroupText));
  48.     Help("Enter the text to describe this group of elements");
  49.     HotKey(1,1,"~Group Heading",kbAltB);
  50.  
  51.     Element(new DiaChar(9,3,"xxxxxxxxxxxxxxxxxx",HotKeyDefine));
  52.     Help("Enter the hot key #define to assign to this group heading");
  53.     HotKey(1,3,"~Hot Key",kbAltH);
  54.  
  55.     Element(new DiaInt(49,3,"#####",GroupingCode));
  56.     Help("Enter the group that this heading will coorespond to");
  57.     HotKey(28,3,"~Cooresponds to Group",kbAltC);
  58.  
  59.   Element(new DiaPushButton(15,5,"Continue",layoutContinue,0,1));
  60.     Help("Accept this title and continue");
  61.  
  62.   Element(new DiaPushButton(31,5,"Cancel",layoutCancel));
  63.     Help("Do not accept this title");
  64. }
  65.  
  66. //-------------------------------------------------------------------------
  67. //
  68. // Display and request information from user about the group heading
  69. //
  70. //-------------------------------------------------------------------------
  71.  
  72. int GroupDialog::GetGroup()
  73. {
  74. DoAgain:
  75.  
  76.     int Save=UseDialog();
  77.  
  78.     if (Save==kbCr || Save==layoutContinue)
  79.   {
  80.     if (!GroupText[0])
  81.     {
  82.       InfoBox NotValid;
  83.  
  84.       NotValid
  85.         + "Sorry, you must define the text"
  86.         + "to describe the group!";
  87.  
  88.       NotValid.Title("Need a Description");
  89.       NotValid.UseInfoBox();
  90.  
  91.       goto DoAgain;
  92.     }
  93.     if (!HotKeyDefine[0])
  94.     {
  95.       InfoBox NotValid;
  96.  
  97.       NotValid
  98.         + "Sorry, you MUST define a hot key"
  99.         + "for this group.";
  100.  
  101.       NotValid.Title("Need a Hot Key");
  102.       NotValid.UseInfoBox();
  103.  
  104.       goto DoAgain;
  105.     }
  106.     if (!GroupingCode)
  107.     {
  108.       InfoBox NotValid;
  109.  
  110.       NotValid
  111.         + "Sorry, you MUST define the group"
  112.         + "code to identify which group this"
  113.         + "heading goes with.";
  114.  
  115.       NotValid.Title("Need a Group Code");
  116.       NotValid.UseInfoBox();
  117.  
  118.       goto DoAgain;
  119.     }
  120.     return 1;
  121.   }
  122.  
  123.   return 0;
  124. }
  125.