home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / tfield / tfldex.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  18.3 KB  |  626 lines

  1. /*---------------------------------------------------------*/
  2. /*                                                         */
  3. /*   Turbo Vision Extensions 1.1                           */
  4. /*                                                         */
  5. /*   TField Example Program File                           */
  6. /*---------------------------------------------------------*/
  7.  
  8. #define Uses_MsgBox
  9. #define Uses_TApplication
  10. #define Uses_TButton
  11. #define Uses_TCheckBoxes
  12. #define Uses_TDateField
  13. #define Uses_TDeskTop
  14. #define Uses_TDialog
  15. #define Uses_TEvent
  16. #define Uses_TEventQueue
  17. #define Uses_TFrame
  18. #define Uses_TIndicator
  19. #define Uses_TKeys
  20. #define Uses_TLabel
  21. #define Uses_TMenuBar
  22. #define Uses_TMenuItem
  23. #define Uses_TMessageBox
  24. #define Uses_TProgram
  25. #define Uses_TRect
  26. #define Uses_TSItem
  27. #define Uses_TStaticText
  28. #define Uses_TStatusDef
  29. #define Uses_TStatusItem
  30. #define Uses_TStatusLine
  31. #define Uses_TStreamable
  32. #define Uses_TStreamableClass
  33. #define Uses_TSubMenu
  34. #define Uses_TView
  35. #define Uses_TWindow
  36.  
  37. #define Uses_TField
  38. #define Uses_TUpperField
  39. #define Uses_TIntField
  40. #define Uses_TLongField
  41. #define Uses_TFloatField
  42.  
  43. #include <tv.h>
  44. #include "TField.h"
  45.  
  46. #if !defined( __STRING_H )
  47. #include <string.h>
  48. #endif  // __STRING_H
  49.  
  50. #if !defined( __STDLIB_H )
  51. #include <stdlib.h>
  52. #endif  // __STDLIB_H
  53.  
  54. #if !defined( __STRSTREAM_H )
  55. #include <strstream.h>
  56. #endif  // __STRSTREAM_H
  57.  
  58.  
  59. const int cmFieldOptDlg = 101;
  60. const int cmDoFOD = 102;
  61.  
  62. short gWinNumber = 0; // Window Number
  63.  
  64. #define cpForm14 "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"\
  65.                       "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
  66.  
  67. struct Form14Record
  68. {
  69.      long dateValue;
  70.      int  intValue;
  71.      char charValue[128];
  72.      char upperValue[128];
  73.      long longValue;
  74.      float floatValue;
  75. };
  76.  
  77. Form14Record *F14MyData;
  78.  
  79. void TFieldOptDlg( TField *field, TApplication *application )
  80.     {
  81.     int fieldType = field->fieldType;
  82.  
  83.     if ( (fieldType < 0) || (fieldType > 6) )
  84.         {
  85.         messageBox("This field does not have TField options!", mfError | mfCancelButton);
  86.         return;
  87.         };
  88.  
  89.     TDialog *pd = new TDialog( TRect( 15, 2, 65, 21), "Change TField Options" );
  90.     if( pd )
  91.         {
  92.         // add fieldName input
  93.         TView *b = new TField( TRect( 13, 3, 26, 4), 33 );
  94.         pd->insert( b );
  95.         pd->insert( new TLabel( TRect( 2, 3, 12, 4 ),
  96.             "fieldName", b ));
  97.  
  98.         // add fieldHint input
  99.         b = new TField( TRect( 13, 4, 26, 5), 33 );
  100.         pd->insert( b );
  101.         pd->insert( new TLabel( TRect( 2, 4, 12, 5 ),
  102.             "fieldHint", b ));
  103.  
  104.         // add hideChar input
  105.         b = new TField( TRect( 19, 6, 20, 7), 2 );
  106.             ((TField *)b)->setTFOptions( tfNoScroll, True );
  107.         pd->insert( b );
  108.         pd->insert( new TLabel( TRect( 9, 6, 18, 7 ),
  109.             "h~i~deChar", b ));
  110.  
  111.         // add securityChar input
  112.         b = new TField( TRect( 19, 7, 20, 8 ), 2 );
  113.             ((TField *)b)->setTFOptions( tfNoScroll, True );
  114.         pd->insert( b );
  115.         pd->insert( new TLabel( TRect( 5, 7, 18, 8 ),
  116.             "sec~u~rityChar", b ));
  117.  
  118.         // add fieldSecurity input
  119.         b = new TIntField( TRect( 19, 9, 26, 10 ), 7 );
  120.             ((TField *)b)->setTFOptions( tfNoScroll | tfRight, True );
  121.         pd->insert( b);
  122.         pd->insert( new TLabel( TRect( 4, 9, 18, 10 ),
  123.             "fiel~d~Security", b ));
  124.  
  125.         // add currentSecurity input
  126.         b = new TIntField( TRect( 19, 10, 26, 11 ), 7 );
  127.             ((TField *)b)->setTFOptions( tfNoScroll | tfRight, True );
  128.         pd->insert( b);
  129.         pd->insert( new TLabel( TRect( 2, 10, 18, 11 ),
  130.             "currentSecurit~y~", b ));
  131.  
  132.         struct DialogData
  133.             {
  134.             char fieldName[33];
  135.             char fieldHint[33];
  136.             char hideChar[2];
  137.             char securityChar[2];
  138.             int fieldSecurity;
  139.             int currentSecurity;
  140.             ushort tfOptions;
  141.             };
  142.         struct DateDialogData
  143.             {
  144.             char fieldName[33];
  145.             char fieldHint[33];
  146.             char hideChar[2];
  147.             char securityChar[2];
  148.             int fieldSecurity;
  149.             int currentSecurity;
  150.             long minValue;
  151.             long maxValue;
  152.             ushort tfOptions;
  153.             };
  154.         struct IntDialogData
  155.             {
  156.             char fieldName[33];
  157.             char fieldHint[33];
  158.             char hideChar[2];
  159.             char securityChar[2];
  160.             int fieldSecurity;
  161.             int currentSecurity;
  162.             int minValue;
  163.             int maxValue;
  164.             ushort tfOptions;
  165.             };
  166.         struct LongDialogData
  167.             {
  168.             char fieldName[33];
  169.             char fieldHint[33];
  170.             char hideChar[2];
  171.             char securityChar[2];
  172.             int fieldSecurity;
  173.             int currentSecurity;
  174.             long minValue;
  175.             long maxValue;
  176.             ushort tfOptions;
  177.             };
  178.         struct FloatDialogData
  179.             {
  180.             char fieldName[33];
  181.             char fieldHint[33];
  182.             char hideChar[2];
  183.             char securityChar[2];
  184.             int fieldSecurity;
  185.             int currentSecurity;
  186.             float    minValue;
  187.             float maxValue;
  188.             char formatString[33];
  189.             ushort tfOptions;
  190.             };
  191.         void *optionsData = NULL;
  192.  
  193.         switch (fieldType)
  194.             {
  195.             case TDateFieldType:
  196.                 // add minValue input
  197.                 b = new TDateField( TRect( 13, 13, 26, 14), 33 );
  198.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  199.                 pd->insert( b );
  200.                 pd->insert( new TLabel( TRect( 3, 13, 12, 14 ),
  201.                     "minValue", b ));
  202.  
  203.                 // add maxValue input
  204.                 b = new TDateField( TRect( 13, 14, 26, 15), 33 );
  205.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  206.                 pd->insert( b );
  207.                 pd->insert( new TLabel( TRect( 3, 14, 12, 15 ),
  208.                     "maxValue", b ));
  209.  
  210.                 optionsData = new DateDialogData;
  211.                 break;
  212.  
  213.             case TIntFieldType:
  214.                 // add minValue input
  215.                 b = new TIntField( TRect( 13, 13, 26, 14), 33 );
  216.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  217.                 pd->insert( b );
  218.                 pd->insert( new TLabel( TRect( 3, 13, 12, 14 ),
  219.                     "minValue", b ));
  220.  
  221.                 // add maxValue input
  222.                 b = new TIntField( TRect( 13, 14, 26, 15), 33 );
  223.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  224.                 pd->insert( b );
  225.                 pd->insert( new TLabel( TRect( 3, 14, 12, 15 ),
  226.                     "maxValue", b ));
  227.  
  228.                 optionsData = new IntDialogData;
  229.                 break;
  230.  
  231.             case TLongFieldType:
  232.                 // add minValue input
  233.                 b = new TLongField( TRect( 13, 13, 26, 14), 33 );
  234.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  235.                 pd->insert( b );
  236.                 pd->insert( new TLabel( TRect( 3, 13, 12, 14 ),
  237.                     "minValue", b ));
  238.  
  239.                 // add maxValue input
  240.                 b = new TLongField( TRect( 13, 14, 26, 15), 33 );
  241.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  242.                 pd->insert( b );
  243.                 pd->insert( new TLabel( TRect( 3, 14, 12, 15 ),
  244.                     "maxValue", b ));
  245.  
  246.                 optionsData = new LongDialogData;
  247.                 break;
  248.  
  249.             case TFloatFieldType:
  250.                 // add minValue input
  251.                 b = new TFloatField( TRect( 13, 12, 26, 13), 33 );
  252.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  253.                 if ( ((TFloatField *)field)->formatString != NULL )
  254.                     ((TFloatField *)b)->setFormat( ((TFloatField *)field)->formatString );
  255.                 pd->insert( b );
  256.                 pd->insert( new TLabel( TRect( 3, 12, 12, 13 ),
  257.                     "minValue", b ));
  258.  
  259.                 // add maxValue input
  260.                 b = new TFloatField( TRect( 13, 13, 26, 14), 33 );
  261.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  262.                 if ( ((TFloatField *)field)->formatString != NULL )
  263.                     ((TFloatField *)b)->setFormat( ((TFloatField *)field)->formatString );
  264.                 pd->insert( b );
  265.                 pd->insert( new TLabel( TRect( 3, 13, 12, 14 ),
  266.                     "maxValue", b ));
  267.  
  268.                 // add formatString input
  269.                 b = new TField( TRect( 16, 14, 26, 15), 33 );
  270.                 ((TField *)b)->setTFOptions( tfNoScroll | tfStayError, True );
  271.                 pd->insert( b );
  272.                 pd->insert( new TLabel( TRect( 2, 14, 15, 15 ),
  273.                     "formatString", b ));
  274.  
  275.                 optionsData = new FloatDialogData;
  276.                 break;
  277.  
  278.             default:
  279.                 optionsData = new DialogData;
  280.                 break;
  281.             };
  282.  
  283.         b = new TCheckBoxes( TRect( 28, 3, 47, 15),
  284.             new TSItem( "tf~R~ight",
  285.             new TSItem( "tfNo~S~croll",
  286.             new TSItem( "tf~H~ideSecure",
  287.             new TSItem( "tfValidate~M~ax",
  288.             new TSItem( "tfValidateMi~n~",
  289.             new TSItem( "tfMust~F~ill",
  290.             new TSItem( "tfNot~E~mpty",
  291.             new TSItem( "tf~B~eepError",
  292.             new TSItem( "tfEnter~T~abs",
  293.             new TSItem( "tfSt~a~yError",
  294.             new TSItem( "tfPopUp",
  295.             new TSItem( "tfPreValidate", 0 )))))))))))));
  296.         pd->insert( b );
  297.         pd->insert( new TLabel( TRect( 27, 2, 37, 3), "tfO~p~tions", b ));
  298.  
  299.         pd->insert( new TButton( TRect( 14, 16, 24, 18 ), "~O~K", cmOK,
  300.             bfDefault ));
  301.         pd->insert( new TButton( TRect( 26, 16, 36, 18 ), "~C~ancel", cmCancel,
  302.             bfNormal ));
  303.  
  304.         if (optionsData)
  305.             {
  306.             // we save the dialog data:
  307.             if (field->fieldName != NULL)
  308.                 strncpy(((DialogData *)optionsData)->fieldName, field->fieldName, 33);
  309.             else
  310.                 ((DialogData *)optionsData)->fieldName[0] = EOS;
  311.             if (field->fieldHint != NULL)
  312.                 strncpy(((DialogData *)optionsData)->fieldHint, field->fieldHint, 33);
  313.             else
  314.                 ((DialogData *)optionsData)->fieldHint[0] = EOS;
  315.             ((DialogData *)optionsData)->hideChar[0] = field->hideChar;
  316.             ((DialogData *)optionsData)->hideChar[1] = EOS;
  317.             ((DialogData *)optionsData)->securityChar[0] = field->securityChar;
  318.             ((DialogData *)optionsData)->securityChar[1] = EOS;
  319.             ((DialogData *)optionsData)->fieldSecurity = field->fieldSecurity;
  320.             ((DialogData *)optionsData)->currentSecurity = field->currentSecurity;
  321.             switch (fieldType)
  322.                 {
  323.                 case TDateFieldType:
  324.                     ((DateDialogData *)optionsData)->minValue = ((TDateField *)field)->minValue.julDate();
  325.                     ((DateDialogData *)optionsData)->maxValue = ((TDateField *)field)->maxValue.julDate();
  326.                     ((DateDialogData *)optionsData)->tfOptions = field->tfOptions;
  327.                     break;
  328.                 case TIntFieldType:
  329.                     ((IntDialogData *)optionsData)->minValue = ((TIntField *)field)->minValue;
  330.                     ((IntDialogData *)optionsData)->maxValue = ((TIntField *)field)->maxValue;
  331.                     ((IntDialogData *)optionsData)->tfOptions = field->tfOptions;
  332.                     break;
  333.                 case TLongFieldType:
  334.                     ((LongDialogData *)optionsData)->minValue = ((TLongField *)field)->minValue;
  335.                     ((LongDialogData *)optionsData)->maxValue = ((TLongField *)field)->maxValue;
  336.                     ((LongDialogData *)optionsData)->tfOptions = field->tfOptions;
  337.                     break;
  338.                 case TFloatFieldType:
  339.                     ((FloatDialogData *)optionsData)->minValue = ((TFloatField *)field)->minValue;
  340.                     ((FloatDialogData *)optionsData)->maxValue = ((TFloatField *)field)->maxValue;
  341.                     ((FloatDialogData *)optionsData)->tfOptions = field->tfOptions;
  342.                     if ( ((TFloatField *)field)->formatString == NULL )
  343.                         ((FloatDialogData *)optionsData)->formatString[0] = '\0';
  344.                     else
  345.                         strcpy( ((FloatDialogData *)optionsData)->formatString, ((TFloatField *)field)->formatString );
  346.                     break;
  347.                 default:
  348.                     ((DialogData *)optionsData)->tfOptions = field->tfOptions;
  349.                     break;
  350.                 };
  351.  
  352.             pd->setData( optionsData );
  353.  
  354.             ushort control = application->execView( pd );
  355.  
  356.             // and read it back when the dialog box is successfully closed
  357.             if( control != cmCancel )
  358.                 {
  359.                 pd->getData( optionsData );
  360.                 if (((DialogData *)optionsData)->fieldName[0] != EOS)
  361.                 field->setFieldName( ((DialogData *)optionsData)->fieldName );
  362.                 field->setFieldHint( ((DialogData *)optionsData)->fieldHint );
  363.                 field->hideChar = ((DialogData *)optionsData)->hideChar[0];
  364.                 field->securityChar = ((DialogData *)optionsData)->securityChar[0];
  365.                 field->fieldSecurity = ((DialogData *)optionsData)->fieldSecurity;
  366.                 field->currentSecurity = ((DialogData *)optionsData)->currentSecurity;
  367.                 switch (fieldType)
  368.                     {
  369.                     case TDateFieldType:
  370.                         ((TDateField *)field)->minValue = ((DateDialogData *)optionsData)->minValue;
  371.                         ((TDateField *)field)->maxValue = ((DateDialogData *)optionsData)->maxValue;
  372.                         field->tfOptions = ((DateDialogData *)optionsData)->tfOptions;
  373.                         break;
  374.                     case TIntFieldType:
  375.                         ((TIntField *)field)->minValue = ((IntDialogData *)optionsData)->minValue;
  376.                         ((TIntField *)field)->maxValue = ((IntDialogData *)optionsData)->maxValue;
  377.                         field->tfOptions = ((IntDialogData *)optionsData)->tfOptions;
  378.                         break;
  379.                     case TLongFieldType:
  380.                         ((TLongField *)field)->minValue = ((LongDialogData *)optionsData)->minValue;
  381.                         ((TLongField *)field)->maxValue = ((LongDialogData *)optionsData)->maxValue;
  382.                         field->tfOptions = ((LongDialogData *)optionsData)->tfOptions;
  383.                         break;
  384.                     case TFloatFieldType:
  385.                         ((TFloatField *)field)->minValue = ((FloatDialogData *)optionsData)->minValue;
  386.                         ((TFloatField *)field)->maxValue = ((FloatDialogData *)optionsData)->maxValue;
  387.                         if ( ((FloatDialogData *)optionsData)->formatString[0] == '\0' )
  388.                             if ( ((TFloatField *)field)->formatString != NULL )
  389.                                 {
  390.                                 delete ((TFloatField *)field)->formatString;
  391.                                 ((TFloatField *)field)->formatString = NULL;
  392.                                 }
  393.                             else
  394.                                 ((TFloatField *)field)->formatString = NULL;
  395.                         else
  396.                             ((TFloatField *)field)->setFormat(((FloatDialogData *)optionsData)->formatString);
  397.                         field->tfOptions = ((FloatDialogData *)optionsData)->tfOptions;
  398.                         break;
  399.                     default:
  400.                         field->tfOptions = ((DialogData *)optionsData)->tfOptions;
  401.                         break;
  402.                     };
  403.                 field->drawView();
  404.                 };
  405.  
  406.             // free the storage space
  407.             delete optionsData;
  408.             };
  409.         };
  410.  
  411.     application->destroy( pd );
  412.     }
  413.  
  414.  
  415. class TForm14Window : public TWindow // define a new window class for form 14's
  416. {
  417. public:
  418.  
  419.     TForm14Window( const TRect& r, const char *aTitle, short aNumber); // declare a constructor
  420.     ~TForm14Window(); // declare a destructor class
  421.     TPalette& getPalette() const; // override the getPalette function
  422.     virtual void handleEvent( TEvent& event );
  423.  
  424. };
  425.  
  426. TForm14Window::TForm14Window( const TRect& r, const char *aTitle, short aNumber):
  427.     TWindow( r, aTitle, aNumber),
  428.     TWindowInit( &TForm14Window::initFrame)
  429. {
  430.     growMode = 0;                        // Window is not resizable
  431.     flags &= ~(wfClose | wfGrow | wfZoom);
  432. }
  433.  
  434. TForm14Window::~TForm14Window()
  435. {
  436.     // Enable the Forms|Form14 menu command
  437.     disableCommand( cmFieldOptDlg );
  438. }
  439.  
  440. TPalette& TForm14Window::getPalette() const
  441. {
  442.     static TPalette palette( cpForm14, sizeof( cpForm14 )-1 );
  443.     return palette;
  444. }
  445.  
  446. void TForm14Window::handleEvent( TEvent& event )
  447. {
  448.     TWindow::handleEvent( event );
  449.  
  450.      if( event.what == evCommand )
  451.           {
  452.           switch( event.message.command )
  453.                 {
  454.                 case cmFieldOptDlg:
  455.                     event.message.command = cmDoFOD;
  456.                     event.message.infoPtr = current;
  457.                     putEvent( event );
  458.                     break;
  459.                 default:
  460.                     return;
  461.                 };
  462.             clearEvent( event );
  463.             };
  464. }
  465.  
  466.  
  467. class TBudgetApp : public TApplication
  468. {
  469.  
  470. public:
  471.  
  472.      TBudgetApp();
  473.      ~TBudgetApp();
  474.  
  475.      virtual void handleEvent( TEvent& event );
  476.      static TMenuBar *initMenuBar( TRect );
  477.      static TStatusLine *initStatusLine( TRect );
  478.  
  479. private:
  480.  
  481.      void form14();
  482. };
  483.  
  484.  
  485. TBudgetApp::TBudgetApp() :
  486.      TProgInit( &TBudgetApp::initStatusLine,
  487.                     &TBudgetApp::initMenuBar,
  488.                     &TBudgetApp::initDeskTop
  489.                  )
  490. {
  491.     // Initialize the F14MyData structure
  492.     F14MyData = new Form14Record;
  493.     TDate tempDate = "TODAY";
  494.     F14MyData->dateValue = 0;//tempDate.julDate();
  495.     F14MyData->intValue = 0;
  496.     strcpy( F14MyData->charValue, "Testing a TField field!!!");
  497.     strcpy( F14MyData->upperValue, "Testing a TUpperField field!!!");
  498.     F14MyData->longValue = 65536;
  499.     F14MyData->floatValue = 34.95;
  500.     disableCommand( cmFieldOptDlg );
  501.     form14();
  502. }
  503.  
  504. void TBudgetApp::~TBudgetApp()
  505. {
  506.     // Clear up the dynamic data storage
  507.     delete F14MyData;
  508. }
  509.  
  510. void TBudgetApp::form14()
  511. {
  512.     TView *control, *histry;
  513.     ushort value;
  514.  
  515.     // Create the new window //
  516.         TForm14Window *F14win = new TForm14Window(TRect(10, 2, 70, 21), "Test Application", wnNoNumber);
  517.  
  518.     // If unsuccessful, then return //
  519.         if (!F14win)
  520.             return;
  521.  
  522.     // Begin Inserting User-Editable Areas //
  523.  
  524.         // Demo TDateField //
  525.         TField *field = new TDateField(TRect(18,3,55,4), 39);
  526.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  527.         ((TDateField *)field)->setMin( (TDate)"TODAY" - 7 );
  528.         ((TDateField *)field)->setMax( (TDate)"TODAY" + 7 );
  529.         ((TDateField *)field)->value.setOption(NO_CENTURY, 1);
  530.         F14win->insert(field);
  531.         F14win->insert(new TLabel(TRect(5,3,17,4), "T~D~ateField:", field));
  532.  
  533.         // Demo TIntField //
  534.         field = new TIntField(TRect(18,5,55,6), 39);
  535.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  536.         ((TIntField *)field)->setMin( -10 );
  537.         ((TIntField *)field)->setMax( 10 );
  538.         F14win->insert(field);
  539.         F14win->insert(new TLabel(TRect(5,5,17,6), "T~I~ntField:", field));
  540.  
  541.         // Demo TField //
  542.         field = new TField(TRect(18,7,55,8), 128);
  543.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  544.         F14win->insert(field);
  545.         F14win->insert(new TLabel(TRect(5,7,17,8), "~T~Field:", field));
  546.  
  547.         // Demo TUpperField //
  548.         field = new TUpperField(TRect(18,9,55,10), 128);
  549.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  550.         F14win->insert(field);
  551.         F14win->insert(new TLabel(TRect(5,9,17,10), "T~U~pperField:", field));
  552.  
  553.         // Demo TLongField //
  554.         field = new TLongField(TRect(18,11,55,12), 39);
  555.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  556.         F14win->insert(field);
  557.         F14win->insert(new TLabel(TRect(5,11,17,12), "T~L~ongField:", field));
  558.  
  559.         // Demo TFloatField //
  560.         field = new TFloatField(TRect(18,13,55,14), 39);
  561.         field->setTFOptions(tfBeepError | tfEnterTabs | tfStayError, True);
  562.         F14win->insert(field);
  563.         F14win->insert(new TLabel(TRect(5,13,17,14), "TFl~o~atField:", field));
  564.  
  565.         // Select the first field on the form
  566.         F14win->selectNext(False);
  567.  
  568.         // Insert the form onto the desktop
  569.         deskTop->insert( F14win );
  570.  
  571.         enableCommand( cmFieldOptDlg );
  572.  
  573.         // Initialize the form's data
  574.         F14win->setData( F14MyData );
  575.  
  576.         //Return the window pointer
  577.         return;
  578. }
  579.  
  580. void TBudgetApp::handleEvent( TEvent& event )
  581. {
  582.      TApplication::handleEvent( event );
  583.      if( event.what == evCommand )
  584.           {
  585.           switch( event.message.command )
  586.                 {
  587.                 case cmDoFOD:
  588.                     TFieldOptDlg( (TField *)event.message.infoPtr, this );
  589.                     break;
  590.                 default:
  591.                      return;
  592.                 }
  593.           clearEvent( event ); // Clear the event after handling it
  594.           }
  595. }
  596.  
  597. TMenuBar *TBudgetApp::initMenuBar( TRect r )
  598. {
  599.  
  600.      r.b.y = r.a.y+1;
  601.  
  602.      return new TMenuBar( r,
  603.         *new TSubMenu( "~F~ile", kbAltF ) +
  604.           *new TMenuItem( "E~x~it", cmQuit, cmQuit, hcNoContext, "Alt-X" )
  605.           );
  606.  
  607. }
  608.  
  609. TStatusLine *TBudgetApp::initStatusLine( TRect r )
  610. {
  611.      r.a.y = r.b.y-1;
  612.      return new TStatusLine( r,
  613.           *new TStatusDef( 0, 0xFFFF ) +
  614.                 *new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit ) +
  615.                 *new TStatusItem( "~F2~ tfOptions", kbF2, cmFieldOptDlg ) +
  616.                 *new TStatusItem( 0, kbF10, cmMenu )
  617.                 );
  618. }
  619.  
  620. int main()
  621. {
  622.      TBudgetApp BudgetApp;
  623.      BudgetApp.run();
  624.      return 0;
  625. }
  626.