home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / TVDEMOS.ZIP / GENPARTS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  4.2 KB  |  172 lines

  1. /*------------------------------------------------------*/
  2. /*                                                      */
  3. /*   Turbo Vision 1.0                                   */
  4. /*   Turbo Vision Forms Demo                            */
  5. /*   Copyright (c) 1991 by Borland International        */
  6. /*                                                      */
  7. /*------------------------------------------------------*/
  8.  
  9. // Use GENFORMS.MAK to generate data files for TVFORMS demo
  10. // (this file is used in GENFORM.CPP).
  11.  
  12. #if !defined( __GENPARTS_H )
  13. #define __GENPARTS_H
  14.  
  15. #define Uses_TRect
  16. #define Uses_TButton
  17. #define Uses_TMemo
  18. #define Uses_TLabel
  19. #define Uses_TScrollBar
  20. #include <tv.h>
  21. __link( RScrollBar )
  22. __link( RLabel )
  23. __link( RMemo )
  24. __link( RButton )
  25.  
  26. #if !defined( __FORMS_H )
  27. #include "forms.h"
  28. #endif  // __FORMS_H
  29.  
  30. #if !defined( __FORMCMDS_H )
  31. #include "formcmds.h"
  32. #endif  // __FORMCMDS_H
  33.  
  34. #if !defined( __DATACOLL_H )
  35. #include "datacoll.h"
  36. #endif  // __DATACOLL_H
  37.  
  38. #if !defined( __FIELDS_H )
  39. #include "fields.h"
  40. #endif  // __FIELDS_H
  41.  
  42. const
  43.     char rezFileName[] = "PARTS.TVF";
  44. const
  45.     partNumWidth   =   6,
  46.     descrWidth     =  30,
  47.     qtyWidth       =   6,
  48.     descrLen       = 512;            // Length of text array
  49.  
  50.  
  51. struct TDescrRec 
  52. {
  53.     ushort textLen;
  54.     char textData[descrLen];
  55. };
  56.  
  57. struct TDataRec
  58. {
  59.     long partNum;
  60.     long qty;
  61.     TDescrRec descr;
  62. };
  63.  
  64. const
  65.     Boolean allowDuplicates = False;
  66.  
  67. const
  68.     KeyTypes dataKeyType = longIntKey,
  69.     dataCount = 5;
  70.  
  71.     TDataRec data[dataCount] =
  72.         {
  73.         1, 1036, { 0,  "Government standard issue\r"
  74.                        "and certified by FAA for\r"
  75.                        "international use."
  76.                  }, 
  77.         2035, 33, { 0, "Warbling mini version with\r"
  78.                        "modified mechanisms for\r"
  79.                        "handling streamliners."
  80.                   },
  81.         2034, 13, { 0, "Hybrid version." },
  82.         2, -123,  { 0, "Catalytic version for\r"
  83.                        "meeting stricter emission\r"
  84.                        "standards in industrial areas."
  85.                   },
  86.         45, 8567, {0, "Prototype for new model."}
  87.  
  88.         };
  89.  
  90.  
  91. void initDescrLengths()
  92. {
  93.   for ( int i = 0 ; i < dataCount ; i++ )
  94.       data[i].descr.textLen = strlen(data[i].descr.textData);
  95. }
  96.  
  97. TForm *makeForm()
  98. {
  99.     const
  100.         formX1 = 1,
  101.         formY1 = 1,
  102.         formWd = 36,
  103.         formHt = 17,
  104.         labelCol = 1,
  105.         labelWid = 8,
  106.         inputCol = 11,
  107.         buttonWd = 12,
  108.         descrHt = 6;
  109.  
  110.     TForm *f;
  111.     int x, y;
  112.     TView *c;
  113.     TView *d;
  114.  
  115.     // Create a form
  116.     TRect r(formX1, formY1, formX1 + formWd, formY1 + formHt);
  117.     f =  new TForm(r, "Parts");
  118.  
  119.     // Create and insert controls into the form }
  120.     f->keyWidth = partNumWidth + 2;
  121.     y = 2;
  122.  
  123.     r = TRect(inputCol, y, inputCol + partNumWidth + 2, y + 1);
  124.     c = new TNumInputLine(r, partNumWidth, 0, 9999);
  125.     f->insert(c);
  126.  
  127.     r = TRect(labelCol, y, labelCol + labelWid, y + 1);
  128.     f->insert( new TLabel(r, "~P~art", c));
  129.  
  130.     y += 2;
  131.     r = TRect(inputCol, y, inputCol + qtyWidth + 2, y + 1);
  132.     c = new TNumInputLine(r, qtyWidth, -99999, 99999);
  133.     f->insert(c);
  134.  
  135.     r = TRect(labelCol, y, labelCol + qtyWidth, y + 1);
  136.     f->insert( new TLabel(r, "~Q~ty", c));
  137.  
  138.     y += 3;
  139.     r = TRect(labelCol + descrWidth + 1, y, labelCol + descrWidth + 2,
  140.                   y + descrHt);
  141.     c = new TScrollBar(r);
  142.     f->insert(c);
  143.  
  144.     r = TRect(labelCol + 1, y, labelCol + descrWidth + 1, y + descrHt);
  145.     d = new TMemo(r, 0, (TScrollBar *) c, 0, descrLen);
  146.     f->insert(d);
  147.  
  148.     r = TRect(labelCol, y - 1, labelCol + strlen("Description") + 1, y);
  149.     f->insert( new TLabel(r, "~D~escription", c));
  150.  
  151.     // Buttons 
  152.     y += descrHt + 1;
  153.     x = formWd - 2 * (buttonWd + 2);
  154.     r = TRect(x, y, x + buttonWd, y + 2);
  155.     f->insert( new TButton(r, "~S~ave", cmFormSave, bfDefault));
  156.  
  157.     x = formWd - 1 * (buttonWd + 2);
  158.     r = TRect(x, y, x + buttonWd, y + 2);
  159.  
  160.     f->insert( new TButton(r, "Cancel", cmCancel, bfNormal));
  161.  
  162.     f->selectNext(False);      // Select first field 
  163.  
  164.     initDescrLengths();
  165.  
  166.     return f;
  167. }
  168.  
  169.  
  170.  
  171. #endif  // __GENPARTS_H
  172.