static void UB_Paint( HWND hwnd, HDC hDC, UINT action );
static void OB_Paint( HWND hwnd, HDC hDC, UINT action );
static void BUTTON_CheckAutoRadioButton( HWND hwnd );
-static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
-static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
#define MAX_BTN_TYPE 12
static inline LONG get_button_state( HWND hwnd )
{
- return GetWindowLongW( hwnd, STATE_GWL_OFFSET );
+ return GetWindowLongPtrW( hwnd, STATE_GWL_OFFSET );
}
static inline void set_button_state( HWND hwnd, LONG state )
{
- SetWindowLongW( hwnd, STATE_GWL_OFFSET, state );
+ SetWindowLongPtrW( hwnd, STATE_GWL_OFFSET, state );
}
static __inline void set_ui_state( HWND hwnd, LONG flags )
{
- SetWindowLongW( hwnd, UISTATE_GWL_OFFSET, flags );
+ SetWindowLongPtrW( hwnd, UISTATE_GWL_OFFSET, flags );
}
static __inline LONG get_ui_state( HWND hwnd )
/***********************************************************************
* ButtonWndProc_common
*/
-static LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg,
- WPARAM wParam, LPARAM lParam, BOOL unicode )
+LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
+ WPARAM wParam, LPARAM lParam, BOOL unicode )
{
RECT rect;
POINT pt;
- LONG style = GetWindowLongW( hWnd, GWL_STYLE );
+ LONG style = GetWindowLongPtrW( hWnd, GWL_STYLE );
UINT btn_type = get_button_type( style );
LONG state;
HANDLE oldHbitmap;
}
if (btn_type >= MAX_BTN_TYPE)
return -1; /* abort */
+
+ /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
+ if (btn_type == BS_USERBUTTON )
+ {
+ style = (style & ~0x0f) | BS_PUSHBUTTON;
+ SetWindowLongPtrW( hWnd, GWL_STYLE, style );
+ }
set_button_state( hWnd, BUTTON_UNCHECKED );
button_update_uistate( hWnd, unicode );
return 0;
{
SendMessageW( hWnd, BM_SETSTATE, TRUE, 0 );
set_button_state( hWnd, get_button_state( hWnd ) | BUTTON_BTNPRESSED );
+ SetCapture( hWnd );
}
break;
if (style & BS_NOTIFY)
BUTTON_NOTIFY_PARENT(hWnd, BN_KILLFOCUS);
+ InvalidateRect( hWnd, NULL, FALSE );
break;
case WM_SYSCOLORCHANGE:
InvalidateRect( hWnd, NULL, FALSE );
break;
-#ifndef __REACTOS__
- case BM_SETSTYLE16:
-#endif
case BM_SETSTYLE:
if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
btn_type = wParam & 0x0f;
style = (style & ~0x0f) | btn_type;
- SetWindowLongW( hWnd, GWL_STYLE, style );
+ SetWindowLongPtrW( hWnd, GWL_STYLE, style );
/* Only redraw if lParam flag is set.*/
if (lParam)
- paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
+ InvalidateRect( hWnd, NULL, TRUE );
break;
case BM_GETIMAGE:
return GetWindowLongPtrW( hWnd, HIMAGE_GWL_OFFSET );
-#ifndef __REACTOS__
- case BM_GETCHECK16:
-#endif
case BM_GETCHECK:
return get_button_state( hWnd ) & 3;
-#ifndef __REACTOS__
- case BM_SETCHECK16:
-#endif
case BM_SETCHECK:
if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
state = get_button_state( hWnd );
{
if (wParam) style |= WS_TABSTOP;
else style &= ~WS_TABSTOP;
- SetWindowLongW( hWnd, GWL_STYLE, style );
+ SetWindowLongPtrW( hWnd, GWL_STYLE, style );
}
if ((state & 3) != wParam)
{
BUTTON_CheckAutoRadioButton( hWnd );
break;
-#ifndef __REACTOS__
- case BM_GETSTATE16:
-#endif
case BM_GETSTATE:
return get_button_state( hWnd );
-#ifndef __REACTOS__
- case BM_SETSTATE16:
-#endif
case BM_SETSTATE:
state = get_button_state( hWnd );
if (wParam)
* the passed HWND and calls the real window procedure (with a WND*
* pointer pointing to the locked windowstructure).
*/
-static LRESULT WINAPI ButtonWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+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
*/
-static LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+LRESULT WINAPI ButtonWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if (!IsWindow( hWnd )) return 0;
return ButtonWndProc_common( hWnd, uMsg, wParam, lParam, FALSE );
*/
static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
{
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
- LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
+ LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE );
+ LONG ex_style = GetWindowLongPtrW( hwnd, GWL_EXSTYLE );
WCHAR *text;
ICONINFO iconInfo;
BITMAP bm;
HBRUSH hbr = 0;
UINT flags = IsWindowEnabled(hwnd) ? DSS_NORMAL : DSS_DISABLED;
LONG state = get_button_state( hwnd );
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
+ LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE );
WCHAR *text = NULL;
/* FIXME: To draw disabled label in Win31 look-and-feel, we probably
*/
static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
{
- RECT rc, focus_rect, r;
+ RECT rc, r;
UINT dtFlags, uState;
HPEN hOldPen;
HBRUSH hOldBrush;
COLORREF oldTxtColor;
HFONT hFont;
LONG state = get_button_state( hwnd );
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
+ LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE );
BOOL pushedState = (state & BUTTON_HIGHLIGHTED);
HWND parent;
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
setup_clipping( hwnd, hDC );
-
+#ifdef __REACTOS__
+ hOldPen = SelectObject(hDC, GetStockObject(DC_PEN));
+ SetDCPenColor(hDC, GetSysColor(COLOR_WINDOWFRAME));
+#else
hOldPen = SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
+#endif
hOldBrush = SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
oldBkMode = SetBkMode(hDC, TRANSPARENT);
if (get_button_type(style) == BS_DEFPUSHBUTTON)
{
- Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
+ if (action != ODA_FOCUS)
+ Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
InflateRect( &rc, -1, -1 );
}
- uState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT;
+ /* completely skip the drawing if only focus has changed */
+ if (action == ODA_FOCUS) goto draw_focus;
+
+ uState = DFCS_BUTTONPUSH;
if (style & BS_FLAT)
uState |= DFCS_MONO;
DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
- focus_rect = rc;
-
/* draw button label */
r = rc;
dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r);
if (pushedState)
OffsetRect(&r, 1, 1);
- IntersectClipRect(hDC, rc.left, rc.top, rc.right, rc.bottom);
-
oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);
SetTextColor( hDC, oldTxtColor );
- if (state & BUTTON_HASFOCUS)
+draw_focus:
+ if ((action == ODA_FOCUS) ||
+ ((action == ODA_DRAWENTIRE) && (state & BUTTON_HASFOCUS)))
{
if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
{
- InflateRect( &focus_rect, -1, -1 );
- IntersectRect(&focus_rect, &focus_rect, &rc);
- DrawFocusRect( hDC, &focus_rect );
+ InflateRect( &rc, -2, -2 );
+ DrawFocusRect( hDC, &rc );
}
}
UINT dtFlags;
HFONT hFont;
LONG state = get_button_state( hwnd );
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
+ LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE );
HWND parent;
if (style & BS_PUSHLIKE)
{
if (!sibling) break;
if ((hwnd != sibling) &&
- ((GetWindowLongW( sibling, GWL_STYLE) & 0x0f) == BS_AUTORADIOBUTTON))
+ ((GetWindowLongPtrW( sibling, GWL_STYLE) & 0x0f) == BS_AUTORADIOBUTTON))
SendMessageW( sibling, BM_SETCHECK, BUTTON_UNCHECKED, 0 );
sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
} while (sibling != start);
HFONT hFont;
UINT dtFlags;
TEXTMETRICW tm;
- LONG style = GetWindowLongW( hwnd, GWL_STYLE );
+ LONG style = GetWindowLongPtrW( hwnd, GWL_STYLE );
HWND parent;
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
DrawFocusRect( hDC, &rc );
}
+
+ BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
}