home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / push.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  5.0 KB  |  190 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. // This is the event handler for the push button dialog
  20. //
  21. //-------------------------------------------------------------------------
  22.  
  23. int PushDialog::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. // Allocate and display the push button creation dialog
  38. //
  39. //-------------------------------------------------------------------------
  40.  
  41.  
  42. PushDialog::PushDialog(int Gp,int Hs,int Sl) :
  43.   DialogClass(78,19,"Button Specifications")
  44. {
  45.   PushText[0]=0;
  46.   HotKeyDefine[0]=0;
  47.   Constant[0]=0;
  48.   HelpLine[0]=0;
  49.   DerivedClass[0]=0;
  50.  
  51.   GroupingCode=Gp;
  52.   HelpScreen=Hs;
  53.   SetForLiving=Sl;
  54.  
  55.   Blaze.Box(1,1,57,7,Colors.DiaInterior);
  56.   Blaze.Box(1,8,57,5,Colors.DiaInterior);
  57.   Blaze.Box(1,13,74,3,Colors.DiaInterior);
  58.  
  59.   GroupHeading(18,1,1,"Element ~Characteristics",kbAltC);
  60.   GroupHeading(18,8,2,"~Derivision Characteristics",kbAltD);
  61.   GroupHeading(30,13,3,"Help/Prompt ~Line",kbAltL);
  62.  
  63.     GroupElement(1,new DiaChar(15,2,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",PushText));
  64.     Help("Enter the text to place on the button");
  65.     HotKey(3,2,"~Button Text",kbAltB);
  66.  
  67.     GroupElement(1,new DiaChar(17,4,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",Constant));
  68.     Help("Enter the name that will be used for this constant");
  69.     HotKey(3,4,"~Constant Name",kbAltC);
  70.  
  71.     GroupElement(1,new DiaChar(11,6,"xxxxxxxxxxxxx",HotKeyDefine));
  72.     Help("Enter the hot key #define to assign to this element");
  73.     HotKey(3,6,"~Hot Key",kbAltH);
  74.  
  75.     GroupElement(1,new DiaInt(39,6,"#####",GroupingCode));
  76.     Help("Enter the group to assign this element to (0 for none)");
  77.     HotKey(25,6,"~Grouping Code",kbAltG);
  78.  
  79.     GroupElement(1,new DiaInt(51,6,"#####",HelpScreen));
  80.     Help("Enter the help screen for this element");
  81.     HotKey(45,6,"~Event",kbAltE);
  82.  
  83.   GroupElement(2,new DiaHorizRadio(17,9,SetForLiving,0,0));
  84.   (*this) + "Do Not Derive!" + "Derive a Class";
  85.   Help("Should a derived class be created for this element?");
  86.   HotKey(3,9,"~Derived Class",kbAltD);
  87.  
  88.     GroupElement(2,new DiaChar(19,11,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",DerivedClass));
  89.     Help("Enter the name of the derived class");
  90.     HotKey(3,11,"~Name of Derived",kbAltN);
  91.  
  92.     GroupElement(3,new DiaChar(13,14,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",HelpLine));
  93.     Help("Help that you would like to appear at the bottom of the screen");
  94.     HotKey(3,14,"Help ~Line",kbAltL);
  95.  
  96.   Element(new DiaPushButton(62,5,"Continue",layoutContinue,0,1));
  97.     Help("Accept this title and continue");
  98.  
  99.   Element(new DiaPushButton(63,8,"Cancel",layoutCancel));
  100.     Help("Do not accept this title");
  101. }
  102.  
  103. //-------------------------------------------------------------------------
  104. //
  105. // Call up the dialog and request user intervention
  106. //
  107. //-------------------------------------------------------------------------
  108.  
  109. int PushDialog::GetPush()
  110. {
  111. DoAgain:
  112.  
  113.     int Save=UseDialog();
  114.  
  115.     if (Save==kbCr || Save==layoutContinue)
  116.   {
  117.     if (!PushText[0])
  118.     {
  119.       InfoBox NotValid;
  120.  
  121.       NotValid
  122.         + "Sorry, you must define the text"
  123.         + "to describe the push button!";
  124.  
  125.       NotValid.Title("Need a Description");
  126.       NotValid.UseInfoBox();
  127.  
  128.       goto DoAgain;
  129.     }
  130.     if (!HelpScreen)
  131.     {
  132.       InfoBox NotValid;
  133.  
  134.       NotValid
  135.         + "Sorry, you MUST define the event"
  136.         + "code to use for this push button.";
  137.  
  138.       NotValid.Title("Need an Event");
  139.       NotValid.UseInfoBox();
  140.  
  141.       goto DoAgain;
  142.     }
  143.     if (HelpScreen && (HelpScreen<1000 || HelpScreen>32000))
  144.     {
  145.       InfoBox NotValid;
  146.  
  147.       NotValid
  148.         + "Sorry, the event code that you"
  149.         + "specified is invalid.  It must"
  150.         + "be between 1000 and 32000.";
  151.  
  152.       NotValid.Title("Incorrect Event");
  153.       NotValid.UseInfoBox();
  154.  
  155.       goto DoAgain;
  156.     }
  157.     if (!Constant[0])
  158.     {
  159.       InfoBox NotValid;
  160.  
  161.       NotValid
  162.         + "Sorry, you MUST define the name"
  163.         + "of the constant that will be"
  164.         + "used when this button is"
  165.         + "placed in the generated code.";
  166.  
  167.       NotValid.Title("Need a Constant");
  168.       NotValid.UseInfoBox();
  169.  
  170.       goto DoAgain;
  171.     }
  172.     if (SetForLiving && !DerivedClass[0])
  173.     {
  174.       InfoBox NotValid;
  175.  
  176.       NotValid
  177.         + "Sorry, a name for the derived"
  178.         + "class must be specified.";
  179.  
  180.       NotValid.Title("Missing Derived");
  181.       NotValid.UseInfoBox();
  182.  
  183.       goto DoAgain;
  184.     }
  185.     return 1;
  186.   }
  187.  
  188.   return 0;
  189. }
  190.