home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / srcos2 / vcolor.cpp < prev    next >
C/C++ Source or Header  |  1999-03-03  |  4KB  |  125 lines

  1. //===============================================================
  2. // vcolor.cxx: vColor class for drawing - Windows
  3. //
  4. // Copyright (C) 1995,1996,1997,1998  Bruce E. Wampler
  5. //
  6. // This file is part of the V C++ GUI Framework, and is covered
  7. // under the terms of the GNU Library General Public License,
  8. // Version 2. This library has NO WARRANTY. See the source file
  9. // vapp.cxx for more complete information about license terms.
  10. //===============================================================
  11. #include <v/vos2.h>        // for OS/2 stuff
  12. #include <v/vapp.h>
  13. #include <v/vcolor.h>
  14.   // Define 16 standard colors for use by everyone
  15.   vColor vGlobalStdColors[16] =
  16.   {
  17.     vColor( 0, 0, 0),    // vC_Black
  18.     vColor( 255, 0, 0),    // vC_Red
  19.     vColor( 127, 0, 0),    // vC_DimRed
  20.     vColor( 0, 255, 0),    // vC_Green
  21.     vColor( 0, 127, 0),    // vC_DimGreen
  22.     vColor( 0, 0, 255),    // vC_Blue
  23.     vColor( 0, 0, 127),    // vC_DimBlue
  24.     vColor( 255, 255, 0),    // vC_Yellow
  25.     vColor( 127, 127, 0),    // vC_DimYellow
  26.     vColor( 255, 0, 255),    // vC_Magenta
  27.     vColor( 127, 0, 127),    // vC_DimMagenta
  28.     vColor( 0, 255, 255),    // vC_Cyan
  29.     vColor( 0, 127, 127),    // vC_DimCyan
  30.     vColor( 63, 63, 63),    // vC_DarkGray
  31.     vColor( 127, 127, 127),    // vC_MedGray
  32.     vColor( 255, 255, 255)    // vC_White
  33.   };
  34.  
  35.   char* vGlobalColorNames[16] =
  36.   {
  37.     "Black", "Red", "Dim Red", "Green", "Dim Green", "Blue",
  38.     "Dim Blue", "Yellow", "Dim Yellow", "Magenta", "Dim Magenta",
  39.     "Cyan", "Dim Cyan", "Dark Gray", "Med Gray", "White"
  40.   };
  41.  
  42. // Following added in 1.21 for DLL
  43. //=======================>>> vGetStdColors <<<===========================
  44.   vColor* vGetStdColors()
  45.   {
  46.     return &vGlobalStdColors[0];
  47.   }
  48.  
  49. //=======================>>> vGetColorNames <<<===========================
  50.   char**  vGetColorNames()
  51.   {
  52.     return &vGlobalColorNames[0];
  53.   }
  54.  
  55. //=======================>>> vColor::vColor <<<===========================
  56.   vColor::vColor(unsigned int rd, unsigned int gr, unsigned int bl)
  57.   {
  58.     _r = (unsigned char) rd;
  59.     _g = (unsigned char) gr;
  60.     _b = (unsigned char) bl;
  61.     _pixel = SETRGB2(0,_r,_g,_b);
  62.   }
  63.  
  64. //=======================>>> vColor::BitsOfColor <<<===========================
  65. // returns the number of bits per pixel (eg. 8, 16, 24)
  66.   int vColor::BitsOfColor() VCONST
  67.   {
  68.     HPS hdc = WinGetScreenPS(HWND_DESKTOP);
  69.     LONG bits;
  70.     DevQueryCaps (hdc, CAPS_COLOR_BITCOUNT, 1, &bits);
  71.     WinReleasePS(hdc);
  72.     return bits;
  73.   }
  74.  
  75. //=======================>>> vColor::ResetColor <<<===========================
  76.   void vColor::ResetColor(unsigned int rd, unsigned int gr, unsigned int bl)
  77.   {
  78.     _r = (unsigned char) rd;
  79.     _g = (unsigned char) gr;
  80.     _b = (unsigned char) bl;
  81.     _pixel = SETRGB(_r,_g,_b);
  82.   }
  83. //=======================>>> vColor::ResetColor <<<===========================
  84.   void vColor::ResetColor(VCONST vColor& c)
  85.   {
  86.     _r = c.r();
  87.     _g = c.g();
  88.     _b = c.b();
  89.     _pixel = SETRGB(_r,_g,_b);
  90.   }
  91. //=======================>>> vColor::Set <<<===========================
  92.   void vColor::Set(unsigned int rd, unsigned int gr, unsigned int bl)
  93.   {
  94.     _r = (unsigned char) rd;
  95.     _g = (unsigned char) gr;
  96.     _b = (unsigned char) bl;
  97.     _pixel = SETRGB(_r,_g,_b);
  98.   }
  99. //=======================>>> vColor::Set <<<===========================
  100.   void vColor::Set(VCONST vColor& c)
  101.   {
  102.     _r = c.r();
  103.     _g = c.g();
  104.     _b = c.b();
  105.     _pixel = SETRGB(_r,_g,_b);
  106.   }
  107. //=======================>>> vColor::SetR <<<===========================
  108.   void vColor::SetR(unsigned int rd)
  109.   {
  110.     _r = (unsigned char) rd;
  111.     _pixel = SETRGB(_r,_g,_b);
  112.   }
  113. //=======================>>> vColor::SetG <<<===========================
  114.   void vColor::SetG(unsigned int gr)
  115.   {
  116.     _g = (unsigned char) gr;
  117.     _pixel = SETRGB(_r,_g,_b);
  118.   }
  119. //=======================>>> vColor::SetB <<<===========================
  120.   void vColor::SetB(unsigned int bl)
  121.   {
  122.     _b = (unsigned char) bl;
  123.     _pixel = SETRGB(_r,_g,_b);
  124.   }
  125.