Moves more stuff from windows.h.
[wine/multimedia.git] / controls / button.c
blob13b56899bda57220f51503c06cc8da41c754e6d3
1 /* File: button.c -- Button type widgets
3 * Copyright (C) 1993 Johannes Ruscheinski
4 * Copyright (C) 1993 David Metcalfe
5 * Copyright (C) 1994 Alexandre Julliard
6 */
8 #include "win.h"
9 #include "button.h"
10 #include "winuser.h"
11 #include "wine/winuser16.h"
12 #include "tweak.h"
14 static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
15 static void PB_PaintGrayOnGray(HDC32 hDC,HFONT32 hFont,RECT32 *rc,char *text);
16 static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
17 static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
18 static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
19 static void OB_Paint( WND *wndPtr, HDC32 hDC, WORD action );
20 static void BUTTON_CheckAutoRadioButton( WND *wndPtr );
22 #define MAX_BTN_TYPE 12
24 static const WORD maxCheckState[MAX_BTN_TYPE] =
26 BUTTON_UNCHECKED, /* BS_PUSHBUTTON */
27 BUTTON_UNCHECKED, /* BS_DEFPUSHBUTTON */
28 BUTTON_CHECKED, /* BS_CHECKBOX */
29 BUTTON_CHECKED, /* BS_AUTOCHECKBOX */
30 BUTTON_CHECKED, /* BS_RADIOBUTTON */
31 BUTTON_3STATE, /* BS_3STATE */
32 BUTTON_3STATE, /* BS_AUTO3STATE */
33 BUTTON_UNCHECKED, /* BS_GROUPBOX */
34 BUTTON_UNCHECKED, /* BS_USERBUTTON */
35 BUTTON_CHECKED, /* BS_AUTORADIOBUTTON */
36 BUTTON_UNCHECKED, /* Not defined */
37 BUTTON_UNCHECKED /* BS_OWNERDRAW */
40 typedef void (*pfPaint)( WND *wndPtr, HDC32 hdc, WORD action );
42 static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
44 PB_Paint, /* BS_PUSHBUTTON */
45 PB_Paint, /* BS_DEFPUSHBUTTON */
46 CB_Paint, /* BS_CHECKBOX */
47 CB_Paint, /* BS_AUTOCHECKBOX */
48 CB_Paint, /* BS_RADIOBUTTON */
49 CB_Paint, /* BS_3STATE */
50 CB_Paint, /* BS_AUTO3STATE */
51 GB_Paint, /* BS_GROUPBOX */
52 UB_Paint, /* BS_USERBUTTON */
53 CB_Paint, /* BS_AUTORADIOBUTTON */
54 NULL, /* Not defined */
55 OB_Paint /* BS_OWNERDRAW */
58 #define PAINT_BUTTON(wndPtr,style,action) \
59 if (btnPaintFunc[style]) { \
60 HDC32 hdc = GetDC32( (wndPtr)->hwndSelf ); \
61 (btnPaintFunc[style])(wndPtr,hdc,action); \
62 ReleaseDC32( (wndPtr)->hwndSelf, hdc ); }
64 #define BUTTON_SEND_CTLCOLOR(wndPtr,hdc) \
65 SendMessage32A( GetParent32((wndPtr)->hwndSelf), WM_CTLCOLORBTN, \
66 (hdc), (wndPtr)->hwndSelf )
68 static HBITMAP32 hbitmapCheckBoxes = 0;
69 static WORD checkBoxWidth = 0, checkBoxHeight = 0;
72 /***********************************************************************
73 * ButtonWndProc
75 LRESULT WINAPI ButtonWndProc( HWND32 hWnd, UINT32 uMsg,
76 WPARAM32 wParam, LPARAM lParam )
78 RECT32 rect;
79 POINT32 pt = { LOWORD(lParam), HIWORD(lParam) };
80 WND *wndPtr = WIN_FindWndPtr(hWnd);
81 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
82 LONG style = wndPtr->dwStyle & 0x0f;
84 switch (uMsg)
86 case WM_GETDLGCODE:
87 switch(style)
89 case BS_PUSHBUTTON: return DLGC_BUTTON | DLGC_UNDEFPUSHBUTTON;
90 case BS_DEFPUSHBUTTON: return DLGC_BUTTON | DLGC_DEFPUSHBUTTON;
91 case BS_RADIOBUTTON:
92 case BS_AUTORADIOBUTTON: return DLGC_BUTTON | DLGC_RADIOBUTTON;
93 default: return DLGC_BUTTON;
96 case WM_ENABLE:
97 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
98 break;
100 case WM_CREATE:
101 if (!hbitmapCheckBoxes)
103 BITMAP32 bmp;
104 hbitmapCheckBoxes = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_CHECKBOXES));
105 GetObject32A( hbitmapCheckBoxes, sizeof(bmp), &bmp );
106 checkBoxWidth = bmp.bmWidth / 4;
107 checkBoxHeight = bmp.bmHeight / 3;
109 if (style < 0L || style >= MAX_BTN_TYPE) return -1; /* abort */
110 infoPtr->state = BUTTON_UNCHECKED;
111 infoPtr->hFont = 0;
112 return 0;
114 case WM_ERASEBKGND:
115 return 1;
117 case WM_PAINT:
118 if (btnPaintFunc[style])
120 PAINTSTRUCT32 ps;
121 HDC32 hdc = wParam ? (HDC32)wParam : BeginPaint32( hWnd, &ps );
122 SetBkMode32( hdc, OPAQUE );
123 (btnPaintFunc[style])( wndPtr, hdc, ODA_DRAWENTIRE );
124 if( !wParam ) EndPaint32( hWnd, &ps );
126 break;
128 case WM_LBUTTONDOWN:
129 case WM_LBUTTONDBLCLK:
130 SendMessage32A( hWnd, BM_SETSTATE32, TRUE, 0 );
131 SetFocus32( hWnd );
132 SetCapture32( hWnd );
133 break;
135 case WM_LBUTTONUP:
136 ReleaseCapture();
137 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
138 SendMessage32A( hWnd, BM_SETSTATE32, FALSE, 0 );
139 GetClientRect32( hWnd, &rect );
140 if (PtInRect32( &rect, pt ))
142 switch(style)
144 case BS_AUTOCHECKBOX:
145 SendMessage32A( hWnd, BM_SETCHECK32,
146 !(infoPtr->state & BUTTON_CHECKED), 0 );
147 break;
148 case BS_AUTORADIOBUTTON:
149 SendMessage32A( hWnd, BM_SETCHECK32, TRUE, 0 );
150 break;
151 case BS_AUTO3STATE:
152 SendMessage32A( hWnd, BM_SETCHECK32,
153 (infoPtr->state & BUTTON_3STATE) ? 0 :
154 ((infoPtr->state & 3) + 1), 0 );
155 break;
157 SendMessage32A( GetParent32(hWnd), WM_COMMAND,
158 MAKEWPARAM( wndPtr->wIDmenu, BN_CLICKED ), hWnd);
160 break;
162 case WM_MOUSEMOVE:
163 if (GetCapture32() == hWnd)
165 GetClientRect32( hWnd, &rect );
166 SendMessage32A( hWnd, BM_SETSTATE32, PtInRect32(&rect, pt), 0 );
168 break;
170 case WM_NCHITTEST:
171 if(style == BS_GROUPBOX) return HTTRANSPARENT;
172 return DefWindowProc32A( hWnd, uMsg, wParam, lParam );
174 case WM_SETTEXT:
175 DEFWND_SetText( wndPtr, (LPCSTR)lParam );
176 if( wndPtr->dwStyle & WS_VISIBLE )
177 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
178 return 0;
180 case WM_SETFONT:
181 infoPtr->hFont = (HFONT16)wParam;
182 if (lParam && (wndPtr->dwStyle & WS_VISIBLE))
183 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
184 break;
186 case WM_GETFONT:
187 return infoPtr->hFont;
189 case WM_SETFOCUS:
190 infoPtr->state |= BUTTON_HASFOCUS;
191 if (style == BS_AUTORADIOBUTTON)
193 SendMessage32A( hWnd, BM_SETCHECK32, 1, 0 );
195 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
196 break;
198 case WM_KILLFOCUS:
199 infoPtr->state &= ~BUTTON_HASFOCUS;
200 PAINT_BUTTON( wndPtr, style, ODA_FOCUS );
201 InvalidateRect32( hWnd, NULL, TRUE );
202 break;
204 case WM_SYSCOLORCHANGE:
205 InvalidateRect32( hWnd, NULL, FALSE );
206 break;
208 case BM_SETSTYLE16:
209 case BM_SETSTYLE32:
210 if ((wParam & 0x0f) >= MAX_BTN_TYPE) break;
211 wndPtr->dwStyle = (wndPtr->dwStyle & 0xfffffff0)
212 | (wParam & 0x0000000f);
213 style = wndPtr->dwStyle & 0x0000000f;
214 PAINT_BUTTON( wndPtr, style, ODA_DRAWENTIRE );
215 break;
217 case BM_GETCHECK16:
218 case BM_GETCHECK32:
219 return infoPtr->state & 3;
221 case BM_SETCHECK16:
222 case BM_SETCHECK32:
223 if (wParam > maxCheckState[style]) wParam = maxCheckState[style];
224 if ((infoPtr->state & 3) != wParam)
226 if ((style == BS_RADIOBUTTON) || (style == BS_AUTORADIOBUTTON))
228 if (wParam)
229 wndPtr->dwStyle |= WS_TABSTOP;
230 else
231 wndPtr->dwStyle &= ~WS_TABSTOP;
233 infoPtr->state = (infoPtr->state & ~3) | wParam;
234 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
236 if ((style == BS_AUTORADIOBUTTON) && (wParam == BUTTON_CHECKED))
237 BUTTON_CheckAutoRadioButton( wndPtr );
238 break;
240 case BM_GETSTATE16:
241 case BM_GETSTATE32:
242 return infoPtr->state;
244 case BM_SETSTATE16:
245 case BM_SETSTATE32:
246 if (wParam)
248 if (infoPtr->state & BUTTON_HIGHLIGHTED) break;
249 infoPtr->state |= BUTTON_HIGHLIGHTED;
251 else
253 if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break;
254 infoPtr->state &= ~BUTTON_HIGHLIGHTED;
256 PAINT_BUTTON( wndPtr, style, ODA_SELECT );
257 break;
259 default:
260 return DefWindowProc32A(hWnd, uMsg, wParam, lParam);
262 return 0;
266 /**********************************************************************
267 * Push Button Functions
270 static void PB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
272 RECT32 rc;
273 HPEN32 hOldPen;
274 HBRUSH32 hOldBrush;
275 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
277 GetClientRect32( wndPtr->hwndSelf, &rc );
279 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
280 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
281 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
282 hOldPen = (HPEN32)SelectObject32(hDC, GetSysColorPen32(COLOR_WINDOWFRAME));
283 hOldBrush =(HBRUSH32)SelectObject32(hDC,GetSysColorBrush32(COLOR_BTNFACE));
284 SetBkMode32(hDC, TRANSPARENT);
285 Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
286 if (action == ODA_DRAWENTIRE)
288 SetPixel32( hDC, rc.left, rc.top, GetSysColor32(COLOR_WINDOW) );
289 SetPixel32( hDC, rc.left, rc.bottom-1, GetSysColor32(COLOR_WINDOW) );
290 SetPixel32( hDC, rc.right-1, rc.top, GetSysColor32(COLOR_WINDOW) );
291 SetPixel32( hDC, rc.right-1, rc.bottom-1, GetSysColor32(COLOR_WINDOW));
293 InflateRect32( &rc, -1, -1 );
295 if ((wndPtr->dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
297 Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
298 InflateRect32( &rc, -1, -1 );
301 if (infoPtr->state & BUTTON_HIGHLIGHTED)
303 /* draw button shadow: */
304 SelectObject32(hDC, GetSysColorBrush32(COLOR_BTNSHADOW));
305 PatBlt32(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
306 PatBlt32(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
307 rc.left += 2; /* To position the text down and right */
308 rc.top += 2;
309 } else {
310 rc.right++, rc.bottom++;
311 DrawEdge32( hDC, &rc, EDGE_RAISED, BF_RECT );
312 rc.right--, rc.bottom--;
315 /* draw button label, if any: */
316 if (wndPtr->text && wndPtr->text[0])
318 LOGBRUSH32 lb;
319 GetObject32A( GetSysColorBrush32(COLOR_BTNFACE), sizeof(lb), &lb );
320 if (wndPtr->dwStyle & WS_DISABLED &&
321 GetSysColor32(COLOR_GRAYTEXT)==lb.lbColor)
322 /* don't write gray text on gray bkg */
323 PB_PaintGrayOnGray(hDC,infoPtr->hFont,&rc,wndPtr->text);
324 else
326 SetTextColor32( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
327 GetSysColor32(COLOR_GRAYTEXT) :
328 GetSysColor32(COLOR_BTNTEXT) );
329 DrawText32A( hDC, wndPtr->text, -1, &rc,
330 DT_SINGLELINE | DT_CENTER | DT_VCENTER );
331 /* do we have the focus? */
332 if (infoPtr->state & BUTTON_HASFOCUS)
334 RECT32 r = { 0, 0, 0, 0 };
335 INT32 xdelta, ydelta;
337 DrawText32A( hDC, wndPtr->text, -1, &r,
338 DT_SINGLELINE | DT_CALCRECT );
339 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
340 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
341 if (xdelta < 0) xdelta = 0;
342 if (ydelta < 0) ydelta = 0;
343 InflateRect32( &rc, -xdelta, -ydelta );
344 DrawFocusRect32( hDC, &rc );
349 SelectObject32( hDC, hOldPen );
350 SelectObject32( hDC, hOldBrush );
354 /**********************************************************************
355 * Push Button sub function [internal]
356 * using a raster brush to avoid gray text on gray background
359 void PB_PaintGrayOnGray(HDC32 hDC,HFONT32 hFont,RECT32 *rc,char *text)
361 static const int Pattern[] = {0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55};
362 HBITMAP32 hbm = CreateBitmap32( 8, 8, 1, 1, Pattern );
363 HDC32 hdcMem = CreateCompatibleDC32(hDC);
364 HBITMAP32 hbmMem;
365 HBRUSH32 hBr;
366 RECT32 rect,rc2;
368 rect=*rc;
369 DrawText32A( hDC, text, -1, &rect, DT_SINGLELINE | DT_CALCRECT);
370 rc2=rect;
371 rect.left=(rc->right-rect.right)/2; /* for centering text bitmap */
372 rect.top=(rc->bottom-rect.bottom)/2;
373 hbmMem = CreateCompatibleBitmap32( hDC,rect.right,rect.bottom );
374 SelectObject32( hdcMem, hbmMem);
375 hBr = SelectObject32( hdcMem, CreatePatternBrush32(hbm) );
376 DeleteObject32( hbm );
377 PatBlt32( hdcMem,0,0,rect.right,rect.bottom,WHITENESS);
378 if (hFont) SelectObject32( hdcMem, hFont);
379 DrawText32A( hdcMem, text, -1, &rc2, DT_SINGLELINE);
380 PatBlt32( hdcMem,0,0,rect.right,rect.bottom,0xFA0089);
381 DeleteObject32( SelectObject32( hdcMem,hBr) );
382 BitBlt32(hDC,rect.left,rect.top,rect.right,rect.bottom,hdcMem,0,0,0x990000);
383 DeleteDC32( hdcMem);
384 DeleteObject32( hbmMem );
388 /**********************************************************************
389 * Check Box & Radio Button Functions
392 static void CB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
394 RECT32 rbox, rtext, client;
395 HBRUSH32 hBrush;
396 int textlen, delta;
397 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
399 textlen = 0;
400 GetClientRect32(wndPtr->hwndSelf, &client);
401 rbox = rtext = client;
403 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
405 /* Something is still not right, checkboxes (and edit controls)
406 * in wsping32 have white backgrounds instead of dark grey.
407 * BUTTON_SEND_CTLCOLOR() is even worse since it returns 0 in this
408 * particular case and the background is not painted at all.
411 hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
413 if (wndPtr->dwStyle & BS_LEFTTEXT)
415 /* magic +4 is what CTL3D expects */
417 rtext.right -= checkBoxWidth + 4;
418 rbox.left = rbox.right - checkBoxWidth;
420 else
422 rtext.left += checkBoxWidth + 4;
423 rbox.right = checkBoxWidth;
426 /* Draw the check-box bitmap */
428 if (wndPtr->text) textlen = strlen( wndPtr->text );
429 if (action == ODA_DRAWENTIRE || action == ODA_SELECT)
431 HDC32 hMemDC = CreateCompatibleDC32( hDC );
432 int x = 0, y = 0;
433 delta = (rbox.bottom - rbox.top - checkBoxHeight) >> 1;
435 if (action == ODA_SELECT) FillRect32( hDC, &rbox, hBrush );
436 else FillRect32( hDC, &client, hBrush );
438 if (infoPtr->state & BUTTON_HIGHLIGHTED) x += 2 * checkBoxWidth;
439 if (infoPtr->state & (BUTTON_CHECKED | BUTTON_3STATE)) x += checkBoxWidth;
440 if (((wndPtr->dwStyle & 0x0f) == BS_RADIOBUTTON) ||
441 ((wndPtr->dwStyle & 0x0f) == BS_AUTORADIOBUTTON)) y += checkBoxHeight;
442 else if (infoPtr->state & BUTTON_3STATE) y += 2 * checkBoxHeight;
444 SelectObject32( hMemDC, hbitmapCheckBoxes );
445 BitBlt32( hDC, rbox.left, rbox.top + delta, checkBoxWidth,
446 checkBoxHeight, hMemDC, x, y, SRCCOPY );
447 DeleteDC32( hMemDC );
449 if( textlen && action != ODA_SELECT )
451 if (wndPtr->dwStyle & WS_DISABLED)
452 SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
453 DrawText32A( hDC, wndPtr->text, textlen, &rtext,
454 DT_SINGLELINE | DT_VCENTER );
455 textlen = 0; /* skip DrawText() below */
459 if ((action == ODA_FOCUS) ||
460 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
462 /* again, this is what CTL3D expects */
464 SetRectEmpty32(&rbox);
465 if( textlen )
466 DrawText32A( hDC, wndPtr->text, textlen, &rbox,
467 DT_SINGLELINE | DT_CALCRECT );
468 textlen = rbox.bottom - rbox.top;
469 delta = ((rtext.bottom - rtext.top) - textlen)/2;
470 rbox.bottom = (rbox.top = rtext.top + delta - 1) + textlen + 2;
471 textlen = rbox.right - rbox.left;
472 rbox.right = (rbox.left += --rtext.left) + textlen + 2;
473 IntersectRect32(&rbox, &rbox, &rtext);
474 DrawFocusRect32( hDC, &rbox );
479 /**********************************************************************
480 * BUTTON_CheckAutoRadioButton
482 * wndPtr is checked, uncheck every other auto radio button in group
484 static void BUTTON_CheckAutoRadioButton( WND *wndPtr )
486 HWND32 parent, sibling, start;
487 if (!(wndPtr->dwStyle & WS_CHILD)) return;
488 parent = wndPtr->parent->hwndSelf;
489 /* assure that starting control is not disabled or invisible */
490 start = sibling = GetNextDlgGroupItem32( parent, wndPtr->hwndSelf, TRUE );
493 if (!sibling) break;
494 if ((wndPtr->hwndSelf != sibling) &&
495 ((WIN_FindWndPtr(sibling)->dwStyle & 0x0f) == BS_AUTORADIOBUTTON))
496 SendMessage32A( sibling, BM_SETCHECK32, BUTTON_UNCHECKED, 0 );
497 sibling = GetNextDlgGroupItem32( parent, sibling, FALSE );
498 } while (sibling != start);
502 /**********************************************************************
503 * Group Box Functions
506 static void GB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
508 RECT32 rc, rcFrame;
509 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
511 if (action != ODA_DRAWENTIRE) return;
513 BUTTON_SEND_CTLCOLOR( wndPtr, hDC );
515 GetClientRect32( wndPtr->hwndSelf, &rc);
516 if (TWEAK_WineLook == WIN31_LOOK) {
517 HPEN32 hPrevPen = SelectObject32( hDC,
518 GetSysColorPen32(COLOR_WINDOWFRAME));
519 HBRUSH32 hPrevBrush = SelectObject32( hDC,
520 GetStockObject32(NULL_BRUSH) );
522 Rectangle32( hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1 );
523 SelectObject32( hDC, hPrevBrush );
524 SelectObject32( hDC, hPrevPen );
525 } else {
526 TEXTMETRIC32A tm;
527 rcFrame = rc;
529 if (infoPtr->hFont)
530 SelectObject32 (hDC, infoPtr->hFont);
531 GetTextMetrics32A (hDC, &tm);
532 rcFrame.top += (tm.tmHeight / 2) - 1;
533 DrawEdge32 (hDC, &rcFrame, EDGE_ETCHED, BF_RECT);
536 if (wndPtr->text)
538 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
539 if (wndPtr->dwStyle & WS_DISABLED)
540 SetTextColor32( hDC, GetSysColor32(COLOR_GRAYTEXT) );
541 rc.left += 10;
542 DrawText32A( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
547 /**********************************************************************
548 * User Button Functions
551 static void UB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
553 RECT32 rc;
554 HBRUSH32 hBrush;
555 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
557 if (action == ODA_SELECT) return;
559 GetClientRect32( wndPtr->hwndSelf, &rc);
561 if (infoPtr->hFont) SelectObject32( hDC, infoPtr->hFont );
562 hBrush = GetControlBrush( wndPtr->hwndSelf, hDC, CTLCOLOR_BTN );
564 FillRect32( hDC, &rc, hBrush );
565 if ((action == ODA_FOCUS) ||
566 ((action == ODA_DRAWENTIRE) && (infoPtr->state & BUTTON_HASFOCUS)))
567 DrawFocusRect32( hDC, &rc );
571 /**********************************************************************
572 * Ownerdrawn Button Functions
575 static void OB_Paint( WND *wndPtr, HDC32 hDC, WORD action )
577 BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
578 DRAWITEMSTRUCT32 dis;
580 dis.CtlType = ODT_BUTTON;
581 dis.CtlID = wndPtr->wIDmenu;
582 dis.itemID = 0;
583 dis.itemAction = action;
584 dis.itemState = ((infoPtr->state & BUTTON_HASFOCUS) ? ODS_FOCUS : 0) |
585 ((infoPtr->state & BUTTON_HIGHLIGHTED) ? ODS_SELECTED : 0) |
586 ((wndPtr->dwStyle & WS_DISABLED) ? ODS_DISABLED : 0);
587 dis.hwndItem = wndPtr->hwndSelf;
588 dis.hDC = hDC;
589 dis.itemData = 0;
590 GetClientRect32( wndPtr->hwndSelf, &dis.rcItem );
591 SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_DRAWITEM,
592 wndPtr->wIDmenu, (LPARAM)&dis );