home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------*/
- /* */
- /* Turbo Vision 1.0 */
- /* Copyright (c) 1991 by Borland International */
- /* */
- /* Budget FORM14 Editor Program File */
- /*---------------------------------------------------------*/
-
- #define Uses_MsgBox
- #define Uses_TApplication
- #define Uses_TButton
- #define Uses_TDeskTop
- #define Uses_TDialog
- #define Uses_TEvent
- #define Uses_TEventQueue
- #define Uses_TFrame
- #define Uses_TIndicator
- #define Uses_TKeys
- #define Uses_TLabel
- #define Uses_TMenuBar
- #define Uses_TMenuItem
- #define Uses_TProgram
- #define Uses_TRect
- #define Uses_TStaticText
- #define Uses_TStatusDef
- #define Uses_TStatusItem
- #define Uses_TStatusLine
- #define Uses_TStreamable
- #define Uses_TStreamableClass
- #define Uses_TSubMenu
- #define Uses_TView
- #define Uses_TWindow
-
- #define Uses_TField
-
- #include <tv.h>
- #include "TField.h"
-
- __link( RInputLine )
-
-
- #if !defined( __STRING_H )
- #include <string.h>
- #endif // __STRING_H
-
- #if !defined( __STDLIB_H )
- #include <stdlib.h>
- #endif // __STDLIB_H
-
- #if !defined( __STRSTREAM_H )
- #include <strstream.h>
- #endif // __STRSTREAM_H
-
-
- const cmForm14 = 100;
- const cmScroll = 101;
- const cmJustify = 102;
-
- short gWinNumber = 0; // Window Number
- short gForm14Active = 0; // Count of Form14 windows open
- TField *gfield;
-
- #define cpForm14 "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F"\
- "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F"
-
- struct Form14Record
- {
- char Program[7];
- };
-
- Form14Record *F14MyData;
-
-
- class TForm14Window : public TWindow // define a new window class for form 14's
- {
- public:
-
- TForm14Window( const TRect& r, const char *aTitle, short aNumber); // declare a constructor
- ~TForm14Window(); // declare a destructor class
- TPalette& getPalette() const; // override the getPalette function
- };
-
- TForm14Window::TForm14Window( const TRect& r, const char *aTitle, short aNumber):
- TWindow( r, aTitle, aNumber),
- TWindowInit( &TForm14Window::initFrame)
- {
- growMode = 0; // Window is not resizable
- flags &= ~(wfGrow | wfZoom); // set the window to non-growable & non-zoomable
- }
-
- TForm14Window::~TForm14Window()
- {
- // Enable the Forms|Form14 menu command
- enableCommand( cmForm14 );
-
- // Decrement the gForm14Active variable
- gForm14Active--;
-
- }
-
- TPalette& TForm14Window::getPalette() const
- {
- static TPalette palette( cpForm14, sizeof( cpForm14 )-1 );
- return palette;
- }
-
-
-
- class TBudgetApp : public TApplication
- {
-
- public:
-
- TBudgetApp();
- ~TBudgetApp();
-
- virtual void handleEvent( TEvent& event );
- static TMenuBar *initMenuBar( TRect );
- static TStatusLine *initStatusLine( TRect );
-
- private:
-
- void form14();
- };
-
- TBudgetApp::TBudgetApp() :
- TProgInit( &TBudgetApp::initStatusLine,
- &TBudgetApp::initMenuBar,
- &TBudgetApp::initDeskTop
- )
- {
- // Initialize the F14MyData structure
- F14MyData = new Form14Record;
- strcpy( F14MyData->Program, "013003" );
- }
-
- void TBudgetApp::~TBudgetApp()
- {
- // Clear up the dynamic data storage
- delete F14MyData;
- }
-
- void TBudgetApp::form14()
- {
- TView *control, *histry;
- ushort value;
-
- // Create the new window //
- TForm14Window *F14win = new TForm14Window(TRect(0, 0, 80, 23), "Test Application", wnNoNumber);
-
- // If unsuccessful, then return //
- if (!F14win)
- return;
-
- // Begin Inserting User-Editable Areas //
-
- // Insert the Program # input area //
- gfield = new TField(TRect(68,3,75,4), 7);
- gfield->setScroll(False);
- F14win->insert(gfield);
- F14win->insert(new TLabel(TRect(55,3,67,4), "~T~est Field:", gfield));
-
-
- // Insert the Scroll Button onto the form //
- control = new TButton(TRect(66,9,77,11), "~S~croll", cmScroll, bfNormal);
- F14win->insert(control);
-
-
- // Insert the Justify Button onto the form //
- control = new TButton(TRect(66,13,77,15), "~J~ustify", cmJustify, bfNormal);
- F14win->insert(control);
-
-
- // Select the first field on the form
- F14win->selectNext(False);
-
- // Insert the form onto the desktop
- deskTop->insert( F14win );
-
- // Increment the form14 open counter
- gForm14Active++;
-
- // Disable the Forms|Form14 command
- disableCommand( cmForm14 );
-
- // Initialize the form's data
- F14win->setData( F14MyData );
-
- //Return the window pointer
- return;
- }
-
- void TBudgetApp::handleEvent( TEvent& event )
- {
- TApplication::handleEvent( event );
- if( event.what == evCommand )
- {
- switch( event.message.command )
- {
- case cmForm14:
- // Open a form14 window if one is not already open
- if( gForm14Active < 1 )
- form14();
- break;
- case cmScroll:
- // Open a message dialog box
- ushort yesno = messageBox( "Allow the test field to scroll?", mfYesButton | mfNoButton );
- if (yesno != cmCancel)
- if (yesno == cmYes )
- gfield->setScroll(True);
- else
- gfield->setScroll(False);
- drawView();
- break;
- case cmJustify:
- // Open a message dialog box
- ushort yesno1 = messageBox( "Enter new justification value:\nYes = jLeft, No = jRight", mfYesButton | mfNoButton );
- if (yesno1 != cmCancel)
- if (yesno1 == cmYes )
- gfield->setJustification(jLeft);
- else
- gfield->setJustification(jRight);
- break;
- default:
- return;
- }
- clearEvent( event ); // Clear the event after handling it
- }
- }
-
- TMenuBar *TBudgetApp::initMenuBar( TRect r )
- {
-
- r.b.y = r.a.y+1;
-
- return new TMenuBar( r,
- *new TSubMenu( "~F~orms", kbAltF ) +
- *new TMenuItem( "~T~est Form...", cmForm14, kbAltF ) +
- newLine() +
- *new TMenuItem( "E~x~it", cmQuit, cmQuit, hcNoContext, "Alt-X" )
- );
-
- }
-
- TStatusLine *TBudgetApp::initStatusLine( TRect r )
- {
- r.a.y = r.b.y-1;
- return new TStatusLine( r,
- *new TStatusDef( 0, 0xFFFF ) +
- *new TStatusItem( "~Alt-X~ Exit", kbAltX, cmQuit ) +
- *new TStatusItem( "~Ctrl-F4~ Close", kbCtrlF4, cmClose ) +
- *new TStatusItem( 0, kbF10, cmMenu )
- );
- }
-
- int main()
- {
- TBudgetApp BudgetApp;
- BudgetApp.run();
- return 0;
- }
-