Author: akhaldi Date: Fri May 29 21:48:55 2015 New Revision: 67959
URL: http://svn.reactos.org/svn/reactos?rev=67959&view=rev Log: [USER32] Sync button.c with Wine Staging 1.7.37. CORE-9246
Modified: trunk/reactos/media/doc/README.WINE trunk/reactos/win32ss/user/user32/controls/button.c
Modified: trunk/reactos/media/doc/README.WINE URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=6... ============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Fri May 29 21:48:55 2015 @@ -292,7 +292,7 @@ reactos/lib/sdk/crt/thread/thread.c # Synced at 20080604
User32 - - reactos/win32ss/user/user32/controls/button.c # Synced to Wine-1_1_39 + reactos/win32ss/user/user32/controls/button.c # Synced to WineStaging-1.7.37 reactos/win32ss/user/user32/controls/combo.c # Synced to Wine-1.5.10 reactos/win32ss/user/user32/controls/edit.c # Synced to Wine-1_1_40 reactos/win32ss/user/user32/controls/icontitle.c # Synced to WineStaging-1.7.37
Modified: trunk/reactos/win32ss/user/user32/controls/button.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/control... ============================================================================== --- trunk/reactos/win32ss/user/user32/controls/button.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/controls/button.c [iso-8859-1] Fri May 29 21:48:55 2015 @@ -74,12 +74,14 @@ #define UISTATE_GWL_OFFSET (HIMAGE_GWL_OFFSET+sizeof(HFONT)) #define NB_EXTRA_BYTES (UISTATE_GWL_OFFSET+sizeof(LONG))
- /* undocumented flags */ +/* undocumented flags */ #define BUTTON_NSTATES 0x0F #define BUTTON_BTNPRESSED 0x40 #define BUTTON_UNKNOWN2 0x20 #define BUTTON_UNKNOWN3 0x10 +#ifdef __REACTOS__ #define BUTTON_BMCLICK 0x100 // ReactOS Need to up to wine! +#endif
#define BUTTON_NOTIFY_PARENT(hWnd, code) \ do { /* Notify parent which has created this button control */ \ @@ -145,8 +147,12 @@ { buttonW, /* name */ CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC, /* style */ +#ifdef __REACTOS__ ButtonWndProcA, /* procA */ ButtonWndProcW, /* procW */ +#else + WINPROC_BUTTON, /* proc */ +#endif NB_EXTRA_BYTES, /* extra */ IDC_ARROW, /* cursor */ 0 /* brush */ @@ -163,6 +169,8 @@ SetWindowLongPtrW( hwnd, STATE_GWL_OFFSET, state ); }
+#ifdef __REACTOS__ + static __inline void set_ui_state( HWND hwnd, LONG flags ) { SetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET, flags ); @@ -173,7 +181,9 @@ return GetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET ); }
-__inline static HFONT get_button_font( HWND hwnd ) +#endif /* __REACTOS__ */ + +static inline HFONT get_button_font( HWND hwnd ) { return (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET ); } @@ -208,6 +218,7 @@ return buffer; }
+#ifdef __REACTOS__ /* Retrieve the UI state for the control */ static BOOL button_update_uistate(HWND hwnd, BOOL unicode) { @@ -228,6 +239,7 @@
return FALSE; } +#endif
/*********************************************************************** * ButtonWndProc_common @@ -259,8 +271,11 @@ return 0; } } - } -#endif + } + +#else + if (!IsWindow( hWnd )) return 0; +#endif
pt.x = (short)LOWORD(lParam); pt.y = (short)HIWORD(lParam); @@ -306,7 +321,9 @@ #endif } set_button_state( hWnd, BST_UNCHECKED ); +#ifdef __REACTOS__ button_update_uistate( hWnd, unicode ); +#endif return 0;
#ifdef __REACTOS__ @@ -324,7 +341,14 @@ HBRUSH hBrush; HWND parent = GetParent(hWnd); if (!parent) parent = hWnd; +#ifdef __REACTOS__ hBrush = GetControlColor( parent, hWnd, hdc, WM_CTLCOLORBTN); +#else + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, + (WPARAM)hdc, (LPARAM)hWnd); +#endif GetClientRect(hWnd, &rc); FillRect(hdc, &rc, hBrush); } @@ -433,22 +457,33 @@ // Patch: http://source.winehq.org/patches/data/70889 // By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR* // +#ifdef __REACTOS__ if (style & WS_VISIBLE) { +#endif HDC hdc = GetDC(hWnd); HBRUSH hbrush; RECT client, rc; HWND parent = GetParent(hWnd); - UINT ctlMessage=(btn_type == BS_PUSHBUTTON || - btn_type == BS_DEFPUSHBUTTON || - btn_type == BS_PUSHLIKE || - btn_type == BS_USERBUTTON || - btn_type == BS_OWNERDRAW) ? - WM_CTLCOLORBTN : WM_CTLCOLORSTATIC; +#ifdef __REACTOS__ + UINT ctlMessage = (btn_type == BS_PUSHBUTTON || + btn_type == BS_DEFPUSHBUTTON || + btn_type == BS_PUSHLIKE || + btn_type == BS_USERBUTTON || + btn_type == BS_OWNERDRAW) ? + WM_CTLCOLORBTN : WM_CTLCOLORSTATIC; +#endif
if (!parent) parent = hWnd; - - hbrush = GetControlColor( parent, hWnd, hdc, ctlMessage); +#ifdef __REACTOS__ + hbrush = GetControlColor(parent, hWnd, hdc, ctlMessage); +#else + hbrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hdc, (LPARAM)hWnd); + if (!hbrush) /* did the app forget to call DefWindowProc ? */ + hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hdc, (LPARAM)hWnd); +#endif
GetClientRect(hWnd, &client); rc = client; @@ -458,8 +493,10 @@ if (rc.bottom > client.bottom) rc.bottom = client.bottom; FillRect(hdc, &rc, hbrush); ReleaseDC(hWnd, hdc); - } -//// +#ifdef __REACTOS__ + } +#endif + if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam ); else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam ); if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */ @@ -508,9 +545,9 @@ btn_type = wParam & BS_TYPEMASK; style = (style & ~BS_TYPEMASK) | btn_type; #ifdef __REACTOS__ - NtUserAlterWindowStyle(hWnd, GWL_STYLE, style ); + NtUserAlterWindowStyle(hWnd, GWL_STYLE, style); #else - WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style ); + WIN_SetStyle( hWnd, style, BS_TYPEMASK & ~style ); #endif
/* Only redraw if lParam flag is set.*/ @@ -520,20 +557,20 @@ break;
case BM_CLICK: - //// ReactOS - state = get_button_state( hWnd ); +#ifdef __REACTOS__ + state = get_button_state(hWnd); if (state & BUTTON_BMCLICK) break; - set_button_state( hWnd, state | BUTTON_BMCLICK ); // Tracked in STATE_GWL_OFFSET. - //// + set_button_state(hWnd, state | BUTTON_BMCLICK); // Tracked in STATE_GWL_OFFSET. +#endif SendMessageW( hWnd, WM_LBUTTONDOWN, 0, 0 ); SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 ); - //// - state = get_button_state( hWnd ); +#ifdef __REACTOS__ + state = get_button_state(hWnd); if (!(state & BUTTON_BMCLICK)) break; state &= ~BUTTON_BMCLICK; - set_button_state( hWnd, state ); - //// + set_button_state(hWnd, state); +#endif break;
case BM_SETIMAGE: @@ -567,7 +604,7 @@ #ifdef __REACTOS__ if (wParam) style |= WS_TABSTOP; else style &= ~WS_TABSTOP; - NtUserAlterWindowStyle(hWnd, GWL_STYLE, style ); + NtUserAlterWindowStyle(hWnd, GWL_STYLE, style); #else if (wParam) WIN_SetStyle( hWnd, WS_TABSTOP, 0 ); else WIN_SetStyle( hWnd, 0, WS_TABSTOP ); @@ -595,6 +632,7 @@ paint_button( hWnd, btn_type, ODA_SELECT ); break;
+#ifdef __REACTOS__ case WM_UPDATEUISTATE: if (unicode) DefWindowProcW(hWnd, uMsg, wParam, lParam); @@ -604,6 +642,7 @@ if (button_update_uistate(hWnd, unicode)) paint_button( hWnd, btn_type, ODA_DRAWENTIRE ); break; +#endif
case WM_NCHITTEST: if(btn_type == BS_GROUPBOX) return HTTRANSPARENT; @@ -615,28 +654,30 @@ return 0; }
+#ifdef __REACTOS__ + /*********************************************************************** * ButtonWndProcW * The button window procedure. This is just a wrapper which locks * the passed HWND and calls the real window procedure (with a WND* * pointer pointing to the locked windowstructure). */ -LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - if (!IsWindow( hWnd )) return 0; - return ButtonWndProc_common( hWnd, uMsg, wParam, lParam, TRUE ); -} - +LRESULT WINAPI ButtonWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (!IsWindow(hWnd)) return 0; + return ButtonWndProc_common(hWnd, uMsg, wParam, lParam, TRUE); +}
/*********************************************************************** * ButtonWndProcA */ -LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) -{ - if (!IsWindow( hWnd )) return 0; - return ButtonWndProc_common( hWnd, uMsg, wParam, lParam, FALSE ); -} - +LRESULT WINAPI ButtonWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + if (!IsWindow(hWnd)) return 0; + return ButtonWndProc_common(hWnd, uMsg, wParam, lParam, FALSE); +} + +#endif /* __REACTOS__ */
/********************************************************************** * Convert button styles to flags used by DrawText. @@ -720,9 +761,10 @@ } DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT); HeapFree( GetProcessHeap(), 0, text ); - - if (get_ui_state( hwnd ) & UISF_HIDEACCEL) +#ifdef __REACTOS__ + if (get_ui_state(hwnd) & UISF_HIDEACCEL) dtStyle |= DT_HIDEPREFIX; +#endif break;
case BS_ICON: @@ -841,8 +883,10 @@ lp = (LPARAM)text; wp = (WPARAM)dtFlags;
+#ifdef __REACTOS__ if (dtFlags & DT_HIDEPREFIX) flags |= DSS_HIDEPREFIX; +#endif break;
case BS_ICON: @@ -888,7 +932,11 @@ if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont ); parent = GetParent(hwnd); if (!parent) parent = hwnd; +#ifdef __REACTOS__ GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); +#else + SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); +#endif
hrgn = set_control_clipping( hDC, &rc ); #ifdef __REACTOS__ @@ -946,11 +994,15 @@ draw_focus: if (action == ODA_FOCUS || (state & BST_FOCUS)) { +#ifdef __REACTOS__ if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) { +#endif InflateRect( &rc, -2, -2 ); DrawFocusRect( hDC, &rc ); - } +#ifdef __REACTOS__ + } +#endif }
cleanup: @@ -990,7 +1042,15 @@
parent = GetParent(hwnd); if (!parent) parent = hwnd; - hBrush = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORSTATIC); +#ifdef __REACTOS__ + hBrush = GetControlColor(parent, hwnd, hDC, WM_CTLCOLORSTATIC); +#else + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd ); +#endif hrgn = set_control_clipping( hDC, &client );
if (style & BS_LEFTTEXT) @@ -1031,8 +1091,8 @@ else if (state & BST_INDETERMINATE) flags = DFCS_BUTTON3STATE; else flags = DFCS_BUTTONCHECK;
- if (state & (BST_CHECKED | BST_INDETERMINATE)) flags |= DFCS_CHECKED; - if (state & BST_PUSHED) flags |= DFCS_PUSHED; + if (state & (BST_CHECKED | BST_INDETERMINATE)) flags |= DFCS_CHECKED; + if (state & BST_PUSHED) flags |= DFCS_PUSHED;
if (style & WS_DISABLED) flags |= DFCS_INACTIVE;
@@ -1077,13 +1137,17 @@ /* ... and focus */ if (action == ODA_FOCUS || (state & BST_FOCUS)) { +#ifdef __REACTOS__ if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) { +#endif rtext.left--; rtext.right++; IntersectRect(&rtext, &rtext, &client); DrawFocusRect( hDC, &rtext ); - } +#ifdef __REACTOS__ + } +#endif } SelectClipRgn( hDC, hrgn ); if (hrgn) DeleteObject( hrgn ); @@ -1132,8 +1196,14 @@ /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */ parent = GetParent(hwnd); if (!parent) parent = hwnd; - hbr = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORSTATIC); - +#ifdef __REACTOS__ + hbr = GetControlColor(parent, hwnd, hDC, WM_CTLCOLORSTATIC); +#else + hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd); + if (!hbr) /* did the app forget to call defwindowproc ? */ + hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, + (WPARAM)hDC, (LPARAM)hwnd); +#endif GetClientRect( hwnd, &rc); rcFrame = rc; hrgn = set_control_clipping( hDC, &rc ); @@ -1182,14 +1252,25 @@
parent = GetParent(hwnd); if (!parent) parent = hwnd; +#ifdef __REACTOS__ hBrush = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); +#else + hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd); + if (!hBrush) /* did the app forget to call defwindowproc ? */ + hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, + (WPARAM)hDC, (LPARAM)hwnd); +#endif
FillRect( hDC, &rc, hBrush ); if (action == ODA_FOCUS || (state & BST_FOCUS)) +#ifdef __REACTOS__ { if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS)) +#endif DrawFocusRect( hDC, &rc ); - } +#ifdef __REACTOS__ + } +#endif
switch (action) { @@ -1236,7 +1317,11 @@ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont ); parent = GetParent(hwnd); if (!parent) parent = hwnd; +#ifdef __REACTOS__ GetControlColor( parent, hwnd, hDC, WM_CTLCOLORBTN); +#else + SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); +#endif
hrgn = set_control_clipping( hDC, &dis.rcItem );