[USER32] - Sync with Wine Staging 1.9.18.

svn path=/trunk/; revision=72650
This commit is contained in:
James Tabor 2016-09-11 00:57:38 +00:00
parent 50ce1f1694
commit cf98f01e86

View file

@ -135,10 +135,6 @@ static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
OB_Paint /* BS_OWNERDRAW */ OB_Paint /* BS_OWNERDRAW */
}; };
static HBITMAP hbitmapCheckBoxes = 0;
static WORD checkBoxWidth = 0, checkBoxHeight = 0;
/********************************************************************* /*********************************************************************
* button class descriptor * button class descriptor
*/ */
@ -272,7 +268,8 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
} }
} }
} }
else
return 0;
#else #else
if (!IsWindow( hWnd )) return 0; if (!IsWindow( hWnd )) return 0;
#endif #endif
@ -299,14 +296,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
break; break;
case WM_CREATE: case WM_CREATE:
if (!hbitmapCheckBoxes)
{
BITMAP bmp;
hbitmapCheckBoxes = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CHECKBOXES));
GetObjectW( hbitmapCheckBoxes, sizeof(bmp), &bmp );
checkBoxWidth = bmp.bmWidth / 4;
checkBoxHeight = bmp.bmHeight / 3;
}
if (btn_type >= MAX_BTN_TYPE) if (btn_type >= MAX_BTN_TYPE)
return -1; /* abort */ return -1; /* abort */
@ -400,8 +389,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
break; break;
/* fall through */ /* fall through */
case WM_LBUTTONUP: case WM_LBUTTONUP:
{ #ifdef _REACTOS_
BOOL TellParent = FALSE; //// ReactOS see note below. BOOL TellParent = FALSE; //// ReactOS see note below.
#endif
state = get_button_state( hWnd ); state = get_button_state( hWnd );
if (!(state & BUTTON_BTNPRESSED)) break; if (!(state & BUTTON_BTNPRESSED)) break;
state &= BUTTON_NSTATES; state &= BUTTON_NSTATES;
@ -429,15 +419,27 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
(state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 ); (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
break; break;
} }
#ifdef _REACTOS_
TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released. TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
#else
ReleaseCapture();
BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
#endif
} }
#ifdef _REACTOS_
ReleaseCapture(); ReleaseCapture();
if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED); if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
#else
else
{
ReleaseCapture();
} }
#endif
break; break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
TRACE("WM_CAPTURECHANGED %p\n", hWnd); TRACE("WM_CAPTURECHANGED %p\n", hWnd);
if (hWnd == (HWND)lParam) break;
state = get_button_state( hWnd ); state = get_button_state( hWnd );
if (state & BUTTON_BTNPRESSED) if (state & BUTTON_BTNPRESSED)
{ {
@ -459,35 +461,36 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
{ {
/* Clear an old text here as Windows does */ /* Clear an old text here as Windows does */
// //
// ReactOS Note :
// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790 // wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
// Patch: http://source.winehq.org/patches/data/70889 // Patch: http://source.winehq.org/patches/data/70889
// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR* // By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
// //
#ifdef __REACTOS__ #ifdef __REACTOS__
if (style & WS_VISIBLE) if (style & WS_VISIBLE)
{ #else
if (IsWindowVisible(hWnd))
#endif #endif
{
HDC hdc = GetDC(hWnd); HDC hdc = GetDC(hWnd);
HBRUSH hbrush; HBRUSH hbrush;
RECT client, rc; RECT client, rc;
HWND parent = GetParent(hWnd); HWND parent = GetParent(hWnd);
#ifdef __REACTOS__ UINT message = (btn_type == BS_PUSHBUTTON ||
UINT ctlMessage = (btn_type == BS_PUSHBUTTON ||
btn_type == BS_DEFPUSHBUTTON || btn_type == BS_DEFPUSHBUTTON ||
btn_type == BS_PUSHLIKE || btn_type == BS_PUSHLIKE ||
btn_type == BS_USERBUTTON || btn_type == BS_USERBUTTON ||
btn_type == BS_OWNERDRAW) ? btn_type == BS_OWNERDRAW) ?
WM_CTLCOLORBTN : WM_CTLCOLORSTATIC; WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
#endif
if (!parent) parent = hWnd; if (!parent) parent = hWnd;
#ifdef __REACTOS__ #ifdef __REACTOS__
hbrush = GetControlColor(parent, hWnd, hdc, ctlMessage); hbrush = GetControlColor(parent, hWnd, hdc, message);
#else #else
hbrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, hbrush = (HBRUSH)SendMessageW(parent, message,
(WPARAM)hdc, (LPARAM)hWnd); (WPARAM)hdc, (LPARAM)hWnd);
if (!hbrush) /* did the app forget to call DefWindowProc ? */ if (!hbrush) /* did the app forget to call DefWindowProc ? */
hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, hbrush = (HBRUSH)DefWindowProcW(parent, message,
(WPARAM)hdc, (LPARAM)hWnd); (WPARAM)hdc, (LPARAM)hWnd);
#endif #endif
@ -499,9 +502,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
if (rc.bottom > client.bottom) rc.bottom = client.bottom; if (rc.bottom > client.bottom) rc.bottom = client.bottom;
FillRect(hdc, &rc, hbrush); FillRect(hdc, &rc, hbrush);
ReleaseDC(hWnd, hdc); ReleaseDC(hWnd, hdc);
#ifdef __REACTOS__
} }
#endif
if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam ); else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam );
@ -842,11 +843,8 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy) static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
{ {
RECT rc; RECT rc;
rc.left = 0;
rc.top = 0;
rc.right = cx;
rc.bottom = cy;
SetRect(&rc, 0, 0, cx, cy);
DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp); DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
return TRUE; return TRUE;
} }
@ -1026,7 +1024,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
{ {
RECT rbox, rtext, client; RECT rbox, rtext, client;
HBRUSH hBrush; HBRUSH hBrush;
int delta; int delta, text_offset, checkBoxWidth, checkBoxHeight;
UINT dtFlags; UINT dtFlags;
HFONT hFont; HFONT hFont;
LONG state = get_button_state( hwnd ); LONG state = get_button_state( hwnd );
@ -1043,7 +1041,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
GetClientRect(hwnd, &client); GetClientRect(hwnd, &client);
rbox = rtext = client; rbox = rtext = client;
checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
GetCharWidthW( hDC, '0', '0', &text_offset );
text_offset /= 2;
parent = GetParent(hwnd); parent = GetParent(hwnd);
if (!parent) parent = hwnd; if (!parent) parent = hwnd;
@ -1062,12 +1065,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
{ {
/* magic +4 is what CTL3D expects */ /* magic +4 is what CTL3D expects */
rtext.right -= checkBoxWidth + 4; rtext.right -= checkBoxWidth + text_offset;;
rbox.left = rbox.right - checkBoxWidth; rbox.left = rbox.right - checkBoxWidth;
} }
else else
{ {
rtext.left += checkBoxWidth + 4; rtext.left += checkBoxWidth + text_offset;;
rbox.right = checkBoxWidth; rbox.right = checkBoxWidth;
} }