[-----------------]
|  TVPAL Package  |
[-----------------]

Copyright (c) 1992 CC Software
All rights reserved

Author: Craig Nelson
        71151,3264


TVPAL.ZIP Contents
------------------

The following files should be in TVPAL.ZIP:

    TVPAL.H         : Header file for inclusion into TVision programs
    TVPAL.CPP       : Source code for the TStreamPalette class
    TVPAL.TXT       : Description of the class in general.
    EXAMPLE.CPP     : Example program for using TStreamPalette


Please make sure you have these files.  If get some other version
feel free to write the author and ask for the complete package.


Description
-----------
Streamable palette is something Borland left out of the Turbo Vision
hierarchy.  Through multiple inheritence we can solve this problem
with the class TStreamPalette.  Since it is derived from both the
TPalette and TStreamable classes, you can freely use all the members
of both in your applications.  No new members are added so for complete
descriptions on what TStreamPalette is capable of see the source code,
and the documentation on TPalette and TStreamable from Borland


Streamablilty
-------------
Suppose you wanted to store serveral versions of the application
palette on an object stream, for example, to have serveral predefined
color schemes available to the user.  Using the standard TPalette and
regular streams requires more work than you deserve to go through.
TStreamPalette solves this problem.  For example, say you want to
save the application palette on a stream.  Under normal stream
operation this is not at all intuitive. However, using TStreamPalette,
the code (assuming it is somewhere in the TApplication derived class
members) simplifies to the following:

TApp::savePalette( const char *fileName )
{
  fpstream fp( fileName, ios::binary | ios::out );
  TStreamablePalette *sp;

  if ( fp.good() )
  {
     sp = new TStreamPalette( application->getPalette() );
     if ( sp )
     {
        fp << sp;
        delete sp;
     }
  }
};
// --------------------------------------------------------------------



Reading the object written in the above code and assigning it to the
application would simplify to the following:


TApp::readPalette( const char *fileName )
{
  fpstream fp( fileName, ios::binary | ios::in | ios::nocreate )
  TStreamPalette *sp;

  if ( fp.good() )
  (
     fp >> sp;
     if ( sp )
     {
        application->getPalette() = *sp;
        delete sp;
     }
  }
};
// --------------------------------------------------------------------




Example Program
---------------
The example program uses the TVPAL object definitions for a resource
file that can store the application palette.  Please make note that
if you are using the TStreamPalette object class and are actually
performing stream IO (why else would you use it) the RStreamPalette
stream registration record MUST be __link() 'ed in to any source
module calling for this IO.  These aren't my rules; their Borlands :)

Feel free to play with the example, possibly adding the functionality
for the user to create different color schemes and save them in the
resource file.  A TListBox in a TDialog object to save/restore color
schemes would make for a nice touch, and I would be interested in what
you all think.

Above all, have FUN.  Turbo Vision is easy to break, but if you're
carefull you can create wonderfull user options with just a few
program lines.
