Commit 176bd922 authored by Rafał Harabień's avatar Rafał Harabień Committed by Alexandre Julliard

comctl32: Send WM_CTLCOLORSTATIC for all static control types.

parent 4e8277e6
......@@ -44,13 +44,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(static);
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
struct static_extra_info
{
......@@ -64,7 +64,7 @@ struct static_extra_info
BOOL image_has_alpha;
};
typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
typedef void (*pfPaint)( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
static const pfPaint staticPaintFunc[SS_TYPEMASK+1] =
{
......@@ -371,6 +371,22 @@ static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
return hicon;
}
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
{
HBRUSH hBrush;
HWND parent = GetParent(hwnd);
if (!parent) parent = hwnd;
hBrush = (HBRUSH) SendMessageW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
if (!hBrush) /* did the app forget to call DefWindowProc ? */
{
/* FIXME: DefWindowProc should return different colors if a
manifest is present */
hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd);
}
return hBrush;
}
/***********************************************************************
* STATIC_TryPaintFcn
*
......@@ -378,40 +394,26 @@ static HICON STATIC_LoadIconW( HINSTANCE hInstance, LPCWSTR name, DWORD style )
*/
static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
{
LONG style = full_style & SS_TYPEMASK;
RECT rc;
GetClientRect( hwnd, &rc );
if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
if (IsWindowVisible(hwnd))
{
RECT rc;
HDC hdc;
HRGN hrgn;
HBRUSH hbrush;
LONG style = full_style & SS_TYPEMASK;
GetClientRect( hwnd, &rc );
hdc = GetDC( hwnd );
hrgn = set_control_clipping( hdc, &rc );
(staticPaintFunc[style])( hwnd, hdc, full_style );
hbrush = STATIC_SendWmCtlColorStatic( hwnd, hdc );
if (staticPaintFunc[style])
(staticPaintFunc[style])( hwnd, hdc, hbrush, full_style );
SelectClipRgn( hdc, hrgn );
if (hrgn) DeleteObject( hrgn );
ReleaseDC( hwnd, hdc );
}
}
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
{
HBRUSH hBrush;
HWND parent = GetParent(hwnd);
if (!parent) parent = hwnd;
hBrush = (HBRUSH) SendMessageW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
if (!hBrush) /* did the app forget to call DefWindowProc ? */
{
/* FIXME: DefWindowProc should return different colors if a
manifest is present */
hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd);
}
return hBrush;
}
/***********************************************************************
* hasTextStyle
*
......@@ -492,14 +494,16 @@ static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
PAINTSTRUCT ps;
RECT rect;
HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
HRGN hrgn;
HBRUSH hbrush;
GetClientRect( hwnd, &rect );
hrgn = set_control_clipping( hdc, &rect );
hbrush = STATIC_SendWmCtlColorStatic( hwnd, hdc );
if (staticPaintFunc[style])
{
HRGN hrgn = set_control_clipping( hdc, &rect );
(staticPaintFunc[style])( hwnd, hdc, full_style );
SelectClipRgn( hdc, hrgn );
if (hrgn) DeleteObject( hrgn );
}
(staticPaintFunc[style])( hwnd, hdc, hbrush, full_style );
SelectClipRgn( hdc, hrgn );
if (hrgn) DeleteObject( hrgn );
if (!wParam) EndPaint(hwnd, &ps);
}
break;
......@@ -653,7 +657,7 @@ static LRESULT CALLBACK STATIC_WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
return lResult;
}
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
DRAWITEMSTRUCT dis;
HFONT font, oldFont = NULL;
......@@ -671,15 +675,13 @@ static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
font = STATIC_GetFont( hwnd );
if (font) oldFont = SelectObject( hdc, font );
SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
if (font) SelectObject( hdc, oldFont );
}
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
RECT rc;
HBRUSH hBrush;
HFONT hFont, hOldFont = NULL;
UINT format;
INT len, buf_size;
......@@ -736,13 +738,9 @@ static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
if ((hFont = STATIC_GetFont( hwnd )))
hOldFont = SelectObject( hdc, hFont );
/* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
brush is not used */
hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
if ((style & SS_TYPEMASK) != SS_SIMPLE)
{
FillRect( hdc, &rc, hBrush );
FillRect( hdc, &rc, hbrush );
if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
}
......@@ -779,56 +777,52 @@ no_TextOut:
SelectObject( hdc, hOldFont );
}
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
RECT rc;
HBRUSH hBrush;
GetClientRect( hwnd, &rc);
/* FIXME: send WM_CTLCOLORSTATIC */
switch (style & SS_TYPEMASK)
{
case SS_BLACKRECT:
hBrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
FillRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
FillRect( hdc, &rc, hbrush );
break;
case SS_GRAYRECT:
hBrush = CreateSolidBrush(comctl32_color.clr3dShadow);
FillRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dShadow);
FillRect( hdc, &rc, hbrush );
break;
case SS_WHITERECT:
hBrush = CreateSolidBrush(comctl32_color.clr3dHilight);
FillRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dHilight);
FillRect( hdc, &rc, hbrush );
break;
case SS_BLACKFRAME:
hBrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
FrameRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dDkShadow);
FrameRect( hdc, &rc, hbrush );
break;
case SS_GRAYFRAME:
hBrush = CreateSolidBrush(comctl32_color.clr3dShadow);
FrameRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dShadow);
FrameRect( hdc, &rc, hbrush );
break;
case SS_WHITEFRAME:
hBrush = CreateSolidBrush(comctl32_color.clr3dHilight);
FrameRect( hdc, &rc, hBrush );
hbrush = CreateSolidBrush(comctl32_color.clr3dHilight);
FrameRect( hdc, &rc, hbrush );
break;
default:
return;
}
DeleteObject( hBrush );
DeleteObject( hbrush );
}
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
RECT rc, iconRect;
HBRUSH hbrush;
HICON hIcon;
SIZE size;
GetClientRect( hwnd, &rc );
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
hIcon = STATIC_GetImage( hwnd, IMAGE_ICON, style );
if (!hIcon || !get_icon_size( hIcon, &size ))
{
......@@ -851,13 +845,10 @@ static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
}
}
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
HDC hMemDC;
HBITMAP hBitmap, oldbitmap;
HBRUSH hbrush;
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
if ((hBitmap = STATIC_GetImage( hwnd, IMAGE_BITMAP, style ))
&& (GetObjectType(hBitmap) == OBJ_BITMAP)
......@@ -902,14 +893,12 @@ static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
}
}
static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
HENHMETAFILE hEnhMetaFile;
RECT rc;
HBRUSH hbrush;
GetClientRect(hwnd, &rc);
hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
FillRect(hdc, &rc, hbrush);
if ((hEnhMetaFile = STATIC_GetImage( hwnd, IMAGE_ENHMETAFILE, style )))
{
......@@ -920,11 +909,10 @@ static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
}
}
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style )
{
RECT rc;
/* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
GetClientRect( hwnd, &rc );
DrawEdge(hdc, &rc, EDGE_ETCHED, BF_RECT);
}
......
......@@ -874,11 +874,11 @@ static void test_themed_background(void)
{REBARCLASSNAMEA, 0, empty_seq},
{WC_STATICA, SS_LEFT, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_ICON, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_BLACKRECT, wm_ctlcolorstatic_seq, TRUE},
{WC_STATICA, SS_BLACKRECT, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_OWNERDRAW, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_BITMAP, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_ENHMETAFILE, wm_ctlcolorstatic_seq},
{WC_STATICA, SS_ETCHEDHORZ, wm_ctlcolorstatic_seq, TRUE},
{WC_STATICA, SS_ETCHEDHORZ, wm_ctlcolorstatic_seq},
{STATUSCLASSNAMEA, 0, empty_seq},
{"SysLink", 0, wm_ctlcolorstatic_seq},
{WC_TABCONTROLA, 0, drawthemeparentbackground_seq},
......
......@@ -424,18 +424,18 @@ START_TEST(static)
test_updates(0, 0);
test_updates(SS_ICON, 0);
test_updates(SS_BLACKRECT, TODO_COUNT);
test_updates(SS_WHITERECT, TODO_COUNT);
test_updates(SS_BLACKFRAME, TODO_COUNT);
test_updates(SS_WHITEFRAME, TODO_COUNT);
test_updates(SS_USERITEM, TODO_COUNT);
test_updates(SS_BLACKRECT, 0);
test_updates(SS_WHITERECT, 0);
test_updates(SS_BLACKFRAME, 0);
test_updates(SS_WHITEFRAME, 0);
test_updates(SS_USERITEM, 0);
test_updates(SS_SIMPLE, 0);
test_updates(SS_OWNERDRAW, 0);
test_updates(SS_BITMAP, 0);
test_updates(SS_BITMAP | SS_CENTERIMAGE, 0);
test_updates(SS_ETCHEDHORZ, TODO_COUNT);
test_updates(SS_ETCHEDVERT, TODO_COUNT);
test_updates(SS_ETCHEDFRAME, TODO_COUNT);
test_updates(SS_ETCHEDHORZ, 0);
test_updates(SS_ETCHEDVERT, 0);
test_updates(SS_ETCHEDFRAME, 0);
test_updates(SS_SUNKEN, 0);
test_set_text();
test_set_image();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment