home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / SETCOL.ZIP / COLORSET.PRN next >
Encoding:
Text File  |  1990-04-30  |  9.4 KB  |  226 lines

  1.  
  2.  
  3.  
  4.  
  5.                               Color Setup Module
  6.  
  7.  
  8.                       Copyright (c) 1990 Jeffrey S. Kline
  9.  
  10.  
  11.  
  12.                 A user color configuration enhancment utility.
  13.  
  14.  
  15.                        In the spirit of "C your Pascal"!
  16.  
  17.  
  18.  
  19.                          Share-Ware Release Vers. 1.00
  20.  
  21.  
  22.                                       For
  23.                     Microsoft's Quick-Pascal v1.0 compiler
  24.                                       and
  25.              Borlands Turbo Pascal compilers Vers. 4.0, 5.0 & 5.5
  26.  
  27.  
  28.  
  29.  
  30.     Introduction:
  31.  
  32.     For some time now, I have been working on and writing many programs and
  33.     utilities for around my office and home as well as for friends. In this
  34.     time, I have not been able to do many of the nicer things with them
  35.     because there just wasn't time. Well, now I have made some time to
  36.     increase the size and types of my libraries to make like with this PC a
  37.     little more easier.
  38.  
  39.     Seems that of late, I've wanted to put personalized touches into all my
  40.     programs and couldn't find an easy way of doing it. One of these just
  41.     happens to be color setups for various screens, data entry lines, and
  42.     so forth. I'm currently in the middle of developing a commercial
  43.     program of which this module will be used. I wanted an easy way of
  44.     calling up the color setup utility and also have it smart and easy
  45.     enough to use both from the programmer standpoint as well as the end
  46.     user of the software that makes use of this module.
  47.  
  48.     Take a "gander" at the source code for the test program that is
  49.     supplied with this archive and you'll see just how easy it is to use. A
  50.     more detailed look here is forthcoming.
  51.  
  52.  
  53.     SPECIAL NOTE REGARDING LIABILITY:
  54.  
  55.     NOTE: Under no circumstances am I liable for any mis-use or in-ability
  56.     to use this code. Further more, I shall not be held accountable for any
  57.     damages that might arise out of the use of or in-ability to use this
  58.     work. This include any consequential or inconsequential damages.
  59.  
  60.     This code has been tested on all the compilers listed and has performed
  61.     flawlessly. If you should have problems with it, most likely, you have
  62.     something wrong in one of your host program's VAR's or TYPE's. You
  63.     should be quite familiar with Pascal coding before attempting to make
  64.     use of this code.
  65.  
  66.     If you like what you see and wish to support the author in his on-going
  67.     endeavors, please remit $15 in personal checkque or money order to the
  68.     address listed at the end of this document. You will be sent a current
  69.     copy of the source code on disk and any further information regarding
  70.     it if deemed necessary.
  71.  
  72.  
  73.     Compatibility:
  74.  
  75.     This code is supplied in Borland compatible TPU's for versions 4.0 and
  76.     5.0 and 5.5(see note) of their compiler. DEBUG is disabled so as to
  77.     help protect my work. In addition to this a Microsoft QuickPascal QPU
  78.     is supplied for those who either use it solely or in addition to
  79.     Borlands compilers.
  80.  
  81.     This code is fully portable among compilers as well as being
  82.     convertible to Microsoft's Full Pascal compilers. If you should wish to
  83.     get a copy to run under the Full compiler for Microsoft, you must
  84.     register to get the code. No object files will be supplied in this
  85.     archive.
  86.  
  87.     The test program also is fully compatible directly under any of the
  88.     above mentioned compilers.
  89.  
  90.     Also note that it tested fine using Turbo Technojock code and Turbo
  91.     Professional code as well so those of you using those sets of libraries
  92.     will have no trouble.
  93.  
  94.     NOTE: For those who have Turbo Pascal vers. 5.5, you will have to make
  95.     special arrangements with me to get a 5.5 compatible TPU prior to
  96.     registering but... A fully functional test program is supplied to which
  97.     you can make a pretty good evaluation based on what you see on your
  98.     screen and what you see in the source code for the test program.
  99.  
  100.  
  101.     Preparatory:
  102.  
  103.     Before making use of the unit, you must make some things in your host
  104.     program source code. These are listed below with a short description
  105.     about why they are there.
  106.  
  107.     MainFG     : Integer;  { your host programs main color selector }
  108.     MainBG     : Integer;  { same but for Background color. }
  109.     SecFG      : Integer;  { an alternate Forground color selector }
  110.     SecBG      : Integer;  { alternate Background color selector }
  111.     ...                    { as many others as you either see fit or want }
  112.     Change     : Boolean;  { a boolean variable used to make the call to }
  113.                            { the function. The return ordinal will tell  }
  114.                            { you if you need to take any action with it. }
  115.  
  116.     The naming conventions used here are strictly by choice or preference.
  117.     Since this language is very flexible in naming of variables, constants
  118.     and the like, you can essentially use just about any names you wish.
  119.  
  120.     Next thing is to design a routine that will cycle through a loop if you
  121.     will or a REPEAT - UNTIL. The choice is yours how you do it. Also note
  122.     that in this version, the screen is not saved prior to displaying the
  123.     selection window. If you are overlaying a screen you wish to restore,
  124.     you should save it to an array and restore it upon exit. There is a
  125.     nice one contained in the Spreadsheet program that comes with your
  126.     compiler (Borland) and it works pretty well. Basically, if you are
  127.     going to be working with many color selection options, you would want
  128.     to do it this way;
  129.  
  130.         Change := Select_Colors(ColorAttr); { if attribute word is known }
  131.  
  132.         or if attribute word is not known, call it like this;
  133.  
  134.         Change := Select_Colors(Attr(MainFG,MainBG));
  135.                                      { if attribute word is not known }
  136.  
  137.     Attr(FG,BG) is in the UNIT and is fully available to your program.
  138.  
  139.     ColorAttr is the combined WORD value for the default position in the
  140.     selection window to go to. Most commonly, you would want to place the
  141.     variable "TEXTATTR" or if you are passing a copy of your present
  142.     program colors, use the converter "ATTR(FG,BG)" to combine the
  143.     foreground and background into one byte.
  144.  
  145.     After the function call, test "Change" and if it's TRUE, then you
  146.     should have something like this happen:
  147.  
  148.         If Change then
  149.         Begin
  150.             MainFG := ChosenFG;  { copy units var to yours }
  151.             MainBG := ChosenBG;          { ditto }
  152.             MainColors := ChosenColors;  { ditto, optional }
  153.         End;
  154.  
  155.     If Change is FALSE, this will be because the user pressed the "ESC"
  156.     key. When this happens, you can either go through the same loop above
  157.     or just do nothing. Either way, the function will not alter the colors.
  158.  
  159.     "ChosenFG" and "ChosenBG" are variables that will contain the selected
  160.     color values if "Change" is TRUE. ChosenColors is also in the unit but
  161.     is will contain the selected colors combined into a WORD value (some
  162.     folks just love splitting words!). This is essentially it. In the
  163.     listing above, you are simply getting a copy of the values from the
  164.     vars in the unit to your local programs vars. From there, you call your
  165.     local program vars for the color defaults.
  166.  
  167.  
  168.     What.. More?!
  169.  
  170.     For your convenience, two more procedures have been written to go into
  171.     this module. They are:
  172.  
  173.         EmptyBox(X1,X2,Y1,Y2 : Byte; FG, BG : Integer; Box : Byte);
  174.  
  175.         FilledBox(X1,X2,Y1,Y2 : Byte; FG, BG : Integer; Box : Byte);
  176.  
  177.     Where X1,X2,Y1,Y2 are coordinates for box and FG and BG are the colors
  178.     to use. Box is either a 1 for a single lined box and 2 is double lined.
  179.     Note that no test is made in this version to insure that BOX is either
  180.     1 or 2 so be careful!
  181.  
  182.     FilledBox is the same as EmptyBox except that it is filled with the
  183.     passed BG color.
  184.  
  185.         WriteCRT(X,Y,Attr : Byte; Ch : Char);
  186.  
  187.     This just does a fast write directly to the video display. Note that on
  188.     older CGA's, snow will be present during a write to the screen. You can
  189.     pass either pointers to Char or Char literals.
  190.  
  191.         WriteLineCRT(X,Y,Attr : Byte; St : String);
  192.  
  193.     This is the same thing except it is used for whole strings. You can
  194.     pass either pointers to strings or string literals. Note that on older
  195.     CGA's, snow will be present during screen writes.
  196.  
  197.     COLOR NAMES are already defined in the unit! The full DOS colors [0..15]
  198.     defined in an array by which your program can reference to pick up the
  199.     color names in string form. (See the example program code)
  200.  
  201.     These functions are here and operate in these manners strictly in this
  202.     version. In a full release version to registered users, direct screen
  203.     writes will function correctly without snow on CGA's as well as be much
  204.     FASTER!
  205.  
  206.     More plans are for mouse support to be added as well as two kinds of
  207.     color selection functions, one for all attributes like this one and one
  208.     with just the normal (NON-BLINKING) attributes in a smaller window.
  209.  
  210.  
  211.     Address any and all correspondence and critiques to:
  212.  
  213.             Jeffrey S. Kline
  214.             Systems 80 Consulting Services
  215.             10815 W. 88th Terr.
  216.             Overland Park, KS 66214
  217.             (913) 894-0816  (Phone calls you your bill only!)
  218.             GENIE: JSKLINE
  219.  
  220.             PRICE:    $15.00 ( US Funds only please )
  221.  
  222.     {end.}
  223.  
  224.  
  225.  
  226.