13 #include "../Image/cSurfaceInfo.h"
26 static const int k_HIMETRIC_PER_INCH = 2540;
27 static const GChar_t* k_pszDisplayDef;
38 void DPFromHimetric(POINT* pt,
ITERATE_t nCount);
39 void HimetricFromDP(POINT* pt,
ITERATE_t nCount);
41 bool isValidDC()
const
52 HGDIOBJ SelectObject(IN HGDIOBJ hGDIObj)
const
55 return ::SelectObject(m_hDC, hGDIObj);
57 HGDIOBJ SelectObject(
const cWndGDI& GDIObj)
const
60 return ::SelectObject(m_hDC, GDIObj.m_hObject);
62 BOOL GetTextMetricsX(OUT
_GTN(TEXTMETRIC)* lptm)
const
64 return _GTN(::GetTextMetrics)(m_hDC, lptm);
66 int GetDeviceCaps(
int index)
const
69 return ::GetDeviceCaps(m_hDC,
index);
71 int GetClipBox(OUT RECT* pRect)
const
73 return ::GetClipBox(m_hDC, pRect);
79 return ::CreateCompatibleBitmap(m_hDC, x, y);
81 bool DrawIconEx(
int x,
int y, HICON hIcon,
int cx,
int cy)
84 return ::DrawIconEx(m_hDC, x, y, hIcon, cx, cy, 0,
WINHANDLE_NULL, DI_NORMAL);
87 void FillRect(
const RECT& rRect, HBRUSH hBrush)
89 ::FillRect(m_hDC, &rRect, hBrush);
91 void FillSolidRect(
const RECT& rRect,
COLORREF clr)
94 brush.CreateSolidBrush(clr);
95 FillRect(rRect, brush.get_HBrush());
100 int SetBkMode(
int iMode)
103 return ::SetBkMode(m_hDC, iMode);
105 int SelectClipRgn(HRGN hrgn)
107 return ::SelectClipRgn(m_hDC, hrgn);
111 return ::SetBkColor(m_hDC, crColor);
115 return ::SetTextColor(m_hDC, crColor);
118 bool GetOutputTextExtent(
const GChar_t* pszText,
StrLen_t iLenMax, OUT SIZE& rSize)
123 return _GTN(::GetTextExtentPoint32)(m_hDC, pszText, iLenMax, &rSize);
129 if (!GetOutputTextExtent(pszText, iLenMax, rSize))
137 BOOL ExtTextOutX(
int x,
int y, UINT options, RECT* pRect,
const GChar_t* lpString,
const int* lpDx)
141 return _GTN(::ExtTextOut)(m_hDC, x, y, options, pRect, lpString, nCount, lpDx);
144 HPALETTE SelectPalette(HPALETTE hPal,
bool bForceBkgd =
false)
147 return ::SelectPalette(m_hDC, hPal, bForceBkgd);
149 UINT RealizePalette()
151 return ::RealizePalette(m_hDC);
156 return ::GetPixel(m_hDC, x, y);
158 int GetClipBox(RECT&
rect)
const
161 return ::GetClipBox(m_hDC, &
rect);
164 void DrawFocusRect(
const RECT* pRect)
167 ::DrawFocusRect(m_hDC, pRect);
170 BOOL Rectangle(
int x1,
int y1,
int x2,
int y2)
173 return ::Rectangle(m_hDC, x1, y1, x2, y2);
175 BOOL MoveTo(
int x,
int y)
178 BOOL bRet = ::MoveToEx(m_hDC, x, y,
nullptr);
181 BOOL MoveTo(POINT point)
183 return MoveTo(point.x, point.y);
185 BOOL LineTo(
int x,
int y)
189 return ::LineTo(m_hDC, x, y);
191 BOOL LineTo(POINT point)
193 return LineTo(point.x, point.y);
195 BOOL Ellipse(
int x1,
int y1,
int x2,
int y2)
198 return ::Ellipse(m_hDC, x1, y1, x2, y2);
200 BOOL Polygon(
const POINT* lpPoints,
int nCount)
203 return ::Polygon(m_hDC, lpPoints, nCount);
207 int GetPixelFormat()
const
210 return ::GetPixelFormat(m_hDC);
212 int SetPixelFormat(
const PIXELFORMATDESCRIPTOR& pfd)
216 int iPixelFormat = ::ChoosePixelFormat(m_hDC, &pfd);
217 if (iPixelFormat <= 0)
220 BOOL bRet = ::SetPixelFormat(m_hDC, iPixelFormat, &pfd);
228 class GRAYLIB_LINK cWndDCOwn :
public CObject,
public cWndDC
239 cWndDCOwn(HDC hDC =
WINHANDLE_NULL, HWND hWndOwner = HWND_BROADCAST)
241 , m_hWndOwner(hWndOwner)
246 cWndDCOwn(HWND hWndOwner)
247 : cWndDC(::GetDC(hWndOwner))
248 , m_hWndOwner(hWndOwner)
258 bool AttachDC(HWND hWndOwner)
261 m_hWndOwner = hWndOwner;
262 m_hDC = ::GetDC(hWndOwner);
266 bool AttachDCEx(HWND hWndOwner, DWORD dwFlags)
270 m_hWndOwner = hWndOwner;
275 bool CreateCompatibleDC(HDC hDCScreen)
278 ASSERT(m_hWndOwner == HWND_BROADCAST);
282 m_hDC =
_GTN(::CreateDC)(k_pszDisplayDef,
nullptr,
nullptr,
nullptr);
286 m_hDC = ::CreateCompatibleDC(hDCScreen);
290 bool CreateDCX(
const GChar_t* pszDriver =
nullptr,
const GChar_t* pszDevice =
nullptr)
294 if (pszDriver ==
nullptr)
296 pszDriver = k_pszDisplayDef;
299 ASSERT(m_hWndOwner == HWND_BROADCAST);
300 m_hDC =
_GTN(::CreateDC)(pszDriver, pszDevice,
nullptr,
nullptr);
322 HDC get_DCAlt() const noexcept
326 bool get_PaintErase() const noexcept
330 RECT get_PaintRect() const noexcept
338 typedef cWndPaint CPaintDC;
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GTN(c)
_WIN32 name has a A or W for UTF8 or UNICODE (like _FNF)
Definition: StrConst.h:28
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define WINHANDLE_NULL
HWND, HPEN, etc are NOT OS Handles. like HWND_DESKTOP. like HANDLEPTR_NULL. This is a WINAPI void* ha...
Definition: cOSHandle.h:23
UINT32 COLORREF
ABGR (high to low bits)
Definition: cVariantData.h:21
interface const RECTQ_t & rect
Definition: cQuadtree.h:44
int PIXELS_t
Count of pixels in a dimension of some image/surface.
Definition: cSurfaceInfo.h:20
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
int ITERATE_t
like size_t but signed
Definition: Index.h:28
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26
uint16 index
Definition: sample3.cpp:29
static StrLen_t Len(const TYPE *pszStr) noexcept