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

  1. /*-------------------------------------------------------*/
  2. /*                                                       */
  3. /*   Turbo Vision 1.0                                    */
  4. /*   Turbo Vision Forms Demo                             */
  5. /*   Copyright (c) 1990 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( __GENPHONE_H )
  13. #define __GENPHONE_H
  14.  
  15. #define Uses_TButton
  16. #define Uses_TRect
  17. #define Uses_TCheckBoxes
  18. #define Uses_TInputLine
  19. #define Uses_TLabel
  20. #define Uses_TMenuBar
  21. #define Uses_TSItem
  22. #define Uses_TRadioButtons
  23. #include <tv.h>
  24. __link( RButton )
  25. __link( RCheckBoxes )
  26. __link( RInputLine )
  27. __link( RLabel )
  28. __link( RMenuBar )
  29. __link( RRadioButtons )
  30. __link( RFrame )
  31.  
  32. #if !defined( __FORMS_H )
  33. #include "forms.h"
  34. #endif  // _FORMS_H
  35.  
  36. #if !defined( __FORMCMDS_H )
  37. #include "formcmds.h"
  38. #endif  // _FORMCMDS_H
  39.  
  40. #if !defined( __DATACOLL_H )
  41. #include "datacoll.h"
  42. #endif  // _DATACOLL_H
  43.  
  44. #if !defined( __FIELDS_H )
  45. #include "fields.h"
  46. #endif  // _FIELDS_H
  47.  
  48. #if !defined( __STRING_H )
  49. #include <string.h>
  50. #endif  // _STRING_H
  51.  
  52.  
  53. const
  54.     char rezFileName[] = "PHONENUM.TVF";
  55. const
  56.     nameWidth = 25,
  57.     companyWidth = 23,
  58.     remarksWidth = 22,
  59.     phoneWidth = 20;
  60.  
  61. struct TDataRec
  62. {
  63.     char name[nameWidth];
  64.     char company[companyWidth];
  65.     char remarks[remarksWidth];
  66.     char phone[phoneWidth];
  67.     ushort acquaintType;
  68.     ushort gender;
  69. };
  70.  
  71. const
  72.     Boolean allowDuplicates = True;
  73. const
  74.     KeyTypes dataKeyType = stringKey,
  75.     dataCount = 4,
  76.     male      = 0,
  77.     female    = 1,
  78.     business  = 0x1,
  79.     personal  = 0x2;
  80.  
  81. const
  82.     TDataRec data[dataCount] =
  83.         {
  84.             "Helton, Andrew", "Asterisk International", "Purch. Mgr.", "(415) 868-3964",
  85.                 business | personal, male,
  86.             "White, Natalie", "Exclamation, Inc.", "VP sales", "(408) 242-2030",
  87.                 business, female,
  88.             "Stern, Peter", "", "Decent violinist", "(111) 222-5555",
  89.                 personal, male,
  90.             "Whitcom, Hana O.", "Nate''s girlfriend", "Birthday: Jan 8, 1990", "(408) 426-1234",
  91.                 personal, female
  92.         };
  93.  
  94.  
  95. TForm *makeForm()
  96. {
  97.     const
  98.         formX1 = 5,
  99.         formY1 = 3,
  100.         formWd = 41,
  101.         formHt = 17,
  102.         labelCol = 1,
  103.         labelWid = 8,
  104.         inputCol = 11,
  105.         buttonWd = 12;
  106.  
  107.     TForm *f;
  108.     int x,y;
  109.     TView *control;
  110.  
  111.     // Create a form
  112.     TRect r(formX1, formY1, formX1 + formWd, formY1 + formHt);
  113.     f = new TForm(r, "Phone Numbers");
  114.  
  115.     // Create and insert controls into the form
  116.     y = 2;
  117.     f->keyWidth = nameWidth + 2;
  118.     r = TRect(inputCol, y, inputCol + nameWidth + 2, y + 1);
  119.     control = new TKeyInputLine(r, nameWidth);
  120.     f->insert(control);
  121.     r = TRect(labelCol, y, labelCol + labelWid, y + 1);
  122.  
  123.     f->insert(new TLabel(r, "~N~ame", control));
  124.  
  125.     y += 2;
  126.     r = TRect(inputCol, y, inputCol + companyWidth + 2, y + 1);
  127.     control = new TInputLine(r, companyWidth);
  128.     f->insert(control);
  129.  
  130.     r = TRect(labelCol, y, labelCol + labelWid, y + 1);
  131.     f->insert(new TLabel(r, "~C~ompany", control));
  132.  
  133.     y += 2;
  134.     r = TRect(inputCol, y, inputCol + remarksWidth + 2, y + 1);
  135.     control = new TInputLine(r, remarksWidth);
  136.     f->insert(control);
  137.  
  138.     r = TRect(labelCol, y, labelCol + labelWid, y + 1);
  139.  
  140.     f->insert(new TLabel(r, "~R~emarks", control));
  141.  
  142.     y += 2;
  143.     r = TRect(inputCol, y, inputCol + phoneWidth + 2, y + 1);
  144.     control = new TInputLine(r, phoneWidth);
  145.     f->insert(control);
  146.  
  147.     r = TRect(labelCol, y, labelCol + labelWid, y + 1);
  148.     f->insert(new TLabel(r, "~P~hone", control));
  149.  
  150.     // Checkboxes
  151.     x = inputCol;
  152.     y += 3;
  153.     r = TRect(inputCol, y , inputCol + strlen("Business") + 6, y + 2);
  154.     control = new TCheckBoxes(r,
  155.                       new TSItem("Business",
  156.                       new TSItem("Personal",
  157.                       NULL)));
  158.     f->insert(control);
  159.     r = TRect(x, y - 1, x + labelWid, y);
  160.     f->insert(new TLabel(r, "~T~ype", control));
  161.  
  162.     // Radio buttons 
  163.     x += 15;
  164.     r = TRect(x, y, x + strlen("Female") + 6, y + 2);
  165.  
  166.     control = new TRadioButtons(r,
  167.                    new TSItem("Male",
  168.                    new TSItem("Female", NULL)));
  169.     f->insert(control);
  170.     r = TRect(x, y - 1, x + labelWid, y);
  171.     f->insert(new TLabel(r, "~G~ender", control));
  172.  
  173.     // Buttons 
  174.     y += 3;
  175.     x = formWd - 2 * (buttonWd + 2);
  176.     r = TRect(x, y, x + buttonWd, y + 2);
  177.     f->insert(new TButton(r, "~S~ave", cmFormSave, bfDefault));
  178.  
  179.     x = formWd - 1 * (buttonWd + 2);
  180.     r = TRect(x, y, x + buttonWd, y + 2);
  181.     f->insert(new TButton(r, "Cancel", cmCancel, bfNormal));
  182.     f->selectNext(False);      // Select first field 
  183.  
  184.     return f;
  185. }
  186.  
  187. #endif  // __GENPHONE_H
  188.