📄 draw.c
字号:
if((uFlags & BF_BOTTOMLEFT) == BF_BOTTOMLEFT) LBpenplus = 1;
if((uFlags & BF_TOPRIGHT) == BF_TOPRIGHT) RTpenplus = 1;
if((uFlags & BF_BOTTOMRIGHT) == BF_BOTTOMRIGHT) RBpenplus = 1;
if((uFlags & BF_TOPLEFT) == BF_TOPLEFT) LTpenplus = 1;
if(LTInnerI != -1) LTInnerPen = get_edge_pen (LTInnerI, theme, part, state);
if(LTOuterI != -1) LTOuterPen = get_edge_pen (LTOuterI, theme, part, state);
if(RBInnerI != -1) RBInnerPen = get_edge_pen (RBInnerI, theme, part, state);
if(RBOuterI != -1) RBOuterPen = get_edge_pen (RBOuterI, theme, part, state);
MoveToEx(hdc, 0, 0, &SavePoint);
/* Draw the outer edge */
SelectObject(hdc, LTOuterPen);
if(uFlags & BF_TOP)
{
MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
LineTo(hdc, InnerRect.right, InnerRect.top);
}
if(uFlags & BF_LEFT)
{
MoveToEx(hdc, InnerRect.left, InnerRect.top, NULL);
LineTo(hdc, InnerRect.left, InnerRect.bottom);
}
SelectObject(hdc, RBOuterPen);
if(uFlags & BF_BOTTOM)
{
MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
LineTo(hdc, InnerRect.left-1, InnerRect.bottom-1);
}
if(uFlags & BF_RIGHT)
{
MoveToEx(hdc, InnerRect.right-1, InnerRect.bottom-1, NULL);
LineTo(hdc, InnerRect.right-1, InnerRect.top-1);
}
/* Draw the inner edge */
SelectObject(hdc, LTInnerPen);
if(uFlags & BF_TOP)
{
MoveToEx(hdc, InnerRect.left+LTpenplus, InnerRect.top+1, NULL);
LineTo(hdc, InnerRect.right-RTpenplus, InnerRect.top+1);
}
if(uFlags & BF_LEFT)
{
MoveToEx(hdc, InnerRect.left+1, InnerRect.top+LTpenplus, NULL);
LineTo(hdc, InnerRect.left+1, InnerRect.bottom-LBpenplus);
}
SelectObject(hdc, RBInnerPen);
if(uFlags & BF_BOTTOM)
{
MoveToEx(hdc, InnerRect.right-1-RBpenplus, InnerRect.bottom-2, NULL);
LineTo(hdc, InnerRect.left-1+LBpenplus, InnerRect.bottom-2);
}
if(uFlags & BF_RIGHT)
{
MoveToEx(hdc, InnerRect.right-2, InnerRect.bottom-1-RBpenplus, NULL);
LineTo(hdc, InnerRect.right-2, InnerRect.top-1+RTpenplus);
}
if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) )
{
int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
+ (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
if(uFlags & BF_LEFT) InnerRect.left += add;
if(uFlags & BF_RIGHT) InnerRect.right -= add;
if(uFlags & BF_TOP) InnerRect.top += add;
if(uFlags & BF_BOTTOM) InnerRect.bottom -= add;
if((uFlags & BF_MIDDLE) && retval)
{
HBRUSH br = get_edge_brush ((uFlags & BF_MONO) ? EDGE_WINDOW : EDGE_FILL,
theme, part, state);
FillRect(hdc, &InnerRect, br);
DeleteObject (br);
}
if(uFlags & BF_ADJUST)
*contentsRect = InnerRect;
}
/* Cleanup */
SelectObject(hdc, SavePen);
MoveToEx(hdc, SavePoint.x, SavePoint.y, NULL);
if(LTInnerI != -1) DeleteObject (LTInnerPen);
if(LTOuterI != -1) DeleteObject (LTOuterPen);
if(RBInnerI != -1) DeleteObject (RBInnerPen);
if(RBOuterI != -1) DeleteObject (RBOuterPen);
return retval;
}
/***********************************************************************
* DrawThemeEdge (UXTHEME.@)
*
* DrawThemeEdge() is pretty similar to the vanilla DrawEdge() - the
* difference is that it does not rely on the system colors alone, but
* also allows color specification in the theme.
*/
HRESULT WINAPI DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pDestRect, UINT uEdge,
UINT uFlags, RECT *pContentRect)
{
TRACE("%d %d 0x%08x 0x%08x\n", iPartId, iStateId, uEdge, uFlags);
if(!hTheme)
return E_HANDLE;
if(uFlags & BF_DIAGONAL)
return draw_diag_edge (hdc, hTheme, iPartId, iStateId, pDestRect,
uEdge, uFlags, pContentRect);
else
return draw_rect_edge (hdc, hTheme, iPartId, iStateId, pDestRect,
uEdge, uFlags, pContentRect);
}
/***********************************************************************
* DrawThemeIcon (UXTHEME.@)
*/
HRESULT WINAPI DrawThemeIcon(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
const RECT *pRect, HIMAGELIST himl, int iImageIndex)
{
FIXME("%d %d: stub\n", iPartId, iStateId);
if(!hTheme)
return E_HANDLE;
return ERROR_CALL_NOT_IMPLEMENTED;
}
/***********************************************************************
* DrawThemeText (UXTHEME.@)
*/
HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
DWORD dwTextFlags2, const RECT *pRect)
{
HRESULT hr;
HFONT hFont = NULL;
HGDIOBJ oldFont = NULL;
LOGFONTW logfont;
COLORREF textColor;
COLORREF oldTextColor;
int oldBkMode;
RECT rt;
TRACE("%d %d: stub\n", iPartId, iStateId);
if(!hTheme)
return E_HANDLE;
hr = GetThemeFont(hTheme, hdc, iPartId, iStateId, TMT_FONT, &logfont);
if(SUCCEEDED(hr)) {
hFont = CreateFontIndirectW(&logfont);
if(!hFont)
TRACE("Failed to create font\n");
}
CopyRect(&rt, pRect);
if(hFont)
oldFont = SelectObject(hdc, hFont);
if(dwTextFlags2 & DTT_GRAYED)
textColor = GetSysColor(COLOR_GRAYTEXT);
else {
if(FAILED(GetThemeColor(hTheme, iPartId, iStateId, TMT_TEXTCOLOR, &textColor)))
textColor = GetTextColor(hdc);
}
oldTextColor = SetTextColor(hdc, textColor);
oldBkMode = SetBkMode(hdc, TRANSPARENT);
DrawTextW(hdc, pszText, iCharCount, &rt, dwTextFlags);
SetBkMode(hdc, oldBkMode);
SetTextColor(hdc, oldTextColor);
if(hFont) {
SelectObject(hdc, oldFont);
DeleteObject(hFont);
}
return S_OK;
}
/***********************************************************************
* GetThemeBackgroundContentRect (UXTHEME.@)
*/
HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId,
const RECT *pBoundingRect,
RECT *pContentRect)
{
MARGINS margin;
HRESULT hr;
TRACE("(%d,%d)\n", iPartId, iStateId);
if(!hTheme)
return E_HANDLE;
/* try content margins property... */
hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId, TMT_CONTENTMARGINS, NULL, &margin);
if(SUCCEEDED(hr)) {
pContentRect->left = pBoundingRect->left + margin.cxLeftWidth;
pContentRect->top = pBoundingRect->top + margin.cyTopHeight;
pContentRect->right = pBoundingRect->right - margin.cxRightWidth;
pContentRect->bottom = pBoundingRect->bottom - margin.cyBottomHeight;
} else {
/* otherwise, try to determine content rect from the background type and props */
int bgtype = BT_BORDERFILL;
memcpy(pContentRect, pBoundingRect, sizeof(RECT));
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
if(bgtype == BT_BORDERFILL) {
int bordersize = 1;
GetThemeInt(hTheme, iPartId, iStateId, TMT_BORDERSIZE, &bordersize);
InflateRect(pContentRect, -bordersize, -bordersize);
} else if ((bgtype == BT_IMAGEFILE)
&& (SUCCEEDED(hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId,
TMT_SIZINGMARGINS, NULL, &margin)))) {
pContentRect->left = pBoundingRect->left + margin.cxLeftWidth;
pContentRect->top = pBoundingRect->top + margin.cyTopHeight;
pContentRect->right = pBoundingRect->right - margin.cxRightWidth;
pContentRect->bottom = pBoundingRect->bottom - margin.cyBottomHeight;
}
/* If nothing was found, leave unchanged */
}
TRACE("left:%d,top:%d,right:%d,bottom:%d\n", pContentRect->left, pContentRect->top, pContentRect->right, pContentRect->bottom);
return S_OK;
}
/***********************************************************************
* GetThemeBackgroundExtent (UXTHEME.@)
*/
HRESULT WINAPI GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pContentRect,
RECT *pExtentRect)
{
MARGINS margin;
HRESULT hr;
TRACE("(%d,%d)\n", iPartId, iStateId);
if(!hTheme)
return E_HANDLE;
/* try content margins property... */
hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId, TMT_CONTENTMARGINS, NULL, &margin);
if(SUCCEEDED(hr)) {
pExtentRect->left = pContentRect->left - margin.cxLeftWidth;
pExtentRect->top = pContentRect->top - margin.cyTopHeight;
pExtentRect->right = pContentRect->right + margin.cxRightWidth;
pExtentRect->bottom = pContentRect->bottom + margin.cyBottomHeight;
} else {
/* otherwise, try to determine content rect from the background type and props */
int bgtype = BT_BORDERFILL;
memcpy(pExtentRect, pContentRect, sizeof(RECT));
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
if(bgtype == BT_BORDERFILL) {
int bordersize = 1;
GetThemeInt(hTheme, iPartId, iStateId, TMT_BORDERSIZE, &bordersize);
InflateRect(pExtentRect, bordersize, bordersize);
} else if ((bgtype == BT_IMAGEFILE)
&& (SUCCEEDED(hr = GetThemeMargins(hTheme, hdc, iPartId, iStateId,
TMT_SIZINGMARGINS, NULL, &margin)))) {
pExtentRect->left = pContentRect->left - margin.cxLeftWidth;
pExtentRect->top = pContentRect->top - margin.cyTopHeight;
pExtentRect->right = pContentRect->right + margin.cxRightWidth;
pExtentRect->bottom = pContentRect->bottom + margin.cyBottomHeight;
}
/* If nothing was found, leave unchanged */
}
TRACE("left:%d,top:%d,right:%d,bottom:%d\n", pExtentRect->left, pExtentRect->top, pExtentRect->right, pExtentRect->bottom);
return S_OK;
}
/***********************************************************************
* GetThemeBackgroundRegion (UXTHEME.@)
*
* Calculate the background region, taking into consideration transparent areas
* of the background image.
*/
HRESULT WINAPI GetThemeBackgroundRegion(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, const RECT *pRect,
HRGN *pRegion)
{
HRESULT hr = S_OK;
int bgtype = BT_BORDERFILL;
TRACE("(%p,%p,%d,%d)\n", hTheme, hdc, iPartId, iStateId);
if(!hTheme)
return E_HANDLE;
if(!pRect || !pRegion)
return E_POINTER;
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
if(bgtype == BT_IMAGEFILE) {
FIXME("Images not handled yet\n");
hr = ERROR_CALL_NOT_IMPLEMENTED;
}
else if(bgtype == BT_BORDERFILL) {
*pRegion = CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom);
if(!*pRegion)
hr = HRESULT_FROM_WIN32(GetLastError());
}
else {
FIXME("Unknown background type\n");
/* This should never happen, and hence I don't know what to return */
hr = E_FAIL;
}
return hr;
}
/* compute part size for "borderfill" backgrounds */
static HRESULT get_border_background_size (HTHEME hTheme, int iPartId,
int iStateId, THEMESIZE eSize, POINT* psz)
{
HRESULT hr = S_OK;
int bordersize = 1;
if (SUCCEEDED (hr = GetThemeInt(hTheme, iPartId, iStateId, TMT_BORDERSIZE,
&bordersize)))
{
psz->x = psz->y = 2*bordersize;
if (eSize != TS_MIN)
{
psz->x++;
psz->y++;
}
}
return hr;
}
/***********************************************************************
* GetThemePartSize (UXTHEME.@)
*/
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId,
int iStateId, RECT *prc, THEMESIZE eSize,
SIZE *psz)
{
int bgtype = BT_BORDERFILL;
HRESULT hr = S_OK;
POINT size = {1, 1};
if(!hTheme)
return E_HANDLE;
GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
if (bgtype == BT_NONE)
/* do nothing */;
else if(bg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -