home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 9.ddi / TVSRC.ZIP / MAPCOLOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.7 KB  |  42 lines

  1. /*-------------------------------------------------------------------*/
  2. /* filename -   mapcolor.cpp                                         */
  3. /*                                                                   */
  4. /* function(s)                                                       */
  5. /*          mapColor -- maps a color into a pointer into the current */
  6. /*                      palette.                                     */
  7. /*-------------------------------------------------------------------*/
  8.  
  9. /*-------------------------------------------------------------------*/
  10. /*                                                                   */
  11. /*    Turbo Vision -  Version 1.0                                    */
  12. /*                                                                   */
  13. /*                                                                   */
  14. /*    Copyright (c) 1991 by Borland International                    */
  15. /*    All Rights Reserved.                                           */
  16. /*                                                                   */
  17. /*-------------------------------------------------------------------*/
  18.  
  19. #define Uses_TView
  20. #define Uses_TGroup
  21. #include <tv.h>
  22.  
  23. uchar TView::mapColor( uchar color )
  24. {
  25.     if( color == 0 )
  26.         return errorAttr;
  27.     TView *cur = this;
  28.     do  {
  29.         TPalette& p = cur->getPalette();
  30.         if( p[0] != 0 )
  31.             {
  32.             if( color > p[0] )
  33.                 return errorAttr;
  34.             color = p[color];
  35.             if( color == 0 )
  36.                 return errorAttr;
  37.             }
  38.         cur = cur->owner;
  39.         } while( cur != 0 );
  40.     return color;
  41. }
  42.