mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 13:34:53 +00:00
[COMCTL32] -Implement BUTTON_IMAGELIST_ALIGN_RIGHT, BUTTON_IMAGELIST_ALIGN_TOP, BUTTON_IMAGELIST_ALIGN_BOTTOM
svn path=/trunk/; revision=75494
This commit is contained in:
parent
f13b9a9480
commit
02cc8362fa
|
@ -395,6 +395,47 @@ cleanup:
|
|||
return ret;
|
||||
}
|
||||
|
||||
BOOL BUTTON_DrawIml(HDC hDC, BUTTON_IMAGELIST *pimlData, RECT *prc, BOOL bOnlyCalc)
|
||||
{
|
||||
SIZE ImageSize;
|
||||
int left, top;
|
||||
|
||||
if (!pimlData->himl)
|
||||
return FALSE;
|
||||
|
||||
if (!ImageList_GetIconSize(pimlData->himl, &ImageSize.cx, &ImageSize.cy))
|
||||
return FALSE;
|
||||
|
||||
if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
|
||||
{
|
||||
left = prc->left + pimlData->margin.left;
|
||||
top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
|
||||
prc->left += left + pimlData->margin.right + ImageSize.cx;
|
||||
}
|
||||
else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
|
||||
{
|
||||
left = prc->right - pimlData->margin.right - ImageSize.cx;
|
||||
top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
|
||||
prc->right = left - pimlData->margin.left;
|
||||
}
|
||||
else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
|
||||
{
|
||||
left = prc->left + (prc->right - prc->left - ImageSize.cy) / 2;
|
||||
top = prc->top + pimlData->margin.top;
|
||||
prc->top = top + ImageSize.cy + pimlData->margin.bottom;
|
||||
}
|
||||
else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
|
||||
{
|
||||
left = prc->left + (prc->right - prc->left - ImageSize.cy) / 2;
|
||||
top = prc->bottom - pimlData->margin.bottom - ImageSize.cy;
|
||||
prc->bottom = top - pimlData->margin.top;
|
||||
}
|
||||
|
||||
if (!bOnlyCalc)
|
||||
ImageList_Draw(pimlData->himl, 0, hDC, left, top, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1140,6 +1181,9 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
|
|||
UINT dtStyle = BUTTON_BStoDT( style, ex_style );
|
||||
RECT r = *rc;
|
||||
INT n;
|
||||
#ifdef __REACTOS__
|
||||
PBUTTON_DATA pdata = _GetButtonData(hwnd);
|
||||
#endif
|
||||
|
||||
/* Calculate label rectangle according to label type */
|
||||
switch (style & (BS_ICON|BS_BITMAP))
|
||||
|
@ -1147,6 +1191,11 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
|
|||
case BS_TEXT:
|
||||
{
|
||||
HFONT hFont, hPrevFont = 0;
|
||||
#ifdef __REACTOS__
|
||||
BOOL bHasIml;
|
||||
|
||||
bHasIml = BUTTON_DrawIml(hdc, &pdata->imlData, &r, TRUE);
|
||||
#endif
|
||||
|
||||
if (!(text = get_button_text( hwnd ))) goto empty_rect;
|
||||
if (!text[0])
|
||||
|
@ -1162,6 +1211,18 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
|
|||
#ifdef __REACTOS__
|
||||
if (get_ui_state(hwnd) & UISF_HIDEACCEL)
|
||||
dtStyle |= DT_HIDEPREFIX;
|
||||
|
||||
if (bHasIml)
|
||||
{
|
||||
if (pdata->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
|
||||
r.left = pdata->imlData.margin.left;
|
||||
else if (pdata->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
|
||||
r.right = pdata->imlData.margin.right;
|
||||
else if (pdata->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
|
||||
r.top = pdata->imlData.margin.top;
|
||||
else if (pdata->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
|
||||
r.bottom = pdata->imlData.margin.bottom;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -1253,20 +1314,13 @@ static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int
|
|||
HWND hwnd = (HWND)lp;
|
||||
RECT rc;
|
||||
PBUTTON_DATA pdata = _GetButtonData(hwnd);
|
||||
SIZE ImageSize;
|
||||
WCHAR *text = NULL;
|
||||
|
||||
if (!(text = get_button_text( hwnd ))) return TRUE;
|
||||
|
||||
SetRect(&rc, 0, 0, cx, cy);
|
||||
|
||||
if (pdata->imlData.himl && ImageList_GetIconSize(pdata->imlData.himl, &ImageSize.cx, &ImageSize.cy))
|
||||
{
|
||||
int left = pdata->imlData.margin.left;
|
||||
int top = (cy - ImageSize.cy) / 2;
|
||||
rc.left += pdata->imlData.margin.left + pdata->imlData.margin.right + ImageSize.cy;
|
||||
ImageList_Draw(pdata->imlData.himl, 0, hdc, left, top, 0);
|
||||
}
|
||||
BUTTON_DrawIml(hdc, &pdata->imlData, &rc, FALSE);
|
||||
|
||||
DrawTextW(hdc, text, -1, &rc, (UINT)wp);
|
||||
HeapFree(GetProcessHeap(), 0, text);
|
||||
|
|
|
@ -55,6 +55,8 @@ static inline LONG_PTR get_button_image(HWND hwnd)
|
|||
{
|
||||
return _GetButtonData(hwnd)->image;
|
||||
}
|
||||
|
||||
BOOL BUTTON_DrawIml(HDC hdc, BUTTON_IMAGELIST *pimlData, RECT *prc, BOOL bOnlyCalc);
|
||||
#endif
|
||||
|
||||
static UINT get_drawtext_flags(DWORD style, DWORD ex_style)
|
||||
|
@ -127,7 +129,6 @@ static void PB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UIN
|
|||
WCHAR *text = get_button_text(hwnd);
|
||||
#ifdef __REACTOS__ /* r74012 & r74406 */
|
||||
PBUTTON_DATA pdata = _GetButtonData(hwnd);
|
||||
SIZE ImageSize;
|
||||
HWND parent;
|
||||
HBRUSH hBrush;
|
||||
#endif
|
||||
|
@ -156,13 +157,7 @@ static void PB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UIN
|
|||
DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
|
||||
|
||||
#ifdef __REACTOS__ /* r74012 */
|
||||
if (pdata->imlData.himl && ImageList_GetIconSize(pdata->imlData.himl, &ImageSize.cx, &ImageSize.cy))
|
||||
{
|
||||
int left = textRect.left + pdata->imlData.margin.left;
|
||||
int top = textRect.top + (textRect.bottom - textRect.top - ImageSize.cy) / 2;
|
||||
textRect.left += pdata->imlData.margin.left + pdata->imlData.margin.right + ImageSize.cy;
|
||||
ImageList_Draw(pdata->imlData.himl, 0, hDC, left, top, 0);
|
||||
}
|
||||
BUTTON_DrawIml(hDC, &pdata->imlData, &textRect, FALSE);
|
||||
#endif
|
||||
|
||||
if (text)
|
||||
|
|
Loading…
Reference in a new issue