TNB Library
TnbFlatnessDrawer.h
[詳解]
1#pragma once
11#include "TnbDrawable.h"
12
13
14
15//TNB Library
16namespace TNB
17{
18
19
20
34{
35 DEFSUPER(CNullDrawer);
36 COLORREF m_color1;
37 COLORREF m_color2;
38 COLORREF m_back;
39 COLORREF m_base;
40 COLORREF m_work;
41public:
42
51 CFlatnessDrawer(COLORREF color1, COLORREF color2, COLORREF back = CLR_AUTOSELECT, COLORREF base = CLR_AUTOSELECT, COLORREF work = RGB(255, 255, 255))
52 : m_color1(color1), m_color2(color2), m_back(back), m_base(base), m_work(work)
53 {
54 }
55
61 virtual IDrawable* Clone(void) const
62 {
63 return new CFlatnessDrawer(m_color1, m_color2, m_back, m_base, m_work);
64 }
65
73 virtual void Draw(HDC dc, int x = 0, int y = 0) const
74 {
75 COLORREF base = m_base;
76 COLORREF back = m_back;
77 if ( base == CLR_AUTOSELECT )
78 {
79 base = ::GetPixel(dc, x, y + m_size.cy - 1);
80 }
81 if ( ! IS_RGBVALUE(back) )
82 {
83 back = base;
84 }
85 const DWORD CP_ROP = 0xE20746;
86 HBITMAP hBmp = ::CreateBitmap(m_size.cx, m_size.cy, 1, 1, NULL);
87 HDC maskDC = ::CreateCompatibleDC(dc);
88 HGDIOBJ oldBmp = ::SelectObject(maskDC, hBmp);
89 {
90 COLORREF oldColor = ::SetBkColor(dc, base);
91 ::BitBlt(maskDC, 0, 0, m_size.cx, m_size.cy, dc, x, y, SRCCOPY);
92 ::SetBkColor(dc, m_work);
93 ::BitBlt(maskDC, 0, 0, m_size.cx, m_size.cy, dc, x, y, NOTSRCERASE);
94 //
95 RECT rc = { x, y, x + m_size.cx, y + m_size.cy };
96 HBRUSH hr = ::CreateSolidBrush(back);
97 ::FillRect(dc, &rc, hr);
98 _DeleteObject(hr);
99 //
100 HBRUSH brush1 = ::CreateSolidBrush(m_color1);
101 HGDIOBJ oldBrush = ::SelectObject(dc, brush1);
102 ::BitBlt(dc, x, y, m_size.cx, m_size.cy, maskDC, 0, 0, CP_ROP);
103 ::SelectObject(dc, oldBrush);
104 _DeleteObject(brush1);
105 if ( m_color2 != CLR_INVALID )
106 {
107 HBRUSH brush2 = ::CreateSolidBrush(m_color2);
108 HGDIOBJ oldBrush = ::SelectObject(dc, brush2);
109 ::BitBlt(dc, x - 1, y - 1, m_size.cx, m_size.cy, maskDC, 0, 0, CP_ROP);
110 ::SelectObject(dc, oldBrush);
111 _DeleteObject(brush2);
112 }
113 ::SetBkColor(dc, oldColor);
114 }
115 ::SelectObject(maskDC, oldBmp);
116 _DeleteObject(maskDC);
117 _DeleteObject(hBmp);
118 }
119
127 static CFlatnessDrawer* CreateSelectedType(COLORREF base = CLR_AUTOSELECT, COLORREF work = RGB(255, 255, 255))
128 {
129 return new CFlatnessDrawer(::GetSysColor(COLOR_HIGHLIGHTTEXT), CLR_INVALID, ::GetSysColor(COLOR_HIGHLIGHT), base, work);
130 }
131
139 static CFlatnessDrawer* CreateNaSelectedType(COLORREF base = CLR_AUTOSELECT, COLORREF work = RGB(255, 255, 255))
140 {
141 return new CFlatnessDrawer(::GetSysColor(COLOR_WINDOWTEXT), CLR_INVALID, ::GetSysColor(COLOR_BTNFACE), base, work);
142 }
143};
144
145
146
147}; // TNB
描画情報関係のヘッダ
平坦描画クラス
static CFlatnessDrawer * CreateNaSelectedType(COLORREF base=CLR_AUTOSELECT, COLORREF work=RGB(255, 255, 255))
[取得] 非アクティブ選択状態設定インスタンス作成.
virtual void Draw(HDC dc, int x=0, int y=0) const
[描画] 描画.
static CFlatnessDrawer * CreateSelectedType(COLORREF base=CLR_AUTOSELECT, COLORREF work=RGB(255, 255, 255))
[取得] アクティブ選択状態設定インスタンス作成.
CFlatnessDrawer(COLORREF color1, COLORREF color2, COLORREF back=CLR_AUTOSELECT, COLORREF base=CLR_AUTOSELECT, COLORREF work=RGB(255, 255, 255))
コンストラクタ.
virtual IDrawable * Clone(void) const
[作成] クローン作成.
NULL描画クラス
Definition: TnbDrawable.h:106
SIZE m_size
サイズ
Definition: TnbDrawable.h:109
TNB Library
Definition: TnbDoxyTitle.txt:2
描画情報インターフェース
Definition: TnbDrawable.h:37