OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / win32_color.cpp
1 /*
2   win32_color.cpp
3   base class of screen driver
4
5   Made by Studio Breeze. 2002
6
7   Permission is hereby granted, free of charge, to any person obtaining a copy
8   of this software and associated documentation files (the "Software"), to deal
9   in the Software without restriction, including without limitation the rights
10   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11   copies of the Software, and to permit persons to whom the Software is
12   furnished to do so, subject to the following conditions:
13
14   The above copyright notice and this permission notice shall be included in
15   all copies or substantial portions of the Software.
16
17   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23   THE SOFTWARE.
24  */
25 #include "stdafx.h"
26
27 #include "sted_screen_win32.h"
28
29 // private
30 COLORREF
31 CSTedScreenWin32::PageToColor(int in_page)
32 {
33   int c = 0;
34   COLORREF r;
35
36   switch (in_page) {
37           case 0: c=1;break;
38           case 1: c=2;break;
39           case 2: c=3;break;
40           case 3: c=0;break;
41   }
42
43   r = RGB(fTextPalette[c].fBlue,
44           fTextPalette[c].fGreen,
45           fTextPalette[c].fRed);
46   return r;
47 }
48
49 // color
50 int
51 CSTedScreenWin32::SetGraphicsPalette(int in_pal, int in_color)
52 {
53   int r,g,b;
54
55   if (in_pal<0 || in_pal>=fMaxGraphicsColor) return 0;
56
57   r=((in_color>>6)&0x001f)<<3;
58   b=((in_color>>1)&0x001f)<<3;
59   g=((in_color>>11)&0x001f)<<3;
60
61   fGraphicsPalette[in_pal].fRed = r;
62   fGraphicsPalette[in_pal].fGreen = g;
63   fGraphicsPalette[in_pal].fBlue = b;
64
65   return 0;
66 }
67
68 int
69 CSTedScreenWin32::SetTextPalette(int in_pal, int in_color)
70 {
71   int r,g,b;
72   if (in_pal<0 || in_pal>=fMaxTextColor) return 0;
73
74   r=((in_color >> 6) &0x001f)<<3;
75   b=((in_color >> 1) &0x001f)<<3;
76   g=((in_color >> 11)&0x001f)<<3;
77
78   fTextPalette[in_pal].fRed = r;
79   fTextPalette[in_pal].fGreen = g;
80   fTextPalette[in_pal].fBlue = b;
81
82   return 0;
83 }
84
85 int
86 CSTedScreenWin32::SetGraphicsColor(int in_color)
87 {
88   COLORREF r;
89
90   if (in_color<0 || in_color>=fMaxGraphicsColor) return 0;
91
92   fCurrentGraphicsColor = in_color;
93   r = RGB(fGraphicsPalette[in_color].fBlue, 
94           fGraphicsPalette[in_color].fGreen, 
95           fGraphicsPalette[in_color].fRed);
96
97   //::SetTextColor(fGraphicsWindowDC[0], r);
98   //::SetTextColor(fGraphicsWindowDC[1], r);
99   //::SetBkMode(fGraphicsWindowDC[0], TRANSPARENT);
100   //::SetBkMode(fGraphicsWindowDC[1], TRANSPARENT);
101
102   return r;
103 }
104
105 int
106 CSTedScreenWin32::SetTextColor(int in_color)
107 {
108   int c;
109   int lastcolor;
110   COLORREF rgb;
111   BOOL invert = FALSE;
112
113   c = in_color;
114   if (c&0x08) { // reverse
115         invert = TRUE;
116         c&=0x03;
117   }
118   lastcolor = fCurrentTextColor;
119
120   rgb = RGB(fTextPalette[c].fBlue,
121             fTextPalette[c].fGreen,
122             fTextPalette[c].fRed);
123
124   if (invert) {
125
126         //::SetTextColor(fTextDC, RGB(0xff, 0xff, 0xff));
127         //::SetBkColor(fTextDC, rgb);
128         //::SetTextColor(fTextMaskDC, RGB(0x00, 0x00, 0x00));
129         //::SetBkColor(fTextMaskDC, RGB(0xff, 0xff, 0xff));
130         fCurrentTextColor = 0;
131         fCurrentTextBackColor = c;
132   } else {
133         //::SetTextColor(fTextDC, rgb);
134         //::SetBkColor(fTextDC, RGB(0xff, 0xff, 0xff));
135         //::SetTextColor(fTextMaskDC, RGB(0xff, 0xff, 0xff));
136         //::SetBkColor(fTextMaskDC, RGB(0x00, 0x00, 0x00));
137         fCurrentTextColor = c;
138         fCurrentTextBackColor = 0;
139   }
140
141  /* ::SetBkMode(fTextDC, OPAQUE);
142   ::SetBkMode(fTextMaskDC, OPAQUE);*/
143
144   return lastcolor;
145 }