TNB Library
TnbSolidBitmapMaker.h
[詳解]
1#pragma once
11#include "TnbBitmapImage.h"
12#include "TnbHandleHandle.h"
13
14
15
16//TNB Library
17namespace TNB
18{
19
20
21
35{
36public:
37
40 {
41 m_DefaultBrush();
42 m_transColor = CLR_AUTOSELECT;
43 m_baseColor = RGB(255, 0, 255);
44 }
45
51 void SetBaseColor(COLORREF c)
52 {
53 m_baseColor = c;
54 }
55
61 void SetTransColor(COLORREF c)
62 {
63 m_transColor = c;
64 }
65
100 void SetFaceColor(COLORREF c1, COLORREF c2, COLORREF c3)
101 {
102 m_brush1 = ::CreateSolidBrush(c1);
103 m_currentBrush1 = m_brush1;
104 m_brush2 = ::CreateSolidBrush(c2);
105 m_currentBrush2 = m_brush2;
106 m_brush3 = ::CreateSolidBrush(c3);
107 m_currentBrush3 = m_brush3;
108 }
109
116 {
117 m_DefaultBrush();
118 m_brush1.Null();
119 m_brush2.Null();
120 m_brush3.Null();
121 }
122
129 CBitmapImage Make(CBitmapHandle bh, bool isPressed = false) const
130 {
131 CBitmapImage bi = bh;
132 if ( ! isPressed )
133 {
134 return m_MakeButton(bi);
135 }
136 return m_MakeButtonRv(bi);
137 }
138
139private:
140
142 void m_DefaultBrush(void)
143 {
144 m_currentBrush1 = ::GetSysColorBrush(COLOR_3DHILIGHT);
145 m_currentBrush2 = ::GetSysColorBrush(COLOR_3DSHADOW);
146 m_currentBrush3 = ::GetSysColorBrush(COLOR_3DDKSHADOW);
147 }
148
150 CBitmapImage m_MakeButton(const CBitmapImage& bmp) const
151 {
152 CBitmapImage bi;
153 bi.Set(bmp.GetSize().cx + 3, bmp.GetSize().cy + 3, m_baseColor);
154 HRGN hRgn = bmp.CreateRgn(m_transColor);
155 HBRUSH b1 = m_currentBrush1;
156 HBRUSH b2 = m_currentBrush2;
157 HBRUSH b3 = m_currentBrush3;
158 HDC hDC = bi.GetDC();
159 // b3
160 ::OffsetRgn(hRgn, 3, 0);
161 {
162 ::FillRgn(hDC, hRgn, b3);
163 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
164 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
165 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
166 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b3);
167 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b3);
168 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b3);
169 ::OffsetRgn(hRgn, +3, -3);
170 }
171 ::OffsetRgn(hRgn, -3, 0);
172 // b1
173 {
174 ::FillRgn(hDC, hRgn, b1);
175 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b1);
176 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b1);
177 ::OffsetRgn(hRgn, 0, -2);
178 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b1);
179 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b1);
180 ::OffsetRgn(hRgn, -2, 0);
181 }
182 // b2
183 ::OffsetRgn(hRgn, 2, 1);
184 {
185 ::FillRgn(hDC, hRgn, b2);
186 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b2);
187 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b2);
188 ::OffsetRgn(hRgn, 1, -1);
189 }
190 ::OffsetRgn(hRgn, -2, -1);
191 //
192 bi.ReleaseDC();
193 bi.InsertOnTransparent(1, 1, bmp, m_transColor);
194 _DeleteObject(hRgn);
195 return bi;
196 }
197
199 CBitmapImage m_MakeButtonRv(const CBitmapImage& bmp) const
200 {
201 CBitmapImage bi;
202 bi.Set(bmp.GetSize().cx + 3, bmp.GetSize().cy + 3, m_baseColor);
203 HRGN hRgn = bmp.CreateRgn(m_transColor);
204 HBRUSH b1 = m_currentBrush1;
205 HBRUSH b2 = m_currentBrush2;
206 HBRUSH b3 = m_currentBrush3;
207 HDC hDC = bi.GetDC();
208 // b3
209 {
210 ::FillRgn(hDC, hRgn, b3);
211 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
212 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
213 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b3);
214 ::OffsetRgn(hRgn, 0, -3);
215 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b3);
216 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b3);
217 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b3);
218 ::OffsetRgn(hRgn, -3, 0);
219 }
220 // b1
221 ::OffsetRgn(hRgn, 3, 1);
222 {
223 ::FillRgn(hDC, hRgn, b1);
224 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b1);
225 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b1);
226 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b1);
227 ::OffsetRgn(hRgn, -1, 0); ::FillRgn(hDC, hRgn, b1);
228 ::OffsetRgn(hRgn, 2, -2);
229 }
230 ::OffsetRgn(hRgn, -3, -1);
231 // b2
232 ::OffsetRgn(hRgn, 1, 1);
233 {
234 ::FillRgn(hDC, hRgn, b2);
235 ::OffsetRgn(hRgn, 1, 0); ::FillRgn(hDC, hRgn, b2);
236 ::OffsetRgn(hRgn, -1, 0);
237 ::OffsetRgn(hRgn, 0, 1); ::FillRgn(hDC, hRgn, b2);
238 ::OffsetRgn(hRgn, 0, -1);
239 }
240 ::OffsetRgn(hRgn, -1, -1);
241 //
242 bi.ReleaseDC();
243 bi.InsertOnTransparent(2, 2, bmp, m_transColor);
244 _DeleteObject(hRgn);
245 return bi;
246 }
247
248 CBrushHandle m_brush1;
249 CBrushHandle m_brush2;
250 CBrushHandle m_brush3;
251 HBRUSH m_currentBrush1;
252 HBRUSH m_currentBrush2;
253 HBRUSH m_currentBrush3;
254 COLORREF m_transColor;
255 COLORREF m_baseColor;
256};
257
258
259
260};
ビットマップイメージ管理関係のヘッダ
ハンドルハンドル関係のヘッダ
HBITMAP型ハンドルハンドル
ビットマップイメージ管理クラス
HRGN CreateRgn(COLORREF transColor=CLR_AUTOSELECT) const
[作成] リージョン作成.
HDC GetDC(void)
[取得]デバイスコンテキストハンドル取得.
bool InsertOnTransparent(int x, int y, const CBitmapImage &bmpimg, COLORREF color=CLR_AUTOSELECT, int cx=0, int cy=0)
[挿入] 透過処理付イメージ挿入.
const SIZE & GetSize(void) const
[取得] イメージサイズ取得.
bool Set(int cx, int cy, COLORREF color=CLR_INVALID)
[設定] イメージ設定.
bool ReleaseDC(void)
[設定] デバイスコンテキストハンドル返却.
HBRUSH型ハンドルハンドル
void Null(void)
[設定] 開放.
立体ビットマップメーカークラス
void SetDefaultFaceColor(void)
[設定] フェイスカラー設定.
void SetFaceColor(COLORREF c1, COLORREF c2, COLORREF c3)
[設定] フェイスカラー設定.
void SetTransColor(COLORREF c)
[設定] 透過色設定.
CBitmapImage Make(CBitmapHandle bh, bool isPressed=false) const
[作成] 立体ビットマップ作成.
void SetBaseColor(COLORREF c)
[設定] 背景色設定.
CSolidBitmapMaker(void)
コンストラクタ
TNB Library
Definition: TnbDoxyTitle.txt:2