home *** CD-ROM | disk | FTP | other *** search
- //========================================================================
- // The following example routines have been provided by the Technical
- // Support staff at Borland International. They are provided as a
- // courtesy and not as part of a Borland product, and as such, are
- // provided without the assurance of technical support or any specific
- // guarantees.
- //========================================================================
- //
- // funkview.cpp: The member function definition for TMyApp.
- //
-
- #define Uses_TView
- #define Uses_TWindow
- #define Uses_TPalette
- #define Uses_TDrawBuffer
- #define Uses_TStreamable
- #define Uses_TStreamableClass
- #include <tv.h>
- __link( RView );
- __link( RWindow );
-
- #include <stdlib.h> // For random number generator
-
- #include "funkview.h" // Class definition
-
-
- //
- // FunkyView constructor
- //
-
- FunkyView::FunkyView( TRect& r, char *word ) :
- TView( r )
- {
- text = newStr( word );
- }
-
- void FunkyView::draw()
- {
- TDrawBuffer buf;
- char color = random(16); // This has bizarre implications if a
- // monochrome monitor or mode BW80 is used.
-
- buf.moveChar(0, ' ', 112, size.x);
- writeLine(0, 0, size.x, 5, buf);
- buf.moveStr(0, text, color + 112);
- writeLine(0, 2, size.x, 1, buf);
- }
-
-
- const char * const FunkyView::name = "FunkyView";
-
- void FunkyView::write( opstream& os )
- {
- TView::write( os );
- os.writeString(text);
- }
-
- void *FunkyView::read( ipstream& is )
- {
- text = new char [32];
- TView::read( is );
- is.readString(text, 32);
-
- return this;
- }
-
- TStreamable *FunkyView::build()
- {
- return new FunkyView( streamableInit );
- }
-
- TStreamableClass RFunkyView( FunkyView::name,
- FunkyView::build,
- __DELTA( FunkyView )
- );
-
- //
- // FunkyWindow
- //
-
- FunkyWindow::FunkyWindow( TRect& bounds, char *words ) :
- TWindow( bounds, 0, wnNoNumber ),
- TWindowInit( FunkyWindow::initFrame )
- {
- bounds = getExtent();
- bounds.grow(-1, -1);
-
- flags = wfMove | wfClose;
-
- insert( new FunkyView(bounds, words) );
- }
-
-
- // stream support
- //
- // Use inherited read/write functions since there are no data members
- // in this object.
- //
-
- const char * const FunkyWindow::name = "FunkyWindow";
-
- TStreamable *FunkyWindow::build()
- {
- return new FunkyWindow( streamableInit );
- }
-
- TStreamableClass RFunkyWindow( FunkyWindow::name,
- FunkyWindow::build,
- __DELTA( FunkyWindow )
- );
-
-