File: vcolor.cpp

package info (click to toggle)
v1 1.20-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 6,240 kB
  • ctags: 9,439
  • sloc: cpp: 48,033; ansic: 8,939; makefile: 1,369; sh: 30
file content (119 lines) | stat: -rw-r--r-- 3,455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//===============================================================
// vcolor.cxx: vColor class for drawing - Windows
//
// Copyright (C) 1995,1996, 1997, 1998  Bruce E. Wampler
//
// This file is part of the V C++ GUI Framework, and is covered
// under the terms of the GNU Library General Public License,
// Version 2. This library has NO WARRANTY. See the source file
// vapp.cxx for more complete information about license terms.
//===============================================================

#include <v/vwin32.h>		// for Win 32 stuff
#include <v/vapp.h>
#include <v/vcolor.h>

    // Define 16 standard colors for use by everyone

    vColor vStdColors[16] =
      {
	vColor( 0, 0, 0),	// vC_Black
	vColor( 255, 0, 0),	// vC_Red
	vColor( 127, 0, 0),	// vC_DimRed
	vColor( 0, 255, 0),	// vC_Green
	vColor( 0, 127, 0),	// vC_DimGreen
	vColor( 0, 0, 255),	// vC_Blue
	vColor( 0, 0, 127),	// vC_DimBlue
	vColor( 255, 255, 0),	// vC_Yellow
	vColor( 127, 127, 0),	// vC_DimYellow
	vColor( 255, 0, 255),	// vC_Magenta
	vColor( 127, 0, 127),	// vC_DimMagenta
	vColor( 0, 255, 255),	// vC_Cyan
	vColor( 0, 127, 127),	// vC_DimCyan
	vColor( 63, 63, 63),	// vC_DarkGray
	vColor( 127, 127, 127),	// vC_MedGray
	vColor( 255, 255, 255)	// vC_White
      };

    char* vColorNames[16] =
	{
	"Black", "Red", "Dim Red", "Green", "Dim Green", "Blue",
	"Dim Blue", "Yellow", "Dim Yellow", "Magenta", "Dim Magenta",
	"Cyan", "Dim Cyan", "Dark Gray", "Med Gray", "White"
	};

//=======================>>> vColor::vColor <<<===========================
  vColor::vColor(unsigned int rd, unsigned int gr, unsigned int bl)
  {
    _r = (unsigned char) rd;
    _g = (unsigned char) gr;
    _b = (unsigned char) bl;
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::BitsOfColor <<<===========================
  int vColor::BitsOfColor()
  {

    HDC hdc = ::GetDC(theApp->winHwnd());
    int bits = ::GetDeviceCaps(hdc,BITSPIXEL);
    ::ReleaseDC(theApp->winHwnd(),hdc);
    return bits;
  }

//=======================>>> vColor::ResetColor <<<===========================
  void vColor::ResetColor(unsigned int rd, unsigned int gr, unsigned int bl)
  {
    _r = (unsigned char) rd;
    _g = (unsigned char) gr;
    _b = (unsigned char) bl;
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::ResetColor <<<===========================
  void vColor::ResetColor(vColor& c)
  {
    _r = c.r();
    _g = c.g();
    _b = c.b();
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::Set <<<===========================
  void vColor::Set(unsigned int rd, unsigned int gr, unsigned int bl)
  {
    _r = (unsigned char) rd;
    _g = (unsigned char) gr;
    _b = (unsigned char) bl;
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::Set <<<===========================
  void vColor::Set(vColor& c)
  {
    _r = c.r();
    _g = c.g();
    _b = c.b();
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::SetR <<<===========================
  void vColor::SetR(unsigned int rd)
  {
    _r = (unsigned char) rd;
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::SetG <<<===========================
  void vColor::SetG(unsigned int gr)
  {
    _g = (unsigned char) gr;
    _pixel = RGB(_r,_g,_b);
  }

//=======================>>> vColor::SetB <<<===========================
  void vColor::SetB(unsigned int bl)
  {
    _b = (unsigned char) bl;
    _pixel = RGB(_r,_g,_b);
  }