home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / check.cpp next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  4.7 KB  |  176 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. #include "colors.h"
  13.  
  14. const layoutContinue=30000;
  15. const layoutCancel=30001;
  16.  
  17. //-------------------------------------------------------------------------
  18. //
  19. // Dialog that gets information about a check box
  20. //
  21. //-------------------------------------------------------------------------
  22.  
  23. int CheckDialog::EventHandler(int Event)
  24. {
  25.     if (Event==kbEsc ||
  26.             Event==kbCr ||
  27.             Event==CloseEvent ||
  28.             Event==OutsideEvent ||
  29.             Event==layoutContinue ||
  30.             Event==layoutCancel)
  31.         return StopEvent;
  32.     return CompleteEvent;
  33. }
  34.  
  35. //-------------------------------------------------------------------------
  36. //
  37. // Construct the dialog that gets information about a check box
  38. //
  39. //-------------------------------------------------------------------------
  40.  
  41. CheckDialog::CheckDialog(int Gp,int Hs,int Sl) :
  42.   DialogClass(78,19,"Check Box Specifications")
  43. {
  44.   CheckText[0]=0;
  45.   VariableName[0]=0;
  46.   HotKeyDefine[0]=0;
  47.   HelpLine[0]=0;
  48.   DerivedClass[0]=0;
  49.  
  50.   GroupingCode=Gp;
  51.   HelpScreen=Hs;
  52.   SetForLiving=Sl;
  53.  
  54.   Blaze.Box(1,1,57,7,Colors.DiaInterior);
  55.   Blaze.Box(1,8,57,5,Colors.DiaInterior);
  56.   Blaze.Box(1,13,74,3,Colors.DiaInterior);
  57.  
  58.   GroupHeading(18,1,1,"Element ~Characteristics",kbAltC);
  59.   GroupHeading(18,8,2,"~Derivision Characteristics",kbAltD);
  60.   GroupHeading(30,13,3,"Help/Prompt ~Line",kbAltL);
  61.  
  62.     GroupElement(1,new DiaChar(18,2,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",CheckText));
  63.     Help("Enter the text to place next to the check box");
  64.     HotKey(3,2,"~Check Box Text",kbAltC);
  65.  
  66.     GroupElement(1,new DiaChar(12,4,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",VariableName));
  67.     Help("Enter the variable name that this element will be placed into");
  68.     HotKey(3,4,"~Variable",kbAltV);
  69.  
  70.     GroupElement(1,new DiaChar(11,6,"xxxxxxxxxxxxx",HotKeyDefine));
  71.     Help("Enter the hot key #define to assign to this element");
  72.     HotKey(3,6,"~Hot Key",kbAltH);
  73.  
  74.     GroupElement(1,new DiaInt(39,6,"###",GroupingCode));
  75.     Help("Enter the group to assign this element to (0 for none)");
  76.     HotKey(25,6,"~Grouping Code",kbAltG);
  77.  
  78.     GroupElement(1,new DiaInt(51,6,"#####",HelpScreen));
  79.     Help("Enter the help screen for this element (0 for none)");
  80.     HotKey(43,6,"~Help Id",kbAltG);
  81.  
  82.   GroupElement(2,new DiaHorizRadio(17,9,SetForLiving,0,0));
  83.   (*this) + "Do Not Derive!" + "Derive a Class";
  84.   Help("Should a derived class be created for this element?");
  85.   HotKey(3,9,"~Derived Class",kbAltD);
  86.  
  87.     GroupElement(2,new DiaChar(19,11,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",DerivedClass));
  88.     Help("Enter the name of the derived class");
  89.     HotKey(3,11,"~Name of Derived",kbAltN);
  90.  
  91.     GroupElement(3,new DiaChar(13,14,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",HelpLine));
  92.     Help("Help that you would like to appear at the bottom of the screen");
  93.     HotKey(3,14,"Help ~Line",kbAltL);
  94.  
  95.   Element(new DiaPushButton(62,5,"Continue",layoutContinue,0,1));
  96.     Help("Accept this title and continue");
  97.  
  98.   Element(new DiaPushButton(63,8,"Cancel",layoutCancel));
  99.     Help("Do not accept this title");
  100. }
  101.  
  102. //-------------------------------------------------------------------------
  103. //
  104. // Request information about the check box
  105. //
  106. //-------------------------------------------------------------------------
  107.  
  108. int CheckDialog::GetCheck()
  109. {
  110. DoAgain:
  111.  
  112.     int Save=UseDialog();
  113.  
  114.     if (Save==kbCr || Save==layoutContinue)
  115.   {
  116.     if (!CheckText[0])
  117.     {
  118.       InfoBox NotValid;
  119.  
  120.       NotValid
  121.         + "Sorry, you must define the text"
  122.         + "to describe the check box!";
  123.  
  124.       NotValid.Title("Need a Description");
  125.       NotValid.UseInfoBox();
  126.  
  127.       goto DoAgain;
  128.     }
  129.     if (!VariableName[0])
  130.     {
  131.       InfoBox NotValid;
  132.  
  133.       NotValid
  134.         + "Sorry, you must define a variable"
  135.         + "name.  This variable name signifies"
  136.         + "where you would like the input"
  137.         + "from this element to go.";
  138.  
  139.       NotValid.Title("Need a Variable");
  140.       NotValid.UseInfoBox();
  141.  
  142.       goto DoAgain;
  143.     }
  144.     if (HelpScreen && (HelpScreen<1000 || HelpScreen>32000))
  145.     {
  146.       InfoBox NotValid;
  147.  
  148.       NotValid
  149.         + "Sorry, the help screen that you"
  150.         + "specified is invalid.  It must"
  151.         + "be between 1000 and 32000.";
  152.  
  153.       NotValid.Title("Incorrect Help");
  154.       NotValid.UseInfoBox();
  155.  
  156.       goto DoAgain;
  157.     }
  158.     if (SetForLiving && !DerivedClass[0])
  159.     {
  160.       InfoBox NotValid;
  161.  
  162.       NotValid
  163.         + "Sorry, a name for the derived"
  164.         + "class must be specified.";
  165.  
  166.       NotValid.Title("Missing Derived");
  167.       NotValid.UseInfoBox();
  168.  
  169.       goto DoAgain;
  170.     }
  171.     return 1;
  172.   }
  173.  
  174.   return 0;
  175. }
  176.