home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / fli106c / examples / mask.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-25  |  6.8 KB  |  249 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 character/numeric mask dialog
  20. //
  21. //-------------------------------------------------------------------------
  22.  
  23. int MaskDialog::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 and display it
  38. //
  39. //-------------------------------------------------------------------------
  40.  
  41. MaskDialog::MaskDialog(int Gp,int Hp,int Sl) :
  42.   DialogClass(78,21,"Element Specifications")
  43. {
  44.   ElementMask[0]=0;
  45.   VariableName[0]=0;
  46.   Prompter[0]=0;
  47.   HotKeyDefine[0]=0;
  48.   DerivedClass[0]=0;
  49.   HelpLine[0]=0;
  50.  
  51.   GroupingCode=Gp;
  52.   HelpScreen=Hp;
  53.   SetForLiving=Sl;
  54.  
  55.   MaskCharacter[0]=0;
  56.   MaskWidth=0;
  57.   ScrollWidth=0;
  58.  
  59.   CharacterActive=0;
  60.  
  61.   Blaze.Box(1,1,57,9,Colors.DiaInterior);
  62.   Blaze.Box(58,1,17,7,Colors.DiaInterior);
  63.   Blaze.Box(1,10,57,5,Colors.DiaInterior);
  64.   Blaze.Box(1,15,74,3,Colors.DiaInterior);
  65.  
  66.   GroupHeading(18,1,1,"Element ~Characteristics",kbAltC);
  67.   GroupHeading(63,1,4,"~Extras",kbAltE);
  68.   GroupHeading(17,10,2,"~Derivision Characteristics",kbAltD);
  69.   GroupHeading(30,15,3,"Help/Prompt ~Line",kbAltL);
  70.  
  71.     GroupElement(1,new DiaChar(16,2,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",ElementMask));
  72.     Help("Enter the mask for this dialog element");
  73.     HotKey(3,2,"~Element Mask",kbAltE);
  74.  
  75.     GroupElement(1,new DiaChar(12,4,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",VariableName));
  76.     Help("Enter the variable name that this element will be placed into");
  77.     HotKey(3,4,"~Variable",kbAltV);
  78.  
  79.     GroupElement(1,new DiaChar(12,6,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",Prompter));
  80.     Help("Enter the prompter to use for this element (~ for hot key)");
  81.     HotKey(3,6,"~Prompter",kbAltP);
  82.  
  83.     GroupElement(1,new DiaChar(11,8,"xxxxxxxxxxxxx",HotKeyDefine));
  84.   Help("Enter the hot key #define to assign to this element (0 for none)");
  85.     HotKey(3,8,"~Hot Key",kbAltH);
  86.  
  87.     GroupElement(1,new DiaInt(39,8,"###",GroupingCode));
  88.     Help("Enter the group to assign this element to (0 for none)");
  89.     HotKey(25,8,"~Grouping Code",kbAltG);
  90.  
  91.     GroupElement(1,new DiaInt(51,8,"#####",HelpScreen));
  92.     Help("Enter the help screen for this element (0 for none)");
  93.     HotKey(43,8,"~Help Id",kbAltG);
  94.  
  95.     GroupElement(4,new DiaInt(70,2,"###",ScrollWidth));
  96.   Available(CharacterActive);
  97.     Help("Enter the width to show on the dialog (0 for non-scrolling)");
  98.     HotKey(60,2,"~Scrolling",kbAltS);
  99.  
  100.     GroupElement(4,new DiaChar(72,4,"x",MaskCharacter));
  101.   Available(CharacterActive);
  102.     Help("Enter the character for the quick mask (Leave blank for none)");
  103.     HotKey(60,4,"~Mask Char",kbAltM);
  104.  
  105.     GroupElement(4,new DiaInt(70,6,"###",MaskWidth));
  106.   Available(CharacterActive);
  107.     Help("Enter the width for the quick mask (0 for none)");
  108.     HotKey(60,6,"Msk ~Width",kbAltW);
  109.  
  110.   GroupElement(2,new DiaHorizRadio(17,11,SetForLiving,0,0));
  111.   (*this) + "Do Not Derive!" + "Derive a Class";
  112.   Help("Should a derived class be created for this element?");
  113.   HotKey(3,11,"~Derived Class",kbAltD);
  114.  
  115.     GroupElement(2,new DiaChar(19,13,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",DerivedClass));
  116.     Help("Enter the name of the derived class");
  117.     HotKey(3,13,"~Name of Derived",kbAltN);
  118.  
  119.     GroupElement(3,new DiaChar(13,16,"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",HelpLine));
  120.     Help("Help that you would like to appear at the bottom of the screen");
  121.     HotKey(3,16,"Help ~Line",kbAltL);
  122.  
  123.   Element(new DiaPushButton(62,9,"Continue",layoutContinue,0,1));
  124.     Help("Accept this title and continue");
  125.  
  126.   Element(new DiaPushButton(63,12,"Cancel",layoutCancel));
  127.     Help("Do not accept this title");
  128. }
  129.  
  130. //-------------------------------------------------------------------------
  131. //
  132. // Get the mask input from the user
  133. //
  134. //-------------------------------------------------------------------------
  135.  
  136. int MaskDialog::GetMask()
  137. {
  138. DoAgain:
  139.  
  140.     int Save=UseDialog();
  141.  
  142.     if (Save==kbCr || Save==layoutContinue)
  143.   {
  144.     if (!ElementMask[0] && !MaskWidth)
  145.     {
  146.       InfoBox NotValid;
  147.  
  148.       NotValid
  149.         + "Sorry, you must define a mask"
  150.         + "for all input styles of elements!";
  151.  
  152.       NotValid.Title("Need a Mask");
  153.       NotValid.UseInfoBox();
  154.  
  155.       goto DoAgain;
  156.     }
  157.     if (!VariableName[0])
  158.     {
  159.       InfoBox NotValid;
  160.  
  161.       NotValid
  162.         + "Sorry, you must define a variable"
  163.         + "name.  This variable name signifies"
  164.         + "where you would like the input"
  165.         + "from this element to go.";
  166.  
  167.       NotValid.Title("Need a Variable");
  168.       NotValid.UseInfoBox();
  169.  
  170.       goto DoAgain;
  171.     }
  172.     if (Prompter[0] && !HotKeyDefine[0])
  173.     {
  174.       InfoBox NotValid;
  175.  
  176.       NotValid
  177.         + "Sorry, if you define a prompter"
  178.         + "you MUST define a hot key to"
  179.         + "accompany it.  Enter a \"0\" in the"
  180.         + "input spot if there isn't one.";
  181.  
  182.       NotValid.Title("Need a Hot Key");
  183.       NotValid.UseInfoBox();
  184.  
  185.       goto DoAgain;
  186.     }
  187.     if (HelpScreen && (HelpScreen<1000 || HelpScreen>32000))
  188.     {
  189.       InfoBox NotValid;
  190.  
  191.       NotValid
  192.         + "Sorry, the help screen that you"
  193.         + "specified is invalid.  It must"
  194.         + "be between 1000 and 32000.";
  195.  
  196.       NotValid.Title("Incorrect Help");
  197.       NotValid.UseInfoBox();
  198.  
  199.       goto DoAgain;
  200.     }
  201.     if (SetForLiving && !DerivedClass[0])
  202.     {
  203.       InfoBox NotValid;
  204.  
  205.       NotValid
  206.         + "Sorry, a name for the derived"
  207.         + "class must be specified.";
  208.  
  209.       NotValid.Title("Missing Derived");
  210.       NotValid.UseInfoBox();
  211.  
  212.       goto DoAgain;
  213.     }
  214.     if ((MaskWidth && !MaskCharacter[0]) ||
  215.       (MaskCharacter[0] && !MaskWidth))
  216.     {
  217.       InfoBox NotValid;
  218.  
  219.       NotValid
  220.         + "To do a quick mask, you must define"
  221.         + "both the mask character and the quick"
  222.         + "mask width.  Please specify both.";
  223.  
  224.       NotValid.Title("Incorrect Quick Mask");
  225.       NotValid.UseInfoBox();
  226.  
  227.       goto DoAgain;
  228.     }
  229.     if (ScrollWidth && ScrollWidth<5)
  230.     {
  231.       InfoBox NotValid;
  232.  
  233.       NotValid
  234.         + "It is recommended that the width of"
  235.         + "the scrolling character box be at"
  236.         + "least 5 characters wide.";
  237.  
  238.       NotValid.Title("Make Wider");
  239.       NotValid.UseInfoBox();
  240.  
  241.       goto DoAgain;
  242.     }
  243.  
  244.     return 1;
  245.   }
  246.  
  247.   return 0;
  248. }
  249.