home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / pick.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  4.7 KB  |  188 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. #include <string.h>
  15.  
  16. const layoutContinue=30000;
  17. const layoutCancel=30001;
  18. const layoutButtons=30002;
  19.  
  20. //-------------------------------------------------------------------------
  21. //
  22. // Event handler for the radio button definition dialog
  23. // This dialog defines each button
  24. //
  25. //-------------------------------------------------------------------------
  26.  
  27. int PickDialog::EventHandler(int Event)
  28. {
  29.     if (Event==kbEsc ||
  30.             Event==kbCr ||
  31.             Event==CloseEvent ||
  32.             Event==OutsideEvent ||
  33.             Event==layoutContinue ||
  34.             Event==layoutCancel)
  35.         return StopEvent;
  36.     return CompleteEvent;
  37. }
  38.  
  39. //-------------------------------------------------------------------------
  40. //
  41. // Define the global radio button dialog
  42. //
  43. //-------------------------------------------------------------------------
  44.  
  45. PickDialog::PickDialog(int Hp,int Wide,int Hi) :
  46.   DialogClass(78,16,"Pick List Specifications")
  47. {
  48.   Prompter[0]=0;
  49.   HotKeyDefine[0]=0;
  50.   DerivedClass[0]=0;
  51.   HelpLine[0]=0;
  52.  
  53.   HelpScreen=Hp;
  54.   Width=Wide;
  55.   Height=Hi;
  56.  
  57.   Blaze.Box(1,1,57,9,Colors.DiaInterior);
  58.   Blaze.Box(1,10,74,3,Colors.DiaInterior);
  59.  
  60.   GroupHeading(18,1,1,"Element ~Characteristics",kbAltC);
  61.   GroupHeading(30,10,3,"Help/Prompt ~Line",kbAltL);
  62.  
  63.   GroupElement(1,new DiaInt(22,2,"###",Width));
  64.   Help("Enter the width of this pick list");
  65.   HotKey(3,2,"~Width of Pick List",kbAltW);
  66.  
  67.   GroupElement(1,new DiaInt(53,2,"###",Height));
  68.   Help("Enter the height of this pick list");
  69.   HotKey(33,2,"~Height of Pick List",kbAltH);
  70.  
  71.     GroupElement(1,new DiaChar(12,4,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",Prompter));
  72.     Help("Enter the prompter to use for this element (~ for hot key)");
  73.     HotKey(3,4,"~Prompter",kbAltP);
  74.  
  75.     GroupElement(1,new DiaChar(11,6,0,HotKeyDefine,0,'x',29));
  76.   Help("Enter the hot key #define to assign to this element (0 for none)");
  77.     HotKey(3,6,"~Hot Key",kbAltH);
  78.  
  79.     GroupElement(1,new DiaInt(51,6,"#####",HelpScreen));
  80.     Help("Enter the help screen for this element (0 for none)");
  81.     HotKey(43,6,"~Help Id",kbAltG);
  82.  
  83.     GroupElement(1,new DiaChar(19,8,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",DerivedClass));
  84.     Help("Enter the name of the derived class");
  85.     HotKey(3,8,"~Name of Derived",kbAltN);
  86.  
  87.     GroupElement(3,new DiaChar(13,11,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",HelpLine));
  88.     Help("Help that you would like to appear at the bottom of the screen");
  89.     HotKey(3,11,"Help ~Line",kbAltL);
  90.  
  91.   Element(new DiaPushButton(62,3,"Continue",layoutContinue,0,1));
  92.     Help("Accept this title and continue");
  93.  
  94.   Element(new DiaPushButton(63,6,"Cancel",layoutCancel));
  95.     Help("Do not accept this title");
  96. }
  97.  
  98. //-------------------------------------------------------------------------
  99. //
  100. // Get the global radio button information
  101. //
  102. //-------------------------------------------------------------------------
  103.  
  104. int PickDialog::GetPick()
  105. {
  106. DoAgain:
  107.  
  108.     int Save=UseDialog();
  109.  
  110.     if (Save==kbCr || Save==layoutContinue)
  111.   {
  112.     if (!Width || !Height)
  113.     {
  114.       InfoBox NotValid;
  115.  
  116.       NotValid
  117.         + "Sorry, you define the width and"
  118.         + "height before I can declare this"
  119.         + "pick list.";
  120.  
  121.       NotValid.Title("Dimensions Necessary");
  122.       NotValid.UseInfoBox();
  123.  
  124.       goto DoAgain;
  125.     }
  126.     if (Width<3 || Height<3)
  127.     {
  128.       InfoBox NotValid;
  129.  
  130.       NotValid
  131.         + "Sorry, the pick list dimensions must"
  132.         + "be at least 3x3.  In other words, at"
  133.         + "least 3 wide and 3 high.";
  134.  
  135.       NotValid.Title("Too thin");
  136.       NotValid.UseInfoBox();
  137.  
  138.       goto DoAgain;
  139.     }
  140.     if (Prompter[0] && !HotKeyDefine[0])
  141.     {
  142.       InfoBox NotValid;
  143.  
  144.       NotValid
  145.         + "Sorry, if you define a prompter"
  146.         + "you MUST define a hot key to"
  147.         + "accompany it.  Enter a \"0\" in the"
  148.         + "input spot if there isn't one.";
  149.  
  150.       NotValid.Title("Need a Hot Key");
  151.       NotValid.UseInfoBox();
  152.  
  153.       goto DoAgain;
  154.     }
  155.     if (HelpScreen && (HelpScreen<1000 || HelpScreen>32000))
  156.     {
  157.       InfoBox NotValid;
  158.  
  159.       NotValid
  160.         + "Sorry, the help screen that you"
  161.         + "specified is invalid.  It must"
  162.         + "be between 1000 and 32000.";
  163.  
  164.       NotValid.Title("Incorrect Help");
  165.       NotValid.UseInfoBox();
  166.  
  167.       goto DoAgain;
  168.     }
  169.     if (!DerivedClass[0])
  170.     {
  171.       InfoBox NotValid;
  172.  
  173.       NotValid
  174.         + "Sorry, a name for the derived"
  175.         + "class must be specified.";
  176.  
  177.       NotValid.Title("Missing Derived");
  178.       NotValid.UseInfoBox();
  179.  
  180.       goto DoAgain;
  181.     }
  182.  
  183.     return 1;
  184.   }
  185.  
  186.   return 0;
  187. }
  188.